mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-14 07:47:05 +00:00
lxc-alpine: add support for setting arch from command line
This allows us to lxc-create 32 bit guests on x86_64 hosts. Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Acked-by: Stéphane Graber <stgraber@ubuntu.com>
This commit is contained in:
parent
e5846a6f89
commit
2b49de9a3f
@ -9,7 +9,11 @@ install_alpine() {
|
|||||||
else
|
else
|
||||||
cp /etc/apk/repositories "$rootfs"/etc/apk/repositories || return 1
|
cp /etc/apk/repositories "$rootfs"/etc/apk/repositories || return 1
|
||||||
fi
|
fi
|
||||||
${APK:-apk} add -U --initdb --root $rootfs alpine-base
|
opt_arch=
|
||||||
|
if [ -n "$apk_arch" ]; then
|
||||||
|
opt_arch="--arch $apk_arch"
|
||||||
|
fi
|
||||||
|
${APK:-apk} add -U --initdb --root $rootfs $opt_arch alpine-base
|
||||||
}
|
}
|
||||||
|
|
||||||
configure_alpine() {
|
configure_alpine() {
|
||||||
@ -68,6 +72,9 @@ copy_configuration() {
|
|||||||
|
|
||||||
grep -q "^lxc.rootfs" $path/config 2>/dev/null \
|
grep -q "^lxc.rootfs" $path/config 2>/dev/null \
|
||||||
|| echo "lxc.rootfs = $rootfs" >> $path/config
|
|| echo "lxc.rootfs = $rootfs" >> $path/config
|
||||||
|
if [ -n "$lxc_arch" ]; then
|
||||||
|
echo "lxc.arch = $lxc_arch" >> $path/config
|
||||||
|
fi
|
||||||
cat <<EOF >> $path/config
|
cat <<EOF >> $path/config
|
||||||
lxc.tty = 4
|
lxc.tty = 4
|
||||||
lxc.pts = 1024
|
lxc.pts = 1024
|
||||||
@ -120,7 +127,7 @@ die() {
|
|||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat >&2 <<EOF
|
cat >&2 <<EOF
|
||||||
Usage: $(basename $0) [-h|--help] [-r|--repository <url>]
|
Usage: $(basename $0) [-h|--help] [-r|--repository <url>] [-a|--arch <arch>]
|
||||||
-p|--path <path> -n|--name <name>
|
-p|--path <path> -n|--name <name>
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
@ -161,6 +168,11 @@ while [ $# -gt 0 ]; do
|
|||||||
repository=$1
|
repository=$1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-a|--arch)
|
||||||
|
optarg_check $opt "$1"
|
||||||
|
arch=$1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--)
|
--)
|
||||||
break;;
|
break;;
|
||||||
--*=*)
|
--*=*)
|
||||||
@ -193,6 +205,18 @@ if [ -z "$rootfs" ]; then
|
|||||||
rootfs="${path}/rootfs"
|
rootfs="${path}/rootfs"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
lxc_arch=$arch
|
||||||
|
apk_arch=$arch
|
||||||
|
|
||||||
|
case "$arch" in
|
||||||
|
i[3-6]86)
|
||||||
|
apk_arch=x86;;
|
||||||
|
x86)
|
||||||
|
lxc_arch=i686;;
|
||||||
|
x86_64|"") ;;
|
||||||
|
*) die "unsupported architecture: $arch";;
|
||||||
|
esac
|
||||||
|
|
||||||
install_alpine "$rootfs" || die "Failed to install rootfs for $name"
|
install_alpine "$rootfs" || die "Failed to install rootfs for $name"
|
||||||
configure_alpine "$rootfs" "$name" || die "Failed to configure $name"
|
configure_alpine "$rootfs" "$name" || die "Failed to configure $name"
|
||||||
copy_configuration "$path" "$rootfs" "$name"
|
copy_configuration "$path" "$rootfs" "$name"
|
||||||
|
Loading…
Reference in New Issue
Block a user