Files
minideb/dockerdiff
T
James Westby 44030c910b Make the image build reproducible
Change the mkimage script so that the produced image is
reproducible. This involves:

   - removing the ldconfig aux-cache as it changes on every build.
   - set the mtimes of the files to a specific date so that the
     resulting tar file will have the same contents.
   - The `strings` guard around the unsafe-io tweak seems to be
     non-deterministic. It was sometimes not adding the tweak
     for the same file. Remove it as we don't care about older
     than jessie.
   - Importing the image by constructing a docker image with
     a specific timestamp and doing `docker load`.

Also change the buildall script to build each image twice and
confirm that the same tarball is produced, and that results
in the layers in the imported images matching.

Add a dockerdiff script that checks that two images are equivalent,
and tries to show the differences if not. This is useful when the
build script reports differences, as it can point to what the
differences are.
2017-02-10 11:48:28 +00:00

47 lines
1009 B
Bash
Executable File

#!/bin/bash
# Compare two docker images, reporting what changed.
# The script will exit 1 if there are differences between the images
# other than their tags.
#
# It will also try and show what the differences are, comparing
# - the image config
# - the installed dpkg packages
# - changed file metadata
# - changed file checksums
set -e
set -u
set -o pipefail
IMAGE1=$1
IMAGE2=$2
inspect() {
docker inspect $1 | jq ".[0]|del(.RepoTags,.RepoDigests)"
}
dpkgl() {
docker run --rm $1 dpkg -l
}
lslr() {
docker run --rm $1 bash -c 'find / -xdev -not -path /proc -a -not -path /sys -print0 | sort -z | xargs -0 ls -ld'
}
md5() {
docker run --rm $1 bash -c 'find / -xdev -not -path /etc/hosts -a -not -path /etc/hostname -a -type f -print0 | sort -z | xargs -0 md5sum'
}
_diff() {
local cmd=$1
diff -u --label $IMAGE1 --label $IMAGE2 <($cmd $IMAGE1) <($cmd $IMAGE2)
}
if ! _diff inspect; then
_diff dpkgl || true
_diff lslr || true
_diff md5 || true
exit 1
fi