From 6c3be6a60f6c7fee77c94f55b16f4d1f0f4a8df0 Mon Sep 17 00:00:00 2001
From: Andreas Loibl <andreas@andreas-loibl.de>
Date: Fri, 2 Mar 2012 23:09:10 +0100
Subject: updated README, moved isohybrid-bg2 out of chroot

---
 README                                             |   8 +-
 README.tmpfs                                       |  26 ----
 config/chroot_local-includes/usr/bin/isohybrid-bg2 | 164 ---------------------
 isohybrid-bg2                                      | 164 +++++++++++++++++++++
 4 files changed, 168 insertions(+), 194 deletions(-)
 delete mode 100644 README.tmpfs
 delete mode 100755 config/chroot_local-includes/usr/bin/isohybrid-bg2
 create mode 100755 isohybrid-bg2

diff --git a/README b/README
index 192fbca..57b5c2c 100644
--- a/README
+++ b/README
@@ -9,9 +9,9 @@ The purpose of this live-build tree is to build "KANOTIX" (http://kanotix.com) l
 Full Example:
 	lb config -a amd64 -p kanotix-master --bootloader grub2 --gfxoverlays true
 	lb build
-	isohybrid-bg2 kanotix32.iso
+	./isohybrid-bg2 kanotix64.iso
 	./mkefipart-hfsplus
-	./isohybrid-acritox kanotix32.iso 
+	./isohybrid-acritox kanotix64.iso 
 will create a 64bit multi-hybrid-ISO with GRUB2 and embedded gfxoverlays.
 
 Compat
@@ -116,9 +116,9 @@ use "lb config --tmpfs true" to enable.
 
 you may specify mount-options with --tmpfs-options, e.g.
 
-	lb config --tmpfs-options "size=6G"
+	lb config --tmpfs-options "size=9G"
 
-to set the maximum size of the ramdisk to 6GB.
+to set the maximum size of the ramdisk to 9GB.
 
 "lb build" will then mount a tmpfs into the "tmpfs" directory and the build process
 will take place there.
diff --git a/README.tmpfs b/README.tmpfs
deleted file mode 100644
index 0733ef4..0000000
--- a/README.tmpfs
+++ /dev/null
@@ -1,26 +0,0 @@
-Live-Build: Build using tmpfs
-==============================
-
-use "lb config --tmpfs true" to enable.
-
-you may specify mount-options with --tmpfs-options, e.g.
-
-	lb config --tmpfs-options "size=6G"
-
-to set the maximum size of the ramdisk to 6GB.
-
-"lb build" will then mount a tmpfs into the "tmpfs" directory and the build process
-will take place there.
-
-after the build the result and the cache will reside on the tmpfs, so if you
-want to keep them you should move or copy them to somewhere else.
-everything inside the "tmpfs" directory will be lost when umounting it, so if
-you want to save the cache for later builds you have to move (or copy) it:
-	
-	mv tmpfs/cache .
-
-live-helper will not umount the "tmpfs" unless you run "lb clean --tmpfs"
-or "lb clean --all", so if you are going to do multiple builds without
-umounting the "tmpfs" you do not need to backup the cache, it will stay there
-and will be used for the next build.
-
diff --git a/config/chroot_local-includes/usr/bin/isohybrid-bg2 b/config/chroot_local-includes/usr/bin/isohybrid-bg2
deleted file mode 100755
index 79eb28c..0000000
--- a/config/chroot_local-includes/usr/bin/isohybrid-bg2
+++ /dev/null
@@ -1,164 +0,0 @@
-#!/usr/bin/perl
-# Post-process an ISO 9660 image generated with mkisofs/genisoimage
-# to allow "hybrid booting" as a CD-ROM or as a hard disk.
-#
-# This is isohybrid-bg2 - written by Andreas Loibl <andreas@andreas-loibl.de>
-#
-# It works for ISO images with BURG or GRUB2. For ISO images with
-# syslinux/isolinux use isohybrid (written by H. Peter Anvin)
-#
-# isohybrid-bg2 is based on isohybrid:
-## -----------------------------------------------------------------------
-##
-##   Copyright 2002-2008 H. Peter Anvin - All Rights Reserved
-##
-##   This program is free software; you can redistribute it and/or modify
-##   it under the terms of the GNU General Public License as published by
-##   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
-##   Boston MA 02111-1307, USA; either version 2 of the License, or
-##   (at your option) any later version; incorporated herein by reference.
-##
-## -----------------------------------------------------------------------
-
-# 512byte boot.img
-$mbr='eb639000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800100000000000000fffaeb07f6c2807502b280ea747c000031c08ed88ed0bc0020fba0647c3cff740288c252be807de81c01be057cf6c2807448b441bbaa55cd135a52723d81fb55aa753783e101743231c0894404408844ff894402c7041000668b1e5c7c66895c08668b1e607c66895c0cc744060070b442cd137205bb0070eb76b408cd13730df6c2800f84d800be8b7de98200660fb6c68864ff40668944040fb6d1c1e20288e888f4408944080fb6c2c0e80266890466a1607c6609c0754e66a15c7c6631d266f73488d131d266f774043b44087d37fec188c530c0c1e80208c188d05a88c6bb00708ec331dbb80102cd13721e8cc3601eb900018edb31f6bf00808ec6fcf3a51f61ff265a7cbe867deb03be957de83400be9a7de82e00cd18ebfe47525542200047656f6d0048617264204469736b005265616400204572726f720d0a00bb0100b40ecd10ac3c0075f4c3000000000000000000000000000024120f0900bebd7d31c0cd13468a0c80f900750fbeda7de8d2ffeb9c466c6f70707900bb0070b80102b500b600cd1372d7b601b54fe9fbfe000000000000000055aa';
-
-($file) = @ARGV;
-open(FILE, "+< $file\0") or die "$0: cannot open $file: $!\n";
-binmode FILE;
-
-# search pattern to find location of boot.isohybrid on ISO image
-$pattern="ACRITOX!"x64;
-$p=0;
-while($p++ < 0xffff)
-{
-	seek(FILE, $p*512, SEEK_SET) or die "$0: $file: $!\n";
-	read(FILE, $sector, 512) == 512 or die "$0: $file: read error\n";
-	if($sector eq $pattern)
-	{
-		seek(FILE, 0, SEEK_SET) or die "$0: $file: $!\n";
-		print FILE pack('H*',$mbr);
-		$boot_offset = hex(substr($mbr,2,2));
-		seek(FILE, $boot_offset - 0x7, SEEK_SET) or die "$0: $file: $!\n";
-		print FILE pack("V", $p+1);
-		seek(FILE, $p*512 + 0x3f4, SEEK_SET) or die "$0: $file: $!\n";
-		print FILE pack("V", $p+2);
-		last;
-	}
-}
-if($p>0xffff) {
-	die "$0: error: $file does not contain boot.isohybrid in its first 32MB!\n";
-}
-
-# Use this fake geometry (zipdrive-style...)
-$h = 64; $s = 32;
-
-sub get_random() {
-    # Get a 32-bit random number
-    my $rfd, $rnd;
-    my $rid;
-
-    if (open($rfd, "< /dev/urandom\0") && read($rfd, $rnd, 4) == 4) {
-	$rid = unpack("V", $rnd);
-    }
-
-    close($rfd) if (defined($rfd));
-    return $rid if (defined($rid));
-
-    # This sucks but is better than nothing...
-    return ($$+time()) & 0xffffffff;
-}
-
-#
-# First, actually figure out where mkisofs hid isolinux.bin
-#
-seek(FILE, 17*2048, SEEK_SET) or die "$0: $file: $!\n";
-read(FILE, $boot_record, 2048) == 2048 or die "$0: $file: read error\n";
-($br_sign, $br_cat_offset) = unpack("a71V", $boot_record);
-if ($br_sign ne ("\0CD001\1EL TORITO SPECIFICATION" . ("\0" x 41))) {
-    die "$0: $file: no boot record found\n";
-}
-seek(FILE, $br_cat_offset*2048, SEEK_SET) or die "$0: $file: $!\n";
-read(FILE, $boot_cat, 2048) == 2048 or die "$0: $file: read error\n";
-
-# We must have a Validation Entry followed by a Default Entry...
-# no fanciness allowed for the Hybrid mode [XXX: might relax this later]
-@ve = unpack("v16", $boot_cat);
-$cs = 0;
-for ($i = 0; $i < 16; $i++) {
-    $cs += $ve[$i];
-}
-if ($ve[0] != 0x0001 || $ve[15] != 0xaa55 || $cs & 0xffff) {
-    die "$0: $file: invalid boot catalog\n";
-}
-($de_boot, $de_media, $de_seg, $de_sys, $de_mbz1, $de_count,
- $de_lba, $de_mbz2) = unpack("CCvCCvVv", substr($boot_cat, 32, 32));
-if ($de_boot != 0x88 || $de_media != 0 ||
-    ($de_segment != 0 && $de_segment != 0x7c0) || $de_count != 4) {
-    die "$0: $file: unexpected boot catalog parameters\n";
-}
-# Get the total size of the image
-(@imgstat = stat(FILE)) or die "$0: $file: $!\n";
-$imgsize = $imgstat[7];
-if (!$imgsize) {
-    die "$0: $file: cannot determine length of file\n";
-}
-# Target image size: round up to a multiple of $h*$s*512
-$cylsize = $h*$s*512;
-$frac = $imgsize % $cylsize;
-$padding = ($frac > 0) ? $cylsize - $frac : 0;
-$imgsize += $padding;
-$c = $imgsize/$cylsize;
-if ($c > 1024) {
-    print STDERR "Warning: more than 1024 cylinders ($c).\n";
-    print STDERR "Not all BIOSes will be able to boot this device.\n";
-    $cc = 1024;
-} else {
-    $cc = $c;
-}
-
-
-$mbr = pack("VV", $de_lba*4, 0);
-if (defined($id)) {
-    $id = to_int($id);
-} else {
-    $id = get_random();
-}
-$mbr .= pack("V", $id);		# Offset 440: MBR ID
-$mbr .= "\0\0";			# Offset 446: actual partition table
-
-# Print partition table
-$psize   = $c*$h*$s;
-$bhead   = 0;
-$bsect   = 1;
-$bcyl    = 0;
-$ehead   = $h-1;
-$esect   = $s + ((($cc-1) & 0x300) >> 2);
-$ecyl    = ($cc-1) & 0xff;
-$fstype  = 0x83;		# Linux (any better ideas?)
-$pentry  = 1;			# First partition slot
-
-for ( $i = 1 ; $i <= 4 ; $i++ ) {
-    if ( $i == $pentry ) {
-	$mbr .= pack("CCCCCCCCVV", 0x80, $bhead, $bsect, $bcyl, $fstype,
-		     $ehead, $esect, $ecyl, 0, $psize);
-    } else {
-	$mbr .= "\0" x 16;
-    }
-}
-$mbr .= "\x55\xaa";
-
-# Print the partition table
-seek(FILE, 432, SEEK_SET) or die "$0: $file: $!\n";
-print FILE $mbr;
-
-# Pad the image to a fake cylinder boundary
-seek(FILE, $imgstat[7], SEEK_SET) or die "$0: $file: $!\n";
-if ($padding) {
-    print FILE "\0" x $padding;
-}
-
-# Done...
-close(FILE);
-
-exit 0;
diff --git a/isohybrid-bg2 b/isohybrid-bg2
new file mode 100755
index 0000000..79eb28c
--- /dev/null
+++ b/isohybrid-bg2
@@ -0,0 +1,164 @@
+#!/usr/bin/perl
+# Post-process an ISO 9660 image generated with mkisofs/genisoimage
+# to allow "hybrid booting" as a CD-ROM or as a hard disk.
+#
+# This is isohybrid-bg2 - written by Andreas Loibl <andreas@andreas-loibl.de>
+#
+# It works for ISO images with BURG or GRUB2. For ISO images with
+# syslinux/isolinux use isohybrid (written by H. Peter Anvin)
+#
+# isohybrid-bg2 is based on isohybrid:
+## -----------------------------------------------------------------------
+##
+##   Copyright 2002-2008 H. Peter Anvin - All Rights Reserved
+##
+##   This program is free software; you can redistribute it and/or modify
+##   it under the terms of the GNU General Public License as published by
+##   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
+##   Boston MA 02111-1307, USA; either version 2 of the License, or
+##   (at your option) any later version; incorporated herein by reference.
+##
+## -----------------------------------------------------------------------
+
+# 512byte boot.img
+$mbr='eb639000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800100000000000000fffaeb07f6c2807502b280ea747c000031c08ed88ed0bc0020fba0647c3cff740288c252be807de81c01be057cf6c2807448b441bbaa55cd135a52723d81fb55aa753783e101743231c0894404408844ff894402c7041000668b1e5c7c66895c08668b1e607c66895c0cc744060070b442cd137205bb0070eb76b408cd13730df6c2800f84d800be8b7de98200660fb6c68864ff40668944040fb6d1c1e20288e888f4408944080fb6c2c0e80266890466a1607c6609c0754e66a15c7c6631d266f73488d131d266f774043b44087d37fec188c530c0c1e80208c188d05a88c6bb00708ec331dbb80102cd13721e8cc3601eb900018edb31f6bf00808ec6fcf3a51f61ff265a7cbe867deb03be957de83400be9a7de82e00cd18ebfe47525542200047656f6d0048617264204469736b005265616400204572726f720d0a00bb0100b40ecd10ac3c0075f4c3000000000000000000000000000024120f0900bebd7d31c0cd13468a0c80f900750fbeda7de8d2ffeb9c466c6f70707900bb0070b80102b500b600cd1372d7b601b54fe9fbfe000000000000000055aa';
+
+($file) = @ARGV;
+open(FILE, "+< $file\0") or die "$0: cannot open $file: $!\n";
+binmode FILE;
+
+# search pattern to find location of boot.isohybrid on ISO image
+$pattern="ACRITOX!"x64;
+$p=0;
+while($p++ < 0xffff)
+{
+	seek(FILE, $p*512, SEEK_SET) or die "$0: $file: $!\n";
+	read(FILE, $sector, 512) == 512 or die "$0: $file: read error\n";
+	if($sector eq $pattern)
+	{
+		seek(FILE, 0, SEEK_SET) or die "$0: $file: $!\n";
+		print FILE pack('H*',$mbr);
+		$boot_offset = hex(substr($mbr,2,2));
+		seek(FILE, $boot_offset - 0x7, SEEK_SET) or die "$0: $file: $!\n";
+		print FILE pack("V", $p+1);
+		seek(FILE, $p*512 + 0x3f4, SEEK_SET) or die "$0: $file: $!\n";
+		print FILE pack("V", $p+2);
+		last;
+	}
+}
+if($p>0xffff) {
+	die "$0: error: $file does not contain boot.isohybrid in its first 32MB!\n";
+}
+
+# Use this fake geometry (zipdrive-style...)
+$h = 64; $s = 32;
+
+sub get_random() {
+    # Get a 32-bit random number
+    my $rfd, $rnd;
+    my $rid;
+
+    if (open($rfd, "< /dev/urandom\0") && read($rfd, $rnd, 4) == 4) {
+	$rid = unpack("V", $rnd);
+    }
+
+    close($rfd) if (defined($rfd));
+    return $rid if (defined($rid));
+
+    # This sucks but is better than nothing...
+    return ($$+time()) & 0xffffffff;
+}
+
+#
+# First, actually figure out where mkisofs hid isolinux.bin
+#
+seek(FILE, 17*2048, SEEK_SET) or die "$0: $file: $!\n";
+read(FILE, $boot_record, 2048) == 2048 or die "$0: $file: read error\n";
+($br_sign, $br_cat_offset) = unpack("a71V", $boot_record);
+if ($br_sign ne ("\0CD001\1EL TORITO SPECIFICATION" . ("\0" x 41))) {
+    die "$0: $file: no boot record found\n";
+}
+seek(FILE, $br_cat_offset*2048, SEEK_SET) or die "$0: $file: $!\n";
+read(FILE, $boot_cat, 2048) == 2048 or die "$0: $file: read error\n";
+
+# We must have a Validation Entry followed by a Default Entry...
+# no fanciness allowed for the Hybrid mode [XXX: might relax this later]
+@ve = unpack("v16", $boot_cat);
+$cs = 0;
+for ($i = 0; $i < 16; $i++) {
+    $cs += $ve[$i];
+}
+if ($ve[0] != 0x0001 || $ve[15] != 0xaa55 || $cs & 0xffff) {
+    die "$0: $file: invalid boot catalog\n";
+}
+($de_boot, $de_media, $de_seg, $de_sys, $de_mbz1, $de_count,
+ $de_lba, $de_mbz2) = unpack("CCvCCvVv", substr($boot_cat, 32, 32));
+if ($de_boot != 0x88 || $de_media != 0 ||
+    ($de_segment != 0 && $de_segment != 0x7c0) || $de_count != 4) {
+    die "$0: $file: unexpected boot catalog parameters\n";
+}
+# Get the total size of the image
+(@imgstat = stat(FILE)) or die "$0: $file: $!\n";
+$imgsize = $imgstat[7];
+if (!$imgsize) {
+    die "$0: $file: cannot determine length of file\n";
+}
+# Target image size: round up to a multiple of $h*$s*512
+$cylsize = $h*$s*512;
+$frac = $imgsize % $cylsize;
+$padding = ($frac > 0) ? $cylsize - $frac : 0;
+$imgsize += $padding;
+$c = $imgsize/$cylsize;
+if ($c > 1024) {
+    print STDERR "Warning: more than 1024 cylinders ($c).\n";
+    print STDERR "Not all BIOSes will be able to boot this device.\n";
+    $cc = 1024;
+} else {
+    $cc = $c;
+}
+
+
+$mbr = pack("VV", $de_lba*4, 0);
+if (defined($id)) {
+    $id = to_int($id);
+} else {
+    $id = get_random();
+}
+$mbr .= pack("V", $id);		# Offset 440: MBR ID
+$mbr .= "\0\0";			# Offset 446: actual partition table
+
+# Print partition table
+$psize   = $c*$h*$s;
+$bhead   = 0;
+$bsect   = 1;
+$bcyl    = 0;
+$ehead   = $h-1;
+$esect   = $s + ((($cc-1) & 0x300) >> 2);
+$ecyl    = ($cc-1) & 0xff;
+$fstype  = 0x83;		# Linux (any better ideas?)
+$pentry  = 1;			# First partition slot
+
+for ( $i = 1 ; $i <= 4 ; $i++ ) {
+    if ( $i == $pentry ) {
+	$mbr .= pack("CCCCCCCCVV", 0x80, $bhead, $bsect, $bcyl, $fstype,
+		     $ehead, $esect, $ecyl, 0, $psize);
+    } else {
+	$mbr .= "\0" x 16;
+    }
+}
+$mbr .= "\x55\xaa";
+
+# Print the partition table
+seek(FILE, 432, SEEK_SET) or die "$0: $file: $!\n";
+print FILE $mbr;
+
+# Pad the image to a fake cylinder boundary
+seek(FILE, $imgstat[7], SEEK_SET) or die "$0: $file: $!\n";
+if ($padding) {
+    print FILE "\0" x $padding;
+}
+
+# Done...
+close(FILE);
+
+exit 0;
-- 
cgit v1.0