#!/bin/bash # # Author: Daniel Kahn Gillmor # Date: 2009-10-08 # License: GPL v3+ # # depends on grub2 # usage: # di-maker ISOFILE [FILE ...] # make a new debian installer ISO, packing any additionally-supplied files into the initramfs directly set -e # specify the first argument as the new installer image: output="$1" SUITE=${SUITE:-stable} ARCH=${ARCH:-amd64} DISTRO=${DISTRO:-debian} if [ -z "$output" ] ; then printf "Usage: di-maker ISOFILE [FILE ...]\n" >&2 exit 1 fi # remaining arguments should be files to re-pack into the initrd shift WORKDIR=$(mktemp -d) cleanup() { rm -rf "$WORKDIR" } trap cleanup EXIT case "$DISTRO" in debian) BASEPATH="http://ftp.nl.debian.org/debian/dists/$SUITE/main/installer-$ARCH/current/images/netboot/debian-installer/$ARCH" ;; ubuntu) BASEPATH="http://archive.ubuntu.com/ubuntu/dists/$SUITE/main/installer-$ARCH/current/images/netboot/ubuntu-installer/$ARCH" ;; esac KERNEL=linux INITRAMFS=initrd.gz BOOTINSTRUCTIONS=" linux /$KERNEL verbose console=ttyS0,115200n8 -- console=ttyS0,115200n8 initrd /$INITRAMFS " case "$ARCH" in kfreebsd-*) # FIXME: this discards the requested SUITE, and just pulls the # latest d-i, because dkg is lazy SUITE=sid KERNEL=kfreebsd.gz BASEPATH="http://d-i.debian.org/daily-images/$ARCH/daily/monolithic/" BOOTINSTRUCTIONS=' # this set came from mini.iso kfreebsd /kfreebsd.gz kfreebsd_module /initrd.gz type=mfs_root set kFreeBSD.vfs.root.mountfrom=ufs:/dev/md0 set kFreeBSD.hw.ata.ata_dma=0 # needed for qemu hard disk # TODO: delete set kFreeBSD.hw.ata.atapi_dma=0 # needed for qemu cd # TODO: 1 # this set came from http://jdc.parodius.com/freebsd/pxeboot_serial_install_7.html set kFreeBSD.comconsole_speed="115200" set kFreeBSD.console="comconsole" ' esac if ! [ -e "$output" ] ; then ( cd "$WORKDIR" && wget "$BASEPATH"/{$KERNEL,$INITRAMFS} ) else if ! which isoinfo > /dev/null; then printf "Could not find isoinfo.\nYou probably need to install the genisoimage\npackage if you want to work with an existing .iso like '%s'.\n" "$output" >&2 exit 1 fi isoinfo -R -i "$output" -x "/$KERNEL" > "$WORKDIR/$KERNEL" isoinfo -R -i "$output" -x "/$INITRAMFS" > "$WORKDIR/$INITRAMFS" fi if [ "$#" -gt 0 ]; then unpackdir=$(mktemp -d) fstate=$(mktemp) gzip -d < "$WORKDIR/$INITRAMFS" | (cd "$unpackdir" && fakeroot -i "$fstate" -s "$fstate" cpio --extract) cp "$@" "$unpackdir/" (cd "$unpackdir" && find . | fakeroot -i "$fstate" -s "$fstate" cpio --create -H newc | gzip ) > "$WORKDIR/$INITRAMFS" rm -rf "$unpackdir" fi mkdir -p "$WORKDIR/boot/grub" cat > "$WORKDIR/boot/grub/grub.cfg" <