From 7fa40ef513aedffefce9237a7db30340be0b6696 Mon Sep 17 00:00:00 2001 From: cristiano balducci Date: Mon, 28 Dec 2015 13:54:12 +0100 Subject: [PATCH] Additional repo and container cleanup - Added support for adding custom repo (defaults to community) - Added cleanup of the test container (--rm) - Added --text to grep in apkv() to avoid "Binary file matches" output on Fedora Signed-off-by: Cristiano Balducci --- contrib/mkimage-alpine.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/contrib/mkimage-alpine.sh b/contrib/mkimage-alpine.sh index 71fb914388..47cd35ce62 100755 --- a/contrib/mkimage-alpine.sh +++ b/contrib/mkimage-alpine.sh @@ -8,7 +8,7 @@ set -e } usage() { - printf >&2 '%s: [-r release] [-m mirror] [-s]\n' "$0" + printf >&2 '%s: [-r release] [-m mirror] [-s] [-c additional repository]\n' "$0" exit 1 } @@ -19,22 +19,23 @@ tmp() { } apkv() { - curl -sSL $REPO/$ARCH/APKINDEX.tar.gz | tar -Oxz | - grep '^P:apk-tools-static$' -A1 | tail -n1 | cut -d: -f2 + curl -sSL $MAINREPO/$ARCH/APKINDEX.tar.gz | tar -Oxz | + grep --text '^P:apk-tools-static$' -A1 | tail -n1 | cut -d: -f2 } getapk() { - curl -sSL $REPO/$ARCH/apk-tools-static-$(apkv).apk | + curl -sSL $MAINREPO/$ARCH/apk-tools-static-$(apkv).apk | tar -xz -C $TMP sbin/apk.static } mkbase() { - $TMP/sbin/apk.static --repository $REPO --update-cache --allow-untrusted \ + $TMP/sbin/apk.static --repository $MAINREPO --update-cache --allow-untrusted \ --root $ROOTFS --initdb add alpine-base } conf() { - printf '%s\n' $REPO > $ROOTFS/etc/apk/repositories + printf '%s\n' $MAINREPO > $ROOTFS/etc/apk/repositories + printf '%s\n' $ADDITIONALREPO >> $ROOTFS/etc/apk/repositories } pack() { @@ -42,7 +43,7 @@ pack() { id=$(tar --numeric-owner -C $ROOTFS -c . | docker import - alpine:$REL) docker tag $id alpine:latest - docker run -i -t alpine printf 'alpine:%s with id=%s created!\n' $REL $id + docker run -i -t --rm alpine printf 'alpine:%s with id=%s created!\n' $REL $id } save() { @@ -62,6 +63,9 @@ while getopts "hr:m:s" opt; do s) SAVE=1 ;; + c) + ADDITIONALREPO=community + ;; *) usage ;; @@ -71,7 +75,8 @@ done REL=${REL:-edge} MIRROR=${MIRROR:-http://nl.alpinelinux.org/alpine} SAVE=${SAVE:-0} -REPO=$MIRROR/$REL/main +MAINREPO=$MIRROR/$REL/main +ADDITIONALREPO=$MIRROR/$REL/community ARCH=${ARCH:-$(uname -m)} tmp