Apart from trying the hook way, I would default to just checking the timestamp of /var/lib/pacman/sync/core.db
and extra.
As any upgrade should be a system upgrade.
This seems like an easy implementation, and I can skip the variable and just directly check the timestamp from the script i guess. My question is, if I install something, say yay -S a_single_package
does that also update the timestamp of the core.db file?
-S
should not even try to refresh the database, that is what -Sy
is for. And doing any variation of -Sy
without also u
(upgrade) is the unsupported partial "upgrade", so it is possible that the time changes but only in the case of misuse.
Also noticed you can just check the mtime of the directory itself, /var/lib/pacman/sync
- directory mtime does not change when the files change content but pacman/alpm probably downloads the new databases to some temp files then moves them into the directory, changing it's modify time (see stat
, stat -c '%Y'
).
From what I remember, you can run -Sy
, so long as the next pacman -S <package>...
has the -u
flag set.
Edit:
ie. pacman -Sy; pacman -Ss <package>; pacman -Sc; pacman -Su
should be safe, I think.
In the subject you wrote "successful full sys update" but the script and the other suggestions I see so far don't actually handle the "successful" part.
The log message only tells you that the update was started and the db mtime only indicates that the db was touched without saying anything about success.
I'd go about this by always performing the updates through a wrapper script that could check the exit status of the pacman or yay command and record a timestamp accordingly.
I would write a seperate script/daemon that sets up a listener and waits for an inotify event on the pacman.log file. I think you'd have to listen to a CLOSE.
Then you know that a software has written something to the log and can update your variables.
Not able to check the details ATM, but there's a systemd timer which refreshes the pacman cache every week (I think)
That could probably be modified to run every 3 days and output the latest update's timestamp to the envvar you wanted?
Arch Linux
The beloved lightweight distro