[debhelper-devel] [debhelper] 02/02: Dh_Lib: Rename sub to get_source_epoch_date

Niels Thykier nthykier at moszumanska.debian.org
Wed Aug 12 09:08:16 UTC 2015


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

nthykier pushed a commit to branch master
in repository debhelper.

commit 3d16b06e3825905fb882420d83d8e46f986d16d5
Author: Niels Thykier <niels at thykier.net>
Date:   Wed Aug 12 11:00:55 2015 +0200

    Dh_Lib: Rename sub to get_source_epoch_date
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 Debian/Debhelper/Dh_Lib.pm | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index c5b2748..ebac938 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -1143,11 +1143,11 @@ sub cross_command {
 	}
 }
 
-# Read latest debian/changelog timestamp and export the environment
-# variable SOURCE_DATE_EPOCH with its value, so that any package can
-# read it and replace calls to localtime (or other undeterministic
-# timestamps) with the exported timestamp to get reproducible builds.
-sub set_source_date_epoch {
+# Returns the SOURCE_DATE_EPOCH ENV variable if set OR computes it
+# from the latest changelog entry, sets the SOURCE_DATE_EPOCH ENV
+# variable and returns the computed value.
+sub get_source_date_epoch {
+	return $ENV{SOURCE_DATE_EPOCH} if exists($ENV{SOURCE_DATE_EPOCH});
 	eval "use Dpkg::Changelog::Debian";
 	if ($@) {
 		warning "unable to set SOURCE_DATE_EPOCH: $@";
@@ -1166,7 +1166,7 @@ sub set_source_date_epoch {
 	$tt =~ s/\s*\([^\)]+\)\s*$//; # Remove the optional timezone codename
 	my $timestamp = Time::Piece->strptime($tt, "%a, %d %b %Y %T %z");
 
-	$ENV{SOURCE_DATE_EPOCH} = $timestamp->epoch();
+	return $ENV{SOURCE_DATE_EPOCH} = $timestamp->epoch();
 }
 
 # Sets environment variables from dpkg-buildflags. Avoids changing
@@ -1175,7 +1175,8 @@ sub set_buildflags {
 	return if $ENV{DH_INTERNAL_BUILDFLAGS};
 	$ENV{DH_INTERNAL_BUILDFLAGS}=1;
 
-	set_source_date_epoch();
+	# For the side effect of computing the SOURCE_DATE_EPOCH variable.
+	get_source_date_epoch();
 
 	return if compat(8);
 

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




More information about the debhelper-devel mailing list