3
echo "BINARY-HOOK: fix install from USB in Lenny."
5
# This is a *binary-hook* to allow disk installations from USB for
6
# Debian 5.0.x Lenny. Place this file in config/binary_local-hooks/,
7
# make it executable and rebuild your live image (binary only).
9
# This workaround for debian-installer was adapted from Chris Lamb
11
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=498143#5
13
# It works by fooling apt-setup. With an existing /hd-media directory
14
# apt-setup will not try to umount /cdrom. Enable live installer with
17
# lh_config --debian-installer "live"
19
# Rebuild your binary image. No options needed on boot.
21
cat > cdrom-detect.postinst.patch << 'EOF'
26
+ # Try disk partitions masquerading as Debian CDs for Debian Live
27
+ # "usb-hdd" images. Only vfat and ext are supported.
28
+ modprobe vfat >/dev/null 2>&1 || true
29
+ for device in $(list-devices partition); do
30
+ if mount -t vfat -o ro,exec $device /cdrom ||
31
+ mount -t ext2 -o ro,exec $device /cdrom; then
32
+ log "Pseudo CD-ROM mount succeeded: device=$device"
34
+ # Test whether it's a Debian CD
35
+ if [ -e /cdrom/.disk/info ]; then
37
+ db_set cdrom-detect/cdrom_device $device
38
+ # fake hd-media install so that apt-setup doesn't break.
42
+ log "Ignoring pseudo CD-ROM device $device - it is not a Debian CD"
43
+ umount /cdrom 2>/dev/null || true
46
+ log "Psuedo CD-ROM mount failed: device=$device"
50
if [ "$mounted" = "1" ]; then
56
# for the syslinux installer
57
mkdir usb-install-syslinux
58
cd usb-install-syslinux
59
zcat ../binary/install/initrd.gz | cpio -iv
60
patch ./var/lib/dpkg/info/cdrom-detect.postinst < ../cdrom-detect.postinst.patch
62
if [ "${PATCH_ERROR}" != 0 ]
64
# if there was an error, say it and undo everything.
65
echo "ERROR: error while patching cdrom-detect.postinst."
67
rmdir -rf usb-install-syslinux
71
find . -print0 | cpio -0 -H newc -ov | gzip -c > ../initrd-new.gz
73
mv initrd-new.gz binary/install/initrd.gz
74
rm -rf usb-install-syslinux
76
# for the gtk installer
79
zcat ../binary/install/gtk/initrd.gz | cpio -iv
80
patch ./var/lib/dpkg/info/cdrom-detect.postinst < ../cdrom-detect.postinst.patch
82
if [ "${PATCH_ERROR}" != 0 ]
84
# if there was an error, say it and undo everything
85
echo "ERROR: error while patching cdrom-detect.postinst."
87
rmdir -rf usb-install-gtk
91
find . -print0 | cpio -0 -H newc -ov | gzip -c > ../initrd-new.gz
93
mv initrd-new.gz binary/install/gtk/initrd.gz
94
rm -rf usb-install-gtk
96
rm cdrom-detect.postinst.patch