generate-hfs.sh revision 183863
1183863Snwhitehorn#!/bin/sh 2183863Snwhitehorn 3183863Snwhitehorn# This script generates the dummy HFS filesystem used for the PowerPC boot 4183863Snwhitehorn# blocks. It uses hfsutils (emulators/hfsutils) to generate a template 5183863Snwhitehorn# filesystem with the relevant interesting files. These are then found by 6183863Snwhitehorn# grep, and the offsets written to a Makefile snippet. 7183863Snwhitehorn# 8183863Snwhitehorn# Because of licensing concerns, and because it is overkill, we do not 9183863Snwhitehorn# distribute hfsutils as a build tool. If you need to regenerate the HFS 10183863Snwhitehorn# template (e.g. because the boot block or the CHRP script have grown), 11183863Snwhitehorn# you must install it from ports. 12183863Snwhitehorn 13183863Snwhitehorn# $FreeBSD: head/sys/boot/powerpc/boot1.chrp/generate-hfs.sh 183863 2008-10-14 03:32:41Z nwhitehorn $ 14183863Snwhitehorn 15183863SnwhitehornHFS_SIZE=1600 #Size in 512-byte blocks of the produced image 16183863Snwhitehorn 17183863SnwhitehornCHRPBOOT_SIZE=2k 18183863SnwhitehornBOOT1_SIZE=30k 19183863Snwhitehorn 20183863Snwhitehorn# Generate 800K HFS image 21183863SnwhitehornOUTPUT_FILE=hfs.tmpl 22183863Snwhitehorn 23183863Snwhitehorndd if=/dev/zero of=$OUTPUT_FILE bs=512 count=$HFS_SIZE 24183863Snwhitehornhformat -l "FreeBSD Bootstrap" $OUTPUT_FILE 25183863Snwhitehornhmount $OUTPUT_FILE 26183863Snwhitehorn 27183863Snwhitehorn# Create and bless a directory for the boot loader 28183863Snwhitehornhmkdir ppc 29183863Snwhitehornhattrib -b ppc 30183863Snwhitehornhcd ppc 31183863Snwhitehorn 32183863Snwhitehorn# Make two dummy files for the the CHRP boot script and boot1 33183863Snwhitehornecho 'Bootinfo START' | dd of=bootinfo.txt.tmp cbs=$CHRPBOOT_SIZE count=1 conv=block 34183863Snwhitehornecho 'Boot1 START' | dd of=boot1.elf.tmp cbs=$BOOT1_SIZE count=1 conv=block 35183863Snwhitehorn 36183863Snwhitehornhcopy boot1.elf.tmp :boot1.elf 37183863Snwhitehornhcopy bootinfo.txt.tmp :bootinfo.txt 38183863Snwhitehornhattrib -c chrp -t tbxi bootinfo.txt 39183863Snwhitehornhumount 40183863Snwhitehorn 41183863Snwhitehornrm bootinfo.txt.tmp 42183863Snwhitehornrm boot1.elf.tmp 43183863Snwhitehorn 44183863Snwhitehorn# Locate the offsets of the two fake files 45183863SnwhitehornBOOTINFO_OFFSET=$(hd $OUTPUT_FILE | grep 'Bootinfo START' | cut -f 1 -d ' ') 46183863SnwhitehornBOOT1_OFFSET=$(hd $OUTPUT_FILE | grep 'Boot1 START' | cut -f 1 -d ' ') 47183863Snwhitehorn 48183863Snwhitehorn# Convert to numbers of blocks 49183863SnwhitehornBOOTINFO_OFFSET=$(echo 0x$BOOTINFO_OFFSET | awk '{printf("%x\n",$1/512);}') 50183863SnwhitehornBOOT1_OFFSET=$(echo 0x$BOOT1_OFFSET | awk '{printf("%x\n",$1/512);}') 51183863Snwhitehorn 52183863Snwhitehornecho '# This file autogenerated by generate-hfs.sh - DO NOT EDIT' > Makefile.hfs 53183863Snwhitehornecho '# $FreeBSD: head/sys/boot/powerpc/boot1.chrp/generate-hfs.sh 183863 2008-10-14 03:32:41Z nwhitehorn $' >> Makefile.hfs 54183863Snwhitehornecho "BOOTINFO_OFFSET=0x$BOOTINFO_OFFSET" >> Makefile.hfs 55183863Snwhitehornecho "BOOT1_OFFSET=0x$BOOT1_OFFSET" >> Makefile.hfs 56183863Snwhitehorn 57183863Snwhitehornbzip2 $OUTPUT_FILE 58183863Snwhitehornecho 'HFS template boot filesystem created by generate-hfs.sh' > $OUTPUT_FILE.bz2.uu 59183863Snwhitehornecho 'DO NOT EDIT' >> $OUTPUT_FILE.bz2.uu 60183863Snwhitehornecho '$FreeBSD: head/sys/boot/powerpc/boot1.chrp/generate-hfs.sh 183863 2008-10-14 03:32:41Z nwhitehorn $' >> $OUTPUT_FILE.bz2.uu 61183863Snwhitehorn 62183863Snwhitehornuuencode $OUTPUT_FILE.bz2 $OUTPUT_FILE.bz2 >> $OUTPUT_FILE.bz2.uu 63183863Snwhitehornrm $OUTPUT_FILE.bz2 64183863Snwhitehorn 65