43 lines
1.2 KiB
Bash
43 lines
1.2 KiB
Bash
setup-alpine -f ANSWERFILE
|
|
|
|
# setting fastest edge repos in repo list
|
|
grep "edge" /etc/apk/repositories | sed "s/^#//" > repositories
|
|
mv repositories /etc/apk/repositories
|
|
|
|
# setting the mirror
|
|
apk add curl
|
|
curl -LO http://nl.alpinelinux.org/alpine/MIRRORS.txt
|
|
mirror=`grep $(head -n 1 /etc/apk/repositories) | sed -e "s/.*\/\///" | sed -e "s/\//\ /" | awk '{print $1}') MIRRORS.txt`
|
|
rm MIRRORS.txt
|
|
|
|
# setting the chroot dir
|
|
mkdir -p /mnt/chroot
|
|
chroot_dir="/mnt/chroot"
|
|
|
|
# setting the arch (change if needed)
|
|
arch=$(uname -m)
|
|
|
|
|
|
# set up apk
|
|
version="edge"
|
|
curl -LO ${mirror}/latest-stable/main/${arch}/apk-tools-static-${version}.apk
|
|
tar -xzf apk-tools-static-*.apk
|
|
|
|
# install the alpine base installation onto the chroot
|
|
./sbin/apk.static -X ${mirror}/latest-stable/main -U --allow-untrusted -p ${chroot_dir} --initdb add alpine-base
|
|
|
|
# seting up the chroot
|
|
mount -o bind /dev ${chroot_dir}/dev
|
|
mount -t proc none ${chroot_dir}/proc
|
|
mount -o bind /sys ${chroot_dir}/sys
|
|
|
|
# set up name resolution
|
|
cp -L /etc/resolv.conf ${chroot_dir}/etc/
|
|
|
|
# prepare the APK repositories
|
|
branch=$version # change if you want a specific version
|
|
mkdir -p ${chroot_dir}/etc/apk
|
|
echo "${mirror}/${branch}/main" > ${chroot_dir}/etc/apk/repositories
|
|
|
|
chroot ${chroot_dir} chroot_init.sh
|