aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2016-12-15 16:14:51 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2016-12-16 09:50:00 +0000
commit99afbc0aaa18bb50949e16c2cd9d146110205769 (patch)
tree13f12b3405840784d575707d6201f3ba90948685 /scripts
parentfb36c21471581754b91298d1a03e240f9fa0d68f (diff)
downloadaports-99afbc0aaa18bb50949e16c2cd9d146110205769.tar.bz2
aports-99afbc0aaa18bb50949e16c2cd9d146110205769.tar.xz
scripts: add minirootfs release image
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/genrootfs.sh56
-rwxr-xr-xscripts/mkimage.sh2
-rwxr-xr-xscripts/mkimg.minirootfs.sh21
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 @@
+#!/bin/sh -e
+
+cleanup() {
+ rm -rf "$tmp"
+}
+
+tmp="$(mktemp -d)"
+trap cleanup EXIT
+
+arch="$(apk --print-arch)"
+repositories_file=/etc/apk/repositories
+keys_dir=/etc/apk/keys
+
+while getopts "a:r:k:o:" opt; do
+ case $opt in
+ a) arch="$OPTARG";;
+ r) repositories_file="$OPTARG";;
+ k) keys_dir="$OPTARG";;
+ o) outfile="$OPTARG";;
+ esac
+done
+shift $(( $OPTIND - 1))
+
+cat "$repositories_file"
+
+if [ -z "$outfile" ]; then
+ outfile=$name-$arch.tar.gz
+fi
+
+${APK:-apk} add --keys-dir "$keys_dir" \
+ --repositories-file "$repositories_file" \
+ --no-script --no-cache --root "$tmp" --initdb \
+ "$@"
+for link in $("$tmp"/bin/busybox --list-full); do
+ [ -e "$tmp"/$link ] || ln -s /bin/busybox "$tmp"/$link
+done
+
+${APK:-apk} fetch --keys-dir "$keys_dir" \
+ --repositories-file "$repositories_file" \
+ --stdout alpine-base | tar -zx -C "$tmp" etc/
+
+branch=edge
+VERSION_ID=$(awk -F= '$1=="VERSION_ID" {print $2}' "$tmp"/etc/os-release)
+case $VERSION_ID in
+*_alpha*|*_beta*) branch=edge;;
+*.*.*) branch=v${VERSION_ID%.*};;
+esac
+
+cat > "$tmp"/etc/apk/repositories <<EOF
+http://dl-cdn.alpinelinux.org/alpine/$branch/main
+http://dl-cdn.alpinelinux.org/alpine/$branch/community
+EOF
+
+#rm -rf "$tmp"/var/cache/apk/*
+
+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() {
if [ "$_dirty" = "yes" -o ! -e "$output_file" ]; then
# Create image
- output_format="${image_ext//[:\.]/}"
+ [ -n "$output_format" ] || output_format="${image_ext//[:\.]/}"
create_image_${output_format} || { _fail="yes"; false; }
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 @@
+section_minirootfs() {
+ return 0
+}
+
+create_image_rootfs() {
+ local _script=$(readlink -f "$scriptdir/genrootfs.sh")
+ local output_file="$(readlink -f ${OUTDIR:-.})/$output_filename"
+
+ (cd "$OUTDIR"; fakeroot "$_script" -k "$APKROOT"/etc/apk/keys \
+ -r "$APKROOT"/etc/apk/repositories \
+ -o "$output_file" \
+ -a $ARCH \
+ $rootfs_apks)
+}
+
+profile_minirootfs() {
+ image_ext=tar.gz
+ output_format=rootfs
+ arch="x86 x86_64 armhf aarch64"
+ rootfs_apks="busybox alpine-baselayout alpine-keys apk-tools libc-utils"
+}