#!/bin/sh test $# -eq 2 -o $# -eq 3 \ || { echo "usage: $0 imagefile releasedir [kernel]" >&2; exit 1; } image=$1 test -n "$image" -a -f "$image" \ || { echo "'$image' is not a file" >&2; exit 1; } release=$2 test -n "$release" -a -d "$release" -a -d "$release/amiga/binary" \ || { echo "'$release' is not a release directory" >&2; exit 1; } kernel=${3:-$release/amiga/binary/kernel/netbsd-GENERIC.gz} test -n "$kernel" -a -f "$kernel" \ || { echo "'$kernel' is not a file" >&2; exit 1; } tmpdir=$(mktemp -d /tmp/makeimage-$LOGNAME) || exit 1 trap "rmdir $tmpdir; echo ABORT rc=$? >&2" EXIT set -ex ################################################### vendor="NetBSD" product="Hardfile" label="so heiss ich" setdir=$release/amiga/binary/sets hostname=dummy timezone="Europe/Berlin" rootdev=wd0 netdev=le0 hostip=10.28.5.99 netmask=255.255.255.0 ################################################### rdbedit=$HOME/rdbedit/rdbedit dev=$(vnconfig -l | awk -F: ' NR==1 { n=-1 } NF==2 && $2 == " not in use" { print $1; n=-2; exit } NF==2 && $1 ~ /^vnd[0-9][0-9]*$/ { x=substr($1,4); n=(x>n)?x:n} END { if (n>=-1) print "vnd" (n+1) } ') echo "Using device $dev" mkdir -m 700 $tmpdir/mnt || exit 1 mnt=$tmpdir/mnt $rdbedit -F -i -e -s 2 "$image" << EOF r v$vendor p$product q c0 4000 p3 fbootable nroot tNBR\007 o16 p10 x q c0 4000 p4 nswap tNBS\001 o16 p0 x q c0 0 p5 nother x q . q Y EOF $rdbedit -F -t "$image" \ | disklabel -w -F -f /dev/fd/0 "$image" hardfile "$product" sudo umount $mnt/data || true sudo umount $mnt || true sudo vnconfig -u $dev || true sudo vnconfig $dev "$image" sudo newfs -B be -O1 NAME="$product"/a sudo newfs -B be -O2 NAME="$product"/e sudo mount -o async NAME="$product"/a $mnt sudo mkdir $mnt/data || true sudo mount -o async NAME="$product"/e $mnt/data for s in base comp etc man misc modules tests text; do if [ -f "$setdir/$s.tgz" ]; then sudo tar -C $mnt -xzpf $setdir/$s.tgz fi done sudo mkdir $mnt/proc || true qproduct=$(echo "$product" | sed -e 's#[[:space:]\\]#\\&#g') case $usewedges in host) # discover label of x86 host system parta=NAME=$qproduct/a partb=NAME=$qproduct/b partd=NAME=$qproduct/e ;; native) # discover native label parta=NAME=$qproduct/a partb=NAME=$qproduct/b partd=NAME=$qproduct/d ;; "") # no wedges parta=/dev/${rootdev}a partb=/dev/${rootdev}b partd=/dev/${rootdev}d ;; esac sudo ed <