]> spindle.queued.net Git - xodist/blob - initchroot.sh
9d5f4a898546020572400b32b816836942152567
[xodist] / initchroot.sh
1 #!/bin/sh -e
2 #
3 # Copyright © 2008  Andres Salomon <dilinger@queued.net>
4 #
5 # This file is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 DIST=lenny
20 DEFUSER=olpc
21
22 . functions.sh
23
24 usage()
25 {
26         echo "" 1>&2
27         echo "Usage: $0 <root directory>" 1>&2
28         echo "" 1>&2
29         exit 1
30 }
31
32 if [ "$#" != "1" ]; then
33         usage
34 fi
35
36 ROOT_DIR=$1
37
38 if [ -d "${ROOT_DIR}" ]; then
39         echo "" 1>&2
40         echo "*** ${ROOT_DIR} already exists!" 1>&2
41         usage
42 fi
43
44 check_for_cmds debootstrap || exit 1
45
46 # create chroot
47 debootstrap --arch i386 lenny ${ROOT_DIR} http://http.us.debian.org/debian
48 mount -t proc proc ${ROOT_DIR}/proc
49 mount -t devpts devpts ${ROOT_DIR}/dev/pts
50
51 # set up apt
52 export DEBIAN_FRONTEND=noninteractive
53 export DEBCONF_PRIORITY=critical
54 cat >${ROOT_DIR}/etc/apt/apt.conf<<EOF
55 Acquire::Pdiffs "false";
56 APT::Install-Recommends "false";
57 EOF
58 cat >${ROOT_DIR}/etc/apt/sources.list<<EOF
59 deb http://http.us.debian.org/debian ${DIST} main contrib non-free
60 deb http://security.debian.org/ ${DIST}/updates main contrib non-free
61 EOF
62 (chroot ${ROOT_DIR} aptitude update)
63
64 # set up base system
65 echo "en_US.UTF-8 UTF-8" >${ROOT_DIR}/etc/locale.gen
66 (chroot ${ROOT_DIR} aptitude install -y locales)
67 k=$(wget -O- http://queued.mit.edu/~dilinger/builds-master/ | sed -ne 's/.*href="\(.\+\)_i386.deb".*/\1_i386.deb/p' | tail -n1)
68 wget -O ${ROOT_DIR}/${k} http://queued.mit.edu/~dilinger/builds-master/${k}
69 (chroot ${ROOT_DIR} dpkg -i /${k})
70 rm -f ${ROOT_DIR}/${k}
71
72 # install packages
73 (chroot ${ROOT_DIR} aptitude install -y `cat package_list`)
74
75 # add default user
76 (chroot ${ROOT_DIR} useradd -s /bin/bash ${DEFUSER})
77 (chroot ${ROOT_DIR} passwd -d ${DEFUSER})
78 (chroot ${ROOT_DIR} adduser ${DEFUSER} cdrom)
79 (chroot ${ROOT_DIR} adduser ${DEFUSER} audio)
80 (chroot ${ROOT_DIR} adduser ${DEFUSER} video)
81 (chroot ${ROOT_DIR} adduser ${DEFUSER} plugdev)
82 (chroot ${ROOT_DIR} adduser ${DEFUSER} netdev)
83 (chroot ${ROOT_DIR} adduser ${DEFUSER} powerdev)
84 echo "${DEFUSER} ALL=(ALL) ALL" >> ${ROOT_DIR}/etc/sudoers
85
86 # done, clean up
87 (chroot ${ROOT_DIR} aptitude clean)
88 umount ${ROOT_DIR}/proc
89 umount ${ROOT_DIR}/dev/pts