lxc-debian: support unnoficial architectures out of the box

When trying to create containers for unnoficial Debian architectures,
use different defaults for mirror and keyring, install
debian-ports-archive-keyring, and default release to unstable. This way
one can create containers for unnoficial architectures without having to
pass several extra parameters.

Signed-off-by: Antonio Terceiro <terceiro@debian.org>
This commit is contained in:
Antonio Terceiro 2022-04-10 06:20:05 -03:00
parent eebcd76feb
commit 5479240fbd

View File

@ -36,13 +36,16 @@ done
export PATH=$PATH:/usr/sbin:/usr/bin:/sbin:/bin export PATH=$PATH:/usr/sbin:/usr/bin:/sbin:/bin
export GREP_OPTIONS="" export GREP_OPTIONS=""
MIRROR=${MIRROR:-http://deb.debian.org/debian} DEBIAN_MIRROR=http://deb.debian.org/debian
DEBIAN_PORTS_MIRROR=${MIRROR:-http://deb.debian.org/debian-ports}
MIRROR=${MIRROR:-${DEBIAN_MIRROR}}
SECURITY_MIRROR=${SECURITY_MIRROR:-http://security.debian.org/} SECURITY_MIRROR=${SECURITY_MIRROR:-http://security.debian.org/}
LOCALSTATEDIR="@LOCALSTATEDIR@" LOCALSTATEDIR="@LOCALSTATEDIR@"
LXC_TEMPLATE_CONFIG="@LXCTEMPLATECONFIG@" LXC_TEMPLATE_CONFIG="@LXCTEMPLATECONFIG@"
# Allows the lxc-cache directory to be set by environment variable # Allows the lxc-cache directory to be set by environment variable
LXC_CACHE_PATH=${LXC_CACHE_PATH:-"$LOCALSTATEDIR/cache/lxc"} LXC_CACHE_PATH=${LXC_CACHE_PATH:-"$LOCALSTATEDIR/cache/lxc"}
DEBIAN_ARCHIVE_KEYRING=/usr/share/keyrings/debian-archive-keyring.gpg DEBIAN_ARCHIVE_KEYRING=/usr/share/keyrings/debian-archive-keyring.gpg
DEBIAN_PORTS_ARCHIVE_KEYRING=/usr/share/keyrings/debian-ports-archive-keyring.gpg
KEYRING=${KEYRING:-${DEBIAN_ARCHIVE_KEYRING}} KEYRING=${KEYRING:-${DEBIAN_ARCHIVE_KEYRING}}
DOWNLOAD_KEYRING=${DOWNLOAD_KEYRING:-1} DOWNLOAD_KEYRING=${DOWNLOAD_KEYRING:-1}
@ -733,6 +736,7 @@ elif [ "$arch" = "mips64" -a "$littleendian" = "yes" ]; then
arch="mips64el" arch="mips64el"
fi fi
hostarch=$arch hostarch=$arch
packages=
mainonly=1 mainonly=1
flushcache=0 flushcache=0
@ -774,6 +778,21 @@ if [ "$arch" = "x86_64" ]; then
arch=amd64 arch=amd64
fi fi
testing_release_file=${DEBIAN_MIRROR}/dists/testing/main/binary-${arch}/Release
if ! wget -q -O /dev/null "${testing_release_file}"; then
echo "${arch} does not look like a release architecture, trying debian ports"
# non-release architecture; assume debian-ports architecture
if [ "${MIRROR}" = "${DEBIAN_MIRROR}" ]; then
MIRROR="${DEBIAN_PORTS_MIRROR}"
fi
if [ "${KEYRING}" = "${DEBIAN_ARCHIVE_KEYRING}" ]; then
KEYRING="${DEBIAN_PORTS_ARCHIVE_KEYRING}"
fi
packages="debian-ports-archive-keyring,${packages}"
release="${release:-unstable}"
fi
if [ "$interpreter" = "" ] ; then if [ "$interpreter" = "" ] ; then
if [ $hostarch = "i386" -a $arch = "amd64" ]; then if [ $hostarch = "i386" -a $arch = "amd64" ]; then
echo "can't create $arch container on $hostarch" echo "can't create $arch container on $hostarch"