From 0920f72996a16a1d3e18b20a600628e9fb7193c6 Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Tue, 25 Aug 2020 16:03:23 +0200 Subject: [PATCH] hooks/setup00-merged-usr.sh: use /usr/share/debootstrap/functions if available and account for different architectures --- hooks/setup00-merged-usr.sh | 39 ++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/hooks/setup00-merged-usr.sh b/hooks/setup00-merged-usr.sh index 4ed9246..7f9f68f 100755 --- a/hooks/setup00-merged-usr.sh +++ b/hooks/setup00-merged-usr.sh @@ -2,9 +2,38 @@ set -exu -rootdir="$1" +TARGET="$1" -for d in bin sbin lib; do - ln -s usr/$d "$rootdir/$d" - mkdir -p "$rootdir/usr/$d" -done +if [ -e "$TARGET/var/lib/dpkg/arch" ]; then + ARCH=$(head -1 "$TARGET/var/lib/dpkg/arch") +else + 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