attached -- see shy jo
diff --new-file -ur old/menu-2.1.38/debian/changelog menu-2.1.39/debian/changelog
--- old/menu-2.1.38/debian/changelog 2008-03-05 10:59:58.000000000 -0500
+++ menu-2.1.39/debian/changelog 2008-03-30 14:31:00.000000000 -0400
@@ -1,3 +1,9 @@
+menu (2.1.39) UNRELEASED; urgency=low
+
+ * Add trigger support.
+
+ -- Joey Hess <[EMAIL PROTECTED]> Sun, 30 Mar 2008 14:30:56 -0400
+
menu (2.1.38) unstable; urgency=low
* The "little zebra" release.
diff --new-file -ur old/menu-2.1.38/debian/postinst menu-2.1.39/debian/postinst
--- old/menu-2.1.38/debian/postinst 2005-06-28 08:27:32.000000000 -0400
+++ menu-2.1.39/debian/postinst 2008-03-30 14:49:11.000000000 -0400
@@ -13,13 +13,22 @@
# kill -KILL `pidof update-menus` 2> /dev/null || true
#fi
-chmod a+x /usr/bin/update-menus
-update-menus
+case "$1" in
+triggered)
+ # This is triggered by any installation of a menu file and by
+ # any call to update-menus made in a package maintainer script.
+ update-menus --real
+;;
+*)
+ chmod a+x /usr/bin/update-menus
+ update-menus
-install-info --quiet \
- --menuentry="Debian menu" \
- --section "Information" "Information:" \
- --description="The Debian menu system" \
- /usr/share/info/menu.info
+ install-info --quiet \
+ --menuentry="Debian menu" \
+ --section "Information" "Information:" \
+ --description="The Debian menu system" \
+ /usr/share/info/menu.info
+;;
+esac
#DEBHELPER#
diff --new-file -ur old/menu-2.1.38/debian/triggers menu-2.1.39/debian/triggers
--- old/menu-2.1.38/debian/triggers 1969-12-31 19:00:00.000000000 -0500
+++ menu-2.1.39/debian/triggers 2008-03-30 14:30:52.000000000 -0400
@@ -0,0 +1,2 @@
+interest /usr/share/menu
+interest /usr/lib/menu
diff --new-file -ur old/menu-2.1.38/doc/README.changes menu-2.1.39/doc/README.changes
--- old/menu-2.1.38/doc/README.changes 2002-05-18 10:49:54.000000000 -0400
+++ menu-2.1.39/doc/README.changes 2008-03-30 15:02:03.000000000 -0400
@@ -8,7 +8,8 @@
update-menus
*forks to background, waits for dpkg to finish (to get a _correct_
- package listing).
+ package listing). (This is now only done with dpkgs that don't support
+ triggers.)
*allows new menuentry format:
needs=text command=/usr/bin/vi section=Apps/Editors title=Vi \
diff --new-file -ur old/menu-2.1.38/doc/menu.sgml menu-2.1.39/doc/menu.sgml
--- old/menu-2.1.38/doc/menu.sgml 2008-02-27 09:15:09.000000000 -0500
+++ menu-2.1.39/doc/menu.sgml 2008-03-30 15:28:11.000000000 -0400
@@ -145,6 +145,10 @@
<p>
When a package that wants to add something to the menu tree gets
installed, it will run <prgn/update-menus/ in its <file/postinst/ script.
+Or, if the package is used with a trigger-enabled version of dpkg, it can
+omit that, since the menu package registers interest in all files in
+<file>/usr/lib/menu</file> and <file>/usr/share/menu</file>, and will be
+automatically triggered by dpkg when those files change.
Update-menus then reads in all menu files in <file>/etc/menu/</file>,
<file>/usr/lib/menu</file>, <file>/usr/share/menu</file> and
<file>/usr/share/menu/default</file>, and stores the menu entries of all
@@ -814,6 +818,11 @@
(that is, the same line in postinst and in postrm).
<p>
+Note that this is not needed if the package will only be used with dpkg
+1.4.18 or better and menu 2.1.39 or better. The newer versions use triggers
+to automatically run update-menus.
+<p>
+
<chapt>What packages with menu managers should do
<p>
@@ -1006,13 +1015,17 @@
On startup, update-menus checks the file
<file>/var/run/update-menus.pid</> and the pid in it. If there's an
<prgn/update-menus/ process with that pid it kills it.
-If <file>/var/lib/dpkg/lock</> exists, it forks to background and
-returns control to dpkg. The background process checks the
+If <file>/var/lib/dpkg/lock</> exists, it checks to see if dpkg supports
+triggers. If so, it uses dpkg-trigger to trigger a real update-menus run later.
+Otherwise, it forks to background and returns control to dpkg. The background
+process checks the
<file>/var/lib/dpkg/lock</> file approx. every second until the file's
gone.
<p>
-After that, <prgn/update-menus/ reads the menu-entry files in
+Once it's decided to run, whether in the background after dpkg exits, or in
+the foreground when used with a trigger-capable dpkg,
+<prgn/update-menus/ reads the menu-entry files in
the following directories: <file>/etc/menu</>, <file>/usr/lib/menu</>,
<file>/usr/share/menu</>, <file>/usr/share/menu/default</>.
(if a user runs <prgn/update-menus/, it will add <file>~/.menu</> to the
Binary files old/menu-2.1.38/update-menus/.update-menus.cc.swp and menu-2.1.39/update-menus/.update-menus.cc.swp differ
diff --new-file -ur old/menu-2.1.38/update-menus/update-menus.cc menu-2.1.39/update-menus/update-menus.cc
--- old/menu-2.1.38/update-menus/update-menus.cc 2008-03-03 15:13:45.000000000 -0500
+++ menu-2.1.39/update-menus/update-menus.cc 2008-03-30 14:46:53.000000000 -0400
@@ -789,6 +789,8 @@
}
/** Check whether dpkg is running, and fork into background waiting if it is
+ * Or, if this dpkg supports triggers, do nothing unless run with a --real
+ * flag.
*/
void wait_dpkg(string &stdoutfile)
{
@@ -802,14 +804,32 @@
// Check if the dpkg lock is taken
- if (check_dpkglock()) {
+ if (check_dpkglock())
+ {
+ if (! config.real)
+ {
+ // Try to use dpkg-trigger to trigger the menu update later.
+ if (system("dpkg-trigger /usr/share/menu >/dev/null 2>&1") == 0)
+ {
+ // Success, so no need to do anything now.
+ exit(0);
+ }
+ }
// If we can't get the u-m lock, probably another process is waiting
- // for dpkg. We can savely exit.
+ // for dpkg. We can safely exit.
r = create_lock();
if (!r)
exit(0);
+ if (config.real)
+ {
+ // This is the real update-menus run, caused by the trigger.
+ // So ignore the dpkg lock, and continue with updating in
+ // the foreground.
+ return;
+ }
+
// OK, we need to fork, create log file name and tell user about it.
stdoutfile = string("/tmp/update-menus.")+itostring(getpid());
config.report(String::compose(_("Waiting for dpkg to finish (forking to background).\n"
@@ -873,7 +893,7 @@
struct option long_options[] = {
{ "debug", no_argument, NULL, 'd' },
{ "verbose", no_argument, NULL, 'v' },
- { "help", no_argument, NULL, 'h' },
+ { "help", no_argument, NULL, 'h' },
{ "menufilesdir", required_argument, NULL, 'f'},
{ "menumethod", required_argument, NULL, 'm'},
{ "nodefaultdirs", no_argument, NULL, 'n'},
@@ -881,6 +901,7 @@
{ "stdout", no_argument, NULL, 's'},
{ "version", no_argument, NULL, 'V'},
{ "remove", no_argument, NULL, 'r'},
+ { "real", no_argument, NULL, 'R'},
{ NULL, 0, NULL, 0 } };
@@ -918,6 +939,9 @@
case 'r':
config.remove_menu = true;
break;
+ case 'R':
+ config.real = true;
+ break;
case 'V':
cout << "update-menus "VERSION << std::endl;
exit(0);
diff --new-file -ur old/menu-2.1.38/update-menus/update-menus.h menu-2.1.39/update-menus/update-menus.h
--- old/menu-2.1.38/update-menus/update-menus.h 2007-07-10 13:23:12.000000000 -0400
+++ menu-2.1.39/update-menus/update-menus.h 2008-03-30 14:35:29.000000000 -0400
@@ -116,7 +116,7 @@
configinfo()
: method(method_stderr), compat(parsestream::eol_newline),
usedefaultmenufilesdirs(true), onlyoutput_to_stdout(false),
- remove_menu(false), verbosity(report_quiet)
+ remove_menu(false), real(false), verbosity(report_quiet)
{ }
typedef enum { report_quiet, report_normal, report_verbose, report_debug} verbosity_type;
@@ -127,6 +127,7 @@
bool onlyoutput_to_stdout;
bool no_dpkg_check;
bool remove_menu;
+ bool real;
/** Read configuration file from filename */
signature.asc
Description: Digital signature

