hooks/setup00-merged-usr.sh: use /usr/share/debootstrap/functions if available and account for different architectures

This commit is contained in:
Johannes 'josch' Schauer 2020-08-25 16:03:23 +02:00
parent 465c056434
commit 0920f72996
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -2,9 +2,38 @@
set -exu set -exu
rootdir="$1" TARGET="$1"
for d in bin sbin lib; do if [ -e "$TARGET/var/lib/dpkg/arch" ]; then
ln -s usr/$d "$rootdir/$d" ARCH=$(head -1 "$TARGET/var/lib/dpkg/arch")
mkdir -p "$rootdir/usr/$d" else
done ARCH=$(dpkg --print-architecture)
fi
if [ -e /usr/share/debootstrap/functions ]; then
. /usr/share/debootstrap/functions
doing_variant () { [ $1 != "buildd" ]; }
MERGED_USR="yes"
setup_merged_usr
else
case $ARCH in
hurd-*) exit 0;;
amd64) link_dir="lib32 lib64 libx32" ;;
i386) link_dir="lib64 libx32" ;;
mips|mipsel) link_dir="lib32 lib64" ;;
mips64*|mipsn32*) link_dir="lib32 lib64 libo32" ;;
powerpc) link_dir="lib64" ;;
ppc64) link_dir="lib32 lib64" ;;
ppc64el) link_dir="lib64" ;;
s390x) link_dir="lib32" ;;
sparc) link_dir="lib64" ;;
sparc64) link_dir="lib32 lib64" ;;
x32) link_dir="lib32 lib64 libx32" ;;
esac
link_dir="bin sbin lib $link_dir"
for dir in $link_dir; do
ln -s usr/"$dir" "$TARGET/$dir"
mkdir -p "$TARGET/usr/$dir"
done
fi