aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2015-07-14 09:57:19 +0000
committerJohn Crispin <blogic@openwrt.org>2015-07-14 09:57:19 +0000
commitb5f4a9f364263f9f1fdc5093b00b223154aaf5fc (patch)
tree7ef7326177e8a240df113d73dcc1af3ffacc814f /scripts
parentb836f5605179990459d3e22aea192527208902f8 (diff)
downloadmaster-187ad058-b5f4a9f364263f9f1fdc5093b00b223154aaf5fc.tar.gz
master-187ad058-b5f4a9f364263f9f1fdc5093b00b223154aaf5fc.tar.bz2
master-187ad058-b5f4a9f364263f9f1fdc5093b00b223154aaf5fc.zip
ipkg-build: use deterministic timestamps in ipk tarballs
As a follow-up to r46026, this commit sets the modification times of files inside the tarballs to deterministic values. It uses the date of the last git or svn commit and falls back to the old behavior if those are not available. Signed-off-by: Reiner Herrmann <reiner@reiner-h.de> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@46360 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/ipkg-build17
1 files changed, 14 insertions, 3 deletions
diff --git a/scripts/ipkg-build b/scripts/ipkg-build
index 6787ed4199..2d410767f3 100755
--- a/scripts/ipkg-build
+++ b/scripts/ipkg-build
@@ -13,8 +13,19 @@ version=1.0
FIND="$(which find)"
FIND="${FIND:-$(which gfind)}"
TAR="${TAR:-$(which tar)}"
+SVN="$(which svn)"
+GIT="$(which git)"
export GZIP="-n"
+# look up date of last commit
+if [ -d "$TOPDIR/.git" ]; then
+ TIMESTAMP=$($GIT log -1 -s --format=%ci)
+elif [ -d "$TOPDIR/.svn" ]; then
+ TIMESTAMP=$($SVN info "$TOPDIR" | sed -n "s/^Last Changed Date: \(.*\)/\1/p")
+else
+ TIMESTAMP=$(date)
+fi
+
ipkg_extract_value() {
sed -e "s/^[^:]*:[[:space:]]*//"
}
@@ -128,20 +139,20 @@ mkdir $tmp_dir
echo $CONTROL > $tmp_dir/tarX
# Preserve permissions (-p) when creating data.tar.gz as non-root user
-( cd $pkg_dir && $TAR $ogargs -X $tmp_dir/tarX --format=gnu -czpf $tmp_dir/data.tar.gz . )
+( cd $pkg_dir && $TAR $ogargs -X $tmp_dir/tarX --format=gnu -czpf $tmp_dir/data.tar.gz --mtime="$TIMESTAMP" . )
installed_size=`stat -c "%s" $tmp_dir/data.tar.gz`
sed -i -e "s/^Installed-Size: .*/Installed-Size: $installed_size/" \
$pkg_dir/$CONTROL/control
-( cd $pkg_dir/$CONTROL && $TAR $ogargs --format=gnu -czf $tmp_dir/control.tar.gz . )
+( cd $pkg_dir/$CONTROL && $TAR $ogargs --format=gnu -czf $tmp_dir/control.tar.gz --mtime="$TIMESTAMP" . )
rm $tmp_dir/tarX
echo "2.0" > $tmp_dir/debian-binary
pkg_file=$dest_dir/${pkg}_${version}_${arch}.ipk
rm -f $pkg_file
-( cd $tmp_dir && $TAR --format=gnu -zcf $pkg_file ./debian-binary ./data.tar.gz ./control.tar.gz )
+( cd $tmp_dir && $TAR --format=gnu -zcf $pkg_file --mtime="$TIMESTAMP" ./debian-binary ./data.tar.gz ./control.tar.gz )
rm $tmp_dir/debian-binary $tmp_dir/data.tar.gz $tmp_dir/control.tar.gz
rmdir $tmp_dir