blob: f0277df772f59de104be7a4920d2c383ba0f51b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# $OpenBSD: Makefile,v 1.2 2022/08/24 14:57:52 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
CHUNKFILES = ${NCHUNKS:=chunk%.img}
DEVFILES = ${NCHUNKS:=vnd%.txt}
SRFILE = sr.txt
# allow testing with real bootstrap, e.g. for size constraints or formats
STAGEFILE ?= stage.empty
MOUNTPOINT ?= /mnt
REGRESS_SETUP_ONCE = copy-bootstrap-to-softraid
create-new-chunks:
.for n in ${NCHUNKS}
dd if=/dev/zero of=chunk${n}.img bs=1m count=0 seek=32 status=none
${SUDO} vnconfig -- chunk${n}.img 1>vnd${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}
.if ${MACHINE} == "amd64" # assume BIOS/MBR
${SUDO} fdisk -iy -- "$$(<${devfile})" 1>/dev/null
.elif ${MACHINE} == "arm64"
${SUDO} fdisk -g -y -b32768 -- "$$(<${devfile})" 1>/dev/null
.endif
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, -- -)" \
-cc -- softraid0 | \
awk -- '{ print $$NF }' 1>${SRFILE}
format-new-softraid: create-new-softraid
${SUDO} disklabel -Aw -- "$$(<${SRFILE})"
${SUDO} newfs -- "$$(<${SRFILE})"a
${SUDO} mount -- /dev/"$$(<${SRFILE})"a ${MOUNTPOINT}
copy-bootstrap-to-softraid: format-new-softraid
${SUDO} mkdir -- ${MOUNTPOINT}/usr
${SUDO} cp -r -- /usr/mdec ${MOUNTPOINT}/usr/
# most but not all usages rquire the EFI filesystem to be usable
.if ${MACHINE} == "arm64"
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
# XXX -p is not yet softraid(4) aware
prepare:
${SUDO} ${REAL_RUN} -p -- "$$(<${SRFILE})"
.else
REGRESS_TARGETS = # empty
.endif
REGRESS_TARGETS += dry-prepare \
dry-default \
dry-root \
root-installer \
root-explicit-stages
dry-prepare:
${SUDO} ${DRY_RUN} -p -- "$$(<${SRFILE})"
dry-default:
${SUDO} ${DRY_RUN} -- "$$(<${SRFILE})"
dry-root:
${SUDO} ${DRY_RUN} -r/ -- "$$(<${SRFILE})"
# 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
root-installer:
${SUDO} installboot -r /mnt "$$(<${SRFILE})"
root-explicit-stages:
.if ${MACHINE} == "amd64" # assume BIOS/MBR
${SUDO} installboot -- "$$(<${SRFILE})" ${NEWROOT}/usr/mdec/biosboot ${NEWROOT}/usr/mdec/boot
.elif ${MACHINE} == "arm64"
${SUDO} installboot -- "$$(<${SRFILE})" ${NEWROOT}/usr/mdec/BOOTAA64.EFI
.elif ${MACHINE} == "sparc64"
${SUDO} installboot -- "$$(<${SRFILE})" ${NEWROOT}/usr/mdec/bootblk ${NEWROOT}/usr/mdec/ofwboot
.endif
REGRESS_EXPECTED_FAILURES = dry-prepare-root \
dry-prepare-stage \
dry-nodisk-stage \
dry-toomany
REGRESS_TARGETS += ${REGRESS_EXPECTED_FAILURES}
dry-prepare-root:
${DRY_RUN} -p -r/ -- "$$(<${SRFILE})"
dry-prepare-stage:
touch -- ${STAGEFILE}
${DRY_RUN} -p -- "$$(<${SRFILE})" ${STAGEFILE}
dry-nodisk-stage:
touch -- ${STAGEFILE}
${SUDO} ${DRY_RUN} -- ${STAGEFILE}
dry-toomany:
touch -- ${STAGEFILE}
${DRY_RUN} -- disk stage1 stage2 too many
CLEANFILES = ${CHUNKFILES} ${DEVFILES} ${SRFILE} ${STAGEFILE}
REGRESS_CLEANUP = cleanup
# allow failure to always cleanup as much as possible
cleanup:
-${SUDO} umount -- /mnt
-${SUDO} bioctl -d -- "$$(<${SRFILE})"
.for devfile in ${DEVFILES}
-${SUDO} vnconfig -u -- "$$(<${devfile})"
.endfor
.include <bsd.regress.mk>
|