forked from openitg/openitg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chroot-arcade.sh
executable file
·94 lines (77 loc) · 2.6 KB
/
chroot-arcade.sh
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/sh
DEBIAN_SARGE_MIRROR="http://archive.debian.org/debian"
SARGE_DIST_NAME="sarge"
DEBIAN_SARGE_BACKPORTS="deb http://archive.debian.org/debian-backports sarge-backports main contrib"
usage() {
echo "Usage: $0 <path to source code> <chroot location>"
exit 1
}
# used to check for needed files/programs
verify_prog_requirements() {
# debootstrap is needed
if [ "x`which debootstrap`" = "x" ]; then
echo "$0: cannot continue, please install debootstrap on your system"
exit 1
fi
echo "debootstrap location: `which debootstrap`"
# user must be root
if [ ! "x`whoami`" = "xroot" ]; then
echo "$0: you must be root to setup the chroot environment"
exit 1
fi
}
# sets up debian sarge system at the given path, binds src dir to directory within chroot
setup_chroot() {
CHROOT_DIR="$1"
SRC_DIR="$2"
echo "Setting up chroot at $CHROOT_DIR..."
mkdir -p $CHROOT_DIR
debootstrap --arch i386 $SARGE_DIST_NAME $CHROOT_DIR $DEBIAN_SARGE_MIRROR/
if [ $? != 0 ]; then
echo "$0: debootstrap failed, exiting"
exit 1
fi
mkdir $CHROOT_DIR/root/openitg-dev
# first time setup script (sets up debian, retrieves correct packages)
cat <<! >$CHROOT_DIR/root/first_time_setup.sh
#!/bin/sh
export LC_ALL=C
echo -ne "*******************\n* You are now in the OpenITG AC chroot environment\n*******************\n"
echo "Installing necessary dev packages..."
# non-free and contrib for the nvidia packages
echo "deb $DEBIAN_SARGE_MIRROR $SARGE_DIST_NAME main contrib non-free" >/etc/apt/sources.list
echo "$DEBIAN_SARGE_BACKPORTS" >>/etc/apt/sources.list
apt-get update
apt-get install build-essential gettext automake1.8 gcc g++ libavcodec-dev libavformat-dev libxt-dev libogg-dev libpng-dev libjpeg-dev libvorbis-dev libusb-dev libglu1-mesa-dev libx11-dev libxrandr-dev liblua50-dev liblualib50-dev nvidia-glx-dev libmad0-dev libasound-dev git-core
echo "OpenITG AC chroot successfully set up!"
exec /bin/bash
!
chmod +x $CHROOT_DIR/root/first_time_setup.sh
# bootstrap script
cat <<! >$CHROOT_DIR/chroot_bootstrap.sh
#!/bin/sh
mount -o bind /proc $CHROOT_DIR/proc
mount -o bind /sys $CHROOT_DIR/sys
mount -o bind $SRC_DIR $CHROOT_DIR/root/openitg-dev
chroot $CHROOT_DIR /bin/bash
!
chmod +x $CHROOT_DIR/chroot_bootstrap.sh
mount -o bind /proc $CHROOT_DIR/proc
mount -o bind /sys $CHROOT_DIR/sys
mount -o bind $SRC_DIR $CHROOT_DIR/root/openitg-dev
chroot $CHROOT_DIR /root/first_time_setup.sh
}
if [ "x$1" = "x" ]; then
usage
fi
if [ "x$2" = "x" ]; then
usage
fi
if [ ! -d "$1" ]; then
echo "$0: Source code dir not found at $1"
exit 1
fi
verify_prog_requirements
SRC_DIR="`(cd $1; pwd)`"
setup_chroot $2 $SRC_DIR
exit 0;