octopi icon indicating copy to clipboard operation
octopi copied to clipboard

[Feature Request] Add option for custom update command

Open codrcodz opened this issue 2 years ago • 2 comments

Greetings! First and foremost, thank you for all the hard work you've put into making this a great piece of software. I use it daily.

I had an idea for a feature request. My current workflow for updates is:

  • Notice that updates are available (thanks to Octopi Notifier)
  • Run the garuda-update utility shipped with Garuda Linux
  • Tell Octopi Notifier to recheck for updates, turning the notifier green again

What I would like to be able to do instead:

  • Notice that updates are available (thanks to Octopi Notifier)
  • Click the Octopi Notifier icon on my panel to launch an update (like you can now)
  • Have Octopi launch a custom update command specified by me (in this case: garuda-update)

I have a similar command that I run on my Manjaro latptop that emulates some of the behavior of garuda-update on my desktop. Even if you don't have the bandwidth to work on this, thanks for taking a look and once again: I appreciate the great work.

codrcodz avatar Jan 03 '23 13:01 codrcodz

Hi @codrcodz Thank you very much for your preference.

I think you could solve your issue better using pacman hooks. This would entail decoupling "garuda-update" into two scripts: one that runs before "pacman -Su" and another after it. Don't forget to remove all "pacman -Su" commands used by this script, as they will no longer be needed.

In order to implement custom pacman hooks:

  • Create a file called "/usr/share/libalpm/hooks/01-garuda-update-pre.hook" with the following content:
[Trigger]
Operation = Upgrade
Type = Package
Target = *

[Action]
Description = Performing Garuda specific actions BEFORE an update
When = PreTransaction
Exec = THE_GARUDA-UPDATE_PRE_SCRIPT_YOU_JUST_DECOUPLED
  • Create a file called "/usr/share/libalpm/hooks/02-garuda-update-post.hook" with the following content:
[Trigger]
Operation = Upgrade
Type = Package
Target = *

[Action]
Description = Performing Garuda specific actions AFTER an update
When = PostTransaction
Exec = THE_GARUDA-UPDATE_POST_SCRIPT_YOU_JUST_DECOUPLED

What do you think of the solution? This would also solve your problems in Manjaro. And it is pacman GUI agnostic.

aarnt avatar Jan 04 '23 12:01 aarnt

@aarnt, thanks for sharing this trick. I had no idea pacman had a pre- and post- hooks system.

Unfortunately, I'm not sure if this solves the issue. The biggest advantage of calling garuda-update is that it ships as part of Garuda Linux and is used by the developers to apply hotfixes before the system upgrade is run. Basically, anything you'd normally see in the Arch news releases that says stuff like: "do X before an upgrade or things will break" this script automates for you.

I guess I could strip out the part that applies the hotfixes, and add it to a hook, but that seems fragile and prone to issues down the road since the mechanism for applying those hotfixes is likely considered a private/internal interface by the developers and might change without notice.

Although, it might be worth doing, because if it is possible to use pacman hooks for this, I might be able to submit an upstream change to Garuda that uses pacman hooks instead of a custom script.

Give me a few days and I'll get back to you. Thanks again for the advice.

If you're curious, here is the documentation for garuda-update:

https://wiki.garudalinux.org/en/garuda-update

The source code is public too:

https://gitlab.com/garuda-linux/packages/stable-pkgbuilds/garuda-update

codrcodz avatar Jan 05 '23 05:01 codrcodz