Переглянути джерело

dpkg-deb: Add --raw-extract option combining --control and --extract

This allows to extract the control and file system members of a .deb
into a single directory using the same layout dpkg-deb -b expects for
building a package.

Closes: #552123
Guillem Jover 15 роки тому
батько
коміт
02c28c63a3
5 змінених файлів з 45 додано та 0 видалено
  1. 2 0
      debian/changelog
  2. 1 0
      dpkg-deb/dpkg-deb.h
  3. 32 0
      dpkg-deb/extract.c
  4. 3 0
      dpkg-deb/main.c
  5. 7 0
      man/dpkg-deb.1

+ 2 - 0
debian/changelog

@@ -177,6 +177,8 @@ dpkg (1.16.1) UNRELEASED; urgency=low
     in the m4 DPKG_ARCHITECTURE macro.
   * Add new --verbose option to dpkg-deb and change --extract to honour it.
     Closes: #293280
+  * Add new --raw-extract option to dpkg-deb combining --control and
+    --extract. Closes: #552123
   * Fix possible segfault of dpkg in findbreakcycle(). LP: #733414
 
   [ Updated dpkg translations ]

+ 1 - 0
dpkg-deb/dpkg-deb.h

@@ -29,6 +29,7 @@ action_func do_info;
 action_func do_field;
 action_func do_extract;
 action_func do_vextract;
+action_func do_raw_extract;
 action_func do_fsystarfile;
 
 extern int opt_verbose;

+ 32 - 0
dpkg-deb/extract.c

@@ -390,3 +390,35 @@ do_vextract(const char *const *argv)
   opt_verbose = 1;
   return do_extract(argv);
 }
+
+int
+do_raw_extract(const char *const *argv)
+{
+  const char *debar, *dir;
+  char *control_dir;
+
+  debar = *argv++;
+  if (debar == NULL)
+    badusage(_("--%s needs a .deb filename argument"), cipaction->olong);
+
+  dir = *argv++;
+  if (dir == NULL)
+    badusage(_("--%s needs a target directory.\n"
+               "Perhaps you should be using dpkg --install ?"),
+             cipaction->olong);
+  else if (*argv)
+    badusage(_("--%s takes at most two arguments (.deb and directory)"),
+             cipaction->olong);
+
+  m_asprintf(&control_dir, "%s/%s", dir, EXTRACTCONTROLDIR);
+
+  if (opt_verbose)
+    extracthalf(debar, dir, "xpv", 0);
+  else
+    extracthalf(debar, dir, "xp", 0);
+  extracthalf(debar, control_dir, "x", 1);
+
+  free(control_dir);
+
+  return 0;
+}

+ 3 - 0
dpkg-deb/main.c

@@ -79,6 +79,8 @@ usage(const struct cmdinfo *cip, const char *value)
 "  -e|--control <deb> [<directory>] Extract control info.\n"
 "  -x|--extract <deb> <directory>   Extract files.\n"
 "  -X|--vextract <deb> <directory>  Extract & list files.\n"
+"  -R|--raw-extract <deb> <directory>\n"
+"                                   Extract control info and files.\n"
 "  --fsys-tarfile <deb>             Output filesystem tarfile.\n"
 "\n"));
 
@@ -167,6 +169,7 @@ static const struct cmdinfo cmdinfos[]= {
   ACTION("field",         'f', 0, do_field),
   ACTION("extract",       'x', 0, do_extract),
   ACTION("vextract",      'X', 0, do_vextract),
+  ACTION("raw-extract",   'R', 0, do_raw_extract),
   ACTION("fsys-tarfile",  0,   0, do_fsystarfile),
   ACTION("show",          'W', 0, do_showinfo),
 

+ 7 - 0
man/dpkg-deb.1

@@ -143,6 +143,13 @@ with
 .BR \-\-verbose " (" \-v ")"
 which prints a listing of the files extracted as it goes.
 .TP
+.BR \-R ", " \-\-raw\-extract " \fIarchive directory\fP"
+Extracts the filesystem tree from a package archive into a specified
+directory, and the control information files into a DEBIAN subdirectory
+of the specified directory.
+
+The target directory (but not its parents) will be created if necessary.
+.TP
 .BR \-\-fsys\-tarfile " \fIarchive\fP"
 Extracts the filesystem tree data from a binary package and sends it
 to standard output in