You are not logged in.

#1 2019-08-09 22:58:44

lucas2santos
Member
From: Brazil
Registered: 2019-06-17
Posts: 10

[Solved] Pacman hook: Syntax error while updating Nvidia driver

Hi,

I just followed the tip from Nvidia page from Wiki, about use a Pacman hook in order to always update initramfs after a Nvidia driver upgrade. So, I created the following file:

$ cat /etc/pacman.d/hooks/nvidia.hook
[Trigger]
Operation=Install
Operation=Upgrade
Operation=Remove
Type=Package
Target=nvidia
Target=linux

[Action]
Description=Update Nvidia module in initcpio
Depends=mkinitcpio
When=PostTransaction
NeedsTargets
Exec=/bin/sh -c 'while read -r trg; do case $trg in linux} exit 0; esac; done; /usr/bin/mkinitcpio -P'

Now, when I update the driver , I get the following message:

( 4/10) Update Nvidia module in initcpio
/bin/sh: -c: line 0: syntax error near unexpected token `exit'
/bin/sh: -c: line 0: `while read -r trg; do case $trg in linux} exit 0; esac; done; /usr/bin/mkinitcpio -P'
error: command failed to execute correctly

Message suggests that there is something wrong with the "Exec" line of the hook file, but I don't have enough knowledge to figure out what is wrong. What am I supposed to do to correct that?

Thanks for your attention.

Last edited by lucas2santos (2019-08-10 02:14:18)

Offline

#2 2019-08-09 23:02:00

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,530
Website

Re: [Solved] Pacman hook: Syntax error while updating Nvidia driver

It's not the same as in the wiki.  } is not ).

Though that whole Exec line could be replaced by the following:

Exec=/bin/sh -c 'grep -q "^linux$" || mkinitcpio -P'

Unless of course a zero exit code is important, then

Exec=/bin/sh -c 'grep -q "^linux$" && exit 0; mkinitcpio -P'

Last edited by Trilby (2019-08-10 00:16:26)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2019-08-10 02:14:27

lucas2santos
Member
From: Brazil
Registered: 2019-06-17
Posts: 10

Re: [Solved] Pacman hook: Syntax error while updating Nvidia driver

Thanks!!

Offline

Board footer

Powered by FluxBB