1 # $NetBSD: Makefile.bootcd,v 1.32 2015/05/29 06:28:50 martin Exp $
3 # Makefile snipped to create a CD/DVD ISO
7 # 1) merge with src/distrib/cdrom
8 # 2) teach makefs to add data from more than 1 directory (see below)
12 # CDBASE Basename of the iso
15 # CDRELEASE Set to 'true' to include $RELEASEDIR/$MACHINE on the CD
16 # CDRELEASE_NOISOS Excludes installation/cdrom directory if set
17 # CDSOURCE Set to 'true' to include $RELEASEDIR/source on the CD
18 # CDEXTRA Set to a list of files or directories containing extra
19 # stuff to put on CD (set by build.sh -C flag)
20 # CDBUILDEXTRA Set to a list of files or directories containing extra
21 # stuff to put on CD (use in Makefiles)
22 # CDEXTRA_SKIP A list of file exclusion paths to exclude when copying
23 # directories of extra stuff in CDEXTRA AND CDBUILDEXTRA
24 # BOOT Defaults to $DESTDIR/usr/mdec/boot
25 # BOOTXX_CD9660 Defaults to $DESTDIR/usr/mdec/bootxx_cd9660
26 # CDBOOTOPTIONS Options for installboot, eg -o console=com0,speed=9600
27 # CDMAKEFSOPTIONS Options for makefs, eg bootimage=i386;bootxx,no-emul-boot
28 # CDMAKEFSEXTRAOPTS additional options for makefs, e.g. -F specfile
29 # CDROMS_RELEASEDIR Where to install ${CDBASE}.iso
30 # CDINSTKERNEL instkernel directory (relative to ${.CURDIR})
31 # CDKERNELS couples of the form:
33 # CDRUNTIME files/directories to copy from $DESTDIR onto the CD
34 # CD_SETS sets to be extracted onto the CD
35 # SETS_DIR where the CD_SETS are found (default provided)
36 # source kernels are copied from ${CDINSTKERNEL} (or its obj dir)
37 # note that as of yet, bootxx_cd9660 can't load kernel names of more than
38 # 8 chars (though they can be in a sub-directory meaning the pathname is
39 # longer than 8 chars)
42 BOOT?= ${DESTDIR}/usr/mdec/boot
43 BOOTXX_CD9660?= ${DESTDIR}/usr/mdec/bootxx_cd9660
46 .if ${CDRELEASE} == false
47 CDROMS_RELEASEDIR?= ${MACHINE}/installation/cdrom
49 CDROMS_RELEASEDIR?= images
51 .if defined(CDRELEASE_NOISOS)
52 CDRELEASE_EXCLUDE= -s ',./installation/cdrom.*,,gp'
54 .if !defined(CDRELEASE_LIVEIMAGE)
55 CDRELEASE_EXCLUDE+= -s ',./installation/liveimage.*,,gp'
57 .if !defined(CDRELEASE_INSTALLIMAGE)
58 CDRELEASE_EXCLUDE+= -s ',./installation/installimage.*,,gp'
61 SETS_DIR?= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets
63 .include <bsd.own.mk> # For PRINTOBJDIR
64 .include <bsd.kernobj.mk> # For KERNSRCDIR
66 DISTRIBVER!= ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh
67 DISTRIBREV!= ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s
68 CUROBJDIR!= cd ${.CURDIR} && ${PRINTOBJDIR}
69 ISO_VOLID!= echo NETBSD_${DISTRIBREV} | tr a-z A-Z
70 PUBLISHER?= The_NetBSD_Project
71 .if defined(CDMAKEFSOPTIONS)
72 _CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER},${CDMAKEFSOPTIONS}
74 _CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER}
77 .if ${MKUNPRIVED} == "no"
81 CD_METALOG.unpriv=-M ${METALOG}.sanitised
85 # Stuff that should come from elsewhere - XXX where? - HF
92 .if ${CDRELEASE} == false
93 CDIMAGE= ${CDBASE}.iso
95 CDIMAGE= NetBSD-${DISTRIBVER}-${CDBASE:S/cd$//}.iso
99 CLEANFILES+= ${CDIMAGE}
100 CLEANFILES+= bootxx.${MACHINE}
101 CLEANFILES+= ${WORKSPEC}
103 CDSETSENV= DESTDIR=${DESTDIR:Q} \
104 MACHINE=${MACHINE:Q} \
105 MACHINE_ARCH=${MACHINE_ARCH:Q} \
107 CKSUM=${TOOL_CKSUM:Q} \
109 HOST_SH=${HOST_SH:Q} \
111 MKTEMP=${TOOL_MKTEMP:Q} \
112 MTREE=${TOOL_MTREE:Q} \
114 COMPRESS_PROGRAM=${COMPRESS_PROGRAM:Q} \
115 GZIP=${GZIP_FLAGS:Q} \
116 PKG_CREATE=${TOOL_PKG_CREATE:Q} \
124 CDSETSCMD= cd ${NETBSDSRCDIR}/distrib/sets && \
128 .include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
130 .if defined(CDINSTKERNEL)
131 _INSTKERNELNOBJDIR!= cd ${.CURDIR}/${CDINSTKERNEL} && ${PRINTOBJDIR}
133 .if exists(${DESTDIR}/usr/mdec/bootxx_cd9660)
134 .if exists(${DESTDIR}/usr/mdec/boot.${MACHINE})
135 BOOT2=boot.${MACHINE}
142 ${MKDIR} "${CUROBJDIR}/cdrom"
143 .if defined(CDKERNELS)
144 .for kernel target in ${CDKERNELS}
145 ${CP} ${_INSTKERNELNOBJDIR}/${kernel} cdrom/${target}
147 .if exists(${DESTDIR}/usr/mdec/bootxx_cd9660)
148 ${RM} -f cdrom/${BOOT2}
149 ${CP} ${DESTDIR}/usr/mdec/${BOOT2} cdrom/${BOOT2}
150 ${RM} -f bootxx.${MACHINE}
151 ${CP} ${DESTDIR}/usr/mdec/bootxx_cd9660 bootxx.${MACHINE}
152 ${CHMOD} +w bootxx.${MACHINE}
153 .if defined(CDBOOTOPTIONS)
154 ${TOOL_INSTALLBOOT} -m${MACHINE} -e ${CDBOOTOPTIONS} bootxx.${MACHINE}
159 .if ${MAKEVERBOSE} >= 2
165 # Copy $RELEASEDIR/${MACHINE} in the CDROM dir
167 # XXX This could be done a lot easier if makefs(8) could
168 # XXX include more than one directory on the image - HF
171 ${RM} -f ${RELEASEDIR}/${CDROMS_RELEASEDIR}/${CDIMAGE}
172 if ${CDRELEASE}; then \
173 if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then \
174 echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \
177 ${MKDIR} "${CUROBJDIR}/cdrom/${MACHINE}"; \
178 release_destdir="${CUROBJDIR}/cdrom/${MACHINE}"; \
179 cd ${RELEASEDIR}/${RELEASEMACHINEDIR}; \
180 echo Copying $$(pwd) to $$release_destdir ...; \
183 ${CDRELEASE_EXCLUDE} \
184 . $$release_destdir; \
187 if ${CDSOURCE}; then \
188 if [ ! -d ${RELEASEDIR}/source ]; then \
189 echo "Missing ${RELEASEDIR}/source, aborting"; \
192 ${MKDIR} "${CUROBJDIR}/cdrom/source"; \
193 release_destdir="${CUROBJDIR}/cdrom/source"; \
194 cd ${RELEASEDIR}/source; \
195 echo Copying $$(pwd) to $$release_destdir ...; \
198 . $$release_destdir; \
201 if [ "X${CDRUNTIME}" != "X" ]; then \
202 release_destdir=$${curdir}/cdrom; \
203 cd $$release_destdir; \
205 for cde in ${CDRUNTIME}; \
207 ${TOOL_PAX} -rw -pp ${PAX_v} $${cde} $$release_destdir;\
211 if [ "X${CDEXTRA}${CDBUILDEXTRA}" != "X" ]; then \
213 cdextra_skip="${CDEXTRA_SKIP}"; \
214 if [ "X$${cdextra_skip}" != "X" ]; then \
216 for skip in $${cdextra_skip}; \
218 echo $${skip} >> cdskip; \
220 skipflag="-X ${CUROBJDIR:Q}/cdskip"; \
222 cdextra="${CDEXTRA}"; \
223 cdbuildextra="${CDBUILDEXTRA}"; \
224 for cde in $${cdextra} $${cdbuildextra}; \
226 release_destdir="${CUROBJDIR}/cdrom"; \
227 if [ -f $${cde} ]; then \
228 echo Copying $${cde} to $$release_destdir ...; \
229 ${CP} $${cde} $${release_destdir}; \
230 elif [ -d $${cde} ]; then \
232 echo Copying $$(pwd) to $$release_destdir ...; \
233 ${TOOL_MTREE} -c $${skipflag} | \
234 ${TOOL_PAX} -rw -pe ${PAX_v} -M \
237 echo "Missing $${cde}, aborting"; \
244 ${MKDIR} "${CUROBJDIR}/cdrom/etc/mtree"
245 .for set in ${CD_SETS}
246 if [ -f ${CUROBJDIR:Q}/cdrom/etc/mtree/set.${set} ]; then \
247 ${CHMOD} +w ${CUROBJDIR:Q}/cdrom/etc/mtree/set.${set}; \
249 ${CDSETSCMD} ./maketars -i "${CUROBJDIR}/cdrom" \
250 ${CD_METALOG.unpriv} ${mtunpriv} -N ${NETBSDSRCDIR}/etc \
251 -F "${CUROBJDIR}/cdrom/etc/mtree" \
252 -d "${DESTDIR:S,^$,/,}" ${set}
254 if [ -d "${CUROBJDIR}/cdrom/var/spool/ftp/hidden" ]; then \
255 ${CHMOD} +r "${CUROBJDIR}/cdrom/var/spool/ftp/hidden"; \
260 @echo Preparing spec files for makefs...
262 if [ -d cdrom/etc/mtree ]; then \
263 cat cdrom/etc/mtree/* | \
264 ${TOOL_SED} -e 's/ size=[0-9]*//' \
265 -e '/^\.\/etc\/gettytab/d' > ${WORKSPEC}; \
267 if [ -r cdrom/dev/MAKEDEV ]; then \
268 ${HOST_SH} cdrom/dev/MAKEDEV -s init | \
269 ${TOOL_SED} -e '/^\. type=dir/d' \
270 -e 's,^\.,./dev,' >> ${WORKSPEC}; \
273 cat ${SPEC_IN} >> ${WORKSPEC}
275 .if defined(SECONDARY_BOOT)
276 echo "./${SECONDARY_BOOT} type=file uname=root gname=wheel mode=0444" \
279 .if defined(SPEC_EXTRA)
280 cat ${SPEC_EXTRA} >> ${WORKSPEC}
282 if [ -s ${WORKSPEC} ]; then specarg="-F ${WORKSPEC}"; fi; \
283 ${TOOL_MAKEFS} -N ${NETBSDSRCDIR}/etc -t cd9660 $${specarg} \
284 ${CDMAKEFSEXTRAOPTS} -o ${_CDMAKEFSOPTIONS:Q} ${CDIMAGE} cdrom
286 .if ${CDRELEASE} == false
287 release: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post
288 ${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
289 ${RELEASE_INSTALL} ${CDIMAGE} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
295 iso_image: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post
296 ${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
297 ${RELEASE_INSTALL} ${CDIMAGE} ${RELEASEDIR}/${CDROMS_RELEASEDIR}
301 @if [ -d cdrom/var/spool/ftp/hidden ]; then \
302 ${CHMOD} +r cdrom/var/spool/ftp/hidden; \
306 prepare_md_post: .PHONY
307 image_md_post: .PHONY
310 .include <bsd.prog.mk>