1 #!/bin/sh /usr/share/dpatch/dpatch-run
2 ## 01-conglomeration.dpatch
4 ## DP: Needs to be broken out.
8 diff -Naur casper-1.61+debian.orig/bin/casper-reconfigure casper-1.61+debian/bin/casper-reconfigure
9 --- casper-1.61+debian.orig/bin/casper-reconfigure 2006-05-11 19:03:29.000000000 +0000
10 +++ casper-1.61+debian/bin/casper-reconfigure 2006-07-19 18:54:36.000000000 +0000
15 -runcommandinroot "$root" dpkg-reconfigure -fnoninteractive --no-reload "$package"
16 +runcommandinroot "$root" dpkg-reconfigure -fnoninteractive --no-reload -phigh "$package"
19 diff -Naur casper-1.61+debian.orig/casper.conf casper-1.61+debian/casper.conf
20 --- casper-1.61+debian.orig/casper.conf 2006-05-02 12:16:55.000000000 +0000
21 +++ casper-1.61+debian/casper.conf 2006-07-19 18:54:36.000000000 +0000
23 # Supported variables are:
24 # USERNAME, USERFULLNAME, HOST
26 -export USERNAME="ubuntu"
27 -export USERFULLNAME="Custom LiveCD user"
29 +export USERNAME="debian"
30 +export USERFULLNAME="Debian Live user"
33 diff -Naur casper-1.61+debian.orig/hooks/casper casper-1.61+debian/hooks/casper
34 --- casper-1.61+debian.orig/hooks/casper 2006-06-15 09:04:08.000000000 +0000
35 +++ casper-1.61+debian/hooks/casper 2006-07-19 18:54:36.000000000 +0000
38 . /usr/share/initramfs-tools/hook-functions
41 -manual_add_modules cloop
43 manual_add_modules unionfs
45 +# Needed for devmapper
46 +if [ -e /sbin/dmsetup ]; then
47 + manual_add_modules cloop
48 + copy_exec /sbin/blockdev /sbin
49 + copy_exec /sbin/dmsetup /sbin
50 + manual_add_modules dm-snapshot
54 copy_exec /sbin/losetup /sbin
57 copy_exec /usr/share/casper/casper-reconfigure /bin
58 copy_exec /usr/share/casper/casper-preseed /bin
60 -mkdir -p ${DESTDIR}/lib/udev
61 -copy_exec /lib/udev/cdrom_id /lib/udev
62 -copy_exec /lib/udev/vol_id /lib/udev
63 -copy_exec /lib/udev/path_id /lib/udev
64 +# Ubuntu or Debian test
65 +if [ -x /sbin/udevplug ]; then
66 + mkdir -p ${DESTDIR}/lib/udev
67 + copy_exec /lib/udev/cdrom_id /lib/udev
68 + copy_exec /lib/udev/vol_id /lib/udev
69 + copy_exec /lib/udev/path_id /lib/udev
71 + copy_exec /sbin/udevtrigger /sbin
74 copy_exec /usr/bin/udevinfo /bin
76 -# Needed for devmapper
77 -copy_exec /sbin/blockdev /sbin
78 -copy_exec /sbin/dmsetup /sbin
79 -manual_add_modules dm-snapshot
81 +if [ -x /sbin/mount.cifs ]; then
82 + copy_exec /sbin/mount.cifs /sbin
84 + manual_add_modules ${x}
89 manual_add_modules squashfs
90 diff -Naur casper-1.61+debian.orig/scripts/casper casper-1.61+debian/scripts/casper
91 --- casper-1.61+debian.orig/scripts/casper 2006-07-17 10:53:28.000000000 +0000
92 +++ casper-1.61+debian/scripts/casper 2006-07-19 18:54:36.000000000 +0000
95 export PATH=/root/usr/bin:/root/usr/sbin:/root/bin:/root/sbin:/usr/bin:/usr/sbin:/bin:/sbin
98 +mountpoint=/live_media
99 +root_persistence="casper-rw"
100 +home_persistence="home-rw"
105 overlay_method=devmapper
109 -USERFULLNAME="Ubuntu LiveCD user"
112 +USERFULLNAME="Debian Live user"
115 [ -f /etc/casper.conf ] && . /etc/casper.conf
117 export USERNAME USERFULLNAME HOST
120 +casper_path() { # Fixme: uglyness
122 if [ -e "$path/casper/filesystem.cloop" ]; then
123 echo "$path/casper/filesystem.cloop"
125 elif [ -e "$path/casper/filesystem.squashfs" ]; then
126 echo "$path/casper/filesystem.squashfs"
128 + elif [ -e "$path/casper/filesystem.ext2" ]; then
129 + echo "$path/casper/filesystem.ext2"
131 + elif [ -e "$path/casper/filesystem.xfs" ]; then
132 + echo "$path/casper/filesystem.xfs"
139 echo $(setup_loop "$1" "cloop" "/sys/block/cloop*")
142 + *.squashfs|*.ext2|*.xfs)
143 echo $(setup_loop "$1" "loop" "/sys/block/loop*")
150 - modprobe -Qb "$module"
152 + modprobe -qb "$module"
153 + if [ -x /sbin/udevplug ]; then
159 for loopdev in $pattern; do
160 if [ "$(cat $loopdev/size)" -eq 0 ]; then
165 - modprobe -Qb dm-mod
166 + modprobe -qb dm-mod
168 COW_NAME="casper-cow"
170 @@ -143,82 +155,137 @@
175 - for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop); do
176 - for dev in $(subdevices "${sysblock}"); do
177 - devname=$(sys2dev "${dev}")
178 - if [ "$(/lib/udev/vol_id -l $devname 2>/dev/null)" = "casper-rw" ]; then
181 - elif [ "$(get_fstype ${devname})" = "vfat" ]; then
182 - mkdir -p /cow-backing
183 - if where_is_mounted ${devname} > /dev/null; then
184 - mount -o remount,rw ${devname} $(where_is_mounted ${devname}) || panic "Remounting failed"
185 - mount -o bind $(where_is_mounted ${devname}) /cow-backing || panic "Cannot bind-mount"
187 - mount -t $(get_fstype "${devname}") -o rw "${devname}" /cow-backing || panic "Cannot mount $devname on /cow-backing"
190 + copyto="${mountpoint}_swap"
192 - if [ -e "/cow-backing/casper-rw" ]; then
193 - echo $(setup_loop "/cow-backing/casper-rw" "loop" "/sys/block/loop*")
196 - umount /cow-backing
203 + size=$(du -ks ${mountpoint} | cut -f1)
204 + size=$(expr ${size} + ${size}/20 ) # Fixme: 5% more to be sure
205 + needed_space=$(expr ${size} * 1024)
206 + freespace=$( expr $(awk '/MemFree/{print $2}' /proc/meminfo) + $( cat /proc/meminfo | grep Cached | head -n 1 | awk '/Cached/{print $2}' - ))
208 + if [ ! ${freespace} -lt ${needed_space} ] ; then
209 + [ "$quiet" != "y" ] && log_begin_msg "Not enough free memory to copy to ram"
210 + [ "$quiet" != "y" ] && log_end_msg
213 + [ "$quiet" != "y" ] && log_begin_msg "Copying live media to ram..."
215 + mount -t tmpfs -o size=${size}k /dev/shm ${copyto}
216 + cp -a ${mountpoint}/* ${copyto}
217 + umount ${mountpoint}
218 + mount -r -o move ${copyto} ${mountpoint}
220 + [ "$quiet" != "y" ] && log_end_msg
226 + cow_backing="/${pers_label}-backing"
227 + for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop); do
228 + for dev in $(subdevices "${sysblock}"); do
229 + devname=$(sys2dev "${dev}")
230 + if [ "$(/lib/udev/vol_id -l $devname 2>/dev/null)" = "${pers_label}" ]; then
233 + elif [ "$(get_fstype ${devname})" = "vfat" ]; then
234 + mkdir -p "${cow_backing}"
235 + if where_is_mounted ${devname} > /dev/null; then
236 + mount -o remount,rw ${devname} $(where_is_mounted ${devname}) || panic "Remounting failed"
237 + mount -o bind $(where_is_mounted ${devname}) ${cow_backing} || panic "Cannot bind-mount"
239 + mount -t $(get_fstype "${devname}") -o rw "${devname}" ${cow_backing} || panic "Cannot mount $devname on /cow-backing"
242 + if [ -e "${cow_backing}/${pers_label}" ]; then
243 + echo $(setup_loop "${cow_backing}/${pers_label}" "loop" "/sys/block/loop*")
246 + umount ${cow_backing}
255 + # adapted from NFS filesystem mounting
259 + modprobe -q af_packet
261 + ipconfig ${DEVICE} /tmp/net-${DEVICE}.conf
262 + if [ "x${NFSROOT}" = "xauto" ]; then
263 + NFSROOT=${ROOTSERVER}:${ROOTPATH}
266 + NFSOPTS="-ouser=root,password="
268 + [ "$quiet" != "y" ] && log_begin_msg "Mounting using mount.cifs with ${NFSROOT} ${rofsmnt} ${NFSOPTS}"
269 + mount.cifs "${NFSROOT}" "${rofsmnt}" "${NFSOPTS}"
270 + [ "$quiet" != "y" ] && log_end_msg
276 - modprobe -Qb unionfs
278 + modprobe -qb unionfs
282 + # Looking for "${root_persistence}" device or file
283 + if grep -q persistent /proc/cmdline; then
284 + cowprobe=$(find_cow_device "${root_persistence}")
285 + if [ -b "${cowprobe}" ]; then
286 + cowdevice=${cowprobe}
287 + cow_fstype=$(get_fstype "${cowprobe}")
289 + [ "$quiet" != "y" ] && log_begin_msg "Unable to find the persistent medium"
293 - if grep -q persistent /proc/cmdline; then
295 - # We love udev and the kernel!
296 - while [ "$i" -lt 300 ]; do
297 - cowdevice=$(find_cow_device)
298 - if [ -b "$cowdevice" ]; then
299 - mount -t $(get_fstype "$cowdevice") -o rw "$cowdevice" /cow || panic "Can not mount $cowdevice on /cow"
307 - mount -t tmpfs tmpfs /cow
309 + mount ${cowdevice} -t ${cow_fstype} -o rw /cow || panic "Can not mount $cowdevice on /cow"
312 - if [ "$(get_fstype $backdev)" = "unknown" ]; then
313 - panic "Unknown file system type on $backdev"
315 - mount -t $(get_fstype "$backdev") -o ro "$backdev" /rofs || panic "Can not mount $backdev on /rofs"
317 + if grep -q netboot /proc/cmdline; then
318 + do_netmount /rofs || panic "Can not mount netroot on /rofs"
320 + if [ "$(get_fstype $backdev)" = "unknown" ]; then
321 + panic "Unknown file system type on $backdev"
323 + mount -t $(get_fstype "$backdev") -o ro "$backdev" /rofs || panic "Can not mount $backdev on /rofs"
326 mount -t unionfs -o dirs=/cow=rw:/rofs=ro unionfs "$rootmnt"
327 - if grep -q show-cow /proc/cmdline; then
328 - mkdir -p "$rootmnt/cow"
329 - mount -o bind /cow "$rootmnt/cow"
331 - mkdir -p "$rootmnt/rofs"
332 - mount -o bind /rofs "$rootmnt/rofs"
333 + if grep -q show-cow /proc/cmdline; then
334 + mkdir -p "$rootmnt/cow"
335 + mount -o bind /cow "$rootmnt/cow"
337 + mkdir -p "$rootmnt/rofs"
338 + mount -o bind /rofs "$rootmnt/rofs"
340 + # Adding home persitence
341 + if grep -q homepersistence /proc/cmdline; then
342 + homecow=$(find_cow_device "${home_persistence}" )
343 + if [ -b "${homecow}" ]; then
344 + mount ${homecow} -t $(get_fstype "${homecow}") -o rw "${rootmnt}/home"
346 + [ "$quiet" != "y" ] && log_begin_msg "Unable to find the persistent home medium"
352 sysfs_path="${1#/sys}"
353 - if /lib/udev/path_id "${sysfs_path}" | grep -q "ID_PATH=usb"; then
354 + if /lib/udev/path_id "${sysfs_path}" | grep -q "ID_PATH=(usb|pci-[^-]*-usb)"; then
363 for sysblock in $(echo /sys/block/* | tr ' ' '\n' | grep -v loop | grep -v ram); do
364 devname=$(sys2dev "${sysblock}")
365 @@ -283,18 +350,26 @@
368 for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13; do
369 - live_image=$(find_cd)
370 + live_image=$(find_live)
371 if [ "${live_image}" ]; then
376 if [ "$?" -gt 0 ]; then
377 - panic "Unable to find a CD-ROM containing a live file system"
378 + panic "Unable to find a medium containing a live file system"
381 + if grep -q toram /proc/cmdline; then
385 setup_cow "$overlay_method" "$(get_backing_device $live_image)" "$rootmnt"
387 + # show it on new rootfs
388 + mkdir ${rootmnt}/${mountpoint}
389 + mount -o bind ${mountpoint} ${rootmnt}/${mountpoint}
393 maybe_break casper-bottom
394 diff -Naur casper-1.61+debian.orig/scripts/casper-bottom/01integrity_check casper-1.61+debian/scripts/casper-bottom/01integrity_check
395 --- casper-1.61+debian.orig/scripts/casper-bottom/01integrity_check 2006-04-21 14:08:09.000000000 +0000
396 +++ casper-1.61+debian/scripts/casper-bottom/01integrity_check 2006-07-19 18:54:36.000000000 +0000
401 -grep integrity-check /proc/cmdline && casper-md5check /cdrom /cdrom/md5sum.txt < /dev/tty8
402 +grep integrity-check /proc/cmdline && casper-md5check /live_media /live_media/md5sum.txt < /dev/tty8
403 diff -Naur casper-1.61+debian.orig/scripts/casper-bottom/10adduser casper-1.61+debian/scripts/casper-bottom/10adduser
404 --- casper-1.61+debian.orig/scripts/casper-bottom/10adduser 2006-05-11 11:35:21.000000000 +0000
405 +++ casper-1.61+debian/scripts/casper-bottom/10adduser 2006-07-19 18:54:55.000000000 +0000
408 chroot /root debconf-communicate -fnoninteractive casper > /dev/null <<EOF
409 set passwd/root-password-crypted *
410 -set passwd/user-password-crypted U6aMy0wojraho
411 +set passwd/user-password-crypted $1$NkzZXpgE$WUcfPW16xGuUQAlx99HAF0
412 set passwd/user-fullname $USERFULLNAME
413 set passwd/username $USERNAME
414 set passwd/user-uid 999
417 -chroot /root /usr/lib/user-setup/user-setup-apply > /dev/null
418 +chroot /root /usr/bin/env -i HOME="/root" \
419 + TERM="${TERM}" PATH="/usr/sbin:/usr/bin:/sbin:/bin" \
420 + /usr/lib/user-setup/user-setup-apply > /dev/null
422 # Clear out debconf database again to avoid confusing ubiquity later.
423 chroot /root debconf-communicate -fnoninteractive casper > /dev/null <<EOF
427 if [ -f /root/etc/sudoers ]; then
428 - grep -q '^%admin' /root/etc/sudoers && sed -i -e '/^%admin/s/ALL$/NOPASSWD: ALL/' /root/etc/sudoers || echo '%admin ALL=(ALL) NOPASSWD: ALL' >> /root/etc/sudoers
431 -# XXX - awful hack to stop xscreensaver locking the screen (#7150)
432 -echo 'RUNNING_UNDER_GDM="yes"' >> /root/etc/environment
434 -for file in /usr/share/applications/ubiquity-gtkui.desktop /usr/share/applications/kde/ubiquity-kdeui.desktop; do
435 - if [ -f "/root/$file" ]; then
436 - chroot /root install -D -o $USERNAME -g $USERNAME $file /home/$USERNAME/Desktop/$(basename "$file")
438 + if [ -x /sbin/udevplug ]; then
439 + # FIXME: ugly hack, admin is not present in debian so we do here ubuntu stuff
440 + # XXX - awful hack to stop xscreensaver locking the screen (#7150)
441 + echo 'RUNNING_UNDER_GDM="yes"' >> /root/etc/environment
442 + grep -q '^%admin' /root/etc/sudoers && sed -i -e '/^%admin/s/ALL$/NOPASSWD: ALL/' /root/etc/sudoers || echo '%admin ALL=(ALL) NOPASSWD: ALL' >> /root/etc/sudoers
443 + for file in /usr/share/applications/ubiquity-gtkui.desktop /usr/share/applications/kde/ubiquity-kdeui.desktop; do
444 + if [ -f "/root/$file" ]; then
445 + chroot /root install -D -o $USERNAME -g $USERNAME $file /home/$USERNAME/Desktop/$(basename "$file")
449 + else # We are in debian :-)
450 + echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" >> /root/etc/sudoers
455 if [ -L /root/home/$USERNAME/Examples ]; then
456 chroot /root install -o $USERNAME -g $USERNAME -d /home/$USERNAME/Desktop/
457 diff -Naur casper-1.61+debian.orig/scripts/casper-bottom/14locales casper-1.61+debian/scripts/casper-bottom/14locales
458 --- casper-1.61+debian.orig/scripts/casper-bottom/14locales 2006-05-16 10:45:27.000000000 +0000
459 +++ casper-1.61+debian/scripts/casper-bottom/14locales 2006-07-19 18:54:36.000000000 +0000
462 log_begin_msg "$DESCRIPTION"
465 +if [ -e /root/etc/default/locale ]; then
466 + grep_file=/root/etc/default/locale
467 + locale=$(grep 'LANG=' ${grep_file} | sed s/'LANG='// | tr -d '"' )
468 +elif [ -e /root/etc/environment ]; then # Old locales policy
469 + grep_file=/root/etc/environment
473 for x in $(cat /proc/cmdline); do
475 - debian-installer/locale=*)
476 - locale=${x#debian-installer/locale=}
480 + debian-installer/locale=*)
481 + locale=${x#debian-installer/locale=}
487 -LANG=$(grep "^${locale}" /root/usr/share/i18n/SUPPORTED | grep UTF-8 |sed -e 's, .*,,' -e q)
488 +if [ -z "${locale}" ]; then
489 + # Set a default one
494 -printf 'LANG="%s"\n' "${LANG}" >> /root/etc/environment
495 -chroot /root /usr/sbin/locale-gen "${LANG}"
496 +if [ ! -z "${set_locale}" ]; then
497 + LANG=$(grep "^${locale}" /root/usr/share/i18n/SUPPORTED | grep UTF-8 |sed -e 's, .*,,' -e q)
498 + printf 'LANG="%s"\n' "${LANG}" >> "${grep_file}"
499 + chroot /root /usr/sbin/locale-gen "${LANG}"
503 diff -Naur casper-1.61+debian.orig/scripts/casper-bottom/15autologin casper-1.61+debian/scripts/casper-bottom/15autologin
504 --- casper-1.61+debian.orig/scripts/casper-bottom/15autologin 2006-05-11 10:06:07.000000000 +0000
505 +++ casper-1.61+debian/scripts/casper-bottom/15autologin 2006-07-19 18:54:36.000000000 +0000
509 if chroot /root [ -f ${GDMCONF} ]; then
510 + # true hack ! -- nohar
511 + chroot /root cp /usr/share/gdm/defaults.conf /etc/gdm/gdm.conf
512 # Configure GDM autologin
513 chroot /root sed -i \
514 -e "s/^AutomaticLoginEnable=.*\$/AutomaticLoginEnable=true/" \
515 diff -Naur casper-1.61+debian.orig/scripts/casper-bottom/22gnome_panel_data casper-1.61+debian/scripts/casper-bottom/22gnome_panel_data
516 --- casper-1.61+debian.orig/scripts/casper-bottom/22gnome_panel_data 2006-05-11 10:05:55.000000000 +0000
517 +++ casper-1.61+debian/scripts/casper-bottom/22gnome_panel_data 2006-07-19 18:54:36.000000000 +0000
520 log_begin_msg "$DESCRIPTION"
522 -if chroot /root /bin/sh -c laptop-detect; then
523 - casper-reconfigure /root gnome-panel-data
524 +if [ -x /root/usr/sbin/laptop-detect ]; then
525 + if chroot /root /bin/sh -c /usr/sbin/laptop-detect; then
526 + casper-reconfigure /root gnome-panel-data
530 panel_version=$(chroot /root /usr/bin/dpkg-query -W --showformat='${Version}' gnome-panel-data 2>/dev/null) || panel_version=""
531 diff -Naur casper-1.61+debian.orig/scripts/casper-bottom/23networking casper-1.61+debian/scripts/casper-bottom/23networking
532 --- casper-1.61+debian.orig/scripts/casper-bottom/23networking 2006-05-11 10:05:11.000000000 +0000
533 +++ casper-1.61+debian/scripts/casper-bottom/23networking 2006-07-19 18:54:36.000000000 +0000
538 -udevplug -Bpci -Iclass="0x02*"
539 +if [ -x /sbin/udevplug ]; then
540 + udevplug -Bpci -Iclass="0x02*"
545 for interface in /sys/class/net/eth* /sys/class/net/ath* /sys/class/net/wlan*; do
546 [ -e $interface ] || continue
547 diff -Naur casper-1.61+debian.orig/scripts/casper-bottom/25configure_init casper-1.61+debian/scripts/casper-bottom/25configure_init
548 --- casper-1.61+debian.orig/scripts/casper-bottom/25configure_init 2006-06-15 09:08:14.000000000 +0000
549 +++ casper-1.61+debian/scripts/casper-bottom/25configure_init 2006-07-19 18:54:36.000000000 +0000
552 # This has the nice side effect of the cron.{daily,weekly,monthly} jobs in
553 # /etc/crontab remaining disabled, yet also not run by anacron
554 -for f in /root/etc/rc?.d/S??anacron; do
555 - mv ${f} ${f%/*}/K00anacron
557 +if [ -x /root/etc/init.d/anacron ]; then
558 + for f in /root/etc/rc?.d/S??anacron; do
559 + mv ${f} $(dirname ${f})/K00anacron
564 rm -f /root/etc/rc?.d/[SK]??postfix
567 # Disable readahead since it doesn't play well with squashfs + unionfs
568 # use chmod instead of mv to not trigger unionfs bugs.
569 -chmod -x /root/sbin/readahead-list
571 -# Install shutdown script
572 -cp -a /lib/casper/shutdown /root/etc/init.d/casper-shutdown
573 -if [ -f /root/etc/rc0.d/S90halt ]; then
574 - ln -s ../init.d/casper-shutdown /root/etc/rc0.d/S89casper
576 -if [ -f /root/etc/rc6.d/S90reboot ]; then
577 - ln -s ../init.d/casper-shutdown /root/etc/rc6.d/S89casper
578 +if [ -e /root/sbin/readahead-list ]; then
579 + chmod -x /root/sbin/readahead-list
583 diff -Naur casper-1.61+debian.orig/scripts/casper-bottom/33disable_binary_drivers casper-1.61+debian/scripts/casper-bottom/33disable_binary_drivers
584 --- casper-1.61+debian.orig/scripts/casper-bottom/33disable_binary_drivers 2006-05-13 08:13:22.000000000 +0000
585 +++ casper-1.61+debian/scripts/casper-bottom/33disable_binary_drivers 2006-07-19 18:54:36.000000000 +0000
588 log_begin_msg "$DESCRIPTION"
590 -echo 'DISABLED_MODULES="fglrx nv"' >> /root/etc/default/linux-restricted-modules-common
591 +if [ -e /root/etc/default/linux-restricted-modules-common ]; then
592 + echo 'DISABLED_MODULES="fglrx nv"' >> /root/etc/default/linux-restricted-modules-common