~linaro-maintainers/live-build/linaro-live-build-3

« back to all changes in this revision

Viewing changes to examples/hooks/lenny_binary_live-installer-usbfix.sh

  • Committer: Daniel Baumann
  • Date: 2011-03-09 18:19:23 UTC
  • Revision ID: git-v1:c5c3f6133a0fb62ba9c2c3b839e6ea5774f9c76a
Adding debian version 3.0~a1-1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
 
3
 
echo "BINARY-HOOK: fix install from USB in Lenny."
4
 
 
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).
8
 
 
9
 
# This workaround for debian-installer was adapted from Chris Lamb
10
 
original patch:
11
 
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=498143#5
12
 
 
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
15
 
# lh_config:
16
 
#
17
 
# lh_config --debian-installer "live"
18
 
#
19
 
# Rebuild your binary image. No options needed on boot.
20
 
 
21
 
cat > cdrom-detect.postinst.patch << 'EOF'
22
 
@@ -44,6 +44,30 @@ do
23
 
                fi
24
 
        done
25
 
 
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"
33
 
+
34
 
+                       # Test whether it's a Debian CD
35
 
+                       if [ -e /cdrom/.disk/info ]; then
36
 
+                               mounted=1
37
 
+                               db_set cdrom-detect/cdrom_device $device
38
 
+                               # fake hd-media install so that apt-setup doesn't break.
39
 
+                               mkdir /hd-media
40
 
+                               break
41
 
+                       else
42
 
+                               log "Ignoring pseudo CD-ROM device $device - it is not a Debian CD"
43
 
+                               umount /cdrom 2>/dev/null || true
44
 
+                       fi
45
 
+               else
46
 
+                       log "Psuedo CD-ROM mount failed: device=$device"
47
 
+               fi
48
 
+       done
49
 
+
50
 
        if [ "$mounted" = "1" ]; then
51
 
                break
52
 
        fi
53
 
 
54
 
EOF
55
 
 
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
61
 
PATCH_ERROR=${?}
62
 
if [ "${PATCH_ERROR}" != 0 ]
63
 
then
64
 
        # if there was an error, say it and undo everything.
65
 
        echo "ERROR: error while patching cdrom-detect.postinst."
66
 
        cd ..
67
 
        rmdir -rf usb-install-syslinux
68
 
        exit 0
69
 
fi
70
 
# rebuild the initrd
71
 
find . -print0 | cpio -0 -H newc -ov | gzip -c > ../initrd-new.gz
72
 
cd ..
73
 
mv initrd-new.gz binary/install/initrd.gz
74
 
rm -rf usb-install-syslinux
75
 
 
76
 
# for the gtk installer
77
 
mkdir usb-install-gtk
78
 
cd usb-install-gtk
79
 
zcat ../binary/install/gtk/initrd.gz | cpio -iv
80
 
patch ./var/lib/dpkg/info/cdrom-detect.postinst < ../cdrom-detect.postinst.patch
81
 
PATCH_ERROR=${?}
82
 
if [ "${PATCH_ERROR}" != 0 ]
83
 
then
84
 
        # if there was an error, say it and undo everything
85
 
        echo "ERROR: error while patching cdrom-detect.postinst."
86
 
        cd ..
87
 
        rmdir -rf usb-install-gtk
88
 
        exit 0
89
 
fi
90
 
# rebuild the initrd
91
 
find . -print0 | cpio -0 -H newc -ov | gzip -c > ../initrd-new.gz
92
 
cd ..
93
 
mv initrd-new.gz binary/install/gtk/initrd.gz
94
 
rm -rf usb-install-gtk
95
 
 
96
 
rm cdrom-detect.postinst.patch