You are not logged in.

#1 2012-06-24 22:03:20

luolimao
Member
Registered: 2011-09-29
Posts: 10

[SOLVED] Run script after package update

I want to run a script when one of a certain subset of packages are updated. Specifically, when linux, grub2-bios, or grub2-common are updated, I want a script to run to update the grub menu automatically. I have the script already, I just need a way to run it after these updates. How can this be done?
Thanks in advance.

Last edited by luolimao (2013-05-28 01:31:51)

Offline

#2 2012-06-24 22:14:05

bohoomil
Member
Registered: 2010-09-04
Posts: 2,376
Website

Re: [SOLVED] Run script after package update


:: Registered Linux User No. 223384

:: github
:: infinality-bundle+fonts: good looking fonts made easy

Offline

#3 2012-06-25 01:45:34

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,143

Re: [SOLVED] Run script after package update

You shouldn't need to update the menu because linux is upgraded, should you?

When grub2 is upgraded, you also should update the installation on disk by running grub-install etc. again. At least, I believe so. This is certainly sometimes required. I'm not sure it is at all a good idea to automate the updating in the way you have in mind. A script you can run manually sounds fine but if you want the script itself to run automatically, that suggests you are trying to automate upgrades and that's a very bad idea. But maybe I have misunderstood what you have in mind...


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#4 2012-06-25 04:11:16

luolimao
Member
Registered: 2011-09-29
Posts: 10

Re: [SOLVED] Run script after package update

Actually, cfr, what I wanted to do is just run this simple script to update the grub menu:

grub-install /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

It's not really automating the upgrade itself (.pacnew file and such); I just want the GRUB menu to display properly. And the menu entry line in one of my /etc/grub.d files displays the current kernel version:

#...snip...
menuentry 'Arch Linux `file /boot/vmlinuz-linux | ack -o '[0-9\.\-]+ARCH' | sed  's/\-ARCH//'`' #...snip...

Might be a bit messy, but it works as a method of extracting the installed kernel's version number (not the running kernel's, like you would get from uname -r). Regardless, that's why I want it to run the script after a kernel update, so that I know the kernel version on this particular Arch installation directly from the GRUB menu.

bohoomil, I am looking at your suggestion and trying stuff out. Very helpful, thanks. Will let you know if I get it.

EDIT: Actually, bohoomil, I think you misunderstood my question (just noticed this was a wiki page regarding the PKGBUILD file); I'm not creating a new package with a post-install/upgrade script. I want to run my script whenever pacman upgrades one of those three packages.

Last edited by luolimao (2012-06-25 04:21:09)

Offline

#5 2012-06-25 06:44:42

ConnorBehan
Package Maintainer (PM)
From: Long Island NY
Registered: 2007-07-05
Posts: 1,359
Website

Re: [SOLVED] Run script after package update

I considered this to be a limitation of pacman too so I run pacman inside a wrapper. My "pacman-wrapper [args]" calls "pacman [args]" and then it checks /var/log/pacman.log to see if certain packages (in your case linux and grub2) were updated that day. If so, it runs additional commands.


6EA3 F3F3 B908 2632 A9CB E931 D53A 0445 B47A 0DAB
Great things come in tar.xz packages.

Offline

#6 2012-06-25 18:41:20

luolimao
Member
Registered: 2011-09-29
Posts: 10

Re: [SOLVED] Run script after package update

ConnorBehan wrote:

I considered this to be a limitation of pacman too

So i do have to write my own script, then? I didn't find anything relevant in the AUR, either.

Offline

Board footer

Powered by FluxBB