forked from kiss-community/repo
53 lines
1.0 KiB
Bash
Executable File
53 lines
1.0 KiB
Bash
Executable File
#!/bin/sh -e
|
|
#
|
|
# Setup an alpine chroot.
|
|
|
|
chroot_dir=~/alpine-chroot
|
|
mirror=http://dl-cdn.alpinelinux.org/alpine/
|
|
file=apk-tools-static-2.10.3-r1.apk
|
|
|
|
clean() {
|
|
umount "$chroot_dir/dev" ||:
|
|
umount "$chroot_dir/proc" ||:
|
|
umount "$chroot_dir/sys" ||:
|
|
|
|
rm -rf "$chroot_dir" "/tmp/${file:-null}"
|
|
}
|
|
|
|
main() {
|
|
[ "$(id -u)" != 0 ] && {
|
|
echo "Run this script with sudo." >&2
|
|
exit 1
|
|
}
|
|
|
|
clean
|
|
|
|
mkdir -p "/tmp/$file"
|
|
cd "/tmp/$file"
|
|
|
|
wget "$mirror/latest-stable/main/x86_64/$file"
|
|
tar xzf "$file"
|
|
|
|
./sbin/apk.static \
|
|
-X "$mirror/latest-stable/main" \
|
|
-U \
|
|
--allow-untrusted \
|
|
--root "$chroot_dir" \
|
|
--initdb add alpine-base alpine-sdk ||:
|
|
|
|
cp -f /etc/resolv.conf "$chroot_dir/etc"
|
|
|
|
mkdir -p "$chroot_dir/etc/apk"
|
|
echo "$mirror/edge/main" > "$chroot_dir/etc/apk/repositories"
|
|
|
|
mount -o bind /dev "$chroot_dir/dev"
|
|
mount -t proc proc "$chroot_dir/proc"
|
|
mount -t sysfs sys "$chroot_dir/sys"
|
|
|
|
trap clean EXIT INT
|
|
|
|
chroot "$chroot_dir" /bin/sh
|
|
}
|
|
|
|
main
|