Bug#616614: /usr/bin/dpkg-deb: Please support --fsys-tarfile - to mean stdin

2014-12-16 Thread Johannes Schauer
Control: tag -1 patch

Hi,

please find attached a simple patch which enables this functionality by
assigning STDIN_FILENO to the file descriptor instead of trying to open it if
the filename is equal to -.

The tricky part is, that the archive filename is not an argument to the
--ctrl-tarfile or --fsys-tarfile argument as it could be interpreted from the
dpkg-deb man page. Instead, the archive filename is a positional argument and
since there can be no positional argument starting with a minus character, it
must be given after a -- like this:

dpkg-deb --ctrl-tarfile -- -

I added a note about this into the man page.

Thanks!

cheers, josch
diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c
index 2c92940..00683f9 100644
--- a/dpkg-deb/extract.c
+++ b/dpkg-deb/extract.c
@@ -124,7 +124,10 @@ extracthalf(const char *debar, const char *dir,
   bool header_done;
   enum compressor_type decompressor = COMPRESSOR_TYPE_GZIP;
 
-  arfd = open(debar, O_RDONLY);
+  if (strcmp(debar, -) == 0)
+arfd = STDIN_FILENO;
+  else
+arfd = open(debar, O_RDONLY);
   if (arfd  0)
 ohshite(_(failed to read archive `%.255s'), debar);
   if (fstat(arfd, stab))
diff --git a/man/dpkg-deb.1 b/man/dpkg-deb.1
index c5038ec..9fa2aea 100644
--- a/man/dpkg-deb.1
+++ b/man/dpkg-deb.1
@@ -43,6 +43,12 @@ with whatever options you want to pass to
 will spot that you wanted
 .B dpkg\-deb
 and run it for you.
+.PP
+.B dpkg\-deb
+can also read the archive from standard input if the archive name is given as
+single minus character. Note, that this argument must be interpreted as a
+positional argument and must thus be specified after a separating \-\-
+(without the quotes).
 .
 .SH COMMANDS
 .TP


Bug#616614: /usr/bin/dpkg-deb: Please support --fsys-tarfile - to mean stdin

2014-12-16 Thread Guillem Jover
Hi!

On Tue, 2014-12-16 at 09:45:54 +0100, Johannes Schauer wrote:
 please find attached a simple patch which enables this functionality by
 assigning STDIN_FILENO to the file descriptor instead of trying to open it if
 the filename is equal to -.
 
 The tricky part is, that the archive filename is not an argument to the
 --ctrl-tarfile or --fsys-tarfile argument as it could be interpreted from the
 dpkg-deb man page. Instead, the archive filename is a positional argument and
 since there can be no positional argument starting with a minus character, it
 must be given after a -- like this:
 
 dpkg-deb --ctrl-tarfile -- -
 
 I added a note about this into the man page.

Thanks! I've merged it for 1.18.x, and added the same for
--fsys-tarfile. I don't remember if there was any reason why I didn't
implement this at the time, though. :)

Regards,
Guillem


-- 
To UNSUBSCRIBE, email to debian-dpkg-bugs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#616614: /usr/bin/dpkg-deb: Please support --fsys-tarfile - to mean stdin

2014-12-16 Thread Guillem Jover
On Tue, 2014-12-16 at 16:20:49 +0100, Guillem Jover wrote:
 On Tue, 2014-12-16 at 09:45:54 +0100, Johannes Schauer wrote:
  please find attached a simple patch which enables this functionality by
  assigning STDIN_FILENO to the file descriptor instead of trying to open it 
  if
  the filename is equal to -.
  
  The tricky part is, that the archive filename is not an argument to the
  --ctrl-tarfile or --fsys-tarfile argument as it could be interpreted from 
  the
  dpkg-deb man page. Instead, the archive filename is a positional argument 
  and
  since there can be no positional argument starting with a minus character, 
  it
  must be given after a -- like this:
  
  dpkg-deb --ctrl-tarfile -- -
  
  I added a note about this into the man page.
 
 Thanks! I've merged it for 1.18.x, and added the same for
 --fsys-tarfile.

I meant the man page update, but the problem anyway is that there
are some archive arguments that are output names. Hmmm. I guess it
will need more rewording.

 I don't remember if there was any reason why I didn't
 implement this at the time, though. :)

At least now, this will not work with --raw-extract.

Regards,
Guillem


-- 
To UNSUBSCRIBE, email to debian-dpkg-bugs-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org