--- menu-2.1.14.old/update-menus/common.h 2004-05-17 20:43:35 +0400 +++ menu-2.1.14/update-menus/common.h 2004-06-18 17:53:32 +0400 @@ -37,7 +37,7 @@ const int MAX_LINE = 10240; #define USERMETHODS ".menu-methods/" #define UPMEN_LOCKFILE "/var/run/update-menus.pid" -#define DPKG_LOCKFILE "/var/lib/dpkg/lock" +#define RPM_LOCKFILE "/var/lib/rpm/Packages" #define TRANSLATE_FILE "/etc/menu-methods/translate_menus" #define USERTRANSLATE ".menu-methods/translate_menus" #define CONFIG_FILE "/etc/menu-methods/menu.config" --- menu-2.1.41/update-menus/update-menus.cc~ 2008-11-10 15:38:23 +0300 +++ menu-2.1.41/update-menus/update-menus.cc 2008-11-10 15:40:47 +0300 @@ -447,10 +447,7 @@ void read_pkginfo() { // Here we get the list of *installed* packages from dpkg, using sed to // retrieve the package name. - string inst_states="installed\\|triggers-awaited\\|triggers-pending"; - string pkgs = "dpkg-query --show --showformat=\"\\${status} \\${provides} \\${package}\\n\" | sed -n -e \"/" + inst_states - + " /{s/^.*\\("+inst_states+"\\) *//; s/[, ][, ]*/\\n/g; p}\""; - pkgs = "exec /bin/bash -o pipefail -c '" + pkgs + "'"; + string pkgs = "rpm -qa --provides --queryformat '%{NAME}\n'"; FILE *status = popen(pkgs.c_str(), "r"); if (!status) @@ -776,11 +773,11 @@ int check_dpkglock() config.report(_("Update-menus is run by user."), configinfo::report_verbose); return 0; } - fl.l_type = F_WRLCK; + fl.l_type = F_RDLCK; fl.l_whence = SEEK_SET; fl.l_start = 0; fl.l_len = 0; - fd = open(DPKG_LOCKFILE, O_RDWR|O_CREAT|O_TRUNC, 0660); + fd = open(RPM_LOCKFILE,O_RDONLY, 0644); if (fd == -1) /* Probably /var/lib/dpkg does not exist. * Most probably dpkg is not running. @@ -847,8 +844,8 @@ void wait_dpkg(string &stdoutfile) // 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" - "(checking %1)"), DPKG_LOCKFILE), + config.report(String::compose(_("Waiting for rpm to finish (forking to background).\n" + "(checking %1)"), RPM_LOCKFILE), configinfo::report_normal); config.report(String::compose(_("Further output (if any) will appear in %1."), stdoutfile), configinfo::report_normal); @@ -869,8 +866,17 @@ void wait_dpkg(string &stdoutfile) } setsid(); // Sit and wait until dpkg is finished ... - while(check_dpkglock()) - sleep(2); + int n_unlocks = 0; + while(true) + { + if( check_dpkglock() ) + n_unlocks = 0; + else + n_unlocks++; + if( n_unlocks > 3 ) + break; + sleep(1); + } } } else { // Dpkg is not locked. Try to get the u-m lock. If we can't get it, @@ -882,7 +888,7 @@ void wait_dpkg(string &stdoutfile) if (!no_fork && !verbose) stdoutfile = "/dev/null"; - config.report(_("Dpkg is not locking dpkg status area, good."), + config.report(_("RPM is not locking rpm status area, good."), configinfo::report_verbose); } }