You are not logged in.

#1 2016-07-11 21:47:07

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

alpm-hooks - possible to have Exec run in the background?

For example, modifying /usr/share/libalpm/hooks/man-db-purge.hook to run the following in the background:

Exec = /bin/sh -c 'mkdir -p /var/cache/man; exec mandb --quiet'

Is this supported?  Simply adding a & to the end of the command seems to be ignored.  Thanks!


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#2 2016-07-12 01:59:50

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,390
Website

Re: alpm-hooks - possible to have Exec run in the background?

pacman is calling /bin/sh, so making the commend backgrounded has no effect...

(I disabled that hook...  it is annoying)

Offline

#3 2016-07-12 02:03:47

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: alpm-hooks - possible to have Exec run in the background?

Thanks for the reply, Allan.  To serve as a surrogate, I wrote: https://github.com/graysky2/mandb-ondemand


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#4 2016-07-12 02:40:50

apg
Developer
Registered: 2012-11-10
Posts: 211

Re: alpm-hooks - possible to have Exec run in the background?

alpm doesn't have any kind of support for backgrounding a hook, nor do I suggest doing it, but if you run it via a shell you can run it in the background the same way you run anything else in the background with a shell.

Offline

#5 2016-07-12 03:48:45

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: alpm-hooks - possible to have Exec run in the background?

The thing that annoys me most about that hook, is that it runs every time a manpage is installed or updated. I recently discovered that is because I use the following pacman.conf line (removing it will make the hook stop running all the time):

NoExtract   = usr/share/man/* !usr/share/man/man*

Apparently NoExtract counts as "removed"? Although it is not actually preventing anything from being installed for some packages, and still triggers the hook!
I assume this is a bug.
Edit: Or maybe not, on the theory that it could remove a file installed before that NoExtract line was added? Well, it is still annoying.

...

graysky, very nice except you really don't have to invoke /bin/sh in order to run /usr/bin/touch if you aren't using any shell-specific features. However, you probably shouldn't assume /var/cache/man/ exists (the default hook doesn't). I'd probably use /usr/bin/install to save a call to /bin/sh

Last edited by eschwartz (2016-07-12 04:01:04)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#6 2016-07-12 10:35:38

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: alpm-hooks - possible to have Exec run in the background?

Eschwartz wrote:

graysky, very nice except you really don't have to invoke /bin/sh in order to run /usr/bin/touch if you aren't using any shell-specific features. However, you probably shouldn't assume /var/cache/man/ exists (the default hook doesn't). I'd probably use /usr/bin/install to save a call to /bin/sh

Thanks!  Good idea... I am not sure about the syntax of creating a zero-byte file with install as it requires a source and destination as far as I know... what about just:

Exec = /usr/bin/touch /var/cache/man/.runflag

Last edited by graysky (2016-07-12 10:47:02)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#7 2016-07-12 11:13:46

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: alpm-hooks - possible to have Exec run in the background?

Ah!  I see Heftig is making my little package obsolete, but his code still causes delays on an install.

https://git.archlinux.org/svntogit/pack … 8063aa8061

Last edited by graysky (2016-07-23 10:55:13)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#8 2016-07-12 14:46:57

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: alpm-hooks - possible to have Exec run in the background?

/dev/null is a zero-byte file. wink

But that change does look much nicer.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#9 2016-07-23 10:54:46

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: alpm-hooks - possible to have Exec run in the background?

apg wrote:

alpm doesn't have any kind of support for backgrounding a hook, nor do I suggest doing it, but if you run it via a shell you can run it in the background the same way you run anything else in the background with a shell.

I tried backgrounding it within /usr/share/libalpm/hooks/man-db.hook but pacman still waits for the mandb pid to finish before exiting... you can manually delete /var/cache/man/index.db then install a package that has a manpage to see this effect.

Exec = /bin/sh -c 'mkdir -p /var/cache/man; exec mandb --quiet --no-purge &'

CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#10 2016-07-23 13:42:34

apg
Developer
Registered: 2012-11-10
Posts: 211

Re: alpm-hooks - possible to have Exec run in the background?

Shells obviously cannot exec something in the background.  You also need to close the file descriptors that pacman is reading from.

Exec = /bin/sh -c 'mkdir -p /var/cache/man; mandb --quiet --no-purge <&- >&- 2>&- &'

Offline

#11 2016-07-23 13:58:51

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: alpm-hooks - possible to have Exec run in the background?

@graysky
Have you considered triggering your mandb-ondemand with systemd path files instead of using a daily timer? In theory it would achieve the same affect as the blocking pacman hook without the blocking.


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#12 2016-07-23 14:42:33

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: alpm-hooks - possible to have Exec run in the background?

@R - That is exactly what I have been playing with this morning.  I will push the commit to the package once I test it a bit.

EDIT: https://github.com/graysky2/mandb-ondemand/tree/dev

Last edited by graysky (2016-07-23 15:27:59)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#13 2016-07-23 15:45:30

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,597
Website

Re: alpm-hooks - possible to have Exec run in the background?

I am going to move this to a new thread in CC.  Please continue the discussion here


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

Board footer

Powered by FluxBB