[Reproducible-commits] [dpkg] 63/63: dpkg-genbuildinfo: Record some environment variables

Jérémy Bobbio lunar at moszumanska.debian.org
Fri Mar 4 17:44:46 UTC 2016


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch pu/buildinfo
in repository dpkg.

commit 435066d288cb0dc961b1a90762b2a39f1cc37a25
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Sun Jan 31 15:20:24 2016 +0000

    dpkg-genbuildinfo: Record some environment variables
    
    We now record some environment variables in a new Environment field
    according to a whitelist. We also record the computed value for
    dpkg-buildflags using the system and user config.
---
 scripts/dpkg-genbuildinfo.pl | 50 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/scripts/dpkg-genbuildinfo.pl b/scripts/dpkg-genbuildinfo.pl
index 28b6f34..8062434 100755
--- a/scripts/dpkg-genbuildinfo.pl
+++ b/scripts/dpkg-genbuildinfo.pl
@@ -33,6 +33,7 @@ use Dpkg::Gettext;
 use Dpkg::Checksums;
 use Dpkg::ErrorHandling;
 use Dpkg::Arch qw(get_build_arch);
+use Dpkg::BuildFlags;
 use Dpkg::BuildProfiles qw(get_build_profiles);
 use Dpkg::Control::Info;
 use Dpkg::Control::Fields;
@@ -371,4 +372,53 @@ $installed_deps = "\n" . $installed_deps->output();
 $installed_deps =~ s/, /,\n/g;
 $fields->{'Installed-Build-Depends'} = $installed_deps;
 
+my $toolchain =
+    qr{( CC | CPP | CXX
+       | LD | AR | RANLIB
+       | MAKE | AWK
+       )}x;
+my $toolchain_flags =
+    qr{( CFLAGS | CPPFLAGS | CXXFLAGS
+       | OBJCFLAGS | OBJCXXFLAGS
+       | GCJFLAGS | FFLAGS
+       | LDFLAGS | ARFLAGS | MAKEFLAGS
+       )}x;
+my $environment_whitelist =
+    qr{\A( PATH
+         | ${toolchain}
+         | ${toolchain_flags}
+         | LD_LIBRARY_PATH # see ld(1)
+         | LANG | LC_(CTYPE|NUMERIC|TIME|COLLATE|MONETARY|MESSAGES
+                     |PAPER|NAME|ADDRESS|TELEPHONE|MEASUREMENT
+                     |IDENTIFICATION|ALL) # documented in locale(1)
+         | DEB_BUILD_OPTIONS # documented in dpkg-buildpackage(1)
+         | DEB_BUILD_PROFILES # documented in dpkg-buildpackage(1)
+                              # env var will be set if -P is given
+         # DEB_flag_{SET,STRIP,APPEND,PREPEND} will be recorded after
+         # being merged with system config and user config
+         | DEB_VENDOR # documented in deb-vendor(1)
+         | DPKG_DATADIR # documented in dpkg-architecure(1)
+         | DPKG_ORIGINS_DIR # used by Dpkg::Vendor
+         | SOURCE_DATE_EPOCH # see https://reproducible-builds.org/specs/source-date-epoch
+         )\z}x;
+
+my %environment = map { $_, $ENV{$_} } (grep /$environment_whitelist/, sort keys %ENV);
+
+# Record flags from dpkg-buildflags
+my $bf = Dpkg::BuildFlags->new();
+$bf->load_system_config();
+$bf->load_user_config();
+$bf->load_environment_config();
+foreach my $flag ($bf->list()) {
+    if ($bf->get_origin($flag) ne 'vendor') {
+        $environment{"DEB_${flag}_SET"} = $bf->get($flag);
+        # We don't need to record *_{STRIP,APPEND,PREPEND} as they
+        # have been used already to compute the above value
+    }
+}
+
+$fields->{'Environment'} = "\n" .
+    join "\n", map { $_ . '="' . ($environment{$_} =~ s/"/\\"/gr) . '"' }
+                   (sort keys %environment);
+
 $fields->output(\*STDOUT);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list