From 36a9439936b56c9ab0db78f24a7ff34b2e5e9a12 Mon Sep 17 00:00:00 2001 From: fiftydinar <65243233+fiftydinar@users.noreply.github.com> Date: Sun, 15 Dec 2024 20:13:22 +0100 Subject: [PATCH] Use `bootc` autoupdate timer instead of `rpm-ostree` --- files/justfiles/gidro-os.just | 11 +++++------ .../bootc-auto-update-without-reboot.service | 11 +++++++++++ .../system/bootc-auto-update-without-reboot.timer | 14 ++++++++++++++ recipes/base.yml | 10 +--------- recipes/module-recipes/systemd.yml | 1 + 5 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 files/systemd/system/bootc-auto-update-without-reboot.service create mode 100644 files/systemd/system/bootc-auto-update-without-reboot.timer diff --git a/files/justfiles/gidro-os.just b/files/justfiles/gidro-os.just index b752b966..329b43d4 100644 --- a/files/justfiles/gidro-os.just +++ b/files/justfiles/gidro-os.just @@ -5,7 +5,7 @@ update: #!/usr/bin/env bash echo "----------System update section----------" echo "" - rpm-ostree upgrade + sudo bootc upgrade echo "" echo "----------System flatpak section----------" echo "" @@ -37,7 +37,7 @@ toggle-updates ACTION="prompt": #!/usr/bin/env bash source /usr/lib/ujust/ujust.sh CURRENT_STATE="Disabled" - if systemctl -q is-enabled rpm-ostreed-automatic.timer; then + if systemctl -q is-enabled bootc-auto-update-without-reboot.timer; then CURRENT_STATE="Enabled (Default)" fi OPTION={{ ACTION }} @@ -54,14 +54,14 @@ toggle-updates ACTION="prompt": fi if [ "$OPTION" == "Enable (Default)" ] || [ "${OPTION,,}" == "enable" ]; then if [ "${CURRENT_STATE}" == "Disabled" ]; then - sudo bash -c "systemctl enable --now flatpak-system-update.timer rpm-ostreed-automatic.timer; systemctl enable --global flatpak-user-update.timer" + sudo bash -c "systemctl enable --now flatpak-system-update.timer bootc-auto-update-without-reboot.timer; systemctl enable --global flatpak-user-update.timer" echo 'Reverted setting "automatic updates" to defaults (Enabled).' else printf "\e[1;31mERROR: Automatic updates are already enabled, no change is made.\e[0m\n" 1>&2 fi elif [ "${OPTION,,}" == "disable" ]; then if [ "${CURRENT_STATE}" == "Enabled (Default)" ]; then - sudo bash -c "systemctl disable --now flatpak-system-update.timer rpm-ostreed-automatic.timer; systemctl disable --global flatpak-user-update.timer" + sudo bash -c "systemctl disable --now flatpak-system-update.timer bootc-auto-update-without-reboot.timer; systemctl disable --global flatpak-user-update.timer" echo 'Disable automatic updates setting applied.' else printf "\e[1;31mERROR: Automatic updates are already disabled, no change is made.\e[0m\n" 1>&2 @@ -93,14 +93,13 @@ check-local-overrides: #!/usr/bin/env bash sudo ostree admin config-diff -# Clean up old + unused podman images, volumes, flatpak packages & rpm-ostree content +# Clean up old + unused podman images, volumes & flatpak packages clean-system: #!/usr/bin/env bash podman image prune -af podman volume prune -f flatpak uninstall --system --unused flatpak uninstall --user --unused - rpm-ostree cleanup -bm # Configure window close button configure-close-button ACTION="prompt": diff --git a/files/systemd/system/bootc-auto-update-without-reboot.service b/files/systemd/system/bootc-auto-update-without-reboot.service new file mode 100644 index 00000000..fe4f0734 --- /dev/null +++ b/files/systemd/system/bootc-auto-update-without-reboot.service @@ -0,0 +1,11 @@ +[Unit] +Description=Apply bootc updates without reboot +Documentation=man:bootc(8) +ConditionPathExists=/run/ostree-booted +Wants=network-online.target +After=network-online.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/bootc update --quiet +ExecCondition=/bin/bash -c '[[ "$(busctl get-property org.freedesktop.NetworkManager /org/freedesktop/NetworkManager org.freedesktop.NetworkManager Metered | cut -c 3-)" == @(2|4) ]]' diff --git a/files/systemd/system/bootc-auto-update-without-reboot.timer b/files/systemd/system/bootc-auto-update-without-reboot.timer new file mode 100644 index 00000000..b23d3ee4 --- /dev/null +++ b/files/systemd/system/bootc-auto-update-without-reboot.timer @@ -0,0 +1,14 @@ +[Unit] +Description=Apply bootc updates without reboot +Documentation=man:bootc(8) +ConditionPathExists=/run/ostree-booted + +[Timer] +OnBootSec=1h +OnUnitInactiveSec=1d +RandomizedDelaySec=10m +OnCalendar=*-*-* 4:00:00 +Persistent=true + +[Install] +WantedBy=timers.target diff --git a/recipes/base.yml b/recipes/base.yml index 16e19dbd..d4f3b2d4 100644 --- a/recipes/base.yml +++ b/recipes/base.yml @@ -34,15 +34,7 @@ modules: - curl -fLs --create-dirs https://raw.githubusercontent.com/M0Rf30/android-udev-rules/refs/heads/main/51-android.rules -o /usr/lib/udev/rules.d/51-android.rules - echo -e "\033[90mAdding adbusers group to sysusers.d\033[0m" - echo "g adbusers - -" > /usr/lib/sysusers.d/android-udev.conf - # rpm-ostree & flatpak updaters - ## rpm-ostree updater - - echo -e "\033[90mCopying rpm-ostree updater\033[0m" - - mkdir -p /usr/lib/systemd/system/rpm-ostreed-automatic.service.d/ /usr/lib/systemd/system/rpm-ostreed-automatic.timer.d/ - - cp /tmp/ublue-config/config-main/files/etc/systemd/system/rpm-ostreed-automatic.timer.d/override.conf /usr/lib/systemd/system/rpm-ostreed-automatic.timer.d/override.conf - - cp /tmp/ublue-config/config-main/files/etc/systemd/system/rpm-ostreed-automatic.service.d/override.conf /usr/lib/systemd/system/rpm-ostreed-automatic.service.d/override.conf - - echo -e "\033[90mEnabling rpm-ostree updates in config\033[0m" - - sed -i '/^#*AutomaticUpdatePolicy=.*/s/.*/AutomaticUpdatePolicy=stage/' /etc/rpm-ostreed.conf - - systemctl enable rpm-ostreed-automatic.timer + # flatpak updaters (rpm-ostree updater ommited because bootc update is used instead) ## flatpak updater - echo -e "\033[90mCopying flatpak updater\033[0m" - cp /tmp/ublue-config/config-main/files/usr/lib/systemd/system/flatpak-system-update.timer /usr/lib/systemd/system/flatpak-system-update.timer diff --git a/recipes/module-recipes/systemd.yml b/recipes/module-recipes/systemd.yml index d13f6c12..b7258bdb 100644 --- a/recipes/module-recipes/systemd.yml +++ b/recipes/module-recipes/systemd.yml @@ -6,6 +6,7 @@ system: - memory-tweaks-gidro.service - adbusers-append.service - plugdev-append.service + - bootc-auto-update-without-reboot.timer user: enabled: - flatpak-gidro@deluge.service