Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/release/powerpc/mkisoimages.sh
34677 views
1
#!/bin/sh
2
#
3
# Module: mkisoimages.sh
4
# Author: Jordan K Hubbard
5
# Date: 22 June 2001
6
#
7
#
8
# This script is used by release/Makefile to build the (optional) ISO images
9
# for a FreeBSD release. It is considered architecture dependent since each
10
# platform has a slightly unique way of making bootable CDs. This script
11
# is also allowed to generate any number of images since that is more of
12
# publishing decision than anything else.
13
#
14
# Usage:
15
#
16
# mkisoimages.sh [-b] image-label image-name base-bits-dir [extra-bits-dir]
17
#
18
# Where -b is passed if the ISO image should be made "bootable" by
19
# whatever standards this architecture supports (may be unsupported),
20
# image-label is the ISO image label, image-name is the filename of the
21
# resulting ISO image, base-bits-dir contains the image contents and
22
# extra-bits-dir, if provided, contains additional files to be merged
23
# into base-bits-dir as part of making the image.
24
25
set -e
26
27
scriptdir=$(dirname $(realpath $0))
28
. ${scriptdir}/../scripts/tools.subr
29
30
if [ "$1" = "-b" ]; then
31
MAKEFSARG="$4"
32
else
33
MAKEFSARG="$3"
34
fi
35
36
if [ -f ${MAKEFSARG} ]; then
37
BASEBITSDIR=`dirname ${MAKEFSARG}`
38
METALOG=${MAKEFSARG}
39
elif [ -d ${MAKEFSARG} ]; then
40
BASEBITSDIR=${MAKEFSARG}
41
METALOG=
42
else
43
echo "${MAKEFSARG} must exist"
44
exit 1
45
fi
46
47
if [ "$1" = "-b" ]; then
48
bootable=1
49
shift
50
else
51
bootable=""
52
fi
53
54
if [ $# -lt 3 ]; then
55
echo "Usage: $0 [-b] image-label image-name base-bits-dir [extra-bits-dir]"
56
exit 1
57
fi
58
59
LABEL=`echo "$1" | tr '[:lower:]' '[:upper:]'`; shift
60
NAME="$1"; shift
61
# MAKEFSARG extracted already
62
shift
63
64
if [ -n "${METALOG}" ]; then
65
metalogfilename=$(mktemp /tmp/metalog.XXXXXX)
66
cat ${METALOG} > ${metalogfilename}
67
MAKEFSARG=${metalogfilename}
68
fi
69
70
if [ -n "$bootable" ]; then
71
echo "Building bootable disc"
72
73
BOOTBLOCK=$(mktemp /tmp/hfs-boot-block.XXXXXX)
74
75
# Apple boot code
76
uudecode -p "`dirname "$0"`/hfs-boot.bz2.uu" | bunzip2 > $BOOTBLOCK
77
OFFSET=$(hd $BOOTBLOCK | grep 'Loader START' | cut -f 1 -d ' ')
78
OFFSET=0x$(echo 0x$OFFSET | awk '{printf("%x\n",$1/512);}')
79
dd if="$BASEBITSDIR/boot/loader" of=$BOOTBLOCK seek=$OFFSET conv=notrunc
80
81
bootable="-o bootimage=macppc;$BOOTBLOCK -o no-emul-boot"
82
83
# pSeries/PAPR boot code
84
mkdir -p "$BASEBITSDIR/ppc/chrp"
85
cp "$BASEBITSDIR/boot/loader" "$BASEBITSDIR/ppc/chrp"
86
cat > "$BASEBITSDIR/ppc/bootinfo.txt" << EOF
87
<chrp-boot>
88
<description>FreeBSD Install</description>
89
<os-name>FreeBSD</os-name>
90
<boot-script>boot &device;:,\ppc\chrp\loader</boot-script>
91
</chrp-boot>
92
EOF
93
bootable="$bootable -o chrp-boot"
94
if [ -n "${METALOG}" ]; then
95
echo "./ppc type=dir uname=root gname=wheel mode=0755" >> ${metalogfilename}
96
echo "./ppc/chrp type=dir uname=root gname=wheel mode=0755" >> ${metalogfilename}
97
echo "./ppc/chrp/loader type=file uname=root gname=wheel mode=0644" >> ${metalogfilename}
98
echo "./ppc/bootinfo.txt type=file uname=root gname=wheel mode=0644" >> ${metalogfilename}
99
fi
100
101
# Petitboot config for PS3/PowerNV
102
echo FreeBSD Install=\'/boot/kernel/kernel vfs.root.mountfrom=cd9660:/dev/iso9660/$LABEL\' > "$BASEBITSDIR/etc/kboot.conf"
103
if [ -n "${METALOG}" ]; then
104
echo "./etc/kboot.conf type=file uname=root gname=wheel mode=0644" >> ${metalogfilename}
105
fi
106
fi
107
108
publisher="The FreeBSD Project. https://www.FreeBSD.org/"
109
echo "/dev/iso9660/$LABEL / cd9660 ro 0 0" > "$BASEBITSDIR/etc/fstab"
110
if [ -n "${METALOG}" ]; then
111
echo "./etc/fstab type=file uname=root gname=wheel mode=0644" >> ${metalogfilename}
112
fi
113
${MAKEFS} -D -N ${BASEBITSDIR}/etc -t cd9660 $bootable -o rockridge -o label="$LABEL" -o publisher="$publisher" "$NAME" "$MAKEFSARG" "$@"
114
rm -f "$BASEBITSDIR/etc/fstab"
115
if [ n "$bootable" ]; then
116
rm $BOOTBLOCK
117
fi
118
rm -rf "$BASEBITSDIR/ppc"
119
if [ -n "${METALOG}" ]; then
120
rm ${metalogfilename}
121
fi
122
123