generate-hfs.sh revision 183863
113981Sigerasim#!/bin/sh 213981Sigerasim 313981Sigerasim# This script generates the dummy HFS filesystem used for the PowerPC boot 413981Sigerasim# blocks. It uses hfsutils (emulators/hfsutils) to generate a template 513981Sigerasim# filesystem with the relevant interesting files. These are then found by 613981Sigerasim# grep, and the offsets written to a Makefile snippet. 713981Sigerasim# 813981Sigerasim# Because of licensing concerns, and because it is overkill, we do not 913981Sigerasim# distribute hfsutils as a build tool. If you need to regenerate the HFS 1013981Sigerasim# template (e.g. because the boot block or the CHRP script have grown), 1113981Sigerasim# you must install it from ports. 1213981Sigerasim 1313981Sigerasim# $FreeBSD: head/sys/boot/powerpc/boot1.chrp/generate-hfs.sh 183863 2008-10-14 03:32:41Z nwhitehorn $ 1413981Sigerasim 1513981SigerasimHFS_SIZE=1600 #Size in 512-byte blocks of the produced image 1613981Sigerasim 1713981SigerasimCHRPBOOT_SIZE=2k 1813981SigerasimBOOT1_SIZE=30k 1913981Sigerasim 2013981Sigerasim# Generate 800K HFS image 2113981SigerasimOUTPUT_FILE=hfs.tmpl 2213981Sigerasim 2313981Sigerasimdd if=/dev/zero of=$OUTPUT_FILE bs=512 count=$HFS_SIZE 2413981Sigerasimhformat -l "FreeBSD Bootstrap" $OUTPUT_FILE 2513981Sigerasimhmount $OUTPUT_FILE 2613981Sigerasim 2713981Sigerasim# Create and bless a directory for the boot loader 2813981Sigerasimhmkdir ppc 2913981Sigerasimhattrib -b ppc 3013981Sigerasimhcd ppc 3113981Sigerasim 3213981Sigerasim# Make two dummy files for the the CHRP boot script and boot1 3313981Sigerasimecho 'Bootinfo START' | dd of=bootinfo.txt.tmp cbs=$CHRPBOOT_SIZE count=1 conv=block 3413981Sigerasimecho 'Boot1 START' | dd of=boot1.elf.tmp cbs=$BOOT1_SIZE count=1 conv=block 3513981Sigerasim 3613981Sigerasimhcopy boot1.elf.tmp :boot1.elf 3713981Sigerasimhcopy bootinfo.txt.tmp :bootinfo.txt 3813981Sigerasimhattrib -c chrp -t tbxi bootinfo.txt 3913981Sigerasimhumount 4013981Sigerasim 4113981Sigerasimrm bootinfo.txt.tmp 4213981Sigerasimrm boot1.elf.tmp 4313981Sigerasim 4413981Sigerasim# Locate the offsets of the two fake files 4513981SigerasimBOOTINFO_OFFSET=$(hd $OUTPUT_FILE | grep 'Bootinfo START' | cut -f 1 -d ' ') 4613981SigerasimBOOT1_OFFSET=$(hd $OUTPUT_FILE | grep 'Boot1 START' | cut -f 1 -d ' ') 4713981Sigerasim 4813981Sigerasim# Convert to numbers of blocks 4913981SigerasimBOOTINFO_OFFSET=$(echo 0x$BOOTINFO_OFFSET | awk '{printf("%x\n",$1/512);}') 5013981SigerasimBOOT1_OFFSET=$(echo 0x$BOOT1_OFFSET | awk '{printf("%x\n",$1/512);}') 5113981Sigerasim 5213981Sigerasimecho '# This file autogenerated by generate-hfs.sh - DO NOT EDIT' > Makefile.hfs 5313981Sigerasimecho '# $FreeBSD: head/sys/boot/powerpc/boot1.chrp/generate-hfs.sh 183863 2008-10-14 03:32:41Z nwhitehorn $' >> Makefile.hfs 5413981Sigerasimecho "BOOTINFO_OFFSET=0x$BOOTINFO_OFFSET" >> Makefile.hfs 5513981Sigerasimecho "BOOT1_OFFSET=0x$BOOT1_OFFSET" >> Makefile.hfs 5613981Sigerasim 5713981Sigerasimbzip2 $OUTPUT_FILE 5813981Sigerasimecho 'HFS template boot filesystem created by generate-hfs.sh' > $OUTPUT_FILE.bz2.uu 5913981Sigerasimecho 'DO NOT EDIT' >> $OUTPUT_FILE.bz2.uu 6013981Sigerasimecho '$FreeBSD: head/sys/boot/powerpc/boot1.chrp/generate-hfs.sh 183863 2008-10-14 03:32:41Z nwhitehorn $' >> $OUTPUT_FILE.bz2.uu 6113981Sigerasim 6213981Sigerasimuuencode $OUTPUT_FILE.bz2 $OUTPUT_FILE.bz2 >> $OUTPUT_FILE.bz2.uu 6313981Sigerasimrm $OUTPUT_FILE.bz2 6413981Sigerasim 6513981Sigerasim