3 # Copyright © 2008 Andres Salomon <dilinger@queued.net>
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.
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.
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.
21 APT_SOURCES="deb http://http.us.debian.org/debian/ lenny main contrib non-free
22 deb http://security.debian.org/ lenny/updates main contrib non-free"
30 echo "Usage: $0 [<options>] <root directory>" 1>&2
33 echo " --user <user> Username for default user" 1>&2
34 echo " --package-list <list> File containing package list" 1>&2
35 echo " --apt-sources <srcs> Contents of /etc/apt/sources.list" 1>&2
36 echo " --local-apt-mirror <srcs> sources.list for local mirror" 1>&2
51 echo "Error: can't find file '${PLIST}'!" 1>&2
65 if [ "$#" != "1" ]; then
66 echo "Unknown option $1" 1>&2
76 if [ "$ROOT_DIR" = "" ]; then
78 echo "*** No root directory specified!" 1>&2
82 if [ -d "${ROOT_DIR}" ]; then
84 echo "*** ${ROOT_DIR} already exists!" 1>&2
88 check_for_cmds debootstrap || exit 1
90 if [ -z "${LOCAL_APT_MIRROR}" ]; then
91 LOCAL_APT_MIRROR="${APT_SOURCES}"
95 MIRROR=$(printf "${LOCAL_APT_MIRROR}\n" | awk '/deb /{print $2}' | head -n1)
96 DIST=$(printf "${LOCAL_APT_MIRROR}\n" | awk '/deb /{print $3}' | head -n1)
99 debootstrap --arch i386 ${DIST} ${ROOT_DIR} ${MIRROR}
100 mkdir ${ROOT_DIR}/ofw
101 mkdir ${ROOT_DIR}/var/cache/apt/cache
102 chroot_internal_mounts ${ROOT_DIR}
104 # allow daemons to be installed without breaking
105 mv ${ROOT_DIR}/sbin/start-stop-daemon ${ROOT_DIR}/sbin/start-stop-daemon.REAL
106 cat >${ROOT_DIR}/sbin/start-stop-daemon<<EOF
109 echo "Warning: Fake start-stop-daemon called, doing nothing"
111 chmod 755 ${ROOT_DIR}/sbin/start-stop-daemon
113 # set up hostname stuff
114 echo "debxo" > ${ROOT_DIR}/etc/hostname
115 cat >${ROOT_DIR}/etc/hosts<<EOF
116 127.0.0.1 localhost.localdomain localhost
119 # The following lines are desirable for IPv6 capable hosts
120 ::1 ip6-localhost ip6-loopback
122 ff00::0 ip6-mcastprefix
124 ff02::2 ip6-allrouters
128 # set up apt (working around #314334)
129 export DEBIAN_FRONTEND=noninteractive
130 export DEBCONF_PRIORITY=critical
131 cat >${ROOT_DIR}/etc/apt/apt.conf<<EOF
132 Acquire::Pdiffs "false";
133 APT::Install-Recommends "false";
135 Cache "var/cache/apt/" {
136 srcpkgcache "cache/srcpkgcache.bin";
137 pkgcache "cache/pkgcache.bin";
141 printf "${LOCAL_APT_MIRROR}\n" >${ROOT_DIR}/etc/apt/sources.list
142 (chroot ${ROOT_DIR} aptitude update)
144 # set up base system and base packages
145 echo "en_US.UTF-8 UTF-8" >${ROOT_DIR}/etc/locale.gen
146 (chroot ${ROOT_DIR} aptitude install -y `cat base.packages`)
148 k="http://lunge.mit.edu/~dilinger/debxo-0.2/initramfs-tools_0.92l.2_all.deb
149 http://lunge.mit.edu/~dilinger/debxo-0.2/ofw-config_0.1_all.deb
150 http://lunge.mit.edu/~dilinger/debxo-0.3/linux-2.6.25.15_2.6.25.15-147_i386.deb"
154 wget --continue -O cache/${pkg} ${i}
155 cp cache/${pkg} ${ROOT_DIR}/${pkg}
156 (chroot ${ROOT_DIR} dpkg -i /${pkg})
157 pkgbase=$(echo $pkg | cut -d_ -f1)
158 echo $pkgbase hold | (chroot ${ROOT_DIR} dpkg --set-selections)
159 rm -f ${ROOT_DIR}/${pkg}
162 # ensure certain modules get loaded during boot
163 cat >>${ROOT_DIR}/etc/modules<<EOF
172 (chroot ${ROOT_DIR} aptitude install -y `cat ${PLIST}`)
175 if [ -d ${ROOT_DIR}/etc/X11 ]; then
176 cat >${ROOT_DIR}/etc/X11/xorg.conf<<EOF
177 # xorg.conf (X.Org X Window System server configuration file)
180 Identifier "Configured Monitor"
186 HTimings 1200 1208 1216 1240
187 VTimings 900 905 908 912
188 Flags "-HSync" "-VSync"
193 Identifier "Default Screen"
194 Monitor "Configured Monitor"
200 if [ -d ${ROOT_DIR}/etc/kde3/kdm ]; then
201 sed --in-place "s/AllowNullPasswd=false/AllowNullPasswd=true/;s/#AutoLoginEnable=true/AutoLoginEnable=true/;s/#AutoLoginUser=fred/AutoLoginUser=${DEFUSER}/" ${ROOT_DIR}/etc/kde3/kdm/kdmrc
204 # configure gdm, gnome
205 if [ -d ${ROOT_DIR}/etc/gdm ]; then
206 sed -i "s_\[daemon\]_\[daemon\]\n\nGreeter=/usr/lib/gdm/gdmlogin\n\nAutomaticLoginEnable=true\n\nAutomaticLogin=${DEFUSER}_" ${ROOT_DIR}/etc/gdm/gdm.conf
208 if [ -d ${ROOT_DIR}/etc/gconf/2 ]; then
209 cat >${ROOT_DIR}/etc/gconf/2/local-defaults.path<<EOF
210 # DebXO defaults (customized for the XO-1's display
211 xml:readonly:/etc/gconf/debxo.xml.defaults
213 mkdir -p ${ROOT_DIR}/etc/gconf/debxo.xml.defaults
214 cp %gconf-tree.xml ${ROOT_DIR}/etc/gconf/debxo.xml.defaults/
218 (chroot ${ROOT_DIR} passwd -l root)
219 rm -rf ${ROOT_DIR}/home/*; # i have no idea what's adding this crap...
220 (chroot ${ROOT_DIR} useradd -s /bin/bash --create-home ${DEFUSER})
221 (chroot ${ROOT_DIR} passwd -d ${DEFUSER})
222 (chroot ${ROOT_DIR} adduser ${DEFUSER} cdrom)
223 (chroot ${ROOT_DIR} adduser ${DEFUSER} audio)
224 (chroot ${ROOT_DIR} adduser ${DEFUSER} video)
225 (chroot ${ROOT_DIR} adduser ${DEFUSER} plugdev)
226 (chroot ${ROOT_DIR} adduser ${DEFUSER} netdev)
227 (chroot ${ROOT_DIR} adduser ${DEFUSER} powerdev)
228 (chroot ${ROOT_DIR} adduser ${DEFUSER} floppy)
229 echo "${DEFUSER} ALL=(ALL) NOPASSWD: ALL" >> ${ROOT_DIR}/etc/sudoers
231 # add local network interface
232 cat >>${ROOT_DIR}/etc/network/interfaces<<EOF
235 iface lo inet loopback
239 if [ -d ${ROOT_DIR}/usr/share/sugar ]; then
241 ln -sf /usr/share/activities/ ${ROOT_DIR}/usr/share/sugar
242 cat >> ${ROOT_DIR}/home/${DEFUSER}/.Xsession <<- EOF
243 matchbox-window-manager -use_titlebar no &
248 # override sources.list with shipping version
249 printf "${APT_SOURCES}\n" >${ROOT_DIR}/etc/apt/sources.list
250 (chroot ${ROOT_DIR} aptitude update)
253 mv ${ROOT_DIR}/sbin/start-stop-daemon.REAL ${ROOT_DIR}/sbin/start-stop-daemon
254 (chroot ${ROOT_DIR} aptitude clean)
255 chroot_internal_umounts ${ROOT_DIR}