blob: 43da01a4dccfe4737daa1679692d681022d4c7f9 (
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
# $OpenBSD: Makefile,v 1.32 2022/09/14 13:37:03 kn Exp $
INSTALLBOOT ?= /usr/sbin/installboot
DRY_RUN = ${INSTALLBOOT} -n
REAL_RUN = ${INSTALLBOOT}
# see distrib/${MACHINE}/ramdisk/install.md for FORMAT_DISK values
# default to root on softraid(4) on all architectures that have
# bootstrap + kernel + installboot(8) support for it
.if ${MACHINE} == "amd64" || \
${MACHINE} == "i386" # assume BIOS/MBR
FORMAT_DISK = fdisk -iy
STAGENAMES = biosboot boot
USE_SOFTRAID ?= Yes
.elif ${MACHINE} == "arm64"
STAGENAMES = BOOTAA64.EFI
USE_SOFTRAID ?= Yes
.elif ${MACHINE} == "armv7"
STAGENAMES = BOOTARM.EFI
.elif ${MACHINE} == "macppc" # assume MBR
FORMAT_DISK = fdisk -iy -b '2048@1:06'
STAGENAMES = ofwboot
.elif ${MACHINE} == "octeon"
FORMAT_DISK = fdisk -iy -b '65536@64:C'
STAGENAMES = boot
.elif ${MACHINE} == "powerpc64"
STAGENAMES = boot
.elif ${MACHINE} == "riscv64"
STAGENAMES = BOOTRISCV64.EFI
.elif ${MACHINE} == "sparc64"
FORMAT_DISK = true # NOOP
STAGENAMES = bootblk ofwboot
USE_SOFTRAID ?= Yes
.endif
# missing: alpha, hppa, landisk, loongson, luna88k
FORMAT_DISK ?= fdisk -iy -b '32768@32768:C'
STAGEDIR = /usr/mdec
STAGEFILES = ${STAGENAMES:=${STAGEDIR}/%}
USE_SOFTRAID ?= No
.if ${USE_SOFTRAID:L} == "yes"
# install on multi-chunk RAID 1C with keydisk so installboot(8) must
# - iterate over chunks
# - ignore the keydisk/not install to it
NDISKS ?= 2
KEYDISKFILE = keydisk.img
KEYDEVFILE = keydev.txt
.else
NDISKS = 1
.endif
DISKFILES != jot -w disk%d.img -- ${NDISKS}
DISKDEVFILES != jot -w diskdev%d.txt -- ${NDISKS}
ROOTDEVFILE = rootdev.txt
MOUNTPOINT = mnt
REGRESS_SETUP_ONCE = create-root
# |1.img ... n.img| |1.img 1.txt|
# |1.txt ... n.txt| => |... ... |
# |n.img n.txt|
FILETUPLES != { echo ${DISKFILES} ${KEYDISKFILE}; \
echo ${DISKDEVFILES} ${KEYDEVFILE} ; } | \
rs -T -- $$((${NDISKS} + 1)) 2
create-disks:
.for diskfile devfile in ${FILETUPLES}
dd if=/dev/zero of=${diskfile} bs=1m count=0 seek=128 status=none
${SUDO} vnconfig -- ${diskfile} 1>${devfile}
${SUDO} ${FORMAT_DISK} -- "$$(<${devfile})" 1>/dev/null
. if ${USE_SOFTRAID:L} == "yes"
echo 'RAID 1M-* 100%' | \
${SUDO} disklabel -wAT/dev/stdin -- "$$(<${devfile})" 1>/dev/null
. endif
.endfor
create-root: create-disks
.if ${USE_SOFTRAID:L} == "yes"
${SUDO} bioctl -l"$$(sed -- s/$$/a/ ${DISKDEVFILES} | paste -sd, -- -)" \
-c1C -k"$$(<${KEYDEVFILE})"a -- softraid0 | \
awk -- '{ print $$NF }' 1>${ROOTDEVFILE}
${SUDO} ${FORMAT_DISK} -- "$$(<${ROOTDEVFILE})" 1>/dev/null
.else
ln -s -- ${DISKDEVFILES} ${ROOTDEVFILE}
.endif
${SUDO} disklabel -Aw -- "$$(<${ROOTDEVFILE})"
${SUDO} newfs -q -- "$$(<${ROOTDEVFILE})"a 1>/dev/null
mkdir -- ${MOUNTPOINT}
${SUDO} mount -- /dev/"$$(<${ROOTDEVFILE})"a ${MOUNTPOINT}
${SUDO} mkdir -- ${MOUNTPOINT}/usr
${SUDO} cp -r -- ${STAGEDIR} ${MOUNTPOINT}/usr/
# must be first as some targets expect a working filesystem
REGRESS_TARGETS = prepare
prepare:
${SUDO} ${REAL_RUN} -p -- "$$(<${ROOTDEVFILE})"
.if ${USE_SOFTRAID:L} == "yes"
# XXX -p is not yet softraid(4) aware, need to prepare chunks manually
. for devfile in ${DISKDEVFILES}
${SUDO} ${REAL_RUN} -p -- "$$(<${devfile})"
. endfor
.endif
REGRESS_TARGETS += dry-prepare \
dry-default \
dry-root \
root \
root-stages
dry-prepare:
${SUDO} ${DRY_RUN} -p -- "$$(<${ROOTDEVFILE})"
dry-default:
${SUDO} ${DRY_RUN} -- "$$(<${ROOTDEVFILE})"
dry-root:
${SUDO} ${DRY_RUN} -r/ -- "$$(<${ROOTDEVFILE})"
root:
${SUDO} ${REAL_RUN} -r ${MOUNTPOINT} "$$(<${ROOTDEVFILE})"
root-stages:
${SUDO} ${REAL_RUN} -- "$$(<${ROOTDEVFILE})" ${STAGEFILES}
REGRESS_EXPECTED_FAILURES = dry-prepare-root \
dry-prepare-stages \
dry-nodisk-stages \
dry-toofew \
dry-toomany
REGRESS_TARGETS += ${REGRESS_EXPECTED_FAILURES}
dry-prepare-root:
${DRY_RUN} -p -r/ -- "$$(<${ROOTDEVFILE})" 2>/dev/null
dry-prepare-stages:
${DRY_RUN} -p -- "$$(<${ROOTDEVFILE})" ${STAGEFILES} 2>/dev/null
dry-nodisk-stages:
${SUDO} ${DRY_RUN} -- ${STAGEFILES} 2>/dev/null
dry-toofew:
${DRY_RUN} -- 2>/dev/null
dry-toomany:
${DRY_RUN} -- disk stage1 stage2 too many 2>/dev/null
CLEANFILES = *.txt *.img
REGRESS_CLEANUP = cleanup
# allow failure to always cleanup as much as possible
.IGNORE: cleanup
cleanup:
${SUDO} umount -- ${MOUNTPOINT} 2>/dev/null
rmdir -- ${MOUNTPOINT} 2>/dev/null
.if ${USE_SOFTRAID:L} == "yes"
${SUDO} bioctl -d -- "$$(<${ROOTDEVFILE})" 2>/dev/null
.endif
.for _ devfile in ${FILETUPLES}
${SUDO} vnconfig -u -- "$$(<${devfile})" 2>/dev/null
.endfor
.include <bsd.regress.mk>
|