Commit 99afbc0a authored by Natanael Copa's avatar Natanael Copa

scripts: add minirootfs release image

parent fb36c214
#!/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"
......@@ -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
......
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"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment