1# $NetBSD: Makefile.bootcd,v 1.35 2016/06/19 08:44:34 isaki Exp $ 2# 3# Makefile snipped to create a CD/DVD ISO 4# 5 6# XXX TODO: 7# 1) merge with src/distrib/cdrom 8# 2) teach makefs to add data from more than 1 directory (see below) 9 10# 11# Required variables: 12# CDBASE Basename of the iso 13# 14# Optional variables: 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: 32# source name_on_cd 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) 40# 41 42BOOT?= ${DESTDIR}/usr/mdec/boot 43BOOTXX_CD9660?= ${DESTDIR}/usr/mdec/bootxx_cd9660 44CDRELEASE?= false 45CDSOURCE?= false 46.if ${CDRELEASE} == false 47CDROMS_RELEASEDIR?= ${MACHINE}/installation/cdrom 48.else 49CDROMS_RELEASEDIR?= images 50.endif 51.if defined(CDRELEASE_NOISOS) 52CDRELEASE_EXCLUDE= -s ',./installation/cdrom.*,,gp' 53.endif 54.if !defined(CDRELEASE_LIVEIMAGE) 55CDRELEASE_EXCLUDE+= -s ',./installation/liveimage.*,,gp' 56.endif 57.if !defined(CDRELEASE_INSTALLIMAGE) 58CDRELEASE_EXCLUDE+= -s ',./installation/installimage.*,,gp' 59.endif 60 61SETS_DIR?= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets 62 63.include <bsd.own.mk> # For PRINTOBJDIR 64.include <bsd.kernobj.mk> # For KERNSRCDIR 65 66DISTRIBVER!= ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh 67DISTRIBREV!= ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s 68CUROBJDIR!= cd ${.CURDIR} && ${PRINTOBJDIR} 69ISO_VOLID!= echo NETBSD_${DISTRIBREV} | tr a-z A-Z 70PUBLISHER?= The_NetBSD_Project 71.if defined(CDMAKEFSOPTIONS) 72_CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER},${CDMAKEFSOPTIONS} 73.else 74_CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER} 75.endif 76 77.if ${MKREPRO_TIMESTAMP:Uno} != "no" 78MAKEFS_TIMESTAMP=-T "${MKREPRO_TIMESTAMP}" 79.endif 80 81.if ${MKUNPRIVED} == "no" 82CD_METALOG.unpriv= 83mtunpriv= 84.else 85CD_METALOG.unpriv=-M ${METALOG}.sanitised 86mtunpriv="-U" 87.endif 88 89# Stuff that should come from elsewhere - XXX where? - HF 90CP?= cp 91RM?= rm 92MKDIR?= mkdir -p 93CHMOD?= chmod 94ECHO?= echo 95 96.if ${CDRELEASE} == false 97CDIMAGE= ${CDBASE}.iso 98.else 99CDIMAGE= NetBSD-${DISTRIBVER}-${CDBASE:S/cd$//}.iso 100.endif 101WORKSPEC= fs.spec 102 103CLEANFILES+= ${CDIMAGE} 104CLEANFILES+= bootxx.${MACHINE} 105CLEANFILES+= ${WORKSPEC} 106 107CDSETSENV= DESTDIR=${DESTDIR:Q} \ 108 MACHINE=${MACHINE:Q} \ 109 MACHINE_ARCH=${MACHINE_ARCH:Q} \ 110 AWK=${TOOL_AWK:Q} \ 111 CKSUM=${TOOL_CKSUM:Q} \ 112 DB=${TOOL_DB:Q} \ 113 HOST_SH=${HOST_SH:Q} \ 114 MAKE=${MAKE:Q} \ 115 MKTEMP=${TOOL_MKTEMP:Q} \ 116 MTREE=${TOOL_MTREE:Q} \ 117 PAX=${TOOL_PAX:Q} \ 118 COMPRESS_PROGRAM=${COMPRESS_PROGRAM:Q} \ 119 GZIP=${GZIP_FLAGS:Q} \ 120 PKG_CREATE=${TOOL_PKG_CREATE:Q} \ 121 SED=${TOOL_SED:Q} \ 122 TSORT=${TSORT:Q} \ 123 MKRUMP=no \ 124 MKCOMPAT=no \ 125 MKDEBUG=no \ 126 MKDEBUGLIB=no 127 128CDSETSCMD= cd ${NETBSDSRCDIR}/distrib/sets && \ 129 ${CDSETSENV} \ 130 ${HOST_SH} 131 132.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib" 133 134.if defined(CDINSTKERNEL) 135_INSTKERNELNOBJDIR!= cd ${.CURDIR}/${CDINSTKERNEL} && ${PRINTOBJDIR} 136.endif 137.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660) 138.if exists(${DESTDIR}/usr/mdec/boot.${MACHINE}) 139BOOT2=boot.${MACHINE} 140.else 141BOOT2=boot 142.endif 143.endif 144 145prepare: 146 ${MKDIR} "${CUROBJDIR}/cdrom" 147.if defined(CDKERNELS) 148.for kernel target in ${CDKERNELS} 149 ${CP} ${_INSTKERNELNOBJDIR}/${kernel} cdrom/${target} 150.endfor 151.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660) 152 ${RM} -f cdrom/${BOOT2} 153 ${CP} ${DESTDIR}/usr/mdec/${BOOT2} cdrom/${BOOT2} 154 ${RM} -f bootxx.${MACHINE} 155 ${CP} ${DESTDIR}/usr/mdec/bootxx_cd9660 bootxx.${MACHINE} 156 ${CHMOD} +w bootxx.${MACHINE} 157.if defined(CDBOOTOPTIONS) 158 ${TOOL_INSTALLBOOT} -m${MACHINE} -e ${CDBOOTOPTIONS} bootxx.${MACHINE} 159.endif 160.endif 161.endif 162 163.if ${MAKEVERBOSE} >= 2 164PAX_v?= -v 165.else 166PAX_v?= 167.endif 168 169# Copy $RELEASEDIR/${MACHINE} in the CDROM dir 170# 171# XXX This could be done a lot easier if makefs(8) could 172# XXX include more than one directory on the image - HF 173# 174copy-releasedir: 175 ${RM} -f ${RELEASEDIR}/${CDROMS_RELEASEDIR}/${CDIMAGE} 176 if ${CDRELEASE}; then \ 177 if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then \ 178 echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \ 179 exit 1; \ 180 fi; \ 181 ${MKDIR} "${CUROBJDIR}/cdrom/${MACHINE}"; \ 182 release_destdir="${CUROBJDIR}/cdrom/${MACHINE}"; \ 183 cd ${RELEASEDIR}/${RELEASEMACHINEDIR}; \ 184 echo Copying $$(pwd) to $$release_destdir ...; \ 185 ${TOOL_PAX} \ 186 -rw -pe ${PAX_v} \ 187 ${CDRELEASE_EXCLUDE} \ 188 . $$release_destdir; \ 189 cd "${CUROBJDIR}"; \ 190 fi 191 if ${CDSOURCE}; then \ 192 if [ ! -d ${RELEASEDIR}/source ]; then \ 193 echo "Missing ${RELEASEDIR}/source, aborting"; \ 194 exit 1; \ 195 fi; \ 196 ${MKDIR} "${CUROBJDIR}/cdrom/source"; \ 197 release_destdir="${CUROBJDIR}/cdrom/source"; \ 198 cd ${RELEASEDIR}/source; \ 199 echo Copying $$(pwd) to $$release_destdir ...; \ 200 ${TOOL_PAX} \ 201 -rw -pe ${PAX_v} \ 202 . $$release_destdir; \ 203 cd "${CUROBJDIR}"; \ 204 fi 205 if [ "X${CDRUNTIME}" != "X" ]; then \ 206 release_destdir=$${curdir}/cdrom; \ 207 cd $$release_destdir; \ 208 cd ${DESTDIR}; \ 209 for cde in ${CDRUNTIME}; \ 210 do \ 211 ${TOOL_PAX} -rw -pp ${PAX_v} $${cde} $$release_destdir;\ 212 done; \ 213 cd "${CUROBJDIR}"; \ 214 fi 215 if [ "X${CDEXTRA}${CDBUILDEXTRA}" != "X" ]; then \ 216 skipflag=""; \ 217 cdextra_skip="${CDEXTRA_SKIP}"; \ 218 if [ "X$${cdextra_skip}" != "X" ]; then \ 219 rm -f cdskip; \ 220 for skip in $${cdextra_skip}; \ 221 do \ 222 echo $${skip} >> cdskip; \ 223 done; \ 224 skipflag="-X ${CUROBJDIR:Q}/cdskip"; \ 225 fi; \ 226 cdextra="${CDEXTRA}"; \ 227 cdbuildextra="${CDBUILDEXTRA}"; \ 228 for cde in $${cdextra} $${cdbuildextra}; \ 229 do \ 230 release_destdir="${CUROBJDIR}/cdrom"; \ 231 if [ -f $${cde} ]; then \ 232 echo Copying $${cde} to $$release_destdir ...; \ 233 ${CP} -f $${cde} $${release_destdir}; \ 234 elif [ -d $${cde} ]; then \ 235 cd $${cde}; \ 236 echo Copying $$(pwd) to $$release_destdir ...; \ 237 ${TOOL_MTREE} -c $${skipflag} | \ 238 ${TOOL_PAX} -rw -pe ${PAX_v} -M \ 239 $$release_destdir; \ 240 else \ 241 echo "Missing $${cde}, aborting"; \ 242 exit 1; \ 243 fi; \ 244 cd "${CUROBJDIR}"; \ 245 done; \ 246 fi 247.if !empty(CD_SETS) 248 ${MKDIR} "${CUROBJDIR}/cdrom/etc/mtree" 249.for set in ${CD_SETS} 250 if [ -f ${CUROBJDIR:Q}/cdrom/etc/mtree/set.${set} ]; then \ 251 ${CHMOD} +w ${CUROBJDIR:Q}/cdrom/etc/mtree/set.${set}; \ 252 fi; \ 253 ${CDSETSCMD} ./maketars -i "${CUROBJDIR}/cdrom" \ 254 ${CD_METALOG.unpriv} ${mtunpriv} -N ${NETBSDSRCDIR}/etc \ 255 -F "${CUROBJDIR}/cdrom/etc/mtree" \ 256 -d "${DESTDIR:S,^$,/,}" ${set} 257.endfor 258 if [ -d "${CUROBJDIR}/cdrom/var/spool/ftp/hidden" ]; then \ 259 ${CHMOD} +r "${CUROBJDIR}/cdrom/var/spool/ftp/hidden"; \ 260 fi 261.endif 262 263image: 264 @echo Preparing spec files for makefs... 265 ${RM} -f ${WORKSPEC} 266 if [ -d cdrom/etc/mtree ]; then \ 267 cat cdrom/etc/mtree/* | \ 268 ${TOOL_SED} -e 's/ size=[0-9]*//' \ 269 -e '/^\.\/etc\/gettytab/d' > ${WORKSPEC}; \ 270 fi 271 if [ -r cdrom/dev/MAKEDEV ]; then \ 272 ${HOST_SH} cdrom/dev/MAKEDEV -s init | \ 273 ${TOOL_SED} -e '/^\. type=dir/d' \ 274 -e 's,^\.,./dev,' >> ${WORKSPEC}; \ 275 fi 276.if defined(SPEC_IN) 277 cat ${SPEC_IN} >> ${WORKSPEC} 278.endif 279.if defined(SECONDARY_BOOT) 280 echo "./${SECONDARY_BOOT} type=file uname=root gname=wheel mode=0444" \ 281 >> ${WORKSPEC} 282.endif 283.if defined(SPEC_EXTRA) 284 cat ${SPEC_EXTRA} >> ${WORKSPEC} 285.endif 286 if [ -s ${WORKSPEC} ]; then specarg="-F ${WORKSPEC}"; fi; \ 287 ${TOOL_MAKEFS} -N ${NETBSDSRCDIR}/etc -t cd9660 $${specarg} \ 288 ${MAKEFS_TIMESTAMP} ${CDMAKEFSEXTRAOPTS} -o ${_CDMAKEFSOPTIONS:Q} ${CDIMAGE} cdrom 289 290.if ${CDRELEASE} == false 291release: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post 292 ${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 293 ${RELEASE_INSTALL} ${CDIMAGE} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 294 295iso_image: 296.else 297release: 298 299iso_image: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post 300 ${MKDIR} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 301 ${RELEASE_INSTALL} ${CDIMAGE} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 302.endif 303 304clean: 305 @if [ -d cdrom/var/spool/ftp/hidden ]; then \ 306 ${CHMOD} +r cdrom/var/spool/ftp/hidden; \ 307 fi # XXX 308 ${RM} -fr cdrom 309 310prepare_md_post: .PHONY 311image_md_post: .PHONY 312image_md_pre: .PHONY 313 314.include <bsd.prog.mk> 315