Преглед на файлове

dpkg-genbuildinfo: Use deterministic .buildinfo filenames

Using undeterministic filenames based on the buildinfo-id produces ugly
looking filenames, which get left behind when rebuilding the same source
multiple times as they vary by date.

There's really no great point in using unique filenames as they will end
up with different contents depending on the builder.
Guillem Jover преди 9 години
родител
ревизия
d5005e4576

+ 2 - 0
debian/changelog

@@ -8,6 +8,8 @@ dpkg (1.18.15) UNRELEASED; urgency=medium
   * On source builds add 'source' to the Architecture field in the
     .buildinfo file in dpkg-genbuildinfo.
   * Add new Build-Date field to .buildinfo files.
+  * Generate deterministic .buildinfo filenames in dpkg-genbuildinfo,
+    following the same pattern as used for .changes files.
   * Perl modules:
     - Validate architecture arguments in Dpkg::Deps deps_parse().
       Prompted by Johannes Schauer <josch@debian.org>.

+ 8 - 8
man/deb-buildinfo.man

@@ -46,14 +46,14 @@ see below).
 The control data might be enclosed in an OpenPGP ASCII Armored signature,
 as specified in RFC4880.
 .PP
-The \fB.buildinfo\fP filename by default has the following form:
-
-\fIsource-name\fP\fB_\fP\fIsource-version\fP\fB_\fP\fIbuildinfo-id\fP\fB.buildinfo\fP
-
-where \fIbuildinfo-id\fP is composed of the build time formatted as
-\fBstrftime\fP(2) «%Y%m%dT%H%M%Sz», followed by a minus ‘\-’ and the
-eight left-most characters from the \fB.buildinfo\fP's file contents MD5
-digest.
+The name of the \fB.buildinfo\fP file will depend on the type of build and
+will be as specific as necessary but not more;
+for a build that includes \fBany\fP the name will be
+\fIsource-name\fP\fB_\fP\fIsource-version\fP\fB_\fP\fIarch\fP\fB.buildinfo\fP,
+or otherwise for a build that includes \fBall\fP the name will be
+\fIsource-name\fP\fB_\fP\fIsource-version\fP\fB_\fP\fBall.buildinfo\fP,
+or otherwise for a build that includes \fBsource\fP the name will be
+\fIsource-name\fP\fB_\fP\fIsource-version\fP\fB_\fP\fBsource.buildinfo\fP.
 .
 .SH FIELDS
 .TP

+ 0 - 11
man/dpkg-buildpackage.man

@@ -373,17 +373,6 @@ The source package version (without the epoch).
 The upstream version.
 .RE
 .TP
-.BI \-\-buildinfo-id= identifier
-Specify the identifier part of the \fB.buildinfo\fP file name
-(since dpkg 1.18.11).
-By default, \fBdpkg\-buildpackage\fP will create an identifier using
-the current time and the first characters of the MD5 hash.
-An arbitrary identifier can be specified as a replacement.
-The identifier has the same restriction as package names: it must consist
-only of lower case letters (a-z), digits (0-9), plus (+) and minus (\-)
-signs, and periods (.), be at least two characters long and must start
-with an alphanumeric character.
-.TP
 .BI \-\-buildinfo\-option= opt
 Pass option \fIopt\fP to \fBdpkg\-genbuildinfo\fP (since dpkg 1.18.11).
 Can be used multiple times.

+ 1 - 11
man/dpkg-genbuildinfo.man

@@ -92,7 +92,7 @@ for information about alternative formats.
 .BR \-O [\fIfilename\fP]
 Print the buildinfo file to standard output (or \fIfilename\fP if specified)
 rather than to
-.IB dir / source-name _ source-version _ buildinfo-id .buildinfo
+.IB dir / source-name _ source-version _ arch .buildinfo
 (where \fIdir\fP is \fB..\fP by default or \fIupload-files-dir\fP
 if \fB\-u\fP was used).
 .TP
@@ -104,16 +104,6 @@ rather than
 (\fBdpkg\-genbuildinfo\fP needs to find these files so that it can include
 their sizes and checksums in the \fB.buildinfo\fP file).
 .TP
-.BI \-\-buildinfo-id= identifier
-Specify the identifier part of the \fB.buildinfo\fP file name.
-By default, \fBdpkg\-genbuildinfo\fP will create an identifier using
-the current time and the first characters of the MD5 hash.
-An arbitrary identifier can be specified as a replacement.
-The identifier has the same restriction as package names: it must consist
-only of lower case letters (a-z), digits (0-9), plus (+) and minus (\-)
-signs, and periods (.), be at least two characters long and must start
-with an alphanumeric character.
-.TP
 .BI \-\-always\-include\-path
 By default, the \fBBuild\-Path\fR field will only be written if the current
 directory starts with a whitelisted pattern.

+ 0 - 18
scripts/Test/Dpkg.pm

@@ -111,24 +111,6 @@ sub test_neutralize_checksums
     open my $fh, '<', $filename or die;
     while (<$fh>) {
         s/^ ([0-9a-f]{32,}) [1-9][0-9]* /q{ } . $1 =~ tr{0-9a-f}{0}r . q{ 0 }/e;
-        s{^
-            (
-                \s
-                # Digest
-                0{32,}
-                \s
-                # Size
-                0
-                # Optional Section and Priority
-                (?:\s[\w]*\s[\w]*)?
-                \s
-                # Filename (package and version)
-                [^_]*_[^_]*
-            )
-            # Filename (architecture and extension)
-            _[^.]*\.(buildinfo)
-            $
-        }{$1_20160101T123000z-00000000.$2}x;
         print { $fhnew } $_;
     }
     close $fh or die;

+ 3 - 13
scripts/dpkg-buildpackage.pl

@@ -95,7 +95,6 @@ sub usage {
       --hook-<name>=<command> set <command> as the hook <name>, known hooks:
                                 init preclean source build binary buildinfo
                                 changes postclean check sign done
-      --buildinfo-id=<id>     set the <id> part of the .buildinfo filename.
       --buildinfo-option=<opt>
                               pass option <opt> to dpkg-genbuildinfo.
   -p, --sign-command=<command>
@@ -172,7 +171,6 @@ my $since;
 my $maint;
 my $changedby;
 my $desc;
-my $buildinfo_id;
 my @buildinfo_opts;
 my @changes_opts;
 my @hook_names = qw(
@@ -235,8 +233,9 @@ while (@ARGV) {
 	usageerr(g_('missing hook %s command'), $hook_name)
 	    if not defined $hook_cmd;
 	$hook{$hook_name} = $hook_cmd;
-    } elsif (/^--buildinfo-id=(.*)$/) {
-	$buildinfo_id = $1;
+    } elsif (/^--buildinfo-id=.*$/) {
+	# Deprecated option
+	warning('--buildinfo-id is deprecated, it is without effect');
     } elsif (/^(?:-p|--sign-command=)(.*)$/) {
 	$signcommand = $1;
     } elsif (/^(?:-k|--sign-key=)(.*)$/) {
@@ -404,14 +403,6 @@ if (defined $parallel) {
     $build_opts->export();
 }
 
-if (defined $buildinfo_id) {
-    # The .buildinfo identifiers have the same restrictions as package names.
-    my $err = pkg_name_is_illegal($buildinfo_id);
-    if ($err) {
-        error(g_("illegal .buildinfo ID '%s': %s"), $buildinfo_id, $err);
-    }
-}
-
 set_build_profiles(@build_profiles) if @build_profiles;
 
 my $cwd = cwd();
@@ -564,7 +555,6 @@ if (build_has_any(BUILD_BINARY)) {
 run_hook('buildinfo', 1);
 
 push @buildinfo_opts, "--build=$build_types" if build_has_none(BUILD_DEFAULT);
-push @buildinfo_opts, "--buildinfo-id=$buildinfo_id" if $buildinfo_id;
 push @buildinfo_opts, "--admindir=$admindir" if $admindir;
 
 withecho('dpkg-genbuildinfo', @buildinfo_opts);

+ 12 - 13
scripts/dpkg-genbuildinfo.pl

@@ -33,7 +33,7 @@ use Dpkg ();
 use Dpkg::Gettext;
 use Dpkg::Checksums;
 use Dpkg::ErrorHandling;
-use Dpkg::Arch qw(get_build_arch);
+use Dpkg::Arch qw(get_build_arch get_host_arch);
 use Dpkg::Build::Types;
 use Dpkg::Build::Info qw(get_build_env_whitelist);
 use Dpkg::BuildFlags;
@@ -62,7 +62,6 @@ my $admindir = $Dpkg::ADMINDIR;
 my $always_include_path = 0;
 my @build_profiles = get_build_profiles();
 my $buildinfo_format = '0.1';
-my $buildinfo_id;
 my $buildinfo;
 
 my $checksums = Dpkg::Checksums->new();
@@ -289,7 +288,6 @@ sub usage {
   -F<changelog-format>     force changelog format.
   -O[<buildinfo-file>]     write to stdout (or <buildinfo-file>).
   -u<upload-files-dir>     directory with files (default is '..').
-  --buildinfo-id=<id>      specify the buildinfo id for the output file.
   --always-include-path    always include Build-Path.
   --admindir=<directory>   change the administrative directory.
   -?, --help               show this help message.
@@ -315,8 +313,9 @@ while (@ARGV) {
         $stdout = 1;
     } elsif (m/^-O(.*)$/) {
         $outputfile = $1;
-    } elsif (m/^--buildinfo-id=(.*)$/) {
-        $buildinfo_id = $1;
+    } elsif (m/^--buildinfo-id=.*$/) {
+        # Deprecated option
+        warning('--buildinfo-id is deprecated, it is without effect');
     } elsif (m/^--always-include-path$/) {
         $always_include_path = 1;
     } elsif (m/^--admindir=(.*)$/) {
@@ -433,17 +432,17 @@ if ($stdout) {
 } elsif (defined $outputfile) {
     $buildinfo = basename($outputfile);
 } else {
-    if (not defined $buildinfo_id) {
-        require Digest::MD5;
+    my $arch;
 
-        my $buildinfo_contents = $fields->output();
-
-        my $timestamp = strftime('%Y%m%dT%H%M%Sz', gmtime);
-        my $buildinfo_md5 = Digest::MD5::md5_hex($buildinfo_contents);
-        $buildinfo_id = "$timestamp-" . substr($buildinfo_md5, 0, 8);
+    if (build_has_any(BUILD_ARCH_DEP)) {
+        $arch = get_host_arch();
+    } elsif (build_has_any(BUILD_ARCH_INDEP)) {
+        $arch = 'all';
+    } elsif (build_has_any(BUILD_SOURCE)) {
+        $arch = 'source';
     }
 
-    $buildinfo = "${spackage}_${sversion}_${buildinfo_id}.buildinfo";
+    $buildinfo = "${spackage}_${sversion}_${arch}.buildinfo";
     $outputfile = "$uploadfilesdir/$buildinfo";
 }
 

+ 3 - 3
scripts/t/dpkg_buildpackage/test-source_0_all.changes

@@ -18,10 +18,10 @@ Changes:
    * Entry. Closes: #12345
 Checksums-Sha1:
  0000000000000000000000000000000000000000 0 test-binary-all_0_all.deb
- 0000000000000000000000000000000000000000 0 test-source_0_20160101T123000z-00000000.buildinfo
+ 0000000000000000000000000000000000000000 0 test-source_0_all.buildinfo
 Checksums-Sha256:
  0000000000000000000000000000000000000000000000000000000000000000 0 test-binary-all_0_all.deb
- 0000000000000000000000000000000000000000000000000000000000000000 0 test-source_0_20160101T123000z-00000000.buildinfo
+ 0000000000000000000000000000000000000000000000000000000000000000 0 test-source_0_all.buildinfo
 Files:
  00000000000000000000000000000000 0 test optional test-binary-all_0_all.deb
- 00000000000000000000000000000000 0 test optional test-source_0_20160101T123000z-00000000.buildinfo
+ 00000000000000000000000000000000 0 test optional test-source_0_all.buildinfo

+ 3 - 3
scripts/t/dpkg_buildpackage/test-source_0_any.changes

@@ -18,10 +18,10 @@ Changes:
    * Entry. Closes: #12345
 Checksums-Sha1:
  0000000000000000000000000000000000000000 0 test-binary-any_0_amd64.deb
- 0000000000000000000000000000000000000000 0 test-source_0_20160101T123000z-00000000.buildinfo
+ 0000000000000000000000000000000000000000 0 test-source_0_amd64.buildinfo
 Checksums-Sha256:
  0000000000000000000000000000000000000000000000000000000000000000 0 test-binary-any_0_amd64.deb
- 0000000000000000000000000000000000000000000000000000000000000000 0 test-source_0_20160101T123000z-00000000.buildinfo
+ 0000000000000000000000000000000000000000000000000000000000000000 0 test-source_0_amd64.buildinfo
 Files:
  00000000000000000000000000000000 0 test optional test-binary-any_0_amd64.deb
- 00000000000000000000000000000000 0 test optional test-source_0_20160101T123000z-00000000.buildinfo
+ 00000000000000000000000000000000 0 test optional test-source_0_amd64.buildinfo

+ 3 - 3
scripts/t/dpkg_buildpackage/test-source_0_binary.changes

@@ -19,12 +19,12 @@ Changes:
 Checksums-Sha1:
  0000000000000000000000000000000000000000 0 test-binary-all_0_all.deb
  0000000000000000000000000000000000000000 0 test-binary-any_0_amd64.deb
- 0000000000000000000000000000000000000000 0 test-source_0_20160101T123000z-00000000.buildinfo
+ 0000000000000000000000000000000000000000 0 test-source_0_amd64.buildinfo
 Checksums-Sha256:
  0000000000000000000000000000000000000000000000000000000000000000 0 test-binary-all_0_all.deb
  0000000000000000000000000000000000000000000000000000000000000000 0 test-binary-any_0_amd64.deb
- 0000000000000000000000000000000000000000000000000000000000000000 0 test-source_0_20160101T123000z-00000000.buildinfo
+ 0000000000000000000000000000000000000000000000000000000000000000 0 test-source_0_amd64.buildinfo
 Files:
  00000000000000000000000000000000 0 test optional test-binary-all_0_all.deb
  00000000000000000000000000000000 0 test optional test-binary-any_0_amd64.deb
- 00000000000000000000000000000000 0 test optional test-source_0_20160101T123000z-00000000.buildinfo
+ 00000000000000000000000000000000 0 test optional test-source_0_amd64.buildinfo

+ 3 - 3
scripts/t/dpkg_buildpackage/test-source_0_full.changes

@@ -21,16 +21,16 @@ Checksums-Sha1:
  0000000000000000000000000000000000000000 0 test-source_0.tar.xz
  0000000000000000000000000000000000000000 0 test-binary-all_0_all.deb
  0000000000000000000000000000000000000000 0 test-binary-any_0_amd64.deb
- 0000000000000000000000000000000000000000 0 test-source_0_20160101T123000z-00000000.buildinfo
+ 0000000000000000000000000000000000000000 0 test-source_0_amd64.buildinfo
 Checksums-Sha256:
  0000000000000000000000000000000000000000000000000000000000000000 0 test-source_0.dsc
  0000000000000000000000000000000000000000000000000000000000000000 0 test-source_0.tar.xz
  0000000000000000000000000000000000000000000000000000000000000000 0 test-binary-all_0_all.deb
  0000000000000000000000000000000000000000000000000000000000000000 0 test-binary-any_0_amd64.deb
- 0000000000000000000000000000000000000000000000000000000000000000 0 test-source_0_20160101T123000z-00000000.buildinfo
+ 0000000000000000000000000000000000000000000000000000000000000000 0 test-source_0_amd64.buildinfo
 Files:
  00000000000000000000000000000000 0 test optional test-source_0.dsc
  00000000000000000000000000000000 0 test optional test-source_0.tar.xz
  00000000000000000000000000000000 0 test optional test-binary-all_0_all.deb
  00000000000000000000000000000000 0 test optional test-binary-any_0_amd64.deb
- 00000000000000000000000000000000 0 test optional test-source_0_20160101T123000z-00000000.buildinfo
+ 00000000000000000000000000000000 0 test optional test-source_0_amd64.buildinfo