3 # This script generates the dummy HFS filesystem used for the PowerPC boot
4 # blocks. It uses hfsutils (emulators/hfsutils) to generate a template
5 # filesystem with the relevant interesting files. These are then found by
6 # grep, and the offsets written to a Makefile snippet.
8 # Because of licensing concerns, and because it is overkill, we do not
9 # distribute hfsutils as a build tool. If you need to regenerate the HFS
10 # template (e.g. because the boot block or the CHRP script have grown),
11 # you must install it from ports.
15 HFS_SIZE=1600 #Size in 512-byte blocks of the produced image
20 # Generate 800K HFS image
23 dd if=/dev/zero of=$OUTPUT_FILE bs=512 count=$HFS_SIZE
24 hformat -l "FreeBSD Bootstrap" $OUTPUT_FILE
27 # Create and bless a directory for the boot loader
32 # Make two dummy files for the CHRP boot script and boot1
33 echo 'Bootinfo START' | dd of=bootinfo.txt.tmp cbs=$CHRPBOOT_SIZE count=1 conv=block
34 echo 'Boot1 START' | dd of=boot1.elf.tmp cbs=$BOOT1_SIZE count=1 conv=block
36 hcopy boot1.elf.tmp :boot1.elf
37 hcopy bootinfo.txt.tmp :bootinfo.txt
38 hattrib -c chrp -t tbxi bootinfo.txt
44 # Locate the offsets of the two fake files
45 BOOTINFO_OFFSET=$(hd $OUTPUT_FILE | grep 'Bootinfo START' | cut -f 1 -d ' ')
46 BOOT1_OFFSET=$(hd $OUTPUT_FILE | grep 'Boot1 START' | cut -f 1 -d ' ')
48 # Convert to numbers of blocks
49 BOOTINFO_OFFSET=$(echo 0x$BOOTINFO_OFFSET | awk '{printf("%x\n",$1/512);}')
50 BOOT1_OFFSET=$(echo 0x$BOOT1_OFFSET | awk '{printf("%x\n",$1/512);}')
52 echo '# This file autogenerated by generate-hfs.sh - DO NOT EDIT' > Makefile.hfs
53 echo '# $FreeBSD$' >> Makefile.hfs
54 echo "BOOTINFO_OFFSET=0x$BOOTINFO_OFFSET" >> Makefile.hfs
55 echo "BOOT1_OFFSET=0x$BOOT1_OFFSET" >> Makefile.hfs
58 echo 'HFS template boot filesystem created by generate-hfs.sh' > $OUTPUT_FILE.bz2.uu
59 echo 'DO NOT EDIT' >> $OUTPUT_FILE.bz2.uu
60 echo '$FreeBSD$' >> $OUTPUT_FILE.bz2.uu
62 uuencode $OUTPUT_FILE.bz2 $OUTPUT_FILE.bz2 >> $OUTPUT_FILE.bz2.uu