Skip to content

Commit

Permalink
Use bootc autoupdate timer instead of rpm-ostree
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftydinar committed Dec 15, 2024
1 parent ba5d2bd commit 36a9439
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
11 changes: 5 additions & 6 deletions files/justfiles/gidro-os.just
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down Expand Up @@ -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 }}
Expand All @@ -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
Expand Down Expand Up @@ -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":
Expand Down
11 changes: 11 additions & 0 deletions files/systemd/system/bootc-auto-update-without-reboot.service
Original file line number Diff line number Diff line change
@@ -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) ]]'
14 changes: 14 additions & 0 deletions files/systemd/system/bootc-auto-update-without-reboot.timer
Original file line number Diff line number Diff line change
@@ -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
10 changes: 1 addition & 9 deletions recipes/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions recipes/module-recipes/systemd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ system:
- memory-tweaks-gidro.service
- adbusers-append.service
- plugdev-append.service
- bootc-auto-update-without-reboot.timer
user:
enabled:
- [email protected]
Expand Down

0 comments on commit 36a9439

Please sign in to comment.