1
0
mirror of https://github.com/lxc/lxc-templates.git synced 2025-06-21 00:34:45 +00:00

Compare commits

...

7 Commits

Author SHA1 Message Date
Kaarle Ritvanen
5e1c10b3ed
Merge 02e47a6914f7f213f3e0b81963475dda442db300 into c128b962b3c21dc3e870a91de2d75fecf42bfa58 2025-03-16 10:23:00 +07:00
Stéphane Graber
c128b962b3
gentoo: Fix getting stage3
Closes #69

Suggests-by: atlant2011
Signed-off-by: Stéphane Graber <stgraber@stgraber.org>
2025-03-15 15:19:50 -04:00
Jingyun Hua
02e47a6914 alpine: add loongarch64 key 2024-12-10 15:15:28 +02:00
Natanael Copa
edccec80a9 alpine: only create missing device node
Avoid error out if some of the device nodes exists
2024-12-10 15:15:28 +02:00
Natanael Copa
f185645220 alpine: add riscv64 key 2024-12-10 15:15:28 +02:00
Natanael Copa
580796d0b4 alpine: use https repository by default 2024-12-10 15:15:28 +02:00
Natanael Copa
520ccf8c29 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.
2024-12-10 15:15:28 +02:00
2 changed files with 40 additions and 18 deletions

View File

@ -55,10 +55,12 @@ db0b49163f07ffba64a5ca198bcf1688610b0bd1f0d8d5afeaf78559d73f2278 alpine-devel@l
0caf5662fde45616d88cfd7021b7bda269a2fcaf311e51c48945a967a609ec0b alpine-devel@lists.alpinelinux.org-616ac3bc.rsa.pub 0caf5662fde45616d88cfd7021b7bda269a2fcaf311e51c48945a967a609ec0b alpine-devel@lists.alpinelinux.org-616ac3bc.rsa.pub
ebe717d228555aa58133c202314a451f81e71f174781fd7ff8d8970d6cfa60da alpine-devel@lists.alpinelinux.org-616adfeb.rsa.pub ebe717d228555aa58133c202314a451f81e71f174781fd7ff8d8970d6cfa60da alpine-devel@lists.alpinelinux.org-616adfeb.rsa.pub
d11f6b21c61b4274e182eb888883a8ba8acdbf820dcc7a6d82a7d9fc2fd2836d alpine-devel@lists.alpinelinux.org-616ae350.rsa.pub d11f6b21c61b4274e182eb888883a8ba8acdbf820dcc7a6d82a7d9fc2fd2836d alpine-devel@lists.alpinelinux.org-616ae350.rsa.pub
40a216cbd163f22e5f16a9e0929de7cde221b9cbae8e36aa368b1e128afe0a31 alpine-devel@lists.alpinelinux.org-616db30d.rsa.pub" 40a216cbd163f22e5f16a9e0929de7cde221b9cbae8e36aa368b1e128afe0a31 alpine-devel@lists.alpinelinux.org-616db30d.rsa.pub
db0b49163f07ffba64a5ca198bcf1688610b0bd1f0d8d5afeaf78559d73f2278 alpine-devel@lists.alpinelinux.org-60ac2099.rsa.pub
7cf4cb8314e6ccc985b0d7f1aa0c6e0a81e3588f69a41f383af7a63d1ba61793 alpine-devel@lists.alpinelinux.org-66ba20fe.rsa.pub"
readonly APK_KEYS_URI='https://git.alpinelinux.org/aports/plain/main/alpine-keys/' readonly APK_KEYS_URI='https://git.alpinelinux.org/aports/plain/main/alpine-keys/'
readonly DEFAULT_MIRROR_URL='http://dl-cdn.alpinelinux.org/alpine' readonly DEFAULT_MIRROR_URL='https://dl-cdn.alpinelinux.org/alpine'
: ${APK_KEYS_DIR:=/etc/apk/keys} : ${APK_KEYS_DIR:=/etc/apk/keys}
if ! ls "$APK_KEYS_DIR"/alpine* >/dev/null 2>&1; then if ! ls "$APK_KEYS_DIR"/alpine* >/dev/null 2>&1; then
@ -133,13 +135,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
} }
@ -275,7 +282,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
@ -297,18 +305,33 @@ install_packages() {
--update-cache --initdb add $packages --update-cache --initdb add $packages
} }
_mknod() {
while getopts "m:" opt; do
case $opt in
m) MODE="-m $OPTARG";;
\?) return 1;;
esac
done
shift $((OPTIND - 1))
test -c "$1" && return 0 # device exists
test -f "$1" && rm -f "$1" # device is a regular file
mknod $MODE $@
}
make_dev_nodes() { make_dev_nodes() {
mkdir -p -m 755 dev/pts mkdir -p -m 755 dev/pts
mkdir -p -m 1777 dev/shm mkdir -p -m 1777 dev/shm
local i; for i in $(seq 0 4); do local i; for i in $(seq 0 4); do
mknod -m 620 dev/tty$i c 4 $i _mknod -m 620 dev/tty$i c 4 $i
chown 0:5 dev/tty$i # root:tty chown 0:5 dev/tty$i # root:tty
done done
mknod -m 666 dev/tty c 5 0 _mknod -m 666 dev/tty c 5 0
chown 0:5 dev/tty # root:tty chown 0:5 dev/tty # root:tty
mknod -m 666 dev/ptmx c 5 2 _mknod -m 620 dev/console c 5 1
_mknod -m 666 dev/ptmx c 5 2
chown 0:5 dev/ptmx # root:tty chown 0:5 dev/ptmx # root:tty
} }
@ -397,7 +420,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"
@ -512,12 +535,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!

View File

@ -163,7 +163,7 @@ cache_stage3()
printf "Determining path to latest Gentoo %s (%s) stage3 archive...\n" "${arch}" "${variant}" printf "Determining path to latest Gentoo %s (%s) stage3 archive...\n" "${arch}" "${variant}"
printf " => downloading and processing %s\n" "${stage3_pointer}" printf " => downloading and processing %s\n" "${stage3_pointer}"
local stage3_latest_tarball=$(wget -q -O - "${stage3_pointer}" | tail -n1 | cut -d' ' -f1) \ local stage3_latest_tarball=$(wget -q -O - "${stage3_pointer}" | grep stage3 | tail -n1 | cut -d' ' -f1) \
|| die 6 "Error: unable to fetch\n" || die 6 "Error: unable to fetch\n"
printf " => Got: %s\n" "${stage3_latest_tarball}" printf " => Got: %s\n" "${stage3_latest_tarball}"