From a6cc2ebc7efde0ec71f20a9c51c1267436039281 Mon Sep 17 00:00:00 2001 From: Bastien Riviere Date: Sun, 5 May 2024 12:27:56 +0200 Subject: [PATCH] feat: add flatpak install service --- Containerfile | 1 + build.sh | 7 +++++++ build/flatpak-setup | 25 +++++++++++++++++++++++++ build/flatpak-setup.service | 14 ++++++++++++++ files/usr/share/azure/flatpaks/install | 5 +++++ 5 files changed, 52 insertions(+) create mode 100755 build/flatpak-setup create mode 100644 build/flatpak-setup.service create mode 100644 files/usr/share/azure/flatpaks/install diff --git a/Containerfile b/Containerfile index 2583ee2..83838de 100644 --- a/Containerfile +++ b/Containerfile @@ -58,6 +58,7 @@ COPY --from=ghcr.io/ublue-os/config:latest /files/ublue-os-update-services / COPY files / COPY build.sh /tmp/build.sh COPY packages /tmp/packages +COPY build /tmp/build RUN mkdir -p /var/lib/alternatives && \ /tmp/build.sh && \ diff --git a/build.sh b/build.sh index d84bffe..fb8cb3b 100755 --- a/build.sh +++ b/build.sh @@ -25,7 +25,14 @@ rpm-ostree override remove opensc # this would install a package from rpmfusion # rpm-ostree install vlc +### Setup flatpaks + +mkdir -p /etc/azure/flatpaks +cp /tmp/build/flatpak-setup /usr/bin/flatpak-setup +cp /tmp/build/flatpak-setup.service /usr/lib/systemd/user/flatpak-setup.service + #### Services systemctl enable podman.socket systemctl enable tailscaled.service +systemctl enable -f --global flatpak-setup.service diff --git a/build/flatpak-setup b/build/flatpak-setup new file mode 100755 index 0000000..6726179 --- /dev/null +++ b/build/flatpak-setup @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# Installed flatpaks +FLATPAK_LIST=$(flatpak list --user --app --columns=application) + +# Flatpak list files +INSTALL_LIST_FILE="/usr/share/azure/flatpaks/install" +USER_INSTALL_LIST_FILE="/etc/azure/flatpaks/install" +# 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=$(sort "$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]++') + +# 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 + 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 diff --git a/build/flatpak-setup.service b/build/flatpak-setup.service new file mode 100644 index 0000000..e2c1f8b --- /dev/null +++ b/build/flatpak-setup.service @@ -0,0 +1,14 @@ +[Unit] +Description=Configure Flatpaks for current user +Wants=network-online.target +After=network-online.service + +[Service] +Type=simple +ExecStart=/usr/bin/flatpak-setup +Restart=on-failure +RestartSec=30 +StartLimitInterval=0 + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/files/usr/share/azure/flatpaks/install b/files/usr/share/azure/flatpaks/install new file mode 100644 index 0000000..c3f7262 --- /dev/null +++ b/files/usr/share/azure/flatpaks/install @@ -0,0 +1,5 @@ +app/com.github.tchx84.Flatseal/x86_64/stable +app/org.mozilla.firefox/x86_64/stable +app/io.github.dvlv.boxbuddyrs/x86_64/stable +app/com.discordapp.Discord/stable +https://downloads.1password.com/linux/flatpak/1Password.flatpakref \ No newline at end of file