2022-09-06 11:06:40 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
export LC_ALL=C.UTF-8
|
|
|
|
|
2023-02-18 22:05:35 +00:00
|
|
|
trap "rm -rf /tmp/dummypkg.deb /tmp/dummypkg" EXIT INT TERM
|
|
|
|
|
2023-03-19 08:03:19 +00:00
|
|
|
prefix=
|
|
|
|
if [ "$(id -u)" -eq 0 ] && [ "{{ MODE }}" != "root" ] && [ "{{ MODE }}" != "auto" ]; then
|
|
|
|
if ! id "${SUDO_USER:-user}" >/dev/null 2>&1; then
|
|
|
|
if [ ! -e /mmdebstrap-testenv ]; then
|
|
|
|
echo "this test modifies the system and should only be run inside a container" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
useradd --home-dir "/home/${SUDO_USER:-user}" --create-home "${SUDO_USER:-user}"
|
|
|
|
fi
|
|
|
|
prefix="runuser -u ${SUDO_USER:-user} --"
|
|
|
|
fi
|
|
|
|
|
2022-11-14 09:10:30 +00:00
|
|
|
# instead of obtaining a .deb from our cache, we create a new package because
|
|
|
|
# otherwise apt might decide to download the package with the same name and
|
|
|
|
# version from the cache instead of using the local .deb
|
|
|
|
mkdir -p /tmp/dummypkg/DEBIAN
|
|
|
|
cat << END > "/tmp/dummypkg/DEBIAN/control"
|
|
|
|
Package: dummypkg
|
|
|
|
Priority: optional
|
|
|
|
Section: oldlibs
|
|
|
|
Maintainer: Johannes Schauer Marin Rodrigues <josch@debian.org>
|
|
|
|
Architecture: all
|
|
|
|
Multi-Arch: foreign
|
|
|
|
Source: dummypkg
|
|
|
|
Version: 1
|
|
|
|
Description: dummypkg
|
|
|
|
END
|
|
|
|
dpkg-deb --build "/tmp/dummypkg" "/tmp/dummypkg.deb"
|
|
|
|
|
2023-03-19 08:03:19 +00:00
|
|
|
$prefix {{ CMD }} --mode={{ MODE }} --variant=apt --include="/tmp/dummypkg.deb" \
|
2022-11-14 09:10:30 +00:00
|
|
|
--hook-dir=./hooks/file-mirror-automount \
|
|
|
|
--customize-hook='chroot "$1" dpkg-query -W -f="\${Status}\n" dummypkg | grep "^install ok installed$"' \
|
2022-09-06 11:06:40 +00:00
|
|
|
{{ DIST }} /dev/null {{ MIRROR }}
|