summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Clobus <rclobus@rclobus.nl>2020-09-02 12:11:27 +0200
committerLuca Boccassi <bluca@debian.org>2021-01-15 09:22:29 +0000
commit95cd662f4e91438cc179a282c31a8b71ceb49715 (patch)
treeb8a413aed09738faa45501d914409987a06f5f52
parent4d7c8c35e3df4a1d8b3000a18acf8019fcee266e (diff)
downloadvyos-live-build-95cd662f4e91438cc179a282c31a8b71ceb49715.tar.gz
vyos-live-build-95cd662f4e91438cc179a282c31a8b71ceb49715.zip
Ensure that SOURCE_DATE_EPOCH is always set in all sub scripts.
When SOURCE_DATE_EPOCH was already set before 'lb config', also enable UTC timestamps.
-rwxr-xr-xfunctions/chroot.sh8
-rwxr-xr-xfunctions/configuration.sh13
-rw-r--r--manpages/en/lb_config.12
3 files changed, 14 insertions, 9 deletions
diff --git a/functions/chroot.sh b/functions/chroot.sh
index d62a4fad0..17a137ed7 100755
--- a/functions/chroot.sh
+++ b/functions/chroot.sh
@@ -29,13 +29,7 @@ Chroot ()
fi
done
- # Only pass SOURCE_DATE_EPOCH if its already set
- if [ "${SOURCE_DATE_EPOCH:-}" != "" ]
- then
- ENV="${ENV} SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}"
- fi
-
- ${_LINUX32} chroot "${CHROOT}" /usr/bin/env -i HOME="/root" PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" TERM="${TERM}" DEBIAN_FRONTEND="${LB_DEBCONF_FRONTEND}" DEBIAN_PRIORITY="${LB_DEBCONF_PRIORITY}" DEBCONF_NONINTERACTIVE_SEEN="true" DEBCONF_NOWARNINGS="true" ${ENV} ${COMMANDS}
+ ${_LINUX32} chroot "${CHROOT}" /usr/bin/env -i HOME="/root" PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" TERM="${TERM}" DEBIAN_FRONTEND="${LB_DEBCONF_FRONTEND}" DEBIAN_PRIORITY="${LB_DEBCONF_PRIORITY}" DEBCONF_NONINTERACTIVE_SEEN="true" DEBCONF_NOWARNINGS="true" SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} ${ENV} ${COMMANDS}
return ${?}
}
diff --git a/functions/configuration.sh b/functions/configuration.sh
index f853dc263..fac1d0958 100755
--- a/functions/configuration.sh
+++ b/functions/configuration.sh
@@ -45,7 +45,18 @@ Prepare_config ()
LB_DISTRIBUTION_CHROOT="${LB_DISTRIBUTION_CHROOT:-${LB_DISTRIBUTION}}"
LB_DISTRIBUTION_BINARY="${LB_DISTRIBUTION_BINARY:-${LB_DISTRIBUTION_CHROOT}}"
- LB_UTC_TIME="${LB_UTC_TIME:-false}"
+ # Do a reproducible build, i.e. is SOURCE_DATE_EPOCH already set?
+ _REPRODUCIBLE="${SOURCE_DATE_EPOCH:-false}"
+ if [ "${_REPRODUCIBLE}" != "false" ]; then
+ _REPRODUCIBLE=true
+ fi
+ # For a reproducible build, use UTC per default, otherwise the local time
+ _UTC_TIME_DEFAULT=${_REPRODUCIBLE}
+
+ # The current time: for a unified timestamp throughout the building process
+ export SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(date '+%s')}"
+
+ LB_UTC_TIME="${LB_UTC_TIME:-${_UTC_TIME_DEFAULT}}"
# Set UTC option for use with `date` where applicable
if [ "${LB_UTC_TIME}" = "true" ]; then
DATE_UTC_OPTION="--utc"
diff --git a/manpages/en/lb_config.1 b/manpages/en/lb_config.1
index c09abfbaa..898d6840c 100644
--- a/manpages/en/lb_config.1
+++ b/manpages/en/lb_config.1
@@ -445,7 +445,7 @@ enables or disables Secure Boot support when using grub-efi, by installing signe
.IP "\fB\-\-updates\fR true|false" 4
defines if debian updates package archives should be included in the image or not.
.IP "\fB\-\-utc\-time\fR true|false" 4
-defines if timestamps should be UTC. Note, this does not affect the build log which remains local time.
+defines if timestamps should be UTC. Default is false, unless SOURCE_DATE_EPOCH is set. Note, this does not affect the build log which remains local time.
.IP "\fB\-\-validate\fR" 4
requests that the config be validated only, not changed, thus after the validation check the script ends rather than writing an updated config. Please note that at the time of writing, many options do not have corresponding validation checks.
.IP "\fB\-\-verbose\fR" 4