This change is for yum-2.4 from fc4
[bootcd.git] / build.sh
index ef1ffbd..398c335 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -8,7 +8,7 @@ CONFIGURATIONS_DIR=configurations/
 # where built files are stored
 BUILD_DIR=build/
 
-BOOTCD_VERSION="3.0-beta0.5"
+BOOTCD_VERSION="3.1"
 FULL_VERSION_STRING="PlanetLab BootCD"
 OUTPUT_IMAGE_NAME='PlanetLab-BootCD'
     
@@ -68,6 +68,9 @@ function build_cdroot()
     echo "setup rpm to install only en_US locale and no docs"
     mkdir -p $CD_ROOT/etc/rpm
     cp -f $CONF_FILES_DIR/macros $CD_ROOT/etc/rpm
+    # trick rpm and yum
+    export HOME=$PWD
+    cp -f $CONF_FILES_DIR/macros $PWD/.rpmmacros
 
     echo "initialize rpm db"
     mkdir -p $CD_ROOT/var/lib/rpm
@@ -109,6 +112,12 @@ function build_cdroot()
     mv $CD_ROOT/var/lib/rpm $CD_ROOT/usr/relocated/var/lib/
     (cd $CD_ROOT/var/lib && ln -s ../../usr/relocated/var/lib/rpm rpm)
 
+    # get /var/cache/yum out, its 100Mb. create in its place a 
+    # symbolic link to /usr/relocated/var/cache/yum
+    mkdir -p $CD_ROOT/usr/relocated/var/cache/
+    mv $CD_ROOT/var/cache/yum $CD_ROOT/usr/relocated/var/cache/
+    (cd $CD_ROOT/var/cache && ln -s ../../usr/relocated/var/cache/yum yum)
+
     # get /lib/tls out
     mkdir -p $CD_ROOT/usr/relocated/lib
     mv $CD_ROOT/lib/tls $CD_ROOT/usr/relocated/lib/
@@ -125,6 +134,10 @@ function build_cdroot()
     KERNEL=$CD_ROOT/boot/vmlinuz-*
     mv -f $KERNEL $CD_ROOT/usr/isolinux/kernel
 
+    echo "moving /usr/bin/find and /usr/bin/dirname to /bin"
+    mv $CD_ROOT/usr/bin/find $CD_ROOT/bin/
+    mv $CD_ROOT/usr/bin/dirname $CD_ROOT/bin/
+
     echo "creating version files"
     echo "$FULL_VERSION_STRING" > $CD_ROOT/usr/isolinux/pl_version
     echo "$FULL_VERSION_STRING" > $CD_ROOT/pl_version
@@ -249,10 +262,31 @@ function build()
     # always build/rebuild initrd
     build_initrd
 
+    # build iso image
     rm -f $ISO
     mkisofs -o $ISO -R -allow-leading-dots -J -r -b isolinux/isolinux.bin \
        -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table \
        $CD_ROOT/usr
+
+    # build usb image and make it bootable with syslinux (instead of isolinux)
+    USB_IMAGE=${ISO%*.iso}.usb
+    # leave 1 MB of free space on the filesystem
+    USB_KB=$(du -kc $ISO $CD_ROOT/usr/isolinux | awk '$2 == "total" { print $1 + 1024 }')
+    mkfs.vfat -C $USB_IMAGE $USB_KB
+
+    mkdir -p $INITRD_MOUNT
+    mount -o loop,rw $USB_IMAGE $INITRD_MOUNT
+
+    # populate the root of the image with the iso, pl_version, and the syslinux files
+    cp -a $ISO $INITRD_MOUNT
+    cp -a $CD_ROOT/usr/isolinux/{initrd.gz,kernel,message.txt,pl_version} $INITRD_MOUNT
+    cp -a $CD_ROOT/usr/isolinux/isolinux.cfg $INITRD_MOUNT/syslinux.cfg
+
+    umount $INITRD_MOUNT
+    rmdir $INITRD_MOUNT
+
+    # make it bootable
+    syslinux $USB_IMAGE
 }
 
 function burn()