1251881Speter#!/bin/sh 2251881Speter 3251881Speter# This script generates the dummy HFS filesystem used for the PowerPC boot 4251881Speter# blocks. It uses hfsutils (emulators/hfsutils) to generate a template 5251881Speter# filesystem with the relevant interesting files. These are then found by 6251881Speter# grep, and the offsets written to a Makefile snippet. 7251881Speter# 8251881Speter# Because of licensing concerns, and because it is overkill, we do not 9251881Speter# distribute hfsutils as a build tool. If you need to regenerate the HFS 10251881Speter# template (e.g. because the boot block or the CHRP script have grown), 11251881Speter# you must install it from ports. 12251881Speter 13251881Speter# $FreeBSD: releng/11.0/sys/boot/powerpc/boot1.chrp/generate-hfs.sh 305904 2016-09-17 19:38:56Z jhibbits $ 14251881Speter 15251881SpeterHFS_SIZE=1600 #Size in 512-byte blocks of the produced image 16251881Speter 17251881SpeterCHRPBOOT_SIZE=2k 18251881SpeterBOOT1_SIZE=64k 19251881Speter 20251881Speter# Generate 800K HFS image 21251881SpeterOUTPUT_FILE=hfs.tmpl 22251881Speter 23251881Speterdd if=/dev/zero of=$OUTPUT_FILE bs=512 count=$HFS_SIZE 24251881Speterhformat -l "FreeBSD Bootstrap" $OUTPUT_FILE 25251881Speterhmount $OUTPUT_FILE 26251881Speter 27251881Speter# Create and bless a directory for the boot loader 28251881Speterhmkdir ppc 29251881Speterhattrib -b ppc 30251881Speterhcd ppc 31251881Speter 32251881Speter# Make two dummy files for the CHRP boot script and boot1 33251881Speterecho 'Bootinfo START' | dd of=bootinfo.txt.tmp cbs=$CHRPBOOT_SIZE count=1 conv=block 34251881Speterecho 'Boot1 START' | dd of=boot1.elf.tmp cbs=$BOOT1_SIZE count=1 conv=block 35251881Speter 36251881Speterhcopy boot1.elf.tmp :boot1.elf 37251881Speterhcopy bootinfo.txt.tmp :bootinfo.txt 38251881Speterhattrib -c chrp -t tbxi bootinfo.txt 39251881Speterhumount 40251881Speter 41251881Speterrm bootinfo.txt.tmp 42251881Speterrm boot1.elf.tmp 43251881Speter 44251881Speter# Locate the offsets of the two fake files 45251881SpeterBOOTINFO_OFFSET=$(hd $OUTPUT_FILE | grep 'Bootinfo START' | cut -f 1 -d ' ') 46251881SpeterBOOT1_OFFSET=$(hd $OUTPUT_FILE | grep 'Boot1 START' | cut -f 1 -d ' ') 47251881Speter 48251881Speter# Convert to numbers of blocks 49251881SpeterBOOTINFO_OFFSET=$(echo 0x$BOOTINFO_OFFSET | awk '{printf("%x\n",$1/512);}') 50251881SpeterBOOT1_OFFSET=$(echo 0x$BOOT1_OFFSET | awk '{printf("%x\n",$1/512);}') 51251881Speter 52251881Speterecho '# This file autogenerated by generate-hfs.sh - DO NOT EDIT' > Makefile.hfs 53251881Speterecho '# $FreeBSD: releng/11.0/sys/boot/powerpc/boot1.chrp/generate-hfs.sh 305904 2016-09-17 19:38:56Z jhibbits $' >> Makefile.hfs 54251881Speterecho "BOOTINFO_OFFSET=0x$BOOTINFO_OFFSET" >> Makefile.hfs 55251881Speterecho "BOOT1_OFFSET=0x$BOOT1_OFFSET" >> Makefile.hfs 56251881Speter 57251881Speterbzip2 $OUTPUT_FILE 58251881Speterecho 'HFS template boot filesystem created by generate-hfs.sh' > $OUTPUT_FILE.bz2.uu 59251881Speterecho 'DO NOT EDIT' >> $OUTPUT_FILE.bz2.uu 60251881Speterecho '$FreeBSD: releng/11.0/sys/boot/powerpc/boot1.chrp/generate-hfs.sh 305904 2016-09-17 19:38:56Z jhibbits $' >> $OUTPUT_FILE.bz2.uu 61251881Speter 62251881Speteruuencode $OUTPUT_FILE.bz2 $OUTPUT_FILE.bz2 >> $OUTPUT_FILE.bz2.uu 63251881Speterrm $OUTPUT_FILE.bz2 64251881Speter 65251881Speter