Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Convert flatpak-manager into a module #45

Merged
merged 20 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
765fb55
refactor: Move flatpak-manager and user-setup to modules dir
zelikos Oct 1, 2023
0f3c4de
fix: Remove just setup from user-setup
zelikos Oct 1, 2023
92431a4
fix: Disable systemd module
zelikos Oct 1, 2023
4238f9b
refactor: Use generic names for flatpak setup scripts and services
zelikos Oct 1, 2023
50f4a4b
refactor: Standardize config file checks in flatpak-setup scripts
zelikos Oct 1, 2023
a3d50d3
feat: Initial add flatpaks module
zelikos Oct 1, 2023
b8766e4
feat: Enable flatpaks module
zelikos Oct 1, 2023
b688cb9
fix: Copy system and user scripts separately
zelikos Oct 1, 2023
b54fd99
fix: Point to correct directory
zelikos Oct 1, 2023
33e693e
refactor: Move flatpak-setup files back into main usr dirs
zelikos Oct 1, 2023
ed5dfe8
feat: Create flatpak install and remove lists
zelikos Oct 1, 2023
178f727
fix: Point system-flatpak-setup to new install and remove files
zelikos Oct 1, 2023
631e335
feat: Enable flatpak installation and removal for user
zelikos Oct 1, 2023
8ddfb3a
refactor: Move flatpak installation to flatpaks module
zelikos Oct 1, 2023
96574c9
fix: Build install and removal lists correctly
zelikos Oct 1, 2023
75a5b87
fix(main): Remove user flatpak installs
zelikos Oct 1, 2023
609b189
chore: Add output for added flatpaks
zelikos Oct 1, 2023
f0a66b2
style: Make flathub remote name generic
zelikos Oct 1, 2023
8e69616
refactor: Use flatpaks module for kinoite
zelikos Oct 1, 2023
82265f4
fix(dconf): packaging-format-preference: flathub-user -> flathub
zelikos Oct 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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