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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
# $NetBSD: Makefile.bootcd,v 1.32 2015/05/29 06:28:50 martin Exp $
#
# Makefile snipped to create a CD/DVD ISO
#
# XXX TODO:
# 1) merge with src/distrib/cdrom
# 2) teach makefs to add data from more than 1 directory (see below)
#
# Required variables:
# CDBASE Basename of the iso
#
# Optional variables:
# CDRELEASE Set to 'true' to include $RELEASEDIR/$MACHINE on the CD
# CDRELEASE_NOISOS Excludes installation/cdrom directory if set
# CDSOURCE Set to 'true' to include $RELEASEDIR/source on the CD
# CDEXTRA Set to a list of files or directories containing extra
# stuff to put on CD (set by build.sh -C flag)
# CDBUILDEXTRA Set to a list of files or directories containing extra
# stuff to put on CD (use in Makefiles)
# CDEXTRA_SKIP A list of file exclusion paths to exclude when copying
# directories of extra stuff in CDEXTRA AND CDBUILDEXTRA
# BOOT Defaults to $DESTDIR/usr/mdec/boot
# BOOTXX_CD9660 Defaults to $DESTDIR/usr/mdec/bootxx_cd9660
# CDBOOTOPTIONS Options for installboot, eg -o console=com0,speed=9600
# CDMAKEFSOPTIONS Options for makefs, eg bootimage=i386;bootxx,no-emul-boot
# CDMAKEFSEXTRAOPTS additional options for makefs, e.g. -F specfile
# CDROMS_RELEASEDIR Where to install ${CDBASE}.iso
# CDINSTKERNEL instkernel directory (relative to ${.CURDIR})
# CDKERNELS couples of the form:
# source name_on_cd
# CDRUNTIME files/directories to copy from $DESTDIR onto the CD
# CD_SETS sets to be extracted onto the CD
# SETS_DIR where the CD_SETS are found (default provided)
# source kernels are copied from ${CDINSTKERNEL} (or its obj dir)
# note that as of yet, bootxx_cd9660 can't load kernel names of more than
# 8 chars (though they can be in a sub-directory meaning the pathname is
# longer than 8 chars)
#
BOOT?= ${DESTDIR}/usr/mdec/boot
BOOTXX_CD9660?= ${DESTDIR}/usr/mdec/bootxx_cd9660
CDRELEASE?= false
CDSOURCE?= false
.if ${CDRELEASE} == false
CDROMS_RELEASEDIR?= ${MACHINE}/installation/cdrom
.else
CDROMS_RELEASEDIR?= images
.endif
.if defined(CDRELEASE_NOISOS)
CDRELEASE_EXCLUDE= -s ',./installation/cdrom.*,,gp'
.endif
.if !defined(CDRELEASE_LIVEIMAGE)
CDRELEASE_EXCLUDE+= -s ',./installation/liveimage.*,,gp'
.endif
.if !defined(CDRELEASE_INSTALLIMAGE)
CDRELEASE_EXCLUDE+= -s ',./installation/installimage.*,,gp'
.endif
SETS_DIR?= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
.include <bsd.own.mk> # For PRINTOBJDIR
.include <bsd.kernobj.mk> # For KERNSRCDIR
DISTRIBVER!= ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh
DISTRIBREV!= ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s
CUROBJDIR!= cd ${.CURDIR} && ${PRINTOBJDIR}
ISO_VOLID!= echo NETBSD_${DISTRIBREV} | tr a-z A-Z
PUBLISHER?= The_NetBSD_Project
.if defined(CDMAKEFSOPTIONS)
_CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER},${CDMAKEFSOPTIONS}
.else
_CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER}
.endif
.if ${MKUNPRIVED} == "no"
CD_METALOG.unpriv=
mtunpriv=
.else
CD_METALOG.unpriv=-M ${METALOG}.sanitised
mtunpriv="-U"
.endif
# Stuff that should come from elsewhere - XXX where? - HF
CP?= cp
RM?= rm
MKDIR?= mkdir -p
CHMOD?= chmod
ECHO?= echo
.if ${CDRELEASE} == false
CDIMAGE= ${CDBASE}.iso
.else
CDIMAGE= NetBSD-${DISTRIBVER}-${CDBASE:S/cd$//}.iso
.endif
WORKSPEC= fs.spec
CLEANFILES+= ${CDIMAGE}
CLEANFILES+= bootxx.${MACHINE}
CLEANFILES+= ${WORKSPEC}
CDSETSENV= DESTDIR=${DESTDIR:Q} \
MACHINE=${MACHINE:Q} \
MACHINE_ARCH=${MACHINE_ARCH:Q} \
AWK=${TOOL_AWK:Q} \
CKSUM=${TOOL_CKSUM:Q} \
DB=${TOOL_DB:Q} \
HOST_SH=${HOST_SH:Q} \
MAKE=${MAKE:Q} \
MKTEMP=${TOOL_MKTEMP:Q} \
MTREE=${TOOL_MTREE:Q} \
PAX=${TOOL_PAX:Q} \
COMPRESS_PROGRAM=${COMPRESS_PROGRAM:Q} \
GZIP=${GZIP_FLAGS:Q} \
PKG_CREATE=${TOOL_PKG_CREATE:Q} \
SED=${TOOL_SED:Q} \
TSORT=${TSORT:Q} \
MKRUMP=no \
MKCOMPAT=no \
MKDEBUG=no \
MKDEBUGLIB=no
CDSETSCMD= cd ${NETBSDSRCDIR}/distrib/sets && \
${CDSETSENV} \
${HOST_SH}
.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
.if defined(CDINSTKERNEL)
_INSTKERNELNOBJDIR!= cd ${.CURDIR}/${CDINSTKERNEL} && ${PRINTOBJDIR}
.endif
.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660)
.if exists(${DESTDIR}/usr/mdec/boot.${MACHINE})
BOOT2=boot.${MACHINE}
.else
BOOT2=boot
.endif
.endif
prepare:
${MKDIR} "${CUROBJDIR}/cdrom"
.if defined(CDKERNELS)
.for kernel target in ${CDKERNELS}
${CP} ${_INSTKERNELNOBJDIR}/${kernel} cdrom/${target}
.endfor
.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660)
${RM} -f cdrom/${BOOT2}
${CP} ${DESTDIR}/usr/mdec/${BOOT2} cdrom/${BOOT2}
${RM} -f bootxx.${MACHINE}
${CP} ${DESTDIR}/usr/mdec/bootxx_cd9660 bootxx.${MACHINE}
${CHMOD} +w bootxx.${MACHINE}
.if defined(CDBOOTOPTIONS)
${TOOL_INSTALLBOOT} -m${MACHINE} -e ${CDBOOTOPTIONS} bootxx.${MACHINE}
.endif
.endif
.endif
.if ${MAKEVERBOSE} >= 2
PAX_v?= -v
.else
PAX_v?=
.endif
# Copy $RELEASEDIR/${MACHINE} in the CDROM dir
#
# XXX This could be done a lot easier if makefs(8) could
# XXX include more than one directory on the image - HF
#
copy-releasedir:
${RM} -f ${RELEASEDIR}/${CDROMS_RELEASEDIR}/${CDIMAGE}
if ${CDRELEASE}; then \
if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then \
echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \
exit 1; \
fi; \
${MKDIR} "${CUROBJDIR}/cdrom/${MACHINE}"; \
release_destdir="${CUROBJDIR}/cdrom/${MACHINE}"; \
cd ${RELEASEDIR}/${RELEASEMACHINEDIR}; \
echo Copying $$(pwd) to $$release_destdir ...; \
${TOOL_PAX} \
-rw -pe ${PAX_v} \
${CDRELEASE_EXCLUDE} \
. $$release_destdir; \
cd "${CUROBJDIR}"; \
fi
if ${CDSOURCE}; then \
if [ ! -d ${RELEASEDIR}/source ]; then \
echo "Missing ${RELEASEDIR}/source, aborting"; \
exit 1; \
fi; \
${MKDIR} "${CUROBJDIR}/cdrom/source"; \
release_destdir="${CUROBJDIR}/cdrom/source"; \
cd ${RELEASEDIR}/source; \
echo Copying $$(pwd) to $$release_destdir ...; \
${TOOL_PAX} \
-rw -pe ${PAX_v} \
. $$release_destdir; \
cd "${CUROBJDIR}"; \
fi
if [ "X${CDRUNTIME}" != "X" ]; then \
release_destdir=$${curdir}/cdrom; \
cd $$release_destdir; \
cd ${DESTDIR}; \
for cde in ${CDRUNTIME}; \
do \
${TOOL_PAX} -rw -pp ${PAX_v} $${cde} $$release_destdir;\
done; \
cd "${CUROBJDIR}"; \
fi
if [ "X${CDEXTRA}${CDBUILDEXTRA}" != "X" ]; then \
skipflag=""; \
cdextra_skip="${CDEXTRA_SKIP}"; \
if [ "X$${cdextra_skip}" != "X" ]; then \
rm -f cdskip; \
for skip in $${cdextra_skip}; \
do \
echo $${skip} >> cdskip; \
done; \
skipflag="-X ${CUROBJDIR:Q}/cdskip"; \
fi; \
cdextra="${CDEXTRA}"; \
cdbuildextra="${CDBUILDEXTRA}"; \
for cde in $${cdextra} $${cdbuildextra}; \
do \
release_destdir="${CUROBJDIR}/cdrom"; \
if [ -f $${cde} ]; then \
echo Copying $${cde} to $$release_destdir ...; \
${CP} $${cde} $${release_destdir}; \
elif [ -d $${cde} ]; then \
cd $${cde}; \
echo Copying $$(pwd) to $$release_destdir ...; \
${TOOL_MTREE} -c $${skipflag} | \
${TOOL_PAX} -rw -pe ${PAX_v} -M \
$$release_destdir; \
else \
echo "Missing $${cde}, aborting"; \
exit 1; \
fi; \
cd "${CUROBJDIR}"; \
done; \
fi
.if !empty(CD_SETS)
${MKDIR} "${CUROBJDIR}/cdrom/etc/mtree"
.for set in ${CD_SETS}
if [ -f ${CUROBJDIR:Q}/cdrom/etc/mtree/set.${set} ]; then \
${CHMOD} +w ${CUROBJDIR:Q}/cdrom/etc/mtree/set.${set}; \
fi; \
${CDSETSCMD} ./maketars -i "${CUROBJDIR}/cdrom" \
${CD_METALOG.unpriv} ${mtunpriv} -N ${NETBSDSRCDIR}/etc \
-F "${CUROBJDIR}/cdrom/etc/mtree" \
-d "${DESTDIR:S,^$,/,}" ${set}
.endfor
if [ -d "${CUROBJDIR}/cdrom/var/spool/ftp/hidden" ]; then \
${CHMOD} +r "${CUROBJDIR}/cdrom/var/spool/ftp/hidden"; \
fi
.endif
image:
@echo Preparing spec files for makefs...
${RM} -f ${WORKSPEC}
if [ -d cdrom/etc/mtree ]; then \
cat cdrom/etc/mtree/* | \
${TOOL_SED} -e 's/ size=[0-9]*//' \
-e '/^\.\/etc\/gettytab/d' > ${WORKSPEC}; \
fi
if [ -r cdrom/dev/MAKEDEV ]; then \
${HOST_SH} cdrom/dev/MAKEDEV -s init | \
${TOOL_SED} -e '/^\. type=dir/d' \
-e 's,^\.,./dev,' >> ${WORKSPEC}; \
fi
.if defined(SPEC_IN)
cat ${SPEC_IN} >> ${WORKSPEC}
.endif
.if defined(SECONDARY_BOOT)
echo "./${SECONDARY_BOOT} type=file uname=root gname=wheel mode=0444" \
>> ${WORKSPEC}
.endif
.if defined(SPEC_EXTRA)
cat ${SPEC_EXTRA} >> ${WORKSPEC}
.endif
if [ -s ${WORKSPEC} ]; then specarg="-F ${WORKSPEC}"; fi; \
${TOOL_MAKEFS} -N ${NETBSDSRCDIR}/etc -t cd9660 $${specarg} \
${CDMAKEFSEXTRAOPTS} -o ${_CDMAKEFSOPTIONS:Q} ${CDIMAGE} cdrom
.if ${CDRELEASE} == false
release: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post
${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
${RELEASE_INSTALL} ${CDIMAGE} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
iso_image:
.else
release:
iso_image: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post
${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
${RELEASE_INSTALL} ${CDIMAGE} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
.endif
clean:
@if [ -d cdrom/var/spool/ftp/hidden ]; then \
${CHMOD} +r cdrom/var/spool/ftp/hidden; \
fi # XXX
${RM} -fr cdrom
prepare_md_post: .PHONY
image_md_post: .PHONY
image_md_pre: .PHONY
.include <bsd.prog.mk>
|