diff options
author | Fabian Affolter <fabian@affolter-engineering.ch> | 2011-07-03 23:53:01 +0200 |
---|---|---|
committer | Fabian Affolter <fabian@affolter-engineering.ch> | 2011-07-03 23:53:01 +0200 |
commit | 281585c24525dd53ee57ac890a8b1002a1a4fca2 (patch) | |
tree | 2dcd360d51859cf7829423ea5ac1a35b53b72d5e /alpine-chroot.sh | |
download | scripts-281585c24525dd53ee57ac890a8b1002a1a4fca2.tar.bz2 scripts-281585c24525dd53ee57ac890a8b1002a1a4fca2.tar.xz |
Initial commit
Diffstat (limited to 'alpine-chroot.sh')
-rw-r--r-- | alpine-chroot.sh | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/alpine-chroot.sh b/alpine-chroot.sh new file mode 100644 index 0000000..b7b17aa --- /dev/null +++ b/alpine-chroot.sh @@ -0,0 +1,63 @@ +# 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 <fabian at affolter-engineering.ch> + +MIRROR=http://dl-3.alpinelinux.org/alpine +ARCH=x86_64 +CHROOT=alpine-chroot +VERSION=v2.2 + +# 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-tools-static-2.1.0-r1.apk +tar -xzf apk-tools-static-2.1.0-r1.apk +./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-tools-static-2.1.0-r1.apk + +echo " " +echo "Your Alpine Linux installation in '$CHROOT' is ready now." +echo "To start Alpine:" +echo " sudo chroot $CHROOT /bin/sh -l" +echo " " |