Skip to content

Commit

Permalink
fix: Split flatpak installer into separate user & system installers. (#…
Browse files Browse the repository at this point in the history
…548)

Co-authored-by: bobslept <38557801+bobslept@users.noreply.github.com>
  • Loading branch information
KyleGospo and bobslept committed Oct 1, 2023
1 parent 5277f5a commit e43bd07
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 29 deletions.
15 changes: 8 additions & 7 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,16 @@ RUN wget https://copr.fedorainfracloud.org/coprs/ublue-os/bling/repo/fedora-$(rp
/tmp/build.sh && \
/tmp/image-info.sh && \
pip install --prefix=/usr yafti && \
mkdir -p /usr/etc/flatpak/remotes.d && \
wget -q https://dl.flathub.org/repo/flathub.flatpakrepo -P /usr/etc/flatpak/remotes.d && \
systemctl enable rpm-ostree-countme.service && \
systemctl enable tailscaled.service && \
systemctl enable dconf-update.service && \
systemctl disable ublue-update.timer && \
systemctl enable ublue-system-setup.service && \
systemctl enable ublue-system-flatpak-manager.service && \
systemctl --global enable ublue-user-flatpak-manager.service && \
systemctl --global enable ublue-user-setup.service && \
fc-cache -f /usr/share/fonts/ubuntu && \
fc-cache -f /usr/share/fonts/inter && \
find /tmp/just -iname '*.just' -exec printf "\n\n" \; -exec cat {} \; >> /usr/share/ublue-os/just/60-custom.just && \
Expand Down Expand Up @@ -115,13 +121,8 @@ RUN wget https://raw.githubusercontent.com/ahmetb/kubectx/master/kubectx -O /usr
wget https://raw.githubusercontent.com/ahmetb/kubectx/master/kubens -O /usr/bin/kubens && \
chmod +x /usr/bin/kubectx /usr/bin/kubens

# Install FlatHub OOTB, set up services
RUN mkdir -p /usr/etc/flatpak/remotes.d && \
wget -q https://dl.flathub.org/repo/flathub.flatpakrepo -P /usr/etc/flatpak/remotes.d && \
systemctl enable podman.socket && \
systemctl enable ublue-hardware-setup.service && \
systemctl disable ublue-flatpak-manager.service && \
systemctl --global enable ublue-user-setup.service && \
# Set up services
RUN systemctl enable podman.socket && \
systemctl disable pmie.service && \
systemctl disable pmlogger.service

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ fi

# Lists of flatpaks
FLATPAK_LIST=$(flatpak list --columns=application)
INSTALL_LIST=$(cat /usr/etc/flatpak/install)
REMOVE_LIST=$(cat /usr/etc/flatpak/remove)
INSTALL_LIST=$(cat /etc/flatpak/system/install)
REMOVE_LIST=$(cat /etc/flatpak/system/remove)

# Install flatpaks in list
if [[ -n $INSTALL_LIST ]]; then
Expand Down
28 changes: 17 additions & 11 deletions usr/bin/ublue-hardware-setup → usr/bin/ublue-system-setup
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ KNOWN_IMAGE_NAME=$(cat $KNOWN_IMAGE_NAME_FILE)
KNOWN_IMAGE_FLAVOR_FILE="/etc/ublue/image_flavor"
KNOWN_IMAGE_FLAVOR=$(cat $KNOWN_IMAGE_FLAVOR_FILE)

# Run script if updated
if [[ -f $HWS_VER_FILE && $HWS_VER = $HWS_VER_RAN ]]; then
if [[ -f $KNOWN_IMAGE_NAME_FILE && -f $KNOWN_IMAGE_FLAVOR_FILE ]]; then
# Run script if image has been rebased
if [[ $IMAGE_NAME = $KNOWN_IMAGE_NAME && $IMAGE_FLAVOR = $KNOWN_IMAGE_FLAVOR ]]; then
echo "Hardware setup has already run. Exiting..."
exit 0
fi
fi
fi

# GLOBAL
SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)"
GPU_ID=$(lspci -k | grep -A 3 -E "(VGA|3D)")
Expand Down Expand Up @@ -99,6 +88,23 @@ else
echo "No karg changes needed"
fi

# Run script if updated
if [[ -f $HWS_VER_FILE && $HWS_VER = $HWS_VER_RAN ]]; then
if [[ -f $KNOWN_IMAGE_NAME_FILE && -f $KNOWN_IMAGE_FLAVOR_FILE ]]; then
# Run script if image has been rebased
if [[ $IMAGE_NAME = $KNOWN_IMAGE_NAME && $IMAGE_FLAVOR = $KNOWN_IMAGE_FLAVOR ]]; then
echo "Hardware setup has already run. Exiting..."
exit 0
fi
fi
fi

# Remove system flatpaks
if flatpak remotes --system | grep -q fedora; then
flatpak remote-delete fedora --force
flatpak remove --system --noninteractive --all
fi

echo $HWS_VER > $HWS_VER_FILE
echo $IMAGE_NAME > $KNOWN_IMAGE_NAME_FILE
echo $IMAGE_FLAVOR > $KNOWN_IMAGE_FLAVOR_FILE
37 changes: 37 additions & 0 deletions usr/bin/ublue-user-flatpak-manager
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

# Script Version
VER=1
VER_FILE="$HOME/.ublue_flatpak_manager_version"
VER_RAN=$(cat $VER_FILE)

# Run script if updated
if [[ -f $VER_FILE && $VER = $VER_RAN ]]; then
echo "Flatpak manager v$VER has already ran. Exiting..."
exit 0
fi

# Lists of flatpaks
FLATPAK_LIST=$(flatpak list --columns=application)
INSTALL_LIST=$(cat /etc/flatpak/user/install)
REMOVE_LIST=$(cat /etc/flatpak/user/remove)

# Install flatpaks in list
if [[ -n $INSTALL_LIST ]]; then
for flatpak in $INSTALL_LIST; do
if grep -qvz $flatpak <<< $FLATPAK_LIST; then
flatpak install --user --noninteractive flathub $flatpak
fi
done
fi

# Remove flatpaks in list
if [[ -n $REMOVE_LIST ]]; then
for flatpak in $REMOVE_LIST; do
if grep -qz $flatpak <<< $FLATPAK_LIST; then
flatpak remove --user --noninteractive $flatpak
fi
done
fi

echo $VER > $VER_FILE
Empty file added usr/etc/flatpak/system/install
Empty file.
Empty file added usr/etc/flatpak/system/remove
Empty file.
13 changes: 8 additions & 5 deletions usr/etc/flatpak/install → usr/etc/flatpak/user/install
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
org.mozilla.firefox
com.mattjakeman.ExtensionManager
io.missioncenter.MissionCenter
com.raggesilver.BlackBox
org.gnome.Calculator
org.gnome.Calendar
org.gnome.Characters
org.freedesktop.Platform.ffmpeg-full//22.08
org.gnome.Connections
org.gnome.Contacts
org.gnome.Evince
com.mattjakeman.ExtensionManager
org.fedoraproject.MediaWriter
org.mozilla.firefox
com.github.tchx84.Flatseal
org.gnome.Logs
org.gnome.Loupe
org.gnome.Maps
org.gnome.NautilusPreviewer
org.gnome.TextEditor
org.gnome.Weather
org.gnome.baobab
org.gnome.Totem
org.gnome.clocks
org.gnome.eog
org.gnome.font-viewer
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
Description=Manage system flatpaks
Documentation=https://github.com/ublue-os/endlish-oesque/issues/10
Wants=network-online.target
After=network-online.target ublue-hardware-setup.service
After=network-online.target ublue-system-setup.service

[Service]
Type=oneshot
ExecStart=/usr/bin/ublue-flatpak-manager
ExecStart=/usr/bin/ublue-system-flatpak-manager
Restart=on-failure

[Install]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[Unit]
Description=Configure system for current hardware
Description=Configure system
After=rpm-ostreed.service
Before=systemd-user-sessions.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/ublue-hardware-setup
ExecStart=/usr/bin/ublue-system-setup

[Install]
WantedBy=multi-user.target
13 changes: 13 additions & 0 deletions usr/lib/systemd/user/ublue-user-flatpak-manager.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Manage user flatpaks
Documentation=https://github.com/ublue-os/endlish-oesque/issues/10
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/bin/ublue-user-flatpak-manager
Restart=on-failure

[Install]
WantedBy=default.target

0 comments on commit e43bd07

Please sign in to comment.