about summary refs log tree commit diff
path: root/buildtools/stamp-date
diff options
context:
space:
mode:
Diffstat (limited to 'buildtools/stamp-date')
-rwxr-xr-xbuildtools/stamp-date25
1 files changed, 20 insertions, 5 deletions
diff --git a/buildtools/stamp-date b/buildtools/stamp-date
index 902c82e4..baeec3fd 100755
--- a/buildtools/stamp-date
+++ b/buildtools/stamp-date
@@ -12,14 +12,29 @@
 # SOURCE_DATE_EPOCH is an environment variable as described here:
 # https://reproducible-builds.org/specs/source-date-epoch/ on 2017.03.16.
 
+# COMPILED_BY is a similar environment variable whose value is some
+# description of who is doing the build.  If it is not set, we use the
+# value of LOGNAME; if that is not set, we use the value of User; if that
+# is not set, we use the output of program 'whoami'.
+
 SOURCE_DATE_OR_NONE=${SOURCE_DATE_EPOCH:-NONE}
 
-BUILD_DATETIME=$(date +%s)
+NOW_FROM_DATE_PGM=$(date +%s)
+if [ "$NOW_FROM_DATE_PGM" = "%s" ]; then
+    # This system's 'date' doesn't know %s.  (Solaris 10 for example).
+    # Try Perl
+    BUILD_DATETIME=$(perl -e 'print time()')
+else
+    BUILD_DATETIME=$NOW_FROM_DATE_PGM
+fi
 
 LOGNAME_OR_UNKNOWN=${LOGNAME:-UNKNOWN}
-USER=${USER:-$LOGNAME_OR_UNKNOWN}
-if [ "$USER" = "UNKNOWN" ]; then
-    USER=$(whoami)
+USER_OR_UNKNOWN=${USER:-$LOGNAME_OR_UNKNOWN}
+COMPILED_BY_OR_UNKNOWN=${COMPILED_BY:-$USER_OR_UNKNOWN}
+if [ "$COMPILED_BY_OR_UNKNOWN" = "UNKNOWN" ]; then
+    COMPILED_BY=$(whoami)
+else
+    COMPILED_BY=$COMPILED_BY_OR_UNKNOWN
 fi
 
 echo "/* This file tells some facts about the building of the package */"
@@ -29,4 +44,4 @@ if [ "$SOURCE_DATE_OR_NONE" != "NONE" ]; then
   echo "#define SOURCE_DATETIME $SOURCE_DATE_OR_NONE"
 fi
 echo "#define BUILD_DATETIME $BUILD_DATETIME"
-echo "#define COMPILED_BY \"$USER\""
+echo "#define COMPILED_BY \"$COMPILED_BY\""