Changeset 969


Ignore:
Timestamp:
Jan 30, 2008, 6:31:31 PM (11 years ago)
Author:
Daniel Kahn Gillmor
Message:

debirf: add makeiso subcommand (closes #63)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debirf/fs/usr/bin/debirf

    r941 r969  
    5858  enter PROFILE [CMDS]      enter shell in debirf profile root changes
    5959                            (optional execute CMDS in root and exit)
     60  makeiso PROFILE           create a bootable ISO using the given profile
     61                            (requires GRUB)
    6062  help                      this help
    6163
     
    455457}
    456458
     459# create an ISO from the given kernel and initramfs (requires GRUB,
     460# see:
     461# http://www.gnu.org/software/grub/manual/html_node/Making-a-GRUB-bootable-CD-ROM.html)
     462makeiso() {
     463    DEBIRF_PROFILE="$1"
     464    shift
     465    [ -d "$DEBIRF_PROFILE" ] || failure "'$DEBIRF_PROFILE' does not seem to be a directory"
     466
     467    local KERNEL=${KERNEL:-$(echo "vmlinu"*)}
     468    local INITRAMFS=${INITRAMFS:-$(echo "debirf-"*.cgz)}
     469
     470    # FIXME: it would be best to pull the name of the architecture
     471    # exactly instead of using shell globbing to guess at it:
     472    local GRUB_ELTORITO=${GRUB_ELTORITO:-"/usr/lib/grub/"*"-pc/stage2_eltorito"}
     473
     474    ls -l "$KERNEL" > /dev/null || failure "Failed to find a single kernel in '$DEBIRF_PROFILE'"
     475    ls -l "$INITRAMFS" > /dev/null || failure "Failed to find a single initramfs in '$DEBIRF_PROFILE'"
     476    [ -r "$GRUB_ELTORITO" ] || failure "Failed to find a grub El Torito stage2 loader."
     477
     478    mkdir -p iso/boot/grub
     479    ln -s "../$KERNEL" iso/
     480    ln -s "../$INITRAMFS" iso/
     481    ln -s "$GRUB_ELTORITO" iso/boot/grub/
     482    cat >iso/boot/grub/menu.lst <<EOF
     483serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
     484terminal --timeout=10 serial console
     485
     486title        Debirf ($DEBIRF_PROFILE) (created $(date -R))
     487kernel       /$KERNEL
     488initrd       /$INITRAMFS
     489EOF
     490
     491    mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o "debirf-$DEBIRF_PROFILE.iso" -f iso
     492    # do we need to clean up the iso/ directory so that this can be run again?   
     493}
     494
     495
    457496###############################################################
    458497### MAIN
     
    465504    'make'|'m')
    466505        make "$@"
     506        ;;
     507    'makeiso'|'i')
     508        makeiso "$@"
    467509        ;;
    468510    'enter'|'e')
Note: See TracChangeset for help on using the changeset viewer.