# This simple script is setting up a Alpine Linux installation in a chroot. # chroot will be placed in the current working directory. # # Most parts of this script are written down at # http://wiki.alpinelinux.org/wiki/Setting_up_the_build_environment_in_chroot # # Licensed under GPLv2 # # Copyright (c) 2011 Fabian Affolter MIRROR=http://dl-3.alpinelinux.org/alpine ARCH=x86_64 CHROOT=alpine-chroot VERSION=v2.3 APK_TOOL=apk-tools-static-2.2.5-r0.apk # Root has $UID 0 ROOT_UID=0 if [ "$UID" != "$ROOT_UID" ] then echo "You are not root. Please use su to become root." exit 0 fi if [ -d $CHROOT ] then echo "$CHROOT already exists." exit 0 else mkdir -p $CHROOT fi wget $MIRROR/$VERSION/main/$ARCH/$APK_TOOL tar -xzf $APK_TOOL ./sbin/apk.static \ -X $MIRROR/$VERSION/main \ -U \ --allow-untrusted \ --root ././$CHROOT \ --initdb add alpine-base alpine-sdk mkdir -p $CHROOT{/root,/etc/apk,/proc} mount --bind /proc $CHROOT/proc mknod -m 666 $CHROOT/dev/full c 1 7 mknod -m 666 $CHROOT/dev/ptmx c 5 2 mknod -m 644 $CHROOT/dev/random c 1 8 mknod -m 644 $CHROOT/dev/urandom c 1 9 mknod -m 666 $CHROOT/dev/zero c 1 5 mknod -m 666 $CHROOT/dev/tty c 5 0 rm -f $CHROOT/dev/null mknod -m 666 $CHROOT/dev/null c 1 3 cp /etc/resolv.conf $CHROOT/etc/ echo "$MIRROR/$VERSION/main" > $CHROOT/etc/apk/repositories # Cleaning up rm -rf sbin rm -f APK_TOOL echo " " echo "Your Alpine Linux installation in '$CHROOT' is ready now." echo "To start Alpine:" echo " sudo chroot $CHROOT /bin/sh -l" echo " "