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

dpkg-deb: Allow to use the same compression for control.tar as data.tar

Add a new --uniform-compression, that allows to use the same compression
parameters on the control.tar member as for the data.tar member.

This is a transitional need, once a dpkg-deb supporting other control.tar
compressions is widely deployed, ideally on stable distribution releases,
then the default could possibly get switched.
Guillem Jover лет назад: 12
Родитель
Сommit
5dd25afbfa
5 измененных файлов с 32 добавлено и 9 удалено
  1. 2 0
      debian/changelog
  2. 12 9
      dpkg-deb/build.c
  3. 1 0
      dpkg-deb/dpkg-deb.h
  4. 10 0
      dpkg-deb/main.c
  5. 7 0
      man/dpkg-deb.1

+ 2 - 0
debian/changelog

@@ -45,6 +45,8 @@ dpkg (1.17.6) UNRELEASED; urgency=low
     as if -Znone had been passed, as documented. Closes: #718295
     as if -Znone had been passed, as documented. Closes: #718295
   * Add support for .deb archives with a control member not compressed
   * Add support for .deb archives with a control member not compressed
     (control.tar) or compressed with xz (control.tar.xz).
     (control.tar) or compressed with xz (control.tar.xz).
+  * Add support for creating uniformly compressed .deb archive members,
+    with the new dpkg-deb option --uniform-compression.
 
 
   [ Updated dpkg translations ]
   [ Updated dpkg translations ]
   * Swedish (Peter Krefting).
   * Swedish (Peter Krefting).

+ 12 - 9
dpkg-deb/build.c

@@ -432,6 +432,7 @@ pkg_get_pathname(const char *dir, struct pkginfo *pkg)
 int
 int
 do_build(const char *const *argv)
 do_build(const char *const *argv)
 {
 {
+  struct compress_params control_compress_params;
   struct dpkg_error err;
   struct dpkg_error err;
   const char *debar, *dir;
   const char *debar, *dir;
   bool subdir;
   bool subdir;
@@ -516,16 +517,18 @@ do_build(const char *const *argv)
            tfbuf);
            tfbuf);
   free(tfbuf);
   free(tfbuf);
 
 
-  /* And run gzip to compress our control archive. */
+  /* And run the compressor on our control archive. */
+  if (opt_uniform_compression) {
+    control_compress_params = compress_params;
+  } else {
+    control_compress_params.type = compressor_type_gzip;
+    control_compress_params.strategy = compressor_strategy_none;
+    control_compress_params.level = -1;
+  }
+
   c2 = subproc_fork();
   c2 = subproc_fork();
   if (!c2) {
   if (!c2) {
-    struct compress_params params;
-
-    params.type = compressor_type_gzip;
-    params.strategy = compressor_strategy_none;
-    params.level = -1;
-
-    compress_filter(&params, p1[0], gzfd, _("compressing control member"));
+    compress_filter(&control_compress_params, p1[0], gzfd, _("compressing control member"));
     exit(0);
     exit(0);
   }
   }
   close(p1[0]);
   close(p1[0]);
@@ -555,7 +558,7 @@ do_build(const char *const *argv)
     char adminmember[16 + 1];
     char adminmember[16 + 1];
 
 
     sprintf(adminmember, "%s%s", ADMINMEMBER,
     sprintf(adminmember, "%s%s", ADMINMEMBER,
-            compressor_get_extension(compressor_type_gzip));
+            compressor_get_extension(control_compress_params.type));
 
 
     dpkg_ar_put_magic(debar, arfd);
     dpkg_ar_put_magic(debar, arfd);
     dpkg_ar_member_put_mem(debar, arfd, DEBMAGIC, deb_magic, strlen(deb_magic));
     dpkg_ar_member_put_mem(debar, arfd, DEBMAGIC, deb_magic, strlen(deb_magic));

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

@@ -36,6 +36,7 @@ action_func do_raw_extract;
 action_func do_fsystarfile;
 action_func do_fsystarfile;
 
 
 extern int opt_verbose;
 extern int opt_verbose;
+extern int opt_uniform_compression;
 extern int debugflag, nocheckflag;
 extern int debugflag, nocheckflag;
 
 
 extern struct deb_version deb_format;
 extern struct deb_version deb_format;

+ 10 - 0
dpkg-deb/main.c

@@ -107,6 +107,7 @@ usage(const struct cmdinfo *cip, const char *value)
 "      --new                        Legacy alias for '--deb-format=2.0'.\n"
 "      --new                        Legacy alias for '--deb-format=2.0'.\n"
 "  --nocheck                        Suppress control file check (build bad\n"
 "  --nocheck                        Suppress control file check (build bad\n"
 "                                     packages).\n"
 "                                     packages).\n"
+"      --uniform-compression        Use the compression params on all members.\n"
 "  -z#                              Set the compression level when building.\n"
 "  -z#                              Set the compression level when building.\n"
 "  -Z<type>                         Set the compression type used when building.\n"
 "  -Z<type>                         Set the compression type used when building.\n"
 "                                     Allowed types: gzip, xz, bzip2, none.\n"
 "                                     Allowed types: gzip, xz, bzip2, none.\n"
@@ -142,6 +143,7 @@ static const char printforhelp[] =
 int debugflag = 0;
 int debugflag = 0;
 int nocheckflag = 0;
 int nocheckflag = 0;
 int opt_verbose = 0;
 int opt_verbose = 0;
+int opt_uniform_compression = 0;
 
 
 struct deb_version deb_format = DEB_VERSION(2, 0);
 struct deb_version deb_format = DEB_VERSION(2, 0);
 
 
@@ -233,6 +235,7 @@ static const struct cmdinfo cmdinfos[]= {
   { "debug",         'D', 0, &debugflag,     NULL,         NULL,          1 },
   { "debug",         'D', 0, &debugflag,     NULL,         NULL,          1 },
   { "verbose",       'v', 0, &opt_verbose,   NULL,         NULL,          1 },
   { "verbose",       'v', 0, &opt_verbose,   NULL,         NULL,          1 },
   { "nocheck",       0,   0, &nocheckflag,   NULL,         NULL,          1 },
   { "nocheck",       0,   0, &nocheckflag,   NULL,         NULL,          1 },
+  { "uniform-compression", 0, 0, &opt_uniform_compression, NULL, NULL,    1 },
   { NULL,            'z', 1, NULL,           NULL,         set_compress_level },
   { NULL,            'z', 1, NULL,           NULL,         set_compress_level },
   { NULL,            'Z', 1, NULL,           NULL,         set_compress_type  },
   { NULL,            'Z', 1, NULL,           NULL,         set_compress_type  },
   { NULL,            'S', 1, NULL,           NULL,         set_compress_strategy },
   { NULL,            'S', 1, NULL,           NULL,         set_compress_strategy },
@@ -255,6 +258,13 @@ int main(int argc, const char *const *argv) {
   if (!compressor_check_params(&compress_params, &err))
   if (!compressor_check_params(&compress_params, &err))
     badusage(_("invalid compressor parameters: %s"), err.str);
     badusage(_("invalid compressor parameters: %s"), err.str);
 
 
+  if (opt_uniform_compression &&
+      (compress_params.type != compressor_type_none &&
+       compress_params.type != compressor_type_gzip &&
+       compress_params.type != compressor_type_xz))
+    badusage(_("unsupported compression type '%s' with uniform compression"),
+             compressor_get_name(compress_params.type));
+
   ret = cipaction->action(argv);
   ret = cipaction->action(argv);
 
 
   dpkg_program_done();
   dpkg_program_done();

+ 7 - 0
man/dpkg-deb.1

@@ -232,6 +232,13 @@ Specify which compression type to use when building a package. Allowed
 values are \fIgzip\fP, \fIxz\fP, \fIbzip2\fP, \fIlzma\fP, and \fInone\fP
 values are \fIgzip\fP, \fIxz\fP, \fIbzip2\fP, \fIlzma\fP, and \fInone\fP
 (default is \fIxz\fP).
 (default is \fIxz\fP).
 .TP
 .TP
+.B \-\-uniform\-compression
+Specify that the same compression parameters should be used for all archive
+members (i.e. \fBcontrol.tar\fP and \fBdata.tar\fP). Otherwise only the
+\fBdata.tar\fP member will use those parameters. The only supported
+compression types allowed to be uniformly used are \fInone\fP, \fIgzip\fP
+and \fIxz\fP.
+.TP
 .BI \-\-deb\-format= format
 .BI \-\-deb\-format= format
 Set the archive format version used when building (since dpkg 1.17.0).
 Set the archive format version used when building (since dpkg 1.17.0).
 Allowed values are \fI2.0\fP for the new format, and \fI0.939000\fP
 Allowed values are \fI2.0\fP for the new format, and \fI0.939000\fP