Просмотр исходного кода

dpkg-deb: Add support for reading the archive from standard input

All commands reading archives support this, except for --raw-extract
that does not.

Closes: #616614
Based-on-patch-by: Johannes Schauer <j.schauer@email.de>
Guillem Jover лет назад: 11
Родитель
Сommit
d3d8d778d7
3 измененных файлов с 18 добавлено и 1 удалено
  1. 3 0
      debian/changelog
  2. 7 1
      dpkg-deb/extract.c
  3. 8 0
      man/dpkg-deb.1

+ 3 - 0
debian/changelog

@@ -72,6 +72,9 @@ dpkg (1.18.0) UNRELEASED; urgency=low
     an Architecture field. Regression introduced in dpkg 1.16.2.
   * Fix «dpkg --audit» to report missing and empty architecture fields.
     Regression introduced in dpkg 1.16.2.
+  * Add support to dpkg-deb for reading the archive from standard input,
+    except for --raw-extract which does not yet support it. Closes: #616614
+    Based on a patch by Johannes Schauer <j.schauer@email.de>.
 
   [ Updated manpages translations ]
   * German (Helge Kreutzmann).

+ 7 - 1
dpkg-deb/extract.c

@@ -123,7 +123,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))
@@ -475,6 +478,9 @@ do_raw_extract(const char *const *argv)
   if (debar == NULL)
     badusage(_("--%s needs .deb filename and directory arguments"),
              cipaction->olong);
+  else if (strcmp(debar, "-") == 0)
+    badusage(_("--%s does not support (yet) reading the .deb from standard input"),
+             cipaction->olong);
 
   dir = *argv++;
   if (dir == NULL)

+ 8 - 0
man/dpkg-deb.1

@@ -43,6 +43,11 @@ with whatever options you want to pass to
 will spot that you wanted
 .B dpkg\-deb
 and run it for you.
+.PP
+For most commands taking an input archive argument, the archive can be
+read from standard input if the archive name is given as a single minus
+character (\fB\-\fP); otherwise lack of support will be documented in
+their respective command description.
 .
 .SH COMMANDS
 .TP
@@ -169,6 +174,9 @@ directory, and the control information files into a DEBIAN subdirectory
 of the specified directory (since dpkg 1.16.1).
 
 The target directory (but not its parents) will be created if necessary.
+
+The input archive is not (currently) processed sequentially, so reading
+it from standard input (\fB-\fP) is \fBnot\fP supported.
 .TP
 .BR \-\-ctrl\-tarfile " \fIarchive\fP"
 Extracts the control data from a binary package and sends it to standard