-# $OpenBSD: Makefile,v 1.9 2022/08/31 20:23:57 kn Exp $
+# $OpenBSD: Makefile,v 1.10 2022/08/31 20:48:55 kn Exp $
INSTALLBOOT ?= /usr/sbin/installboot
DRY_RUN = ${INSTALLBOOT} -n
# installboot(8) behaviour for multi-chunk softraid(4) differs across platforms
NCHUNKS ?= 1 2
-CHUNKFILES = ${NCHUNKS:=chunk%.img}
-DEVFILES = ${NCHUNKS:=vnd%.txt}
-SRFILE = sr.txt
+DISKFILES = ${NCHUNKS:=disk%.img}
+DISKDEVFILES = ${NCHUNKS:=diskdev%.txt}
+ROOTDEVFILE = rootdev.txt
MOUNTPOINT = mnt
STAGEDIR = /usr/mdec
create-new-chunks:
.for n in ${NCHUNKS}
- dd if=/dev/zero of=chunk${n}.img bs=1m count=0 seek=64 status=none
- ${SUDO} vnconfig -- chunk${n}.img 1>vnd${n}.txt
+ dd if=/dev/zero of=disk${n}.img bs=1m count=0 seek=64 status=none
+ ${SUDO} vnconfig -- disk${n}.img 1>diskdev${n}.txt
.endfor
# what the installer does, see /usr/src/distrib/$(machine)/ramdisk/install.md
format-new-chunks: create-new-chunks
-.for devfile in ${DEVFILES}
+.for devfile in ${DISKDEVFILES}
${SUDO} ${FORMAT_DISK} -- "$$(<${devfile})" 1>/dev/null
printf 'a\n\n\n\nRAID\nw\nq\n' | \
${SUDO} disklabel -E -- "$$(<${devfile})" 1>/dev/null
.endfor
create-new-softraid: format-new-chunks
- ${SUDO} bioctl -l"$$(sed -- s/$$/a/ ${DEVFILES} | paste -sd, -- -)" \
+ ${SUDO} bioctl -l"$$(sed -- s/$$/a/ ${DISKDEVFILES} | paste -sd, -- -)" \
-cc -- softraid0 | \
- awk -- '{ print $$NF }' 1>${SRFILE}
+ awk -- '{ print $$NF }' 1>${ROOTDEVFILE}
create-mountpoint:
mkdir -- ${MOUNTPOINT}
format-new-softraid: create-new-softraid create-mountpoint
- ${SUDO} ${FORMAT_DISK} -- "$$(<${SRFILE})" 1>/dev/null
- ${SUDO} disklabel -Aw -- "$$(<${SRFILE})"
- ${SUDO} newfs -q -- "$$(<${SRFILE})"a 1>/dev/null
- ${SUDO} mount -- /dev/"$$(<${SRFILE})"a ${MOUNTPOINT}
+ ${SUDO} ${FORMAT_DISK} -- "$$(<${ROOTDEVFILE})" 1>/dev/null
+ ${SUDO} disklabel -Aw -- "$$(<${ROOTDEVFILE})"
+ ${SUDO} newfs -q -- "$$(<${ROOTDEVFILE})"a 1>/dev/null
+ ${SUDO} mount -- /dev/"$$(<${ROOTDEVFILE})"a ${MOUNTPOINT}
copy-bootstrap-to-softraid: format-new-softraid
${SUDO} mkdir -- ${MOUNTPOINT}/usr
# what the installer does, see /usr/src/distrib/$(machine)/ramdisk/install.md
# do this as regress target and not in format-new-chunks
prepare:
- ${SUDO} ${REAL_RUN} -p -- "$$(<${SRFILE})"
+ ${SUDO} ${REAL_RUN} -p -- "$$(<${ROOTDEVFILE})"
# XXX -p is not yet softraid(4) aware, need to prepare chunks manually
-. for devfile in ${DEVFILES}
+. for devfile in ${DISKDEVFILES}
${SUDO} ${REAL_RUN} -p -- "$$(<${devfile})"
. endfor
.else
root-explicit-stages
dry-prepare:
- ${SUDO} ${DRY_RUN} -p -- "$$(<${SRFILE})"
+ ${SUDO} ${DRY_RUN} -p -- "$$(<${ROOTDEVFILE})"
dry-default:
- ${SUDO} ${DRY_RUN} -- "$$(<${SRFILE})"
+ ${SUDO} ${DRY_RUN} -- "$$(<${ROOTDEVFILE})"
dry-root:
- ${SUDO} ${DRY_RUN} -r/ -- "$$(<${SRFILE})"
+ ${SUDO} ${DRY_RUN} -r/ -- "$$(<${ROOTDEVFILE})"
# what the installer does, see /usr/src/distrib/$(machine)/ramdisk/install.md
-# XXX fails with N > 1 on sparc64, 1 <= N <= 4 works on amd64
+# XXX fails with NCHUNKS > 1 on sparc64, 1 <= NCHUNKS <= 4 works on amd64
root-installer:
- ${SUDO} ${REAL_RUN} -r ${MOUNTPOINT} "$$(<${SRFILE})"
+ ${SUDO} ${REAL_RUN} -r ${MOUNTPOINT} "$$(<${ROOTDEVFILE})"
root-explicit-stages:
- ${SUDO} ${REAL_RUN} -- "$$(<${SRFILE})" ${STAGEFILES}
+ ${SUDO} ${REAL_RUN} -- "$$(<${ROOTDEVFILE})" ${STAGEFILES}
REGRESS_EXPECTED_FAILURES = dry-prepare-root \
REGRESS_TARGETS += ${REGRESS_EXPECTED_FAILURES}
dry-prepare-root:
- ${DRY_RUN} -p -r/ -- "$$(<${SRFILE})"
+ ${DRY_RUN} -p -r/ -- "$$(<${ROOTDEVFILE})"
dry-prepare-stage:
- ${DRY_RUN} -p -- "$$(<${SRFILE})" ${STAGEFILES}
+ ${DRY_RUN} -p -- "$$(<${ROOTDEVFILE})" ${STAGEFILES}
dry-nodisk-stage:
${SUDO} ${DRY_RUN} -- ${STAGEFILES}
${DRY_RUN} -- disk stage1 stage2 too many
-CLEANFILES = ${CHUNKFILES} ${DEVFILES} ${SRFILE}
+CLEANFILES = ${DISKFILES} ${DISKDEVFILES} ${ROOTDEVFILE}
REGRESS_CLEANUP = cleanup
# allow failure to always cleanup as much as possible
cleanup:
-${SUDO} umount -- ${MOUNTPOINT}
- - rmdir -- ${MOUNTPOINT}
- -${SUDO} bioctl -d -- "$$(<${SRFILE})"
-.for devfile in ${DEVFILES}
+ -rmdir -- ${MOUNTPOINT}
+ -${SUDO} bioctl -d -- "$$(<${ROOTDEVFILE})"
+.for devfile in ${DISKDEVFILES}
-${SUDO} vnconfig -u -- "$$(<${devfile})"
.endfor