From 5e66a4fb7fe8b023dad55c724ccba6b5ddcc4df7 Mon Sep 17 00:00:00 2001 From: Steve Dodd Date: Thu, 20 Aug 2020 19:28:14 +0100 Subject: [PATCH] Fix apt-helper invocation for older versions. Set up dpkg-divert of dpkg to avoid overwrite when dpkg is properly installed. --- hooks/eatmydata/customize.sh | 3 ++- hooks/eatmydata/extract.sh | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hooks/eatmydata/customize.sh b/hooks/eatmydata/customize.sh index 6dfcf62..d031c86 100755 --- a/hooks/eatmydata/customize.sh +++ b/hooks/eatmydata/customize.sh @@ -20,6 +20,7 @@ if ! chroot "$rootdir" dpkg-query --list libeatmydata1; then rm "$rootdir$libdir"/libeatmydata.so* fi -mv "$rootdir/usr/bin/dpkg.orig" "$rootdir/usr/bin/dpkg" +rm "$rootdir/usr/bin/dpkg" +chroot "$rootdir" dpkg-divert --local --rename --remove /usr/bin/dpkg sync diff --git a/hooks/eatmydata/extract.sh b/hooks/eatmydata/extract.sh index 593c339..6dfaf6d 100755 --- a/hooks/eatmydata/extract.sh +++ b/hooks/eatmydata/extract.sh @@ -32,7 +32,8 @@ env --chdir="$tmpdir" APT_CONFIG="$tmpfile" apt-get download --print-uris eatmyd echo "$tmpdir/$fname already exists" >&2 exit 1 fi - env --chdir="$tmpdir" APT_CONFIG="$tmpfile" /usr/lib/apt/apt-helper download-file "$uri" "$fname" Checksum-FileSize:"$size" "$hash" + [ -z "$hash" ] && hash="Checksum-FileSize:$size" + env --chdir="$tmpdir" APT_CONFIG="$tmpfile" /usr/lib/apt/apt-helper download-file "$uri" "$fname" "$hash" case "$fname" in eatmydata_*_all.deb) mkdir -p "$rootdir/usr/bin" @@ -55,9 +56,14 @@ done rm "$tmpfile" rmdir "$tmpdir" -mv "$rootdir/usr/bin/dpkg" "$rootdir/usr/bin/dpkg.orig" +mv "$rootdir/usr/bin/dpkg" "$rootdir/usr/bin/dpkg.distrib" cat << END > "$rootdir/usr/bin/dpkg" #!/bin/sh -exec /usr/bin/eatmydata /usr/bin/dpkg.orig "\$@" +exec /usr/bin/eatmydata /usr/bin/dpkg.distrib "\$@" END chmod +x "$rootdir/usr/bin/dpkg" +cat << END >> "$rootdir/var/lib/dpkg/diversions" +/usr/bin/dpkg +/usr/bin/dpkg.distrib +: +END