1#!/bin/sh
2
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.
7#
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.
12
13HFS_SIZE=400		#Size in 2048-byte blocks of the produced image
14LOADER_SIZE=500k
15
16# Generate 800K HFS image
17OUTPUT_FILE=hfs-boot
18
19dd if=/dev/zero of=$OUTPUT_FILE bs=2048 count=$HFS_SIZE
20hformat -l "FreeBSD Install" $OUTPUT_FILE
21hmount $OUTPUT_FILE
22
23# Create and bless a directory for the boot loader
24hmkdir ppc
25hattrib -b ppc
26hcd ppc
27
28# Make the CHRP boot script, which gets loader from the ISO9660 partition
29cat > bootinfo.txt << EOF
30<CHRP-BOOT>
31<DESCRIPTION>FreeBSD/powerpc bootloader</DESCRIPTION>
32<OS-NAME>FreeBSD</OS-NAME>
33<VERSION> $FreeBSD: head/stand/powerpc/boot1.chrp/bootinfo.txt 184490 2008-10
34-31 00:52:31Z nwhitehorn $ </VERSION>
35
36<COMPATIBLE>
37MacRISC MacRISC3 MacRISC4
38</COMPATIBLE>
39<BOOT-SCRIPT>
40" screen" output
41boot &device;:,\ppc\loader &device;:0
42</BOOT-SCRIPT>
43</CHRP-BOOT>
44EOF
45echo 'Loader START' | dd of=loader.tmp cbs=$LOADER_SIZE count=1 conv=block
46
47hcopy bootinfo.txt :bootinfo.txt
48hcopy loader.tmp :loader
49hattrib -c chrp -t tbxi bootinfo.txt
50humount
51
52rm bootinfo.txt
53rm loader.tmp
54
55bzip2 $OUTPUT_FILE
56echo 'HFS boot filesystem created by generate-hfs.sh' > $OUTPUT_FILE.bz2.uu
57echo 'DO NOT EDIT' >> $OUTPUT_FILE.bz2.uu
58
59uuencode $OUTPUT_FILE.bz2 $OUTPUT_FILE.bz2 >> $OUTPUT_FILE.bz2.uu
60rm $OUTPUT_FILE.bz2
61
62