The following commit has been merged in the master branch:
commit 0790f370e789197b2493b8cd1746374dca9b8316
Author: Guillem Jover <[email protected]>
Date: Mon Sep 10 09:56:35 2012 +0200
dpkg-deb: Add new --deb-format option and base --new and --old on it
The named options are not future-proof, as they will not allow to easily
create packages with specific formats once a future new version gets
introduced. The new option will also allow to request specific minor
revision of a major format, for testing purposes for example.
This also makes the code more explicit as it now refers to specific
format versions when building it.
diff --git a/debian/changelog b/debian/changelog
index 0165116..83df024 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -69,6 +69,9 @@ dpkg (1.17.0) UNRELEASED; urgency=low
* Activate file triggers on removal more accurately, only when we know
we are inevitably removing things.
* Change dir to / before executing maintainer scripts. Closes: #686782
+ * Add new dpkg-deb --deb-format option and base --new and --old on it,
+ as the latter are not future-proof, and neither can be guaranteed to
+ produce a reliable output file format.
-- Guillem Jover <[email protected]> Fri, 03 Aug 2012 13:21:00 +0200
diff --git a/doc/README.feature-removal-schedule
b/doc/README.feature-removal-schedule
index 0b039a0..8a1c13a 100644
--- a/doc/README.feature-removal-schedule
+++ b/doc/README.feature-removal-schedule
@@ -62,6 +62,15 @@ Warning: man page
--control-show, which are a better interface as they do not rely on any
specific database layout.
+What: --new, --old (dpkg-deb options)
+Status: deprecated
+When: 1.18.x
+Warning: program
+Why:
+ These options are not future-proof, and do not give the caller any
+ guarantee of what exact format version will be used to produce the
+ output file. They have been replaced with a new --deb-format option.
+
History of feature removals
~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c
index b798b1f..348e01e 100644
--- a/dpkg-deb/build.c
+++ b/dpkg-deb/build.c
@@ -4,6 +4,7 @@
*
* Copyright © 1994,1995 Ian Jackson <[email protected]>
* Copyright © 2000,2001 Wichert Akkerman <[email protected]>
+ * Copyright © 2007-2012 Guillem Jover <[email protected]>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -495,7 +496,7 @@ do_build(const char *const *argv)
/* We have our first file for the ar-archive. Write a header for it
* to the package and insert it. */
- if (oldformatflag) {
+ if (deb_format.major == 0) {
struct stat controlstab;
char versionbuf[40];
@@ -518,7 +519,7 @@ do_build(const char *const *argv)
close(gzfd);
/* Control is done, now we need to archive the data. */
- if (oldformatflag) {
+ if (deb_format.major == 0) {
/* In old format, the data member is just concatenated after the
* control member, so we do not need a temporary file and can use
* the compression file descriptor. */
@@ -595,7 +596,7 @@ do_build(const char *const *argv)
subproc_wait_check(c2, _("<compress> from tar -cf"), 0);
subproc_wait_check(c1, "tar -cf", 0);
/* Okay, we have data.tar as well now, add it to the ar wrapper. */
- if (!oldformatflag) {
+ if (deb_format.major == 2) {
char datamember[16 + 1];
sprintf(datamember, "%s%s", DATAMEMBER,
diff --git a/dpkg-deb/dpkg-deb.h b/dpkg-deb/dpkg-deb.h
index 1c470cb..1d45135 100644
--- a/dpkg-deb/dpkg-deb.h
+++ b/dpkg-deb/dpkg-deb.h
@@ -3,6 +3,7 @@
* dpkg-deb.h - external definitions for this program
*
* Copyright © 1994,1995 Ian Jackson <[email protected]>
+ * Copyright © 2006-2012 Guillem Jover <[email protected]>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,6 +22,8 @@
#ifndef DPKG_DEB_H
#define DPKG_DEB_H
+#include <dpkg/deb-version.h>
+
action_func do_build;
action_func do_contents;
action_func do_control;
@@ -33,7 +36,9 @@ action_func do_raw_extract;
action_func do_fsystarfile;
extern int opt_verbose;
-extern int debugflag, nocheckflag, oldformatflag;
+extern int debugflag, nocheckflag;
+
+extern struct deb_version deb_format;
enum dpkg_tar_options {
/** Output the tar file directly, without any processing. */
diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c
index cdaeaa3..7db8e60 100644
--- a/dpkg-deb/main.c
+++ b/dpkg-deb/main.c
@@ -102,7 +102,10 @@ usage(const struct cmdinfo *cip, const char *value)
" --showformat=<format> Use alternative format for --show.\n"
" -v, --verbose Enable verbose output.\n"
" -D, --debug Enable debugging output.\n"
-" --old, --new Select archive format.\n"
+" --deb-format=<format> Select archive format.\n"
+" Allowed values: 0.939000, 2.0
(default).\n"
+" --old Legacy alias for
'--deb-format=0.939000'.\n"
+" --new Legacy alias for '--deb-format=2.0'.\n"
" --nocheck Suppress control file check (build bad\n"
" packages).\n"
" -z# Set the compression level when building.\n"
@@ -138,8 +141,44 @@ static const char printforhelp[] =
int debugflag = 0;
int nocheckflag = 0;
-int oldformatflag = 0;
int opt_verbose = 0;
+
+struct deb_version deb_format = DEB_VERSION(2, 0);
+
+static void
+set_deb_format(const struct cmdinfo *cip, const char *value)
+{
+ const char *err;
+
+ err = deb_version_parse(&deb_format, value);
+ if (err)
+ badusage(_("invalid deb format version: %s"), err);
+
+ if ((deb_format.major == 2 && deb_format.minor == 0) ||
+ (deb_format.major == 0 && deb_format.minor == 939000))
+ return;
+ else
+ badusage(_("unknown deb format version: %s"), value);
+}
+
+static void
+set_deb_old(const struct cmdinfo *cip, const char *value)
+{
+ deb_format = DEB_VERSION(0, 939000);
+
+ warning(_("obsolete option '--%s'; please use '--%s' instead"),
+ cip->olong, "deb-format=0.939000");
+}
+
+static void
+set_deb_new(const struct cmdinfo *cip, const char *value)
+{
+ deb_format = DEB_VERSION(2, 0);
+
+ warning(_("obsolete option '--%s'; please use '--%s' instead"),
+ cip->olong, "deb-format=2.0");
+}
+
struct compress_params compress_params = {
.type = compressor_type_gzip,
.strategy = compressor_strategy_none,
@@ -193,8 +232,9 @@ static const struct cmdinfo cmdinfos[]= {
ACTION("fsys-tarfile", 0, 0, do_fsystarfile),
ACTION("show", 'W', 0, do_showinfo),
- { "new", 0, 0, &oldformatflag, NULL, NULL, 0 },
- { "old", 0, 0, &oldformatflag, NULL, NULL, 1 },
+ { "deb-format", 0, 1, NULL, NULL, set_deb_format },
+ { "new", 0, 0, NULL, NULL, set_deb_new },
+ { "old", 0, 0, NULL, NULL, set_deb_old },
{ "debug", 'D', 0, &debugflag, NULL, NULL, 1 },
{ "verbose", 'v', 0, &opt_verbose, NULL, NULL, 1 },
{ "nocheck", 0, 0, &nocheckflag, NULL, NULL, 1 },
diff --git a/man/dpkg-deb.1 b/man/dpkg-deb.1
index 754659e..5618b44 100644
--- a/man/dpkg-deb.1
+++ b/man/dpkg-deb.1
@@ -231,18 +231,21 @@ Specify which compression type to use when building a
package. Allowed
values are \fIgzip\fP, \fIxz\fP, \fIbzip2\fP, \fIlzma\fP, and \fInone\fP
(default is \fIgzip\fP).
.TP
+.BI \-\-deb\-format= format
+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
+for the old one (default is \fI2.0\fP).
+
+The old archive format is less easily parsed by non-Debian tools and is
+now obsolete; its only use is when building packages to be parsed by
+versions of dpkg older than 0.93.76 (September 1995), which was released
+as i386 a.out only.
+.TP
.BR \-\-new
-Ensures that
-.B dpkg\-deb
-builds a `new' format archive. This is the default.
+This is a legacy alias for \fB\-\-deb\-format=2.0\fP.
.TP
.BR \-\-old
-Forces
-.B dpkg\-deb
-to build an `old' format archive. This old archive format is less
-easily parsed by non-Debian tools and is now obsolete; its only use is
-when building packages to be parsed by versions of dpkg older than
-0.93.76 (September 1995), which was released as i386 a.out only.
+This is a legacy alias for \fB\-\-deb\-format=0.939000\fP.
.TP
.BR \-\-nocheck
Inhibits
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]