Bug#341701: Bug#452801: menu: Does not consider virtual packages as installed

2008-03-06 Thread Robert Luberda
Bill Allombert writes:

Hi,

 
 Please try the script in the bug #462648: it report a failure if I
 apply the patch...

I did some research and it turned out that the patch I sent you
yesterday accidentally fixes the problem ;)

Without the patch the 'dpkg-query | sed' pipe always fails when
update-menus runs in background. There're two reasons of this:
 - In background mode update-menus closes all file descriptors and than
reopens stdin for /tmp/update-menus.xxx file (keeping stderr closed).
 - For some unknown reason sed fails when stderr is closed, e.g.:
sed -e ''  /dev/null 2- || echo failed with $?



Regards,
robert



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#341701: Bug#452801: menu: Does not consider virtual packages as installed

2008-03-05 Thread Robert Luberda
Bill Allombert writes:

Hi,
 
 Well, I applied the following patch (w.r.t the CVS version) and this
 breaks menu auto-update feature.  This is very strange.


What do you mean by this? I got the current CVS version, built it and
installed and everything seemed to work OK.

BTW. I've discovered that the /tmp/update-menus.XXX log files are never
written into. Attached patch fixes this minor issue.

Regards,
robert
Index: update-menus.cc
===
RCS file: /cvsroot/menu/menu/update-menus/update-menus.cc,v
retrieving revision 1.59
diff -u -r1.59 update-menus.cc
--- update-menus.cc	27 Feb 2008 13:31:03 -	1.59
+++ update-menus.cc	5 Mar 2008 21:31:54 -
@@ -1022,9 +1025,12 @@
 wait_dpkg(stdoutfile);
 if(!stdoutfile.empty()) {
   close(1);
-  open(stdoutfile.c_str(), O_WRONLY|O_CREAT|O_SYNC|O_EXCL, 0666);
   close(2);
-  dup2(1,2);
+  int i = open(stdoutfile.c_str(), O_WRONLY|O_CREAT|O_SYNC|O_EXCL, 0666);
+  if (i != 2) {
+	  dup2(i,2);
+	  close(i);
+	}  
 }
 if (config.remove_menu)
 {
 }


Bug#341701: Bug#452801: menu: Does not consider virtual packages as installed

2008-03-05 Thread Bill Allombert
On Wed, Mar 05, 2008 at 10:45:26PM +0100, Robert Luberda wrote:
 Bill Allombert writes:
 
 Hi,
  
  Well, I applied the following patch (w.r.t the CVS version) and this
  breaks menu auto-update feature.  This is very strange.
 
 What do you mean by this? I got the current CVS version, built it and
 installed and everything seemed to work OK.

Please try the script in the bug #462648: it report a failure if I
apply the patch...

 BTW. I've discovered that the /tmp/update-menus.XXX log files are never
 written into. Attached patch fixes this minor issue.

Thanks you very much for this fix!

Cheers,
-- 
Bill. [EMAIL PROTECTED]

Imagine a large red swirl here. 



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#341701: Bug#452801: menu: Does not consider virtual packages as installed

2008-03-03 Thread Bill Allombert
On Sun, Jan 27, 2008 at 11:26:40AM +0100, Robert Luberda wrote:
 tags 341701 patch
 thanks
 
 Bill Allombert writes:
 
 
 Hi,
 
 Thanks a lot, it seems fine.
 By any chance do you have an idea how to fix bug #341701 ?
 
 
 The problem is the standard shell returns exit status of the last 
 command as the status of pipe. You can obey this either by avoiding the 
 pipe (i.e. running only dpkg-query and do filtering directly in 
 update-menus) or by using non-POSIX `pipefail' option (so you need to 
 make sure shell supports it).
 
 A simple patch for the second solution:
 
 In read_packages() just after initialization of pkgs variable add the 
 following line:
 
  pkgs = exec /bin/bash -o pipefail -c \ + pkgs + \;
 
 
 Of course you need to check return value of pclose() call, e.g.:
 
   if (pclose(status)) {
 
 exit (1);
   }

Well, I applied the following patch (w.r.t the CVS version) and this
breaks menu auto-update feature.  This is very strange.

Cheers,
-- 
Bill. [EMAIL PROTECTED]

Imagine a large red swirl here. 
Index: update-menus/update-menus.cc
===
RCS file: /cvsroot/menu/menu/update-menus/update-menus.cc,v
retrieving revision 1.59
diff -u -r1.59 update-menus.cc
--- update-menus/update-menus.cc27 Feb 2008 13:31:03 -  1.59
+++ update-menus/update-menus.cc3 Mar 2008 19:37:04 -
@@ -436,7 +436,8 @@
 {
   // Here we get the list of *installed* packages from dpkg, using sed to
   // retrieve the package name.
-  string pkgs = dpkg-query --show --showformat='${status} ${provides} 
${package}\\n' | sed -n -e '/installed /{s/^.*installed *//; s/[, ][, ]*/\\n/g; 
p}';
+  string pkgs = dpkg-query --show --showformat=\\\${status} \\${provides} 
\\${package}\\n\ | sed -n -e \/installed /{s/^.*installed *//; s/[, ][, 
]*/\\n/g; p}\;
+  pkgs = exec /bin/bash -o pipefail -c ' + pkgs + ';
   FILE *status = popen(pkgs.c_str(), r);
 
   if (!status)
@@ -455,7 +456,8 @@
   installed_packages.insert(tmp);
 }
   }
-  pclose(status);
+  if (pclose(status))
+throw pipeerror_read(pkgs.c_str());
 }
 
 /** Read a menufile and create one (or more) menu entries for it.


Bug#341701: Bug#452801: menu: Does not consider virtual packages as installed

2008-01-27 Thread Robert Luberda

tags 341701 patch
thanks

Bill Allombert writes:


Hi,


Thanks a lot, it seems fine.
By any chance do you have an idea how to fix bug #341701 ?



The problem is the standard shell returns exit status of the last 
command as the status of pipe. You can obey this either by avoiding the 
pipe (i.e. running only dpkg-query and do filtering directly in 
update-menus) or by using non-POSIX `pipefail' option (so you need to 
make sure shell supports it).


A simple patch for the second solution:

In read_packages() just after initialization of pkgs variable add the 
following line:


 pkgs = exec /bin/bash -o pipefail -c \ + pkgs + \;


Of course you need to check return value of pclose() call, e.g.:

  if (pclose(status)) {

exit (1);
  }



Regards,
robert



--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]