1
0
mirror of https://github.com/lxc/lxc-templates.git synced 2025-02-26 19:43:42 +00:00

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.
This commit is contained in:
Natanael Copa 2024-12-10 15:15:28 +02:00 committed by Kaarle Ritvanen
parent 26b4468b26
commit 520ccf8c29

View File

@ -133,13 +133,18 @@ latest_release_branch() {
parse_arch() { parse_arch() {
case "$1" in case "$1" in
x86 | i[3-6]86) echo 'x86';; i[3-6]86) echo 'x86';;
x86_64 | amd64) echo 'x86_64';; amd64) echo 'x86_64';;
aarch64 | arm64) echo 'aarch64';; arm64) echo 'aarch64';;
armv7) echo 'armv7';; armv6) echo 'armhf';;
arm*) echo 'armhf';; *) echo "$1";;
ppc64le) echo 'ppc64le';; esac
*) return 1;; }
lxc_arch() {
case "$1" in
armv[67]) echo "armhf";;
*) echo "$1";;
esac esac
} }
@ -261,7 +266,8 @@ install() {
echo "$MIRROR_URL/$branch/$repo" >> etc/apk/repositories echo "$MIRROR_URL/$branch/$repo" >> etc/apk/repositories
done 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 make_dev_nodes
setup_inittab setup_inittab
setup_hosts setup_hosts
@ -383,7 +389,7 @@ setup_services() {
configure_container() { configure_container() {
local config="$1" local config="$1"
local hostname="$2" local hostname="$2"
local arch="$3" local arch="$(lxc_arch "$3")"
cat <<-EOF >> "$config" cat <<-EOF >> "$config"
@ -498,12 +504,11 @@ if [ -z "$rootfs" ]; then
rootfs="$path/rootfs" rootfs="$path/rootfs"
fi fi
arch=$(parse_arch "$arch") \ arch=$(parse_arch "$arch")
|| die 1 "Unsupported architecture: $arch"
if [ -z "$release" ]; then if [ -z "$release" ]; then
release=$(latest_release_branch "$arch") \ 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 fi
# Here we go! # Here we go!