]> xenbits.xensource.com Git - people/dariof/osstest.git/commitdiff
mg-debian-installer-update: produce deterministic output
authorIan Campbell <ian.campbell@citrix.com>
Sat, 10 Jan 2015 14:58:02 +0000 (14:58 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Sat, 10 Jan 2015 15:17:50 +0000 (15:17 +0000)
Currently rerunning mg-debian-install-update when the external files
have changed still produces differences in the local files produced
during post-processing.

Avoid these differences by:

  - Using gzip -n, which avoids storing a timestamp in the gzip
    header (as well as the name, which we don't need).
  - Using pax -M norm, which normalises all timestamps (among other
    things, such as the owner, which we don't care about)
  - Using tar --mtime, with a reference within the dpkg-deb created
    hierarchy (which has timestamps from the package and is therefore
    dependent only on the downloaded package revision)

With this the results of two invocations of
mg-debian-installer-update(-all) are identical (assuming no changes to
the downloaded files) as demonstrated by runnign this quick hack:

#!/bin/bash

set -ex

TMP=$HOME/tmp/mg-di
rm -rf $TMP
mkdir -p $TMP

cat >$TMP/config <<EOF
TftpPath $TMP
TftpDiBase debian-installer
EOF
cat $TMP/config

mkdir -p $TMP/debian-installer

export OSSTEST_CONFIG=production-config:$TMP/config

# ./mg-debian-installer-update wheezy armhf firmware-bnx2
./mg-debian-installer-update-all

find $TMP/debian-installer -type f -print0 | xargs -0x md5sum > $TMP/SUMS.BASE

#rm -rf $TMP/debian-installer/*
mv $TMP/debian-installer $TMP/debian-installer.org
mkdir -p $TMP/debian-installer

# ./mg-debian-installer-update wheezy armhf firmware-bnx2
./mg-debian-installer-update-all
md5sum --quiet -c $TMP/SUMS.BASE

exit 0

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
mg-debian-installer-update

index 3ae50fb94cc55da2d3bd3ff7bf7cee9dd9548df6..5d12cf0ae7323ad49e068d0eba87d0bd0d179f64 100755 (executable)
@@ -78,8 +78,8 @@ for p in $packages; do
         curl -s "$site/$pkgfile" >$p.deb
         rm -rf x
         dpkg-deb -x $p.deb x
-        cd x; pax -x sv4cpio -s '%lib%/lib%' -w lib >../cpio; cd ..
-        gzip -9f cpio
+        cd x; pax -x sv4cpio -s '%lib%/lib%' -w -M norm lib >../cpio; cd ..
+        gzip -9nf cpio
         mv cpio.gz $p.cpio.gz
         rm -rf x
 done
@@ -135,13 +135,14 @@ if [ $arch = armhf ]; then
                          -path \*/kernel/drivers/scsi/\* -o \
                          -path \*/kernel/drivers/usb/dwc3/\* -o \
                          -path \*/kernel/drivers/usb/host/\* \) \
-          |pax -x sv4cpio -s '%lib%/lib%' -d -w >../cpio; cd ..
-    gzip -9f cpio
+          |pax -x sv4cpio -s '%lib%/lib%' -d -w -M norm >../cpio; cd ..
+    gzip -9nf cpio
     mv cpio.gz armmp.cpio.gz
     rm -rf dtbs/
     mkdir dtbs/
     mv x/usr/lib/linux-image-*-armmp/*.dtb dtbs/
-    tar -caf dtbs.tar.gz dtbs
+    tar --mtime=./x/usr/lib -cf dtbs.tar dtbs
+    gzip -9nf dtbs.tar
     rm -rf x
 fi