1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-26 12:45:20 +03:00
aports/scripts/genrootfs.sh
Sertonix d43610d7d8 scripts/mkimage.sh: remove special handling of alpine-release for minirootfs
The special handling was needed when the alpine-base package included release
and other data. This was changed[0] and now the complete alpine-release package
is included in the minirootfs[1]. This change removed the reason the special
handling was added in the first place so we can remove it completely.

Fixes #16553

[0]: 23e66e85c9
[1]: 704af9b4ba
2024-10-22 20:48:32 +00:00

54 lines
1.2 KiB
Bash
Executable file

#!/bin/sh -e
cleanup() {
rm -rf "$tmp"
}
tmp="$(mktemp -d)"
trap cleanup EXIT
chmod 0755 "$tmp"
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=rootfs-$arch.tar.gz
fi
${APK:-apk} add --keys-dir "$keys_dir" --no-cache \
--repositories-file "$repositories_file" \
--no-script --root "$tmp" --initdb --arch "$arch" \
"$@"
for link in $("$tmp"/bin/busybox --list-full); do
[ -e "$tmp"/$link ] || ln -s /bin/busybox "$tmp"/$link
done
# disable password login but allow login with ssh keys for root
sed -i -e 's/^root::/root:*:/' "$tmp"/etc/shadow
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
https://dl-cdn.alpinelinux.org/alpine/$branch/main
https://dl-cdn.alpinelinux.org/alpine/$branch/community
EOF
tar --numeric-owner --exclude='dev/*' -c -C "$tmp" . | gzip -9n > "$outfile"