* feat: add nu script that generates build matrix for github action * chore: push initial version of new github action for testing * fix: properly close github template sequence * chore: screw this i'll write the whole build in nu (nu build script started, continue later) * fix: individual misspellings and such (yeah, i'm tired) * fix: containerfile path * fix: docker arg syntax * fix: docker build path? * feat: code structure, buildx, pushing to registry * fix: tag image properly * fix: split arguments properly * fix: use registry properly * refactor: move docker build to a separate par-each * feat: correctly tag versioned modules * feat: cosign signing, better logging * fix: cosign syntax * fix: differentiate log types with more expressive colors * chore: fix cosign syntax in logs * fix: capture errors, colocate logs while running paraller * chore: partly revert "fix: capture errors, colocate logs while running paraller" This reverts commit 9238a0f1d68183e712b567fc50849964cc964c78. * chore: bring back capture errors, keep order in logs apparently do --capture-errors is required for nushell to catch external commands errors * chore: Revert "chore: bring back capture errors, keep order in logs" These changes didn't do anything... This reverts commit 020b9a1bce9456f2167397b49aa24a65f6bec8e6. * fix: properly tag images in PRs and secondary branches * fix: use tags-variable instead of "tags" string * chore: change default-flatpaks module folder structure to be versioned * fix: also log generated tags for versioned modules * fix: don't add tags meant for latest image for every version of versioned module * fix: better logging and inline docs * fix: better logging pt2 * feat: build-unified for building the legacy modules container with just the latest versions * fix: correct workflow names * fix: add missing ansi resets * chore: add nushell extension to recommendations * fix: update unified job name Co-authored-by: Gerald Pinder <gmpinder@gmail.com> * chore: remove matrix output left over from a previous version --------- Co-authored-by: Gerald Pinder <gmpinder@gmail.com>
100 lines
5.2 KiB
Bash
Executable file
100 lines
5.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# Remove Fedora's flatpak repo, if it exists
|
|
if grep -qz 'fedora' <<< "$(flatpak remotes)"; then
|
|
flatpak remote-delete --user fedora --force
|
|
flatpak remote-delete --user fedora-testing --force
|
|
fi
|
|
|
|
REPO_INFO="/usr/share/bluebuild/default-flatpaks/user/repo-info.yml"
|
|
REPO_URL=$(yq '.repo-url' $REPO_INFO)
|
|
REPO_NAME=$(yq '.repo-name' $REPO_INFO)
|
|
REPO_TITLE=$(yq '.repo-title' $REPO_INFO)
|
|
|
|
# General conditions for not running the unnecessary flatpak setup
|
|
# Currently, we don't modify remote title if it's already modified
|
|
# Flatpak add remote is ran for some reason, even with --if-not-exists flag, apparently, it modifies the URL
|
|
# We cannot compare repo URLs properly
|
|
# Flatpak outputs repo URL, while we have flatpakref URL, which is not the same
|
|
readarray -t CURRENT_REPO_INFO < <(flatpak remotes --user --columns=name,url,title)
|
|
for index in "${CURRENT_REPO_INFO[@]}"; do
|
|
CURRENT_REPO_NAMES+=("$(echo "${index}" | awk '{print $1}')")
|
|
CURRENT_REPO_TITLES+=("$(echo "${index}" | awk '{ for(i=3;i<NF;i++) printf "%s ", $i; print $NF }')")
|
|
for name in "${CURRENT_REPO_NAMES[@]}"; do
|
|
for title in "${CURRENT_REPO_TITLES[@]}"; do
|
|
if [[ "${name}" == "${REPO_NAME}" ]] && [[ "${title}" == "${REPO_TITLE}" ]]; then
|
|
no_title_modify=true
|
|
fi
|
|
done
|
|
done
|
|
done
|
|
|
|
# Set up per-user Flatpak repository
|
|
if [[ $REPO_URL != "null" && $REPO_NAME != "null" ]]; then
|
|
echo "Adding remote $REPO_NAME from $REPO_URL"
|
|
flatpak remote-add --if-not-exists --user "$REPO_NAME" "$REPO_URL"
|
|
fi
|
|
|
|
# Change repository title to configured title, if not null
|
|
if [[ $REPO_TITLE != "null" ]] && ! ${no_title_modify}; then
|
|
flatpak remote-modify --user "$REPO_NAME" --title="$REPO_TITLE"
|
|
echo "Setting title $REPO_TITLE for remote $REPO_NAME"
|
|
fi
|
|
|
|
# Notifications config
|
|
NOTIFICATIONS_FILE="/usr/share/bluebuild/default-flatpaks/notifications"
|
|
USER_NOTIFICATIONS_FILE="/etc/bluebuild/default-flatpaks/notifications"
|
|
# Ignore words starting with # symbol, whitelines & duplicate entries for notifications config
|
|
MAINTAINER_NOTIFICATIONS=$(cat "$NOTIFICATIONS_FILE" | grep -v -E '^#|^$' | awk '!seen[$0]++')
|
|
USER_NOTIFICATIONS=$(cat "$USER_NOTIFICATIONS_FILE" | grep -v -E '^#|^$' | awk '!seen[$0]++')
|
|
|
|
# If user modified notifications config, utilize user's configuration, otherwise maintainer's
|
|
if [[ -n $USER_NOTIFICATIONS ]]; then
|
|
NOTIFICATIONS="$USER_NOTIFICATIONS"
|
|
else
|
|
NOTIFICATIONS="$MAINTAINER_NOTIFICATIONS"
|
|
fi
|
|
|
|
# Installed flatpaks
|
|
FLATPAK_LIST=$(flatpak list --user --app --columns=application)
|
|
|
|
# Flatpak list files
|
|
INSTALL_LIST_FILE="/usr/share/bluebuild/default-flatpaks/user/install"
|
|
REMOVE_LIST_FILE="/usr/share/bluebuild/default-flatpaks/user/remove"
|
|
USER_INSTALL_LIST_FILE="/etc/bluebuild/default-flatpaks/user/install"
|
|
USER_REMOVE_LIST_FILE="/etc/bluebuild/default-flatpaks/user/remove"
|
|
# Prefer user's install + remove list over maintainer's, in case when same flatpak ID is present in maintainer's install list + user's remove list & vice-versa
|
|
# Also ignores words starting with # symbol, whitelines & duplicate entries
|
|
MAINTAINER_INSTALL_LIST=$(comm -23 <(sort "$INSTALL_LIST_FILE") <(sort "$USER_REMOVE_LIST_FILE") | grep -v -E '^#|^$' | awk '!seen[$0]++')
|
|
MAINTAINER_REMOVE_LIST=$(comm -23 <(sort "$REMOVE_LIST_FILE") <(sort "$USER_INSTALL_LIST_FILE") | grep -v -E '^#|^$' | awk '!seen[$0]++')
|
|
# Combine maintainer & user list. Ignore words starting with # symbol, whitelines & duplicate entries
|
|
COMBINED_INSTALL_LIST=$(cat <(echo "$MAINTAINER_INSTALL_LIST") "$USER_INSTALL_LIST_FILE" | grep -v -E '^#|^$' | awk '!seen[$0]++')
|
|
COMBINED_REMOVE_LIST=$(cat <(echo "$MAINTAINER_REMOVE_LIST") "$USER_REMOVE_LIST_FILE" | grep -v -E '^#|^$' | awk '!seen[$0]++')
|
|
|
|
# Install flatpaks in list
|
|
if [[ -f $INSTALL_LIST_FILE ]] || [[ -f $USER_INSTALL_LIST_FILE ]]; then
|
|
if [[ -n $FLATPAK_LIST ]]; then
|
|
INSTALL_LIST=$(comm -23 <(echo "$COMBINED_INSTALL_LIST" | sort) <(echo "$FLATPAK_LIST" | sort))
|
|
else
|
|
INSTALL_LIST="$COMBINED_INSTALL_LIST"
|
|
fi
|
|
if [[ -n $INSTALL_LIST ]] && [[ ! $NOTIFICATIONS == "true" ]]; then
|
|
flatpak install --user --noninteractive "$REPO_NAME" ${INSTALL_LIST[@]}
|
|
elif [[ -n $INSTALL_LIST ]] && [[ $NOTIFICATIONS == "true" ]]; then
|
|
notify-send "Flatpak Installer" "Started install of user flatpaks" --app-name="Flatpak Installer" -u NORMAL
|
|
flatpak install --user --noninteractive "$REPO_NAME" ${INSTALL_LIST[@]}
|
|
notify-send "Flatpak Installer" "Finished install of user flatpaks:\n$INSTALL_LIST" --app-name="Flatpak Installer" -u NORMAL
|
|
fi
|
|
fi
|
|
|
|
# Remove flatpaks in list
|
|
if [[ -f $REMOVE_LIST_FILE ]] || [[ -f $USER_REMOVE_LIST_FILE ]]; then
|
|
REMOVE_LIST=$(comm -12 <(echo "$COMBINED_REMOVE_LIST" | sort) <(echo "$FLATPAK_LIST" | sort))
|
|
if [[ -n $REMOVE_LIST ]] && [[ ! $NOTIFICATIONS == "true" ]]; then
|
|
flatpak uninstall --user --noninteractive ${REMOVE_LIST[@]}
|
|
elif [[ -n $REMOVE_LIST ]] && [[ $NOTIFICATIONS == "true" ]]; then
|
|
notify-send "Flatpak Installer" "Started uninstall of some user flatpaks" --app-name="Flatpak Installer" -u NORMAL
|
|
flatpak uninstall --user --noninteractive ${REMOVE_LIST[@]}
|
|
notify-send "Flatpak Installer" "Finished uninstall of user flatpaks:\n$REMOVE_LIST" --app-name="Flatpak Installer" -u NORMAL
|
|
fi
|
|
fi
|