script: ipkg-build: honour $SOURCE_DATE_EPOCH

When the SOURCE_DATE_EPOCH environment variable is set, use it to
override the timestamps of .ipk archive contents.

This ensures that .ipk archives built in environments without SCM
metadata (mainly the SDK) are reproducible between different runs.

Ref: https://github.com/openwrt/packages/issues/6954
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
master
Jo-Philipp Wich 2018-11-08 11:52:33 +01:00
parent 559635dbb6
commit d157a76c67
1 changed files with 5 additions and 1 deletions

View File

@ -15,8 +15,12 @@ FIND="${FIND:-$(which gfind)}"
TAR="${TAR:-$(which tar)}" TAR="${TAR:-$(which tar)}"
GZIP="$(which gzip)" GZIP="$(which gzip)"
# try to use fixed source epoch
if [ -n "$SOURCE_DATE_EPOCH" ]; then
TIMESTAMP=$(date --date="@$SOURCE_DATE_EPOCH")
# look up date of last commit # look up date of last commit
if [ -d "$TOPDIR/.git" ]; then elif [ -d "$TOPDIR/.git" ]; then
GIT="$(which git)" GIT="$(which git)"
TIMESTAMP=$(cd $TOPDIR; $GIT log -1 -s --format=%ci) TIMESTAMP=$(cd $TOPDIR; $GIT log -1 -s --format=%ci)
elif [ -d "$TOPDIR/.svn" ]; then elif [ -d "$TOPDIR/.svn" ]; then