-# $OpenBSD: Makefile,v 1.11 2022/08/31 22:54:41 kn Exp $
+# $OpenBSD: Makefile,v 1.12 2022/08/31 23:10:01 kn Exp $
INSTALLBOOT ?= /usr/sbin/installboot
DRY_RUN = ${INSTALLBOOT} -n
REAL_RUN = ${INSTALLBOOT}
# installboot(8) behaviour for multi-chunk softraid(4) differs across platforms
-NCHUNKS ?= 1 2
-DISKFILES = ${NCHUNKS:=disk%.img}
-DISKDEVFILES = ${NCHUNKS:=diskdev%.txt}
+NDISKS ?= 1 2
+DISKFILES = ${NDISKS:=disk%.img}
+DISKDEVFILES = ${NDISKS:=diskdev%.txt}
ROOTDEVFILE = rootdev.txt
MOUNTPOINT = mnt
STAGEDIR = /usr/mdec
.endif
STAGEFILES = ${STAGENAMES:=${STAGEDIR}/%}
-REGRESS_SETUP_ONCE = copy-bootstrap-to-softraid
+REGRESS_SETUP_ONCE = copy-bootstrap-to-root
-create-new-chunks:
-.for n in ${NCHUNKS}
+create-disks:
+.for n in ${NDISKS}
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
+format-disks: create-disks
.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
+create-root: format-disks
${SUDO} bioctl -l"$$(sed -- s/$$/a/ ${DISKDEVFILES} | paste -sd, -- -)" \
-cc -- softraid0 | \
awk -- '{ print $$NF }' 1>${ROOTDEVFILE}
create-mountpoint:
mkdir -- ${MOUNTPOINT}
-format-new-softraid: create-new-softraid create-mountpoint
+format-root: create-root create-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
+copy-bootstrap-to-root: format-root
${SUDO} mkdir -- ${MOUNTPOINT}/usr
${SUDO} cp -r -- ${STAGEDIR} ${MOUNTPOINT}/usr/
# must be first as some targets expect a working filesystem
REGRESS_TARGETS = prepare
-# 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 -- "$$(<${ROOTDEVFILE})"
# XXX -p is not yet softraid(4) aware, need to prepare chunks manually
-. for devfile in ${DISKDEVFILES}
+.for devfile in ${DISKDEVFILES}
${SUDO} ${REAL_RUN} -p -- "$$(<${devfile})"
-. endfor
+.endfor
REGRESS_TARGETS += dry-prepare \
dry-default \
dry-root \
- root-installer \
+ root \
root-explicit-stages
dry-prepare:
dry-root:
${SUDO} ${DRY_RUN} -r/ -- "$$(<${ROOTDEVFILE})"
-# what the installer does, see /usr/src/distrib/$(machine)/ramdisk/install.md
-# XXX fails with NCHUNKS > 1 on sparc64, 1 <= NCHUNKS <= 4 works on amd64
-root-installer:
+# XXX fails with NDISKS > 1 on sparc64, 1 <= NDISKS <= 4 works on amd64
+root:
${SUDO} ${REAL_RUN} -r ${MOUNTPOINT} "$$(<${ROOTDEVFILE})"
root-explicit-stages:
# allow failure to always cleanup as much as possible
cleanup:
- -${SUDO} umount -- ${MOUNTPOINT}
- -rmdir -- ${MOUNTPOINT}
- -${SUDO} bioctl -d -- "$$(<${ROOTDEVFILE})"
+ -${SUDO} umount -- ${MOUNTPOINT} 2>/dev/null
+ -rmdir -- ${MOUNTPOINT} 2>/dev/null
+ -${SUDO} bioctl -d -- "$$(<${ROOTDEVFILE})" 2>/dev/null
.for devfile in ${DISKDEVFILES}
- -${SUDO} vnconfig -u -- "$$(<${devfile})"
+ -${SUDO} vnconfig -u -- "$$(<${devfile})" 2>/dev/null
.endfor
.include <bsd.regress.mk>