]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/boot/powerpc/boot1.chrp/generate-hfs.sh
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / boot / powerpc / boot1.chrp / generate-hfs.sh
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
13 # $FreeBSD$
14
15 HFS_SIZE=1600                   #Size in 512-byte blocks of the produced image
16
17 CHRPBOOT_SIZE=2k
18 BOOT1_SIZE=30k
19
20 # Generate 800K HFS image
21 OUTPUT_FILE=hfs.tmpl
22
23 dd if=/dev/zero of=$OUTPUT_FILE bs=512 count=$HFS_SIZE
24 hformat -l "FreeBSD Bootstrap" $OUTPUT_FILE
25 hmount $OUTPUT_FILE
26
27 # Create and bless a directory for the boot loader
28 hmkdir ppc
29 hattrib -b ppc
30 hcd ppc
31
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
35
36 hcopy boot1.elf.tmp :boot1.elf
37 hcopy bootinfo.txt.tmp :bootinfo.txt
38 hattrib -c chrp -t tbxi bootinfo.txt
39 humount
40
41 rm bootinfo.txt.tmp
42 rm boot1.elf.tmp
43
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 ' ')
47
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);}')
51
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
56
57 bzip2 $OUTPUT_FILE
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
61
62 uuencode $OUTPUT_FILE.bz2 $OUTPUT_FILE.bz2 >> $OUTPUT_FILE.bz2.uu
63 rm $OUTPUT_FILE.bz2
64