Fix apt-helper invocation for older versions.

Set up dpkg-divert of dpkg to avoid overwrite when dpkg is properly installed.
This commit is contained in:
Steve Dodd 2020-08-20 19:28:14 +01:00
parent 307cbf5a41
commit 5e66a4fb7f
2 changed files with 11 additions and 4 deletions

View file

@ -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

View file

@ -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