diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2016-12-15 16:14:51 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2016-12-16 09:50:00 +0000 |
commit | 99afbc0aaa18bb50949e16c2cd9d146110205769 (patch) | |
tree | 13f12b3405840784d575707d6201f3ba90948685 | |
parent | fb36c21471581754b91298d1a03e240f9fa0d68f (diff) | |
download | alpine_aports-99afbc0aaa18bb50949e16c2cd9d146110205769.tar.bz2 alpine_aports-99afbc0aaa18bb50949e16c2cd9d146110205769.tar.xz alpine_aports-99afbc0aaa18bb50949e16c2cd9d146110205769.zip |
scripts: add minirootfs release image
-rwxr-xr-x | scripts/genrootfs.sh | 56 | ||||
-rwxr-xr-x | scripts/mkimage.sh | 2 | ||||
-rwxr-xr-x | scripts/mkimg.minirootfs.sh | 21 |
3 files changed, 78 insertions, 1 deletions
diff --git a/scripts/genrootfs.sh b/scripts/genrootfs.sh new file mode 100755 index 0000000000..9c9df40bb1 --- /dev/null +++ b/scripts/genrootfs.sh | |||
@@ -0,0 +1,56 @@ | |||
1 | #!/bin/sh -e | ||
2 | |||
3 | cleanup() { | ||
4 | rm -rf "$tmp" | ||
5 | } | ||
6 | |||
7 | tmp="$(mktemp -d)" | ||
8 | trap cleanup EXIT | ||
9 | |||
10 | arch="$(apk --print-arch)" | ||
11 | repositories_file=/etc/apk/repositories | ||
12 | keys_dir=/etc/apk/keys | ||
13 | |||
14 | while getopts "a:r:k:o:" opt; do | ||
15 | case $opt in | ||
16 | a) arch="$OPTARG";; | ||
17 | r) repositories_file="$OPTARG";; | ||
18 | k) keys_dir="$OPTARG";; | ||
19 | o) outfile="$OPTARG";; | ||
20 | esac | ||
21 | done | ||
22 | shift $(( $OPTIND - 1)) | ||
23 | |||
24 | cat "$repositories_file" | ||
25 | |||
26 | if [ -z "$outfile" ]; then | ||
27 | outfile=$name-$arch.tar.gz | ||
28 | fi | ||
29 | |||
30 | ${APK:-apk} add --keys-dir "$keys_dir" \ | ||
31 | --repositories-file "$repositories_file" \ | ||
32 | --no-script --no-cache --root "$tmp" --initdb \ | ||
33 | "$@" | ||
34 | for link in $("$tmp"/bin/busybox --list-full); do | ||
35 | [ -e "$tmp"/$link ] || ln -s /bin/busybox "$tmp"/$link | ||
36 | done | ||
37 | |||
38 | ${APK:-apk} fetch --keys-dir "$keys_dir" \ | ||
39 | --repositories-file "$repositories_file" \ | ||
40 | --stdout alpine-base | tar -zx -C "$tmp" etc/ | ||
41 | |||
42 | branch=edge | ||
43 | VERSION_ID=$(awk -F= '$1=="VERSION_ID" {print $2}' "$tmp"/etc/os-release) | ||
44 | case $VERSION_ID in | ||
45 | *_alpha*|*_beta*) branch=edge;; | ||
46 | *.*.*) branch=v${VERSION_ID%.*};; | ||
47 | esac | ||
48 | |||
49 | cat > "$tmp"/etc/apk/repositories <<EOF | ||
50 | http://dl-cdn.alpinelinux.org/alpine/$branch/main | ||
51 | http://dl-cdn.alpinelinux.org/alpine/$branch/community | ||
52 | EOF | ||
53 | |||
54 | #rm -rf "$tmp"/var/cache/apk/* | ||
55 | |||
56 | tar --numeric-owner -c -C "$tmp" . | gzip -9n > "$outfile" | ||
diff --git a/scripts/mkimage.sh b/scripts/mkimage.sh index 07ff24b26f..14fa2a60fd 100755 --- a/scripts/mkimage.sh +++ b/scripts/mkimage.sh | |||
@@ -172,7 +172,7 @@ build_profile() { | |||
172 | 172 | ||
173 | if [ "$_dirty" = "yes" -o ! -e "$output_file" ]; then | 173 | if [ "$_dirty" = "yes" -o ! -e "$output_file" ]; then |
174 | # Create image | 174 | # Create image |
175 | output_format="${image_ext//[:\.]/}" | 175 | [ -n "$output_format" ] || output_format="${image_ext//[:\.]/}" |
176 | create_image_${output_format} || { _fail="yes"; false; } | 176 | create_image_${output_format} || { _fail="yes"; false; } |
177 | 177 | ||
178 | if [ "$_checksum" = "yes" ]; then | 178 | if [ "$_checksum" = "yes" ]; then |
diff --git a/scripts/mkimg.minirootfs.sh b/scripts/mkimg.minirootfs.sh new file mode 100755 index 0000000000..4753f093f1 --- /dev/null +++ b/scripts/mkimg.minirootfs.sh | |||
@@ -0,0 +1,21 @@ | |||
1 | section_minirootfs() { | ||
2 | return 0 | ||
3 | } | ||
4 | |||
5 | create_image_rootfs() { | ||
6 | local _script=$(readlink -f "$scriptdir/genrootfs.sh") | ||
7 | local output_file="$(readlink -f ${OUTDIR:-.})/$output_filename" | ||
8 | |||
9 | (cd "$OUTDIR"; fakeroot "$_script" -k "$APKROOT"/etc/apk/keys \ | ||
10 | -r "$APKROOT"/etc/apk/repositories \ | ||
11 | -o "$output_file" \ | ||
12 | -a $ARCH \ | ||
13 | $rootfs_apks) | ||
14 | } | ||
15 | |||
16 | profile_minirootfs() { | ||
17 | image_ext=tar.gz | ||
18 | output_format=rootfs | ||
19 | arch="x86 x86_64 armhf aarch64" | ||
20 | rootfs_apks="busybox alpine-baselayout alpine-keys apk-tools libc-utils" | ||
21 | } | ||