Browse code

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 <cristiano.balducci@gmail.com>

cristiano balducci authored on 2015/12/28 21:54:12
Showing 1 changed files
... ...
@@ -8,7 +8,7 @@ set -e
8 8
 }
9 9
 
10 10
 usage() {
11
-	printf >&2 '%s: [-r release] [-m mirror] [-s]\n' "$0"
11
+	printf >&2 '%s: [-r release] [-m mirror] [-s]  [-c additional repository]\n' "$0"
12 12
 	exit 1
13 13
 }
14 14
 
... ...
@@ -19,22 +19,23 @@ tmp() {
19 19
 }
20 20
 
21 21
 apkv() {
22
-	curl -sSL $REPO/$ARCH/APKINDEX.tar.gz | tar -Oxz |
23
-		grep '^P:apk-tools-static$' -A1 | tail -n1 | cut -d: -f2
22
+	curl -sSL $MAINREPO/$ARCH/APKINDEX.tar.gz | tar -Oxz |
23
+		grep --text '^P:apk-tools-static$' -A1 | tail -n1 | cut -d: -f2
24 24
 }
25 25
 
26 26
 getapk() {
27
-	curl -sSL $REPO/$ARCH/apk-tools-static-$(apkv).apk |
27
+	curl -sSL $MAINREPO/$ARCH/apk-tools-static-$(apkv).apk |
28 28
 		tar -xz -C $TMP sbin/apk.static
29 29
 }
30 30
 
31 31
 mkbase() {
32
-	$TMP/sbin/apk.static --repository $REPO --update-cache --allow-untrusted \
32
+	$TMP/sbin/apk.static --repository $MAINREPO --update-cache --allow-untrusted \
33 33
 		--root $ROOTFS --initdb add alpine-base
34 34
 }
35 35
 
36 36
 conf() {
37
-	printf '%s\n' $REPO > $ROOTFS/etc/apk/repositories
37
+	printf '%s\n' $MAINREPO > $ROOTFS/etc/apk/repositories
38
+	printf '%s\n' $ADDITIONALREPO >> $ROOTFS/etc/apk/repositories
38 39
 }
39 40
 
40 41
 pack() {
... ...
@@ -42,7 +43,7 @@ pack() {
42 42
 	id=$(tar --numeric-owner -C $ROOTFS -c . | docker import - alpine:$REL)
43 43
 
44 44
 	docker tag $id alpine:latest
45
-	docker run -i -t alpine printf 'alpine:%s with id=%s created!\n' $REL $id
45
+	docker run -i -t --rm alpine printf 'alpine:%s with id=%s created!\n' $REL $id
46 46
 }
47 47
 
48 48
 save() {
... ...
@@ -62,6 +63,9 @@ while getopts "hr:m:s" opt; do
62 62
 		s)
63 63
 			SAVE=1
64 64
 			;;
65
+		c)
66
+			ADDITIONALREPO=community
67
+			;;
65 68
 		*)
66 69
 			usage
67 70
 			;;
... ...
@@ -71,7 +75,8 @@ done
71 71
 REL=${REL:-edge}
72 72
 MIRROR=${MIRROR:-http://nl.alpinelinux.org/alpine}
73 73
 SAVE=${SAVE:-0}
74
-REPO=$MIRROR/$REL/main
74
+MAINREPO=$MIRROR/$REL/main
75
+ADDITIONALREPO=$MIRROR/$REL/community
75 76
 ARCH=${ARCH:-$(uname -m)}
76 77
 
77 78
 tmp