2021-08-29 21:48:18 +00:00
|
|
|
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
|
2021-08-30 06:21:30 +00:00
|
|
|
repo_domain=`head -n 1 /etc/apk/repositories | sed -e "s/.*\/\///" | sed -e "s/\//\ /" | awk '{print $1}'`
|
|
|
|
mirror=`grep $repo_domain MIRRORS.txt`
|
2021-08-29 21:48:18 +00:00
|
|
|
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
|
2021-08-30 06:21:30 +00:00
|
|
|
version="2.12.7-r0"
|
2021-08-29 21:48:18 +00:00
|
|
|
curl -LO ${mirror}/latest-stable/main/${arch}/apk-tools-static-${version}.apk
|
|
|
|
tar -xzf apk-tools-static-*.apk
|
2021-08-30 06:21:30 +00:00
|
|
|
rm apk-tools-static-*.apk
|
2021-08-29 21:48:18 +00:00
|
|
|
|
|
|
|
# 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
|
2021-08-30 06:21:30 +00:00
|
|
|
branch="edge" # change if you want a specific version
|
2021-08-29 21:48:18 +00:00
|
|
|
mkdir -p ${chroot_dir}/etc/apk
|
|
|
|
echo "${mirror}/${branch}/main" > ${chroot_dir}/etc/apk/repositories
|
|
|
|
|
2021-08-30 06:21:30 +00:00
|
|
|
cp chroot_init.sh ${chroot_dir}/chroot_init.sh
|
|
|
|
chroot ${chroot_dir} sh
|