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

Offline Updates #45

Open
Justinzobel opened this issue Mar 20, 2024 · 5 comments
Open

Offline Updates #45

Justinzobel opened this issue Mar 20, 2024 · 5 comments
Labels
enhancement New feature or request
Milestone

Comments

@Justinzobel
Copy link
Contributor

This actually feels fairly straight forward.

Reference: https://www.freedesktop.org/software/systemd/man/latest/systemd.offline-updates.html

  1. Get all the packages downloaded (eopkg up -f does this)
  2. Create a symlink /system-update > /var/cache/eopkg/packages/
  3. On reboot systemd checks for this file /system-update and boots into a minimal state and runs a systemd file to do the upgrade

The systemd file needs to:

  1. Check the symlink points to the eopkg package cache folder
  2. Do the update
  3. Send a systemctl reboot

Notes:

  • The update service should be after (wants?) sysinit.target
  • eopkg will need an option to not fetch the latest metadata (I believe this was the default previously). This is important as it's an offline update, there is no network in the offline-update system and eopkg doesn't do the upgrade if it fails to get the latest metadata.

I'm looking into what the systemd service file looks like soon.

@TraceyC77 TraceyC77 added the enhancement New feature or request label Mar 20, 2024
@joebonrichie
Copy link
Contributor

joebonrichie commented Mar 25, 2024

Here's how to get this working manually

Prep

  1. Create service
$ cat /usr/lib/systemd/system/eopkg-offline-update.service
[Unit]
Description=Update the operating system whilst offline

DefaultDependencies=no
Requires=sysinit.target dbus.socket
After=sysinit.target dbus.socket systemd-journald.socket system-update-pre.target
Before=shutdown.target system-update.target

[Service]
Type=oneshot
ExecStart=eopkg up --bypass-update-repo --yes-all
StandardOutput=journal+console

FailureAction=reboot
  1. Create symlink to system-update-generator
$ sudo ln -sv ../eopkg-offline-update.service /usr/lib/systemd/system/system-update.target.wants/eopkg-offline-update.service
$ ls -lah /usr/lib/systemd/system/system-update.target.wants/eopkg-offline-update.service 
lrwxrwxrwx 1 root root 31 Mar 25 13:40 /usr/lib/systemd/system/system-update.target.wants/eopkg-offline-update.service -> ../eopkg-offline-update.service

Prepare offline update

  1. $ sudo eopkg up --fetch-only --yes-all <- download our upgrades
  2. $ eopkg lu -l | sudo tee /var/lib/eopkg/prepared-offline-update <- create a special file with our updates
  3. $ sudo ln -sv /var/lib/eopkg/prepared-offline-update /system-update <- create a symlink to /system-update to instruct systemd upgrade to run
  4. $ reboot <- perform the offline upgrade

After reboot it will update the system but no output will be displayed, this may be due to a setfont bug.

  1. To verify the upgrade took place after reboot run:
    $ eopkg lu <- to verify no updates are available
    $ eopkg history <- to verify the upgrade took place and compare the contents to /var/lib/eopkg/prepared-offline-update
    $ ls /system-update <- verify /system-update no longer exists
$ sudo journalctl -b | grep systemd-update
Mar 25 13:59:04 joey-solus systemd[1]: Starting systemd-update-utmp.service - Record System Boot/Shutdown in UTMP...
Mar 25 13:59:04 joey-solus systemd[1]: Finished systemd-update-utmp.service - Record System Boot/Shutdown in UTMP.
Mar 25 13:59:04 joey-solus systemd[1]: Starting systemd-update-done.service - Update is Completed...
Mar 25 13:59:04 joey-solus systemd[1]: Finished systemd-update-done.service - Update is Completed.

TODO: cleanup /var/lib/eopkg/prepared-update file or just overwrite it for next upgrade.

edit: systemctl soft-reboot should also work here

@EbonJaeger
Copy link
Member

I can confirm that the above steps work.

@Justinzobel
Copy link
Contributor Author

Oh, very cool! I wonder if it would be worth creating an eopkg-offline-update package that has the service file and a small script be it python, bash, go or anything else that sets this up. It would be great for users of the terminal to use for updates, as we have seen in Plasma updates and probably many other situations where updates cause crashes or issues for users while doing online updates.

@Justinzobel
Copy link
Contributor Author

I thought this was supposed to be a symlink to where the packages are: sudo ln -sv /var/lib/eopkg/prepared-offline-update /system-update

I tried with these instructions (probably my fault along the way somewhere) but I got a boot loop.

@joebonrichie
Copy link
Contributor

/system-update

Just needs to exist to tell systemd to trigger offline updates, the contents don't really matter afaict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants