~ogra/cmpc/cmpc-gen1-installer

1 by Oliver Grawert
initial checkin
1
#!/bin/bash -eu
2
3
##########################################################################
4
####           (c) Copyright 2004-2007 Canonical Ltd.                #####
5
#                                                                        #
6
# This program is free software; you can redistribute it and/or modify   #
7
# it under the terms of the GNU General Public License as published by   #
8
# the Free Software Foundation; either version 2, or (at your option)    #
9
# any later version.                                                     #
10
#                                                                        #
11
# This program is distributed in the hope that it will be useful, but    #
12
# WITHOUT ANY WARRANTY; without even the implied warranty of             #
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      #
14
# General Public License for more details.                               #
15
#                                                                        #
16
# You should have received a copy of the GNU General Public License with #
17
# your Ubuntu system, in /usr/share/common-licenses/GPL, or with the     #
18
# livecd-rootfs source package as the file COPYING.  If not, write to    #
19
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,   #
20
# Boston, MA 02110-1301 USA.                                             #
21
##########################################################################
22
23
# Depends: debootstrap, rsync, python-minimal|python, procps, squashfs-tools
24
25
cleanup() {
26
    for mnt in $MOUNTS ${ROOT}lib/modules/*/volatile ${ROOT}var/{lock,run}; do
27
	umount $mnt || true
28
    done
29
30
    [ -n "$DEV" ] && losetup -d $DEV || true
31
    grep ${ROOT} /proc/mounts && return 1 || return 0
32
}
33
34
kill_users() {
35
    set +e
36
    PIDLIST="$(ls -l /proc/*/root 2>/dev/null | grep -- " -> ${ROOT%/}" | sed -n 's/^.*proc.\([0-9]*\).*$/\1/p')"
37
    while [ -n "${PIDLIST}" ]; do
38
	echo killing $PIDLIST
39
	ps -l $(for p in $PIDLIST; do echo ' '-p $p; done)
40
	kill -9 $PIDLIST
41
	sleep 2
42
	PIDLIST="$(ls -l /proc/*/root 2>/dev/null | grep -- " -> ${ROOT%/}" | sed -n 's/^.*proc.\([0-9]*\).*$/\1/p')"
43
    done
44
    set -e
45
}
46
47
without_package() {
48
    echo "$2" | tr ' ' '\n' | grep -v "^$1$" | tr '\n' ' '
49
}
50
51
subst_package() {
52
    echo "$3" | tr ' ' '\n' | sed "s/^$1$/$2/" | tr '\n' ' '
53
}
54
55
56
if [ $(id -u) != 0 ];then
57
  echo "must be run as root"
58
  exit 2
59
fi
60
61
umask 022
62
export TTY=unknown
63
export TERM=vt100
64
export DEBIAN_FRONTEND=noninteractive
65
export LANG=C
66
export CASPER_GENERATE_UUID=1
67
SRCMIRROR=http://archive.ubuntu.com/ubuntu
68
ARCH=$(dpkg --print-installation-architecture)
69
OPTMIRROR=
70
71
select_mirror () {
72
    case $ARCH in
73
	i386|amd64|sparc)
74
	    case $FS in
75
		ubuntu-lpia)
76
		    USERMIRROR=http://ports.ubuntu.com/ubuntu-ports
77
		    SECMIRROR=${USERMIRROR}
78
		    SECSRCMIRROR=${SRCMIRROR}
79
		    ;;
80
		*)
81
		    USERMIRROR=http://archive.ubuntu.com/ubuntu
82
		    SECMIRROR=http://security.ubuntu.com/ubuntu
83
		    SECSRCMIRROR=${SECMIRROR}
84
		    ;;
85
	    esac
86
	    ;;
87
	hppa)
88
	    USERMIRROR=http://ports.ubuntu.com/ubuntu-ports
89
	    SECMIRROR=${USERMIRROR}
90
	    SECSRCMIRROR=${SRCMIRROR}
91
	    ;;
92
	*)
93
	    USERMIRROR=http://ports.ubuntu.com/ubuntu-ports
94
	    SECMIRROR=${USERMIRROR}
95
	    SECSRCMIRROR=${SRCMIRROR}
96
	    ;;
97
    esac
98
    case $(hostname --fqdn) in
99
	bld-*.mmjgroup.com)	MIRROR=${USERMIRROR};;
100
	*.mmjgroup.com)		MIRROR=http://archive.mmjgroup.com/${USERMIRROR##*/};;
101
	*.0c3.net)		MIRROR=http://ftp.iinet.net.au/linux/ubuntu;;
31.1.6 by Colin Watson
use my local mirror on my network
102
	*.pelham.vpn.ucam.org)	MIRROR=http://riva/ubuntu;;
1 by Oliver Grawert
initial checkin
103
	*.ubuntu.com)		MIRROR=http://ftpmaster.internal/ubuntu;;
104
	*.warthogs.hbd.com)	MIRROR=http://ftpmaster.internal/ubuntu;;
105
	*.buildd)		MIRROR=http://ftpmaster.internal/ubuntu;;
106
	*)			MIRROR=${USERMIRROR};;
107
    esac
108
109
    if [ "$OPTMIRROR" ]; then
110
	MIRROR="$OPTMIRROR"
111
    fi
112
}
113
114
STE=gutsy
115
EXCLUDE=""
116
LIST=""
117
SUBARCH=""
118
119
while getopts :d:e:i:I:m:S:s: name; do case $name in
120
    d)  STE=$OPTARG;;
121
    e)  EXCLUDE="$EXCLUDE $OPTARG";;
122
    i)  LIST="$LIST $OPTARG";;
123
    I)	UINUM="$OPTARG";;
124
    m)	OPTMIRROR="$OPTARG";;
125
    S)	USZ="$OPTARG";;
126
    s)	SUBARCH="$OPTARG";;
127
    \?) echo bad usage >&2; exit 2;;
128
    \:) echo missing argument >&2; exit 2;;
129
esac; done;
130
shift $((OPTIND-1))
131
132
if (( $# == 0 )) || [ "X$1" = "Xall" ]; then
133
    set -- ubuntu kubuntu edubuntu xubuntu gobuntu base
134
    if [ "$ARCH" = "i386" ]; then
135
        set -- ubuntu ubuntu-lpia kubuntu edubuntu xubuntu gobuntu base
136
    fi
137
fi
138
139
for arg in "$@"; do
140
    case "$arg" in
141
	ubuntu|ubuntu-lpia|edubuntu|kubuntu|xubuntu|gobuntu|base|tocd|classmate)
142
	    ;;
143
	*)
144
	    echo bad name >&2;
145
	    exit 2
146
	    ;;
147
    esac
148
done
149
150
ROOT=$(pwd)/chroot-livecd/	# trailing / is CRITICAL
151
for FS in "$@"; do
152
    FSS="$FS${SUBARCH:+-$SUBARCH}"
153
    IMG=livecd.${FSS}.fsimg
154
    MOUNTS="${ROOT}dev/pts ${ROOT}dev/shm ${ROOT}.dev ${ROOT}dev ${ROOT}proc ${ROOT}sys"
155
    DEV=""
156
    COMP="main restricted"
157
158
    select_mirror
159
160
    rm -rf ${ROOT}
161
162
    mkdir -p ${ROOT}var/cache/debconf
163
    cat << @@EOF > ${ROOT}var/cache/debconf/config.dat
164
Name: debconf/frontend
165
Template: debconf/frontend
166
Value: Noninteractive
167
Owners: debconf
168
Flags: seen
169
170
@@EOF
171
172
    case "$FS" in
173
	ubuntu|ubuntu-lpia)
174
	    LIST="$LIST minimal^ standard^ ubuntu-desktop^"
175
	    LIVELIST="ubuntu-live^ xresprobe laptop-detect casper lupin-casper"
176
	    ;;
177
	kubuntu)
178
	    LIST="$LIST minimal^ standard^ kubuntu-desktop^"
179
	    LIVELIST="kubuntu-live^ xresprobe laptop-detect casper lupin-casper"
180
	    ;;
181
	edubuntu)
182
	    LIST="$LIST minimal^ standard^ edubuntu-desktop^"
183
	    LIVELIST="edubuntu-live^ xresprobe laptop-detect casper lupin-casper"
184
	    ;;
185
	classmate)
28 by Oliver Grawert
xournal is way to crashy to ship it and there is no touchscreen on cmpc 1.5 yet that would make it useful
186
        LIST="$LIST minimal^ standard^ edubuntu-desktop cheese classmate-initramfs classmate-artwork classmate-tools grub ttf-nafees kpdf kolourpaint thunderbird thunderbird-gnome-support 915resolution"
17 by Oliver Grawert
enable the classmate specific package repository again so teh new kernel with usb resume fix gets pulled from there, make sure gpg is installed in the image, since no packages can be installed at all without being able to read the gpg signatures
187
        REMOVALS="ubiquity tracker sound-juicer kverbos apparmor readahead inkscape tuxtype thin-client-manager-backend bluez-audio bluez-cups bluez-utils bluez-gnome apport aptitude binutils brasero gcompris-sound-cs gcompris-sound-da gcompris-sound-eu gcompris-sound-fi gcompris-sound-it gcompris-sound-mr gdb gimp-python gnome-pilot gnome-pilot-conduits make nano qcad splix tcpdump ttf-kochi-gothic ttf-kochi-mincho ttf-unfonts-core gpaint evince brasero evolution-exchange evolution-common evolution-plugins apmd apport dia-libs xscreensaver-gl jockey-gtk vinagre onboard linux-restricted-modules-2.6.24-19-generic brltty brltty-x11 seahorse dia-libs screensaver-default-images rss-glx linux-headers-2.6.24-19-generic gcc gcc-4.2"
1 by Oliver Grawert
initial checkin
188
	    LIVELIST="xresprobe laptop-detect casper lupin-casper"
189
        LANGLIST="zh en fr de el hu it pt es th ur vi"
190
	    COMP="main restricted universe multiverse"
191
        ;;
192
	xubuntu)
193
	    LIST="$LIST minimal^ standard^ xterm libgoffice-gtk-0-6 xubuntu-desktop^"
194
	    LIVELIST="xubuntu-live^ xresprobe laptop-detect casper lupin-casper"
195
	    COMP="main restricted universe multiverse"
196
	    ;;
197
	gobuntu)
198
	    LIST="$LIST minimal^ standard^ gobuntu-desktop^"
199
	    LIVELIST="gobuntu-live^ xresprobe laptop-detect casper lupin-casper"
200
	    COMP="main"
201
	    ;;
202
	base)
203
	    LIST="$LIST minimal^ standard^"
204
	    LIVELIST="casper lupin-casper"
205
	    ;;
206
	tocd)
207
	    LIST="$LIST minimal^ standard^"
208
	    tocdtmp=`mktemp -d` || exit 1
209
	    tocdgerminate='http://people.ubuntu.com/~cjwatson/germinate-output/tocd3.1-dapper/'
210
	    if wget -O "$tocdtmp"/desktop "$tocdgerminate"/desktop; then
211
	        tocddesktop=`awk '{print $1}' "$tocdtmp"/desktop | egrep -v '^-|^Package|^\|' | tr '\n' ' '`
212
	        echo "TheOpenCD desktop package list is: $tocddesktop"
213
	    else
214
	        echo "Unable to fetch tocd-desktop germinate output."
215
	        [ -d "$tocdtmp" ] && rm -rf "$tocdtmp"
216
		exit 1
217
	    fi
218
	    if wget -O "$tocdtmp"/live "$tocdgerminate"/live; then
219
	        tocdlive=`awk '{print $1}' "$tocdtmp"/live | egrep -v '^-|^Package|^\|' | tr '\n' ' '`
220
	        echo "TheOpenCD live package list is: $tocdlive"
221
	    else
222
	        echo "Unable to fetch tocd-live germinate output."
223
	        [ -d "$tocdtmp" ] && rm -rf "$tocdtmp"
224
		exit 1
225
	    fi
226
	    [ -d "$tocdtmp" ] && rm -rf "$tocdtmp"
227
	    LIST="$LIST $tocddesktop"
228
	    LIVELIST="$tocdlive casper"
229
    esac
230
231
    dpkg -l livecd-rootfs || true	# get our version # in the log.
232
    if [ "$FS" != "ubuntu-lpia" ]; then
233
        debootstrap --components=$(echo $COMP | sed 's/ /,/g') $STE $ROOT $MIRROR
234
    else
235
        debootstrap --components=$(echo $COMP | sed 's/ /,/g') --arch lpia $STE $ROOT $MIRROR
236
    fi
237
31.1.11 by Colin Watson
Sync from livecd-rootfs:
238
    # Recent dpkg has started complaining pretty loudly if dev/pts isn't
239
    # mounted, so let's get it mounted immediately after debootstrap:
240
    mount -t devpts devpts-${STE}-${FSS}-livefs ${ROOT}dev/pts
241
1 by Oliver Grawert
initial checkin
242
    # Just make a few things go away, which lets us skip a few other things.
243
    DIVERTS="usr/sbin/mkinitrd usr/sbin/invoke-rc.d"
244
    for file in $DIVERTS; do
245
	mkdir -p ${ROOT}${file%/*}
246
	chroot $ROOT dpkg-divert --add --local --divert /${file}.livecd --rename /${file}
247
	cp /bin/true ${ROOT}$file
248
    done
249
250
    # /bin/true won't cut it for mkinitrd, need to have -o support.
251
    cat << @@EOF > ${ROOT}/usr/sbin/mkinitrd
252
#!/usr/bin/python
253
import sys
254
for i in range(len(sys.argv)):
255
    if sys.argv[i]=='-o':
256
	open(sys.argv[i+1],"w")
257
@@EOF
258
    chmod 755 ${ROOT}usr/sbin/mkinitrd
259
260
    trap "cleanup" 0 1 2 3 15
261
262
    case $ARCH in
263
        alpha|amd64|i386|ia64|m68k|mips|mipsel)
264
            link_in_boot=no
265
            ;;
266
        *)
267
            link_in_boot=yes
268
            ;;
269
    esac
270
271
    # Make a good /etc/kernel-img.conf for the kernel packages
272
    cat << @@EOF >> ${ROOT}etc/kernel-img.conf
273
do_symlinks = yes
274
relative_links = yes
275
do_bootloader = no
276
do_bootfloppy = no
277
do_initrd = yes
278
link_in_boot = $link_in_boot
279
@@EOF
280
281
    mkdir -p ${ROOT}proc
282
    mount -tproc none ${ROOT}proc
283
284
    case $ARCH+$SUBARCH in
285
	powerpc+ps3)
286
	    mkdir -p ${ROOT}spu;;
287
    esac
288
289
    # In addition to the ones we got from apt, trust whatever the local system
290
    # believes in, but put things back afterwards.
291
    cp ${ROOT}etc/apt/trusted.gpg ${ROOT}etc/apt/trusted.gpg.$$
292
    cat /etc/apt/trusted.gpg >> ${ROOT}etc/apt/trusted.gpg
293
294
    case $ARCH in
295
	amd64)		LIST="$LIST linux-generic";;
296
	i386)
297
	    case $FS in
298
		ubuntu-lpia) LIST="$LIST linux-lpia";;
299
		*)	LIST="$LIST linux-generic";;
300
	    esac;;
301
	powerpc)
302
	    case $SUBARCH in
303
		ps3)	LIST="$LIST linux-cell";;
304
		*)	LIST="$LIST linux-powerpc linux-powerpc64-smp";;
305
	    esac;;
306
307
	# and the bastard stepchildren
308
	ia64)		LIST="$LIST linux-itanium linux-mckinley";;
309
	hppa)		LIST="$LIST linux-hppa32 linux-hppa64";;
310
	sparc*)		LIST="$LIST linux-sparc64";;
311
	*)		echo "Unknown architecture: no kernel."; exit 1;;
312
    esac
313
314
    for x in $EXCLUDE; do
315
	LIST="$(without_package "$x" "$LIST")"
316
    done
317
31.1.6 by Colin Watson
use my local mirror on my network
318
    > ${ROOT}etc/apt/sources.list
1 by Oliver Grawert
initial checkin
319
    # Create a good sources.list, and finish the install
31.1.6 by Colin Watson
use my local mirror on my network
320
    case $(hostname --fqdn) in
321
        *.pelham.vpn.ucam.org)
322
            echo deb $MIRROR $STE main restricted >> ${ROOT}etc/apt/sources.list
323
            MIRROR=${USERMIRROR}
324
            ;;
325
    esac
326
    echo deb $MIRROR $STE ${COMP} >> ${ROOT}etc/apt/sources.list
6 by Oliver Grawert
make app selection changes as discussed and re-add openoffice (which levels out the savings in the image again), also build from hardy-updates
327
    echo deb $MIRROR ${STE}-security ${COMP} >> ${ROOT}etc/apt/sources.list
328
    echo deb $MIRROR ${STE}-updates ${COMP} >> ${ROOT}etc/apt/sources.list
8 by Oliver Grawert
added a note to the not mentioned uncomenting of the cmpc archive, will be re-enabled for the next builds as soon as teh new kernel is up
329
    # only temporary disabled until new kernel is built and cmpc archive
330
    # has valid packages again
17 by Oliver Grawert
enable the classmate specific package repository again so teh new kernel with usb resume fix gets pulled from there, make sure gpg is installed in the image, since no packages can be installed at all without being able to read the gpg signatures
331
    case $FS in
332
        classmate)
31.1.5 by Colin Watson
switch to cmpc.archive.canonical.com
333
            echo "deb http://cmpc.archive.canonical.com hardy main" >>${ROOT}etc/apt/sources.list
31.1.2 by Colin Watson
change archive and key in another spot
334
            chroot ${ROOT} apt-key add - < classmate.pub
17 by Oliver Grawert
enable the classmate specific package repository again so teh new kernel with usb resume fix gets pulled from there, make sure gpg is installed in the image, since no packages can be installed at all without being able to read the gpg signatures
335
            ;;
336
        *)
337
            ;;
338
    esac
339
    chroot $ROOT apt-get update -o Acquire::http::no-cache=1
1 by Oliver Grawert
initial checkin
340
    chroot $ROOT apt-get -y install $LIST </dev/null
341
    chroot ${ROOT} dpkg-query -W --showformat='${Package} ${Version}\n' \
342
	> livecd.${FSS}.manifest-desktop
343
    chroot $ROOT apt-get -y install $LIVELIST </dev/null
344
    case $FS in
345
	edubuntu)
346
	    chroot $ROOT apt-cache dumpavail | \
347
		grep-dctrl -nsPackage -FTask edubuntu-ship-addon -a \
348
				      -FTask edubuntu-live | \
349
		sort -u | \
350
		xargs chroot $ROOT \
351
		    dpkg-query -W --showformat='${Package} ${Version}\n' \
352
		>> livecd.${FSS}.manifest-desktop
353
	    ;;
354
    classmate)
355
        # walk over the removals list, this way the install can use
356
        # all metapackages it wants and we can cherrypick what's removed
357
        chroot $ROOT apt-get -y remove --purge $REMOVALS
358
        chroot $ROOT apt-get -y autoremove
359
360
        #install languages
361
        for lang in $LANGLIST; do
362
            chroot $ROOT apt-get -y install language-pack-gnome-${lang}-base language-pack-kde-${lang}-base
363
            case "$lang" in
364
                zh|th|vi)
365
                    chroot $ROOT apt-get -y install language-support-input-${lang}
15 by Oliver Grawert
make sure the thunderbird-locales-* packages for the different languages get installed (where available)
366
                    case "$lang" in
367
                        zh)
368
                            chroot $ROOT apt-get -y install thunderbird-locale-zh-cn thunderbird-locale-zh-tw
369
                        ;;
370
                        *)
371
                        ;;
372
                    esac
373
                ;;
374
                *)
375
                ;;
376
            esac
377
            case "$lang" in
378
                fr|de|el|hu|it)
379
                   chroot $ROOT apt-get -y install thunderbird-locale-$lang
380
                ;;
381
                pt)
382
                   chroot $ROOT apt-get -y install thunderbird-locale-pt-br
383
                ;;
384
                es)
385
                   chroot $ROOT apt-get -y install thunderbird-locale-es-es
386
                ;;
387
                *)
388
                ;;
389
            esac
1 by Oliver Grawert
initial checkin
390
        done
391
392
        # need multiverse for easy flash installation
393
	    chroot $ROOT apt-cache dumpavail | \
394
		grep-dctrl -nsPackage -FTask edubuntu-ship-addon -a \
395
				      -FTask edubuntu-live | \
396
		sort -u | \
397
		xargs chroot $ROOT \
398
		    dpkg-query -W --showformat='${Package} ${Version}\n' \
399
		>> livecd.${FSS}.manifest-desktop
400
        ;;
401
    esac
402
    chroot ${ROOT} dpkg-query -W --showformat='${Package} ${Version}\n' \
403
	> livecd.${FSS}.manifest
404
    kill_users
405
406
    chroot $ROOT /etc/cron.daily/slocate || true
407
    chroot $ROOT /etc/cron.daily/man-db	|| true
408
409
    # remove our diversions
410
    for file in $DIVERTS; do
411
	ls -ld ${ROOT}${file} ${ROOT}${file}.livecd || true
412
	rm -f ${ROOT}${file}
413
	chroot $ROOT dpkg-divert --remove --rename /${file}
414
    done
415
416
    # And make this look more pristine
417
    cleanup
418
    cat << @@EOF > ${ROOT}etc/apt/sources.list
419
deb ${USERMIRROR} $STE ${COMP}
420
deb-src ${SRCMIRROR} $STE ${COMP}
6 by Oliver Grawert
make app selection changes as discussed and re-add openoffice (which levels out the savings in the image again), also build from hardy-updates
421
deb ${SECMIRROR} ${STE}-security ${COMP}
422
deb-src ${SECSRCMIRROR} ${STE}-security ${COMP}
423
424
## Major bug fix updates produced after the final release of the
425
## distribution.
426
deb ${USERMIRROR} ${STE}-updates ${COMP}
427
deb-src ${USERMIRROR} ${STE}-updates ${COMP}
1 by Oliver Grawert
initial checkin
428
429
## Uncomment the following two lines to add software from the 'universe'
430
## repository.
431
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
432
## team, and may not be under a free licence. Please satisfy yourself as to
433
## your rights to use the software. Also, please note that software in
434
## universe WILL NOT receive any review or updates from the Ubuntu security
435
## team.
436
# deb ${USERMIRROR} $STE universe
437
# deb-src ${SRCMIRROR} $STE universe
438
6 by Oliver Grawert
make app selection changes as discussed and re-add openoffice (which levels out the savings in the image again), also build from hardy-updates
439
# deb ${USERMIRROR} ${STE}-updates universe
440
# deb-src ${USERMIRROR} ${STE}-updates universe
441
# deb ${USERMIRROR} ${STE}-security universe
442
# deb-src ${USERMIRROR} ${STE}-security universe
1 by Oliver Grawert
initial checkin
443
@@EOF
444
    case $FS in
445
        classmate)
446
            echo "# holds classmate specific packages (patched kernel etc)" >>${ROOT}etc/apt/sources.list
31.1.5 by Colin Watson
switch to cmpc.archive.canonical.com
447
            echo "deb http://cmpc.archive.canonical.com hardy main" >>${ROOT}etc/apt/sources.list
1 by Oliver Grawert
initial checkin
448
            ;;
449
        *)
450
            ;;
451
    esac
452
    mv ${ROOT}etc/apt/trusted.gpg.$$ ${ROOT}etc/apt/trusted.gpg
31.1.1 by Colin Watson
use my archive; trust new single-purpose Classmate key
453
    case $FS in
454
        classmate)
455
            chroot ${ROOT} apt-key add - < classmate.pub
456
            ;;
457
    esac
1 by Oliver Grawert
initial checkin
458
459
    # get rid of the .debs - we don't need them.
460
    chroot ${ROOT} apt-get clean
461
    rm -f ${ROOT}etc/X11/xorg.conf
462
    # Restore an empty xorg.conf, else xserver-xorg postinst will be confused
463
    touch ${ROOT}etc/X11/xorg.conf
464
    rm -f ${ROOT}var/lib/apt/lists/*_*
465
    rm -f ${ROOT}var/spool/postfix/maildrop/*
466
    # Removing update-notifier notes is now considered harmful:
467
    #rm -f ${ROOT}var/lib/update-notifier/user.d/*
31.1.10 by Colin Watson
remove bogus home directory created by italc-client.postinst
468
    # italc creates a home directory!
469
    rmdir -p --ignore-fail-on-non-empty ${ROOT}home/*/.config/'iTALC Solutions' || true
31.1.12 by Colin Watson
best make sure /home continues to exist ...
470
    mkdir -p ${ROOT}home
1 by Oliver Grawert
initial checkin
471
    chroot $ROOT apt-get update || true	# give them fresh lists, but don't fail
472
    rm -f ${ROOT}etc/resolv.conf ${ROOT}etc/mailname
473
    if [ -f ${ROOT}/etc/postfix/main.cf ]; then
474
	sed -i '/^myhostname/d; /^mydestination/d; /^myorigin/d' ${ROOT}etc/postfix/main.cf
475
	echo set postfix/destinations | chroot ${ROOT} /usr/bin/debconf-communicate postfix
476
	echo set postfix/mailname | chroot ${ROOT} /usr/bin/debconf-communicate postfix
477
    fi
31.1.7 by Colin Watson
kill build environment leakage in hesiod.conf
478
    sed -i 's/^rhs=.*/rhs=.local/' ${ROOT}etc/hesiod.conf
31.1.8 by Colin Watson
more hesiod crap
479
    echo set hesiod/rhs .local | chroot ${ROOT} /usr/bin/debconf-communicate libhesiod0
1 by Oliver Grawert
initial checkin
480
    KVERS=`chroot ${ROOT} dpkg -l linux-image-2\*|grep ^i|awk '{print $2}'|sed 's/linux-image-//'`
481
    for KVER in ${KVERS}; do
482
	SUBARCH="${KVER#*-*-}"
483
	chroot ${ROOT} update-initramfs -k "${KVER}" -u
484
	# we mv the initramfs, so it's not wasting space on the livefs
485
	mv ${ROOT}/boot/initrd.img-"${KVER}" livecd.${FSS}.initrd-"${SUBARCH}"
486
	cp ${ROOT}/boot/vmlinu?-"${KVER}" livecd.${FSS}.kernel-"${SUBARCH}"
487
    done
488
    NUMKVERS="$(set -- $KVERS; echo $#)"
489
    if [ "$NUMKVERS" = 1 ]; then
490
	# only one kernel
491
	SUBARCH="${KVERS#*-*-}"
492
	ln -s livecd.${FSS}.initrd-"${SUBARCH}" livecd.${FSS}.initrd
493
	ln -s livecd.${FSS}.kernel-"${SUBARCH}" livecd.${FSS}.kernel
494
    fi
495
    case $ARCH+$SUBARCH in
496
	powerpc+ps3)
497
	    chroot ${ROOT} addgroup --system spu;;
498
    esac
499
    # all done with the chroot; reset the debconf frontend, so Colin doesn't cry
500
    echo RESET debconf/frontend | chroot $ROOT debconf-communicate
501
    echo FSET debconf/frontend seen true | chroot $ROOT debconf-communicate
502
503
    # And now that we're done messing with debconf, destroy the backup files:
504
    rm -f ${ROOT}/var/cache/debconf/*-old
505
506
    # show the size of directories in /usr/share/doc
507
    echo BEGIN docdirs
508
    (cd $ROOT && find usr/share/doc -maxdepth 1 -type d | xargs du -s | sort -nr)
509
    echo END docdirs
510
511
    # search for duplicate files, write the summary to stdout, 
512
    if which fdupes >/dev/null 2>&1; then
513
	echo "first line: <total size for dupes> <different dupes> <all dupes>"
514
	echo "data lines: <size for dupes> <number of dupes> <file size> <filename> [<filename> ...]"
515
	echo BEGIN fdupes
516
	(cd $ROOT \
517
	   && fdupes --recurse --noempty --sameline --size --quiet usr \
518
	   | awk '/bytes each/ {s=$1} /^usr/ { n+=1; n2+=NF-1; sum+=s*(NF-1); print s*(NF-1), NF-1, s, $0 } END {print sum, n, n2}' \
519
	   | sort -nr
520
	)
521
	echo END fdupes
522
    fi
523
524
    # Dirty hack to mark langpack stuff as manually installed
525
    perl -i -nle 'print unless /^Package: language-(pack|support)/ .. /^$/;' \
526
        ${ROOT}/var/lib/apt/extended_states
527
528
  livefs_squash()
529
  {
530
    squashsort="http://people.ubuntu.com/~tfheen/livesort/${FSS}.list.${ARCH}"
531
    if wget -O livecd.${FSS}.sort ${squashsort} > /dev/null 2>&1; then
532
      echo "Using the squashfs sort list from ${squashsort}."
533
    else
534
      echo "Unable to fetch squashfs sort list; using a blank list."
535
      : > livecd.${FSS}.sort
536
    fi
537
538
    mksquashfs ${ROOT} livecd.${FSS}.squashfs -nolzma -sort livecd.${FSS}.sort
539
    chmod 644 livecd.${FSS}.squashfs
540
  }
541
542
  livefs_squash
543
544
done