blob: c36885e5cf0be358d832658a805570815e1d4a7d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# 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.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 " "
|