Command to show that updated image has been staged?

Hello,

Is there some command I can run that will show only if a new image is available?

For example rpm-ostree status shows me all of the images available, marks the one that is currently booted, and also shows whether a new image has been staged which will take effect on next reboot.

What I would like is to run something that is completely silent if there is no new image, but produces output if something new has been staged.

I want to add it to my .config/fish/config.fish so that I see the message when I open a terminal, notifying me that a new update has been auto-staged.

It seems bootc requires root access.

So far I’ve come up with:

rpm-ostree db diff | head -n 2 | grep -B1 "pending" || echo "No update staged"

This is because normally db diff seems to show “rollback vs booted”, but when something new is staged it shows “booted vs pending”:

# here there is nothing new staged, so compares to previous (rollback) deployment
user@host ~> rpm-ostree db diff | head -n 2
ostree diff commit from: rollback deployment (6d9b7e88e8fa6835c8170abd9f212e728ac6dd22b870ecb239b32c04848b9b82)
ostree diff commit to:   booted deployment (97aead5fb97fca27a12be192e1d4f2b2d5018f4b16a301478ee3b18b07552a07)

# here a new deployment exists, so it compares upcoming (pending) vs booted
user@host  ~> rpm-ostree db diff | head -n 2
ostree diff commit from: booted deployment (97aead5fb97fca27a12be192e1d4f2b2d5018f4b16a301478ee3b18b07552a07)
ostree diff commit to:   pending deployment (36eee461ebde49706de728ad8ae9709919974b769a30182e104edfdc46ff541c)

After a bit of testing, I can say that this works well enough for me:

user@host ~> cat .config/fish/config.fish

if status is-interactive
    # Commands to run in interactive sessions can go here
    rpm-ostree db diff | head -n 2 | grep -B1 "pending" || echo "No update staged"
end
1 Like