summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDaniel Baumann <daniel@debian.org>2009-11-11 17:12:34 +0100
committerDaniel Baumann <daniel@debian.org>2011-03-09 19:09:48 +0100
commit02fee2236aa2203dbda715ab8c07c7678527f974 (patch)
treef53d6704a2f4da9c2f62a24682b248da2ebb0b6e /examples
parent22c6dc6149967379dd7ab65f8ea59bc94054acc7 (diff)
downloadvyos-live-build-02fee2236aa2203dbda715ab8c07c7678527f974.tar.gz
vyos-live-build-02fee2236aa2203dbda715ab8c07c7678527f974.zip
Adding example hook from Rui Miguel Bernardo <rui.bernardo.pt@gmail.com> for bugfixing cdrom-detect when using live-installer in lenny.
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/hooks/live-installer_lenny-usbfix.sh96
1 files changed, 96 insertions, 0 deletions
diff --git a/examples/hooks/live-installer_lenny-usbfix.sh b/examples/hooks/live-installer_lenny-usbfix.sh
new file mode 100755
index 000000000..ded8b80ed
--- /dev/null
+++ b/examples/hooks/live-installer_lenny-usbfix.sh
@@ -0,0 +1,96 @@
+#!/bin/sh
+
+echo "BINARY-HOOK: fix install from USB in Lenny."
+
+# This is a *binary-hook* to allow disk installations from USB for
+# Debian 5.0.x Lenny. Place this file in config/binary_local-hooks/,
+# make it executable and rebuild your live image (binary only).
+
+# This workaround for debian-installer was adapted from Chris Lamb
+original patch:
+# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=498143#5
+
+# It works by fooling apt-setup. With an existing /hd-media directory
+# apt-setup will not try to umount /cdrom. Enable live installer with
+# lh_config:
+#
+# lh_config --debian-installer "live"
+#
+# Rebuild your binary image. No options needed on boot.
+
+cat > cdrom-detect.postinst.patch << 'EOF'
+@@ -44,6 +44,30 @@ do
+ fi
+ done
+
++ # Try disk partitions masquerading as Debian CDs for Debian Live
++ # "usb-hdd" images. Only vfat and ext are supported.
++ modprobe vfat >/dev/null 2>&1 || true
++ for device in $(list-devices partition); do
++ if mount -t vfat -o ro,exec $device /cdrom ||
++ mount -t ext2 -o ro,exec $device /cdrom; then
++ log "Pseudo CD-ROM mount succeeded: device=$device"
++
++ # Test whether it's a Debian CD
++ if [ -e /cdrom/.disk/info ]; then
++ mounted=1
++ db_set cdrom-detect/cdrom_device $device
++ # fake hd-media install so that apt-setup doesn't break.
++ mkdir /hd-media
++ break
++ else
++ log "Ignoring pseudo CD-ROM device $device - it is not a Debian CD"
++ umount /cdrom 2>/dev/null || true
++ fi
++ else
++ log "Psuedo CD-ROM mount failed: device=$device"
++ fi
++ done
++
+ if [ "$mounted" = "1" ]; then
+ break
+ fi
+
+EOF
+
+# for the syslinux installer
+mkdir usb-install-syslinux
+cd usb-install-syslinux
+zcat ../binary/install/initrd.gz | cpio -iv
+patch ./var/lib/dpkg/info/cdrom-detect.postinst < ../cdrom-detect.postinst.patch
+PATCH_ERROR=${?}
+if [ "${PATCH_ERROR}" != 0 ]
+then
+ # if there was an error, say it and undo everything.
+ echo "ERROR: error while patching cdrom-detect.postinst."
+ cd ..
+ rmdir -rf usb-install-syslinux
+ exit 0
+fi
+# rebuild the initrd
+find . -print0 | cpio -0 -H newc -ov | gzip -c > ../initrd-new.gz
+cd ..
+mv initrd-new.gz binary/install/initrd.gz
+rm -rf usb-install-syslinux
+
+# for the gtk installer
+mkdir usb-install-gtk
+cd usb-install-gtk
+zcat ../binary/install/gtk/initrd.gz | cpio -iv
+patch ./var/lib/dpkg/info/cdrom-detect.postinst < ../cdrom-detect.postinst.patch
+PATCH_ERROR=${?}
+if [ "${PATCH_ERROR}" != 0 ]
+then
+ # if there was an error, say it and undo everything
+ echo "ERROR: error while patching cdrom-detect.postinst."
+ cd ..
+ rmdir -rf usb-install-gtk
+ exit 0
+fi
+# rebuild the initrd
+find . -print0 | cpio -0 -H newc -ov | gzip -c > ../initrd-new.gz
+cd ..
+mv initrd-new.gz binary/install/gtk/initrd.gz
+rm -rf usb-install-gtk
+
+rm cdrom-detect.postinst.patch