]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-alpine: allow to install additional packages 751/head
authorJakub Jirutka <jakub@jirutka.cz>
Sun, 21 Feb 2016 00:31:19 +0000 (01:31 +0100)
committerJakub Jirutka <jakub@jirutka.cz>
Fri, 26 Feb 2016 13:16:35 +0000 (14:16 +0100)
Signed-off-by: Jakub Jirutka <jakub@jirutka.cz>
templates/lxc-alpine.in

index ef3323d6ed709b80ae4d82c25f5da7dd49680b7e..18feda9f27106b7e354f079c52db860c6e4b4fd4 100644 (file)
@@ -67,7 +67,9 @@ usage() {
        cat <<-EOF
                Template specific options can be passed to lxc-create after a '--' like this:
 
-                  lxc-create --name=NAME [lxc-create-options] -- [template-options]
+                  lxc-create --name=NAME [lxc-create-options] -- [template-options] [PKG...]
+
+               PKG  Additional APK package(s) to install into the container.
 
                Template options:
                   -a ARCH, --arch=ARCH   The container architecture (e.g. x86, x86_64); defaults
@@ -230,6 +232,7 @@ install() {
        local dest="$1"
        local arch="$2"
        local branch="$3"
+       local extra_packages="$4"
        local apk_cache="$LXC_CACHE_DIR/apk/$arch"
        local repo_url="$MIRROR_URL/$branch/main"
 
@@ -244,13 +247,9 @@ install() {
 
        mkdir -p etc/apk
        ln -s "$apk_cache" etc/apk/cache
-
-       $APK --update-cache --initdb --arch="$arch" \
-               --root=. --keys-dir="$APK_KEYS_DIR" --repository="$repo_url" \
-               add alpine-base
-
        echo "$repo_url" > etc/apk/repositories
 
+       install_packages "$arch" alpine-base $extra_packages
        make_dev_nodes
        setup_inittab
        setup_hosts
@@ -264,6 +263,14 @@ install() {
        cd - >/dev/null
 }
 
+install_packages() {
+       local arch="$1"; shift
+       local packages="$@"
+
+       $APK --arch="$arch" --root=. --keys-dir="$APK_KEYS_DIR" \
+               --update-cache --initdb add $packages
+}
+
 make_dev_nodes() {
        mkdir -p -m 755 dev/pts
        mkdir -p -m 1777 dev/shm
@@ -454,6 +461,8 @@ while [ $# -gt 0 ]; do
        esac
 done
 
+extra_packages="$@"
+
 [ "$debug" = 'yes' ] && set -x
 
 # Set global variables.
@@ -482,7 +491,7 @@ fi
 
 # Here we go!
 run_exclusively 'bootstrap' 10 bootstrap
-run_exclusively "$arch" 30 install "$rootfs" "$arch" "$release"
+run_exclusively "$arch" 30 install "$rootfs" "$arch" "$release" "$extra_packages"
 configure_container "$path/config" "$name" "$arch"
 
 einfo "Container's rootfs and config have been created"