summaryrefslogtreecommitdiffstats
path: root/hooks/eatmydata/customize.sh
blob: c6758488a6e2913577e26ddf6ecb0f88798fa5c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh

set -eu

if [ "${MMDEBSTRAP_VERBOSITY:-1}" -ge 3 ]; then
	set -x
fi

rootdir="$1"

if [ -e "$rootdir/var/lib/dpkg/arch" ]; then
	chrootarch=$(head -1 "$rootdir/var/lib/dpkg/arch")
else
	chrootarch=$(dpkg --print-architecture)
fi
libdir="/usr/lib/$(dpkg-architecture -a "$chrootarch" -q DEB_HOST_MULTIARCH)"

# if eatmydata was actually installed properly, then we are not removing
# anything here
if ! chroot "$rootdir" dpkg-query --show eatmydata; then
	rm "$rootdir/usr/bin/eatmydata"
fi
if ! chroot "$rootdir" dpkg-query --show libeatmydata1; then
	rm "$rootdir$libdir"/libeatmydata.so*
fi

rm "$rootdir/usr/bin/dpkg"
chroot "$rootdir" dpkg-divert --local --rename --remove /usr/bin/dpkg

sync