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.
This commit is contained in:
Roland Clobus 2020-09-02 12:11:27 +02:00 committed by Luca Boccassi
parent 4d7c8c35e3
commit 95cd662f4e
3 changed files with 14 additions and 9 deletions

View File

@ -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 ${?}
}

View File

@ -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"

View File

@ -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