On startup, update-menus checks the file /var/run/update-menus.pid
and the pid in it. If there's an update-menus
process with that
pid it kills it. If /var/lib/dpkg/lock exists, it forks to
background and returns control to dpkg. The background process checks the
/var/lib/dpkg/lock file approx. every second until the file's
gone.
After that, update-menus
reads the menu-entry-files in the
following directories:/etc/menu /usr/lib/menu
/usr/lib/menu/default (if a user runs update-menus
, it will
add ~/.menu to the front of that list). For every menu entry line in each file
it checks if the corresponding package is installed (works on file bases for
old syntax menu entry files). The menu entries of all "installed"
packages are added together in one big buffer that is kept in memory
(exception: executable menu entry files are executed, and stdout is placed in
the buffer).
Once it's read all menu entry files, update-menus
starts all
executable scripts in /etc/menu-methods/, hands the scripts the previously
created buffer via stdin. (If update-menus
is ran by a user, it
will first try to run the scripts in ~/.menu-methods, and only if that
directory doesn't exist, it will run the scripts in /etc/menu-methods).
Note that as an aid to debugging, one can create a simple script like
#!/bin/sh cat > /tmp/menu-stdout
and then view the file /tmp/menu-stdout to see exactly what update-menus handed the menu-methods on their stdin.
This may also be usefull for people writing /etc/menu-method/* scripts: Running
update-menus
every time you changed something in the script may be
quite time-consuming. So, it's much easier to install the above script in
/etc/menu-methods/, run update-menus
once, and then
run
/etc/menu-methods/mymethod < /tmp/menu-stdin
(and, if that also takes too long, just try editing /tmp/menu-stdin, and removing 90% or so of all entries)
The files /etc/menu-methods/$wm are executable config files that start with the line
#!/usr/sbin/install-menu
and thus start that program, handing it the configuration file for the specific window manager in the first command line argument. This configuration consists of:
See /usr/doc/menu/examples/ of the menu package for more comments.
Options to install-menu
:
-v be verbose -d Produce loads of debugging output
Some window managers don't support an `include' like statement in their
system.*rc files (like m4
or cpp
preprocessing), they cannot read the menudefs.hook file generated
by install-menu from their system.*rc config file. To still be
able to use them, install-menu
will copy the file
$path/$examplercfile to $path/$rcfile (with
$examplercfile and $rcfile