From 4f22286657af9dffae66ea12e6ca91cc603a7766 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Thu, 11 May 2023 16:17:33 +0200 Subject: [PATCH 1/4] alpine: fix arch and enable mips64 and s390x Fix detecion of the alpine architecture name. This allows us to create both armv7 and armhf (armv6) containers on an aarch64 host. eg. lxc-create -t alpine a1 -- -a armv7 It also allows us to create mips64 and s390x containers, and potentially new architectures in the future. --- templates/lxc-alpine.in | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/templates/lxc-alpine.in b/templates/lxc-alpine.in index 18f163c..e3bbab1 100644 --- a/templates/lxc-alpine.in +++ b/templates/lxc-alpine.in @@ -133,13 +133,18 @@ latest_release_branch() { parse_arch() { case "$1" in - x86 | i[3-6]86) echo 'x86';; - x86_64 | amd64) echo 'x86_64';; - aarch64 | arm64) echo 'aarch64';; - armv7) echo 'armv7';; - arm*) echo 'armhf';; - ppc64le) echo 'ppc64le';; - *) return 1;; + i[3-6]86) echo 'x86';; + amd64) echo 'x86_64';; + arm64) echo 'aarch64';; + armv6) echo 'armhf';; + *) echo "$1";; + esac +} + +lxc_arch() { + case "$1" in + armv[67]) echo "armhf";; + *) echo "$1";; esac } @@ -261,7 +266,8 @@ install() { echo "$MIRROR_URL/$branch/$repo" >> etc/apk/repositories done - install_packages "$arch" "alpine-base $extra_packages" + install_packages "$arch" "alpine-base $extra_packages" \ + || die 1 "Failed to install $arch packages" make_dev_nodes setup_inittab setup_hosts @@ -384,7 +390,7 @@ setup_services() { configure_container() { local config="$1" local hostname="$2" - local arch="$3" + local arch="$(lxc_arch "$3")" cat <<-EOF >> "$config" @@ -499,12 +505,11 @@ if [ -z "$rootfs" ]; then rootfs="$path/rootfs" fi -arch=$(parse_arch "$arch") \ - || die 1 "Unsupported architecture: $arch" +arch=$(parse_arch "$arch") if [ -z "$release" ]; then release=$(latest_release_branch "$arch") \ - || die 2 'Failed to resolve Alpine last release branch' + || die 2 "Failed to resolve Alpine $arch last release branch" fi # Here we go! -- 2.40.1