#!/bin/sh

# libc6: Multi-Arch: same
#   (hence co-installed by build-essential:native)
# libglib2.0-data: Multi-Arch: foreign
#   (but not already installed by build-depends:native)

# python3: Multi-Arch: allowed
#   (but not already installed by build-depends:native)
# The commented parts, here and in 40multiarch, pass on amd64 s390x
# but fail on ppc64el riscv64 with (non fatal but relevant part):
#   /var/lib/dpkg/info/python3.13-minimal.postinst: 51: /usr/bin/python3.13: Exec format error
# A more competent test would be welcome.

dpkg --add-architecture i386
apt-get update
apt-get install -y libc6:i386 libglib2.0-data:i386
# python3:i386

script="${0%-root}"

if [ -n "$AUTOPKGTEST_NORMAL_USER" ]; then
    echo 'FIXME: why is this necessary?'
    echo "       chown $AUTOPKGTEST_NORMAL_USER $AUTOPKGTEST_TMP"
    chown "$AUTOPKGTEST_NORMAL_USER" "$AUTOPKGTEST_TMP"
    runuser -u "$AUTOPKGTEST_NORMAL_USER" /bin/sh "$script"
else
    sh "$script"
fi
