]> git.proxmox.com Git - mirror_lxc.git/blobdiff - templates/lxc-alpine.in
Merge pull request #2055 from marcosps/cgfsng_debug
[mirror_lxc.git] / templates / lxc-alpine.in
index fd281f84e2974e844e471c38f5f44b8e1d2a7f12..768e69028f2fb91a378e3d7a943c8515b1f4e788 100644 (file)
@@ -43,10 +43,13 @@ readonly APK_KEYS_SHA256="\
 2adcf7ce224f476330b5360ca5edb92fd0bf91c92d83292ed028d7c4e26333ab  alpine-devel@lists.alpinelinux.org-4d07755e.rsa.pub
 ebf31683b56410ecc4c00acd9f6e2839e237a3b62b5ae7ef686705c7ba0396a9  alpine-devel@lists.alpinelinux.org-5243ef4b.rsa.pub
 1bb2a846c0ea4ca9d0e7862f970863857fc33c32f5506098c636a62a726a847b  alpine-devel@lists.alpinelinux.org-524d27bb.rsa.pub
-12f899e55a7691225603d6fb3324940fc51cd7f133e7ead788663c2b7eecb00c  alpine-devel@lists.alpinelinux.org-5261cecb.rsa.pub"
+12f899e55a7691225603d6fb3324940fc51cd7f133e7ead788663c2b7eecb00c  alpine-devel@lists.alpinelinux.org-5261cecb.rsa.pub
+73867d92083f2f8ab899a26ccda7ef63dfaa0032a938620eda605558958a8041  alpine-devel@lists.alpinelinux.org-58199dcc.rsa.pub
+9a4cd858d9710963848e6d5f555325dc199d1c952b01cf6e64da2c15deedbd97  alpine-devel@lists.alpinelinux.org-58cbb476.rsa.pub
+780b3ed41786772cbc7b68136546fa3f897f28a23b30c72dde6225319c44cfff  alpine-devel@lists.alpinelinux.org-58e4f17d.rsa.pub"
 
 readonly APK_KEYS_URI='http://alpinelinux.org/keys'
-readonly MIRRORS_LIST_URL='http://rsync.alpinelinux.org/alpine/MIRRORS.txt'
+readonly DEFAULT_MIRROR_URL='http://dl-cdn.alpinelinux.org/alpine'
 
 : ${APK_KEYS_DIR:=/etc/apk/keys}
 if ! ls "$APK_KEYS_DIR"/alpine* >/dev/null 2>&1; then
@@ -76,7 +79,7 @@ usage() {
                                          to the host arch.
                   -d, --debug            Run this script in a debug mode (set -x and wget w/o -q).
                   -F, --flush-cache      Remove cached files before build.
-                  -m URL --mirror=URL    The Alpine mirror to use; defaults to random mirror.
+                  -m URL --mirror=URL    The Alpine mirror to use; defaults to $DEFAULT_MIRROR_URL.
                   -r VER, --release=VER  The Alpine release branch to install; default is the
                                          latest stable.
 
@@ -126,15 +129,11 @@ parse_arch() {
                aarch64 | arm64) echo 'aarch64';;
                armv7) echo 'armv7';;
                arm*) echo 'armhf';;
+               ppc64le) echo 'ppc64le';;
                *) return 1;;
        esac
 }
 
-random_mirror_url() {
-       local url=$(fetch "$MIRRORS_LIST_URL" | shuf -n 1)
-       [ -n "$url" ] && echo "$url"
-}
-
 run_exclusively() {
        local lock_name="$1"
        local timeout=$2
@@ -186,7 +185,7 @@ fetch_apk_keys() {
 
        echo "$APK_KEYS_SHA256" | while read -r line; do
                keyname="${line##* }"
-               if [ ! -f "$keyname" ]; then
+               if [ ! -s "$keyname" ]; then
                        fetch "$APK_KEYS_URI/$keyname" > "$keyname"
                fi
                echo "$line" | sha256sum -c -
@@ -211,7 +210,7 @@ fetch_apk_static() {
        fetch "$MIRROR_URL/latest-stable/main/$arch/${pkg_name}-${pkg_ver}.apk" \
                | tar -xz -C "$dest" sbin/  # --extract --gzip --directory
 
-       [ -f "$dest/sbin/apk.static" ] || die 2 'apk.static not found'
+       [ -s "$dest/sbin/apk.static" ] || die 2 'apk.static not found'
 
        local keyname=$(echo "$dest"/sbin/apk.static.*.pub | sed 's/.*\.SIGN\.RSA\.//')
        openssl dgst -sha1 \
@@ -268,8 +267,8 @@ install() {
 }
 
 install_packages() {
-       local arch="$1"; shift
-       local packages="$@"
+       local arch="$1"
+       local packages="$2"
 
        $APK --arch="$arch" --root=. --keys-dir="$APK_KEYS_DIR" \
                --update-cache --initdb add $packages
@@ -389,7 +388,7 @@ configure_container() {
                lxc.arch = $arch
 
                # Set hostname.
-               lxc.utsname = $hostname
+               lxc.uts.name = $hostname
 
                # If something doesn't work, try to comment this out.
                # Dropping sys_admin disables container root from doing a lot of things
@@ -477,14 +476,14 @@ extra_packages="$@"
 # Set global variables.
 readonly DEBUG="$debug"
 readonly FLUSH_CACHE="$flush_cache"
-readonly MIRROR_URL="${mirror_url:-$(random_mirror_url)}"
+readonly MIRROR_URL="${mirror_url:-$DEFAULT_MIRROR_URL}"
 
 # Validate options.
 [ -n "$name" ] || die 1 'Missing required option --name'
 [ -n "$path" ] || die 1 'Missing required option --path'
 
 if [ -z "$rootfs" ] && [ -f "$path/config" ]; then
-       rootfs="$(sed -nE 's/^lxc.rootfs\s*=\s*(.*)$/\1/p' "$path/config")"
+       rootfs="$(sed -nE 's/^lxc.rootfs.path\s*=\s*(.*)$/\1/p' "$path/config")"
 fi
 if [ -z "$rootfs" ]; then
        rootfs="$path/rootfs"