summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Thykier <niels@thykier.net>2015-08-12 11:00:55 +0200
committerNiels Thykier <niels@thykier.net>2015-08-12 11:03:55 +0200
commit3d16b06e3825905fb882420d83d8e46f986d16d5 (patch)
treeb475f7ad0fc678b21d5ae134a1c5e097794f16ca
parentd9ea95e44a83d9f9288b720fbb15b4d8156fd550 (diff)
downloaddebhelper-3d16b06e3825905fb882420d83d8e46f986d16d5.tar.gz
Dh_Lib: Rename sub to get_source_epoch_date
Signed-off-by: Niels Thykier <niels@thykier.net>
-rw-r--r--Debian/Debhelper/Dh_Lib.pm15
1 files changed, 8 insertions, 7 deletions
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index c5b27489..ebac938b 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);