Skip to content

Commit

Permalink
refactor: Convert flatpak-manager into a module (#45)
Browse files Browse the repository at this point in the history
* refactor: Move flatpak-manager and user-setup to modules dir

* fix: Remove just setup from user-setup

* fix: Disable systemd module

We're only enabling the Flatpak-related services, and those are being
converted into a separate module.

* refactor: Use generic names for flatpak setup scripts and services

* refactor: Standardize config file checks in flatpak-setup scripts

* feat: Initial add flatpaks module

* feat: Enable flatpaks module

* fix: Copy system and user scripts separately

* fix: Point to correct directory

* refactor: Move flatpak-setup files back into main usr dirs

Unless this is made a bling module instead, this module is gonna have to
work like yafti in that the necessary files need to be included in
startingpoint directly.

* feat: Create flatpak install and remove lists

* fix: Point system-flatpak-setup to new install and remove files

* feat: Enable flatpak installation and removal for user

* refactor: Move flatpak installation to flatpaks module

* fix: Build install and removal lists correctly

* fix(main): Remove user flatpak installs

Had them there for testing, don't need them to stay.

* chore: Add output for added flatpaks

* style: Make flathub remote name generic

System-wide was flathub-system, per-user was flathub-user. I do like
having it explicit like that myself, but for more general-purpose usage,
it's probably best to keep it generic as just flathub for both. Flatpak
does allow specifying --system or --user already, anyway.

* refactor: Use flatpaks module for kinoite

* fix(dconf): packaging-format-preference: flathub-user -> flathub

Since I'm switching back to using "flathub" as the remote name instead
of specifying -user vs -system
  • Loading branch information
zelikos authored Oct 1, 2023
1 parent 83131d5 commit 7f7c42b
Show file tree
Hide file tree
Showing 14 changed files with 196 additions and 108 deletions.
14 changes: 7 additions & 7 deletions config/common-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ modules:
- dconf-update-service # a service unit that updates the dconf db on boot
# - devpod # https://devpod.sh/ as an rpm

- type: systemd
system:
enabled:
- zeliblue-flatpak-manager.service
user:
enabled:
- zeliblue-user-setup.service
# - type: systemd
# system:
# enabled:
# - zeliblue-flatpak-manager.service
# user:
# enabled:
# - zeliblue-user-setup.service

# - type: yafti

Expand Down
14 changes: 0 additions & 14 deletions config/files/kinoite/etc/flatpak/install

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
#!/usr/bin/env bash

# Adapted from uBlue's Bazzite (https://github.com/ublue-os/bazzite/blob/main/system_files/desktop/shared/usr/bin/bazzite-flatpak-manager)

# Script Version
VER=3
VER_FILE="/etc/zeliblue/flatpak_manager_version"
VER=1
VER_FILE="/etc/ublue-os/system-flatpak-configured"
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..."
echo "Flatpak setup v$VER has already ran. Exiting..."
exit 0
fi

Expand All @@ -21,18 +19,18 @@ if grep -qz 'fedora' <<< $(flatpak remotes); then
fi

# Set up system Flathub
flatpak remote-add --if-not-exists --system --title="Flathub (System)" flathub-system https://flathub.org/repo/flathub.flatpakrepo
flatpak remote-add --if-not-exists --system --title="Flathub (System)" flathub https://flathub.org/repo/flathub.flatpakrepo

# 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
for flatpak in $INSTALL_LIST; do
if grep -qvz $flatpak <<< $FLATPAK_LIST; then
flatpak install --system --noninteractive flathub-system $flatpak
flatpak install --system --noninteractive flathub $flatpak
fi
done
fi
Expand All @@ -46,5 +44,7 @@ if [[ -n $REMOVE_LIST ]]; then
done
fi

mkdir -p /etc/zeliblue
# Prevent future executions
echo "Writing state file"
mkdir -p /etc/ublue-os
echo $VER > $VER_FILE
46 changes: 46 additions & 0 deletions config/files/usr/bin/user-flatpak-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash

# Script Version
VER=1
VER_FILE="$HOME/.config/ublue-os/user-flatpak-configured"
VER_RAN=$(cat $VER_FILE)

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

# Setup Flathub
if grep -qz 'fedora' <<< $(flatpak remotes); then
flatpak remote-delete --user fedora --force
fi
flatpak remote-add --if-not-exists --user flathub https://flathub.org/repo/flathub.flatpakrepo

# 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

# Prevent future executions
echo "Writing state file"
mkdir -p $HOME/.config/ublue-os/
echo $VER > $VER_FILE
19 changes: 0 additions & 19 deletions config/files/usr/bin/zeliblue-user-setup

This file was deleted.

2 changes: 1 addition & 1 deletion config/files/usr/etc/dconf/db/local.d/01-zeliblue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ name="Launch Console"
custom-keybindings=['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']

[org/gnome/software]
packaging-format-preference=['flatpak:flathub-user']
packaging-format-preference=['flatpak:flathub']
download-updates=false
download-updates-notify=false

Expand Down
19 changes: 0 additions & 19 deletions config/files/usr/etc/flatpak/install

This file was deleted.

5 changes: 0 additions & 5 deletions config/files/usr/etc/flatpak/remove

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ After=network-online.target

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

[Install]
Expand Down
10 changes: 10 additions & 0 deletions config/files/usr/lib/systemd/user/user-flatpak-setup.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=Configure Flatpaks for current user
Requires=xdg-desktop-autostart.target

[Service]
Type=simple
ExecStart=/usr/bin/user-flatpak-setup

[Install]
WantedBy=default.target
11 changes: 0 additions & 11 deletions config/files/usr/lib/systemd/user/zeliblue-user-setup.service

This file was deleted.

39 changes: 32 additions & 7 deletions config/gnome-packages.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
type: rpm-ostree
install:
- gnome-console
remove:
- gnome-classic-session
- gnome-terminal
- gnome-terminal-nautilus
modules:

- type: rpm-ostree
install:
- gnome-console
remove:
- gnome-classic-session
- gnome-terminal
- gnome-terminal-nautilus

- type: flatpaks
system:
install:
- org.gnome.Calculator
- org.gnome.Calendar
- io.github.celluloid_player.Celluloid
- org.gnome.Characters
- org.gnome.clocks
- org.gnome.Contacts
- org.gnome.baobab
- org.gnome.SimpleScan
- org.gnome.Evince
- org.gnome.font-viewer
- org.gnome.Logs
- org.gnome.Loupe
- org.gnome.Maps
- org.gnome.NautilusPreviewer
- org.gnome.TextEditor
- org.gnome.Weather
- org.gnome.Epiphany
- com.github.tchx84.Flatseal
- org.gnome.World.PikaBackup
48 changes: 34 additions & 14 deletions config/plasma-packages.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
type: rpm-ostree
# install:
# - ksystemlog
remove:
- ark
- ark-libs
- filelight
- gwenview
- gwenview-libs
- kate
- kate-plugins
- kcalc
- kfind
- okular
modules:

- type: rpm-ostree
# install:
# - ksystemlog
remove:
- ark
- ark-libs
- filelight
- gwenview
- gwenview-libs
- kate
- kate-plugins
- kcalc
- kfind
- okular

- type: flatpaks
system:
install:
- org.kde.ark
- org.kde.filelight
- org.kde.gwenview
- org.kde.haruna
- org.kde.kalk
- org.kde.kclock
- org.kde.kfind
- org.kde.kweather
- org.kde.kwrite
- org.kde.okular
- org.mozilla.firefox
- com.borgbase.Vorta
- com.github.tchx84.Flatseal
- org.gnome.Logs
55 changes: 55 additions & 0 deletions modules/flatpaks/flatpaks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash

# Tell build process to exit if there are any errors.
set -oue pipefail

SYS_INSTALL_LIST=/usr/etc/flatpak/system-install
SYS_REMOVE_LIST=/usr/etc/flatpak/system-remove
USER_INSTALL_LIST=/usr/etc/flatpak/user-install
USER_REMOVE_LIST=/usr/etc/flatpak/user-remove

echo "Enabling flatpaks module"
systemctl enable system-flatpak-setup.service
systemctl enable --global user-flatpak-setup.service
mkdir -p /usr/etc/flatpak

get_yaml_array SYSTEM_INSTALL '.system.install[]' "$1"
get_yaml_array SYSTEM_REMOVE '.system.remove[]' "$1"
get_yaml_array USER_INSTALL '.user.install[]' "$1"
get_yaml_array USER_REMOVE '.user.remove[]' "$1"

echo "Creating system Flatpak install list"
if [[ ${#SYSTEM_INSTALL[@]} -gt 0 ]]; then
rm -f $SYS_INSTALL_LIST && touch $SYS_INSTALL_LIST
for flatpak in "${SYSTEM_INSTALL[@]}"; do
echo "Adding to system flatpak installs: $(printf ${flatpak})"
echo $flatpak >> $SYS_INSTALL_LIST
done
fi

echo "Creating system Flatpak removals list"
if [[ ${#SYSTEM_REMOVE[@]} -gt 0 ]]; then
rm -f $SYS_REMOVE_LIST && touch $SYS_REMOVE_LIST
for flatpak in "${SYSTEM_REMOVE[@]}"; do
echo "Adding to system flatpak removals: $(printf ${flatpak})"
echo $flatpak >> $SYS_REMOVE_LIST
done
fi

echo "Creating user Flatpak install list"
if [[ ${#USER_INSTALL[@]} -gt 0 ]]; then
rm -f $USER_INSTALL_LIST && touch $USER_INSTALL_LIST
for flatpak in "${USER_INSTALL[@]}"; do
echo "Adding to user flatpak installs: $(printf ${flatpak})"
echo $flatpak >> $USER_INSTALL_LIST
done
fi

echo "Creating user Flatpak removals list"
if [[ ${#USER_REMOVE[@]} -gt 0 ]]; then
rm -f $USER_REMOVE_LIST && touch $USER_REMOVE_LIST
for flatpak in "${USER_REMOVE[@]}"; do
echo "Adding to user flatpak removals: $(printf ${flatpak})"
echo $flatpak >> $USER_REMOVE_LIST
done
fi

0 comments on commit 7f7c42b

Please sign in to comment.