Command queuing with dpkg à la update-menus
I would like to implement something that do the following
1) Packages can raise a flag in theirs postinst/prerm
2) When dpkg has completed, if at least one flag is raised, a specific
program is run *once*.
In fact this is already implemented in update-menus but it is rather
1.0) update-menus first check for lock /var/run/update-menus.pid
1.1) If found it kill the pid mentionned.
1.2) update-menus create the lock.
2) update-menus check /var/lib/dpkg/lock. If it is locked,
it goes to background until lock is removed (by checking every second)
3) update-menus do its (time-consuming) processing.
As you see, there only one background update-menus process at a time,
and step 3 will be performed only once. This behaviour is neccessary
since update-menus is run each time a menu entry is added/removed, so
this save a lot of processing time.
Now, do you have a simpler solution ? I have a similar problem with
GAP and I would like to handle it the same way (and why not provide
a generic framework to do that).
Step 2 is a bit involved since it involve fcntl().
Imagine a large red swirl here.