瀏覽代碼

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 <[email protected]>
Jo-Philipp Wich 7 年之前
父節點
當前提交
d157a76c67
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      scripts/ipkg-build

+ 5 - 1
scripts/ipkg-build

@@ -15,8 +15,12 @@ FIND="${FIND:-$(which gfind)}"
 TAR="${TAR:-$(which tar)}"
 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
-if [ -d "$TOPDIR/.git" ]; then
+elif [ -d "$TOPDIR/.git" ]; then
 	GIT="$(which git)"
 	TIMESTAMP=$(cd $TOPDIR; $GIT log -1 -s --format=%ci)
 elif [ -d "$TOPDIR/.svn" ]; then