You are not logged in.

#1 2017-12-14 04:58:04

jkhsjdhjs
Member
Registered: 2017-09-05
Posts: 39

[SOLVED] Preventing double mkinitcpio trigger when using nvidia hook

Hi,

as the title says I'm using the nvidia pacman hook shown here to generate my initramfs image every time the nvidia package is upgraded.
But many times the nvidia package gets updated when the linux kernel is updated too, so the same image is actually generated twice, which is unnecessary.

That's why I'm asking if there is a way to not run a hook when another package has been upgraded too. Or is it advisable to modify the linux pacman hook (/usr/share/libalpm/hooks/90-linux.hook) to target the nvidia package too?

What would be the best solution?

Last edited by jkhsjdhjs (2017-12-15 00:13:00)

Offline

#2 2017-12-14 09:11:16

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,065

Re: [SOLVED] Preventing double mkinitcpio trigger when using nvidia hook

Looks like that hook may no longer be needed.

Check /usr/share/libalpm/60-linux.hook
I'm not entirely sure but do think the changes depmod makes trigger 90-linux .


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#3 2017-12-14 16:48:14

jkhsjdhjs
Member
Registered: 2017-09-05
Posts: 39

Re: [SOLVED] Preventing double mkinitcpio trigger when using nvidia hook

60-linux.hook is actually triggered if I solely upgrade/downgrade nvidia, but the initramfs image isn't regenerated.

I tried it by downgrading nvidia to 387.22 and then upgrading it again to 387.34. The nvidia hook from the wiki was triggered each time.

Offline

#4 2017-12-14 22:03:09

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,065

Re: [SOLVED] Preventing double mkinitcpio trigger when using nvidia hook

That indicates my assumption was wrong.

If you look at 90-linux.hook , one of the things that triggers it is changes in /usr/lib/initcpio/ .
Instead of calling mkinitcpio , try touching a file in that folder in the hook


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#5 2017-12-14 22:27:01

progandy
Member
Registered: 2012-05-17
Posts: 5,312

Re: [SOLVED] Preventing double mkinitcpio trigger when using nvidia hook

You should be able to override the default 90-linux hook. Copy it to /etc/pacman.d/hooks with the same name and then modify it to include the nvidia trigger.

Or run the nvidia hook after the linux hook and check the modification time of the initramfs.
Or add the linux package as a target, use NeedsTargets and then check in a script why the hook was called. Then you can stop if the linux package is in the target list.

Last edited by progandy (2017-12-14 22:29:36)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#6 2017-12-15 00:11:34

jkhsjdhjs
Member
Registered: 2017-09-05
Posts: 39

Re: [SOLVED] Preventing double mkinitcpio trigger when using nvidia hook

Lone_Wolf wrote:

If you look at 90-linux.hook , one of the things that triggers it is changes in /usr/lib/initcpio/ .
Instead of calling mkinitcpio , try touching a file in that folder in the hook

I tried touching a file in /usr/lib/initcpio but it didn't trigger. Touching /boot/vmlinuz-linux performed the same result, because as I just learned from here file triggers trigger for files on the file list of any package, not in the file system. That's also the reason why there is no leading / in the hook targets.

progandy wrote:

You should be able to override the default 90-linux hook. Copy it to /etc/pacman.d/hooks with the same name and then modify it to include the nvidia trigger.

What I actually did now was to copy the hook generating the initramfs image to /etc/pacman.d/hooks/ if the nvidia package is upgraded (pre transaction). Then a trigger for the nvidia package will be added to the hook. The image will then get generated (post transaction) and the overwritten hook will be removed afterwards.

See https://gist.github.com/jkhsjdhjs/228dd … fcbcf4c52c

I did it this way because now the 90-linux.hook can be changed and it will still work, because I always copy the current version. The hook could also be renamed and it would still work, because I'm searching the directory with grep for a hook that runs mkinitcpio.

Thank you very much Lone_Wolf and progandy!

Last edited by jkhsjdhjs (2017-12-15 00:41:04)

Offline

#7 2017-12-15 17:34:54

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,065

Re: [SOLVED] Preventing double mkinitcpio trigger when using nvidia hook

Keep in mind every kernel uses it's own custom hook to run mkinitcpio.

The hook you wrote works fine when only 1 kernel is installed, but what will happen if both linux & linux-lts are present ?

Last edited by Lone_Wolf (2017-12-15 17:35:13)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#8 2017-12-16 01:53:25

jkhsjdhjs
Member
Registered: 2017-09-05
Posts: 39

Re: [SOLVED] Preventing double mkinitcpio trigger when using nvidia hook

I updated the gist, it's now working for all mkinitcpio hooks in /usr/share/libalpm/hooks/. Thanks for the hint!
I also improved the matching criteria for grep a bit. If you have any further hints / remarks, please let me know!

Offline

Board footer

Powered by FluxBB