Makefile.bootcd revision 1.42
11.42Schristos# $NetBSD: Makefile.bootcd,v 1.42 2019/09/23 13:42:31 christos Exp $ 21.1Shubertf# 31.1Shubertf# Makefile snipped to create a CD/DVD ISO 41.1Shubertf# 51.1Shubertf 61.1Shubertf# XXX TODO: 71.1Shubertf# 1) merge with src/distrib/cdrom 81.1Shubertf# 2) teach makefs to add data from more than 1 directory (see below) 91.1Shubertf 101.1Shubertf# 111.1Shubertf# Required variables: 121.1Shubertf# CDBASE Basename of the iso 131.1Shubertf# 141.1Shubertf# Optional variables: 151.42Schristos# CDRELEASE Set to 'true' to include $RELEASEDIR/$RELEASEMACHINEDIR on the CD 161.7Shubertf# CDRELEASE_NOISOS Excludes installation/cdrom directory if set 171.39Smartin# CDRELEASE_NODEBUG Excludes debug sets if set 181.9Schristos# CDSOURCE Set to 'true' to include $RELEASEDIR/source on the CD 191.13Ssborrill# CDEXTRA Set to a list of files or directories containing extra 201.13Ssborrill# stuff to put on CD (set by build.sh -C flag) 211.13Ssborrill# CDBUILDEXTRA Set to a list of files or directories containing extra 221.13Ssborrill# stuff to put on CD (use in Makefiles) 231.13Ssborrill# CDEXTRA_SKIP A list of file exclusion paths to exclude when copying 241.13Ssborrill# directories of extra stuff in CDEXTRA AND CDBUILDEXTRA 251.1Shubertf# BOOT Defaults to $DESTDIR/usr/mdec/boot 261.1Shubertf# BOOTXX_CD9660 Defaults to $DESTDIR/usr/mdec/bootxx_cd9660 271.1Shubertf# CDBOOTOPTIONS Options for installboot, eg -o console=com0,speed=9600 281.8Sbouyer# CDMAKEFSOPTIONS Options for makefs, eg bootimage=i386;bootxx,no-emul-boot 291.25Smartin# CDMAKEFSEXTRAOPTS additional options for makefs, e.g. -F specfile 301.1Shubertf# CDROMS_RELEASEDIR Where to install ${CDBASE}.iso 311.8Sbouyer# CDINSTKERNEL instkernel directory (relative to ${.CURDIR}) 321.8Sbouyer# CDKERNELS couples of the form: 331.8Sbouyer# source name_on_cd 341.15Sad# CDRUNTIME files/directories to copy from $DESTDIR onto the CD 351.28Smartin# CD_SETS sets to be extracted onto the CD 361.28Smartin# SETS_DIR where the CD_SETS are found (default provided) 371.12Ssborrill# source kernels are copied from ${CDINSTKERNEL} (or its obj dir) 381.12Ssborrill# note that as of yet, bootxx_cd9660 can't load kernel names of more than 391.12Ssborrill# 8 chars (though they can be in a sub-directory meaning the pathname is 401.12Ssborrill# longer than 8 chars) 411.1Shubertf# 421.1Shubertf 431.1ShubertfBOOT?= ${DESTDIR}/usr/mdec/boot 441.1ShubertfBOOTXX_CD9660?= ${DESTDIR}/usr/mdec/bootxx_cd9660 451.1ShubertfCDRELEASE?= false 461.9SchristosCDSOURCE?= false 471.8Sbouyer.if ${CDRELEASE} == false 481.8SbouyerCDROMS_RELEASEDIR?= ${MACHINE}/installation/cdrom 491.8Sbouyer.else 501.20SrizCDROMS_RELEASEDIR?= images 511.8Sbouyer.endif 521.7Shubertf.if defined(CDRELEASE_NOISOS) 531.7ShubertfCDRELEASE_EXCLUDE= -s ',./installation/cdrom.*,,gp' 541.7Shubertf.endif 551.39Smartin.if defined(CDRELEASE_NODEBUG) 561.41SmartinCDRELEASE_EXCLUDE+= -s ',./binary/sets/debug.tgz,,gp' 571.41SmartinCDRELEASE_EXCLUDE+= -s ',./binary/sets/xdebug.tgz,,gp' 581.41SmartinCDRELEASE_EXCLUDE+= -s ',./binary/sets/debug.tar.xz,,gp' 591.41SmartinCDRELEASE_EXCLUDE+= -s ',./binary/sets/xdebug.tar.xz,,gp' 601.39Smartin.endif 611.19Stsutsui.if !defined(CDRELEASE_LIVEIMAGE) 621.19StsutsuiCDRELEASE_EXCLUDE+= -s ',./installation/liveimage.*,,gp' 631.19Stsutsui.endif 641.19Stsutsui.if !defined(CDRELEASE_INSTALLIMAGE) 651.19StsutsuiCDRELEASE_EXCLUDE+= -s ',./installation/installimage.*,,gp' 661.19Stsutsui.endif 671.1Shubertf 681.28SmartinSETS_DIR?= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets 691.28Smartin 701.8Sbouyer.include <bsd.own.mk> # For PRINTOBJDIR 711.8Sbouyer.include <bsd.kernobj.mk> # For KERNSRCDIR 721.8Sbouyer 731.18SjmcneillDISTRIBVER!= ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh 741.8SbouyerDISTRIBREV!= ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s 751.28SmartinCUROBJDIR!= cd ${.CURDIR} && ${PRINTOBJDIR} 761.8SbouyerISO_VOLID!= echo NETBSD_${DISTRIBREV} | tr a-z A-Z 771.8SbouyerPUBLISHER?= The_NetBSD_Project 781.8Sbouyer.if defined(CDMAKEFSOPTIONS) 791.22Schristos_CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER},${CDMAKEFSOPTIONS} 801.8Sbouyer.else 811.22Schristos_CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER} 821.8Sbouyer.endif 831.8Sbouyer 841.34Schristos.if ${MKREPRO_TIMESTAMP:Uno} != "no" 851.34SchristosMAKEFS_TIMESTAMP=-T "${MKREPRO_TIMESTAMP}" 861.37SchristosPAX_TIMESTAMP=--timestamp "${MKREPRO_TIMESTAMP}" 871.33Schristos.endif 881.33Schristos 891.28Smartin.if ${MKUNPRIVED} == "no" 901.28SmartinCD_METALOG.unpriv= 911.31Smartinmtunpriv= 921.28Smartin.else 931.28SmartinCD_METALOG.unpriv=-M ${METALOG}.sanitised 941.29Smartinmtunpriv="-U" 951.28Smartin.endif 961.28Smartin 971.1Shubertf# Stuff that should come from elsewhere - XXX where? - HF 981.1ShubertfRM?= rm 991.1ShubertfMKDIR?= mkdir -p 1001.1ShubertfCHMOD?= chmod 1011.17SchristosECHO?= echo 1021.1Shubertf 1031.18Sjmcneill.if ${CDRELEASE} == false 1041.18SjmcneillCDIMAGE= ${CDBASE}.iso 1051.18Sjmcneill.else 1061.18SjmcneillCDIMAGE= NetBSD-${DISTRIBVER}-${CDBASE:S/cd$//}.iso 1071.18Sjmcneill.endif 1081.28SmartinWORKSPEC= fs.spec 1091.1Shubertf 1101.18SjmcneillCLEANFILES+= ${CDIMAGE} 1111.8SbouyerCLEANFILES+= bootxx.${MACHINE} 1121.28SmartinCLEANFILES+= ${WORKSPEC} 1131.1Shubertf 1141.28SmartinCDSETSENV= DESTDIR=${DESTDIR:Q} \ 1151.28Smartin MACHINE=${MACHINE:Q} \ 1161.28Smartin MACHINE_ARCH=${MACHINE_ARCH:Q} \ 1171.28Smartin AWK=${TOOL_AWK:Q} \ 1181.28Smartin CKSUM=${TOOL_CKSUM:Q} \ 1191.28Smartin DB=${TOOL_DB:Q} \ 1201.28Smartin HOST_SH=${HOST_SH:Q} \ 1211.28Smartin MAKE=${MAKE:Q} \ 1221.28Smartin MKTEMP=${TOOL_MKTEMP:Q} \ 1231.28Smartin MTREE=${TOOL_MTREE:Q} \ 1241.28Smartin PAX=${TOOL_PAX:Q} \ 1251.28Smartin COMPRESS_PROGRAM=${COMPRESS_PROGRAM:Q} \ 1261.28Smartin GZIP=${GZIP_FLAGS:Q} \ 1271.28Smartin PKG_CREATE=${TOOL_PKG_CREATE:Q} \ 1281.28Smartin SED=${TOOL_SED:Q} \ 1291.28Smartin TSORT=${TSORT:Q} \ 1301.28Smartin MKRUMP=no \ 1311.28Smartin MKCOMPAT=no \ 1321.28Smartin MKDEBUG=no \ 1331.28Smartin MKDEBUGLIB=no 1341.28Smartin 1351.28SmartinCDSETSCMD= cd ${NETBSDSRCDIR}/distrib/sets && \ 1361.28Smartin ${CDSETSENV} \ 1371.28Smartin ${HOST_SH} 1381.1Shubertf 1391.1Shubertf.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib" 1401.1Shubertf 1411.8Sbouyer.if defined(CDINSTKERNEL) 1421.8Sbouyer_INSTKERNELNOBJDIR!= cd ${.CURDIR}/${CDINSTKERNEL} && ${PRINTOBJDIR} 1431.8Sbouyer.endif 1441.8Sbouyer.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660) 1451.8Sbouyer.if exists(${DESTDIR}/usr/mdec/boot.${MACHINE}) 1461.8SbouyerBOOT2=boot.${MACHINE} 1471.8Sbouyer.else 1481.8SbouyerBOOT2=boot 1491.8Sbouyer.endif 1501.8Sbouyer.endif 1511.1Shubertf 1521.1Shubertfprepare: 1531.36Schristos ${MKDIR} ${MKDIRPERM} "${CUROBJDIR}/cdrom" 1541.8Sbouyer.if defined(CDKERNELS) 1551.8Sbouyer.for kernel target in ${CDKERNELS} 1561.36Schristos ${INSTALL} ${COPY} -m 0644 ${_INSTKERNELNOBJDIR}/${kernel} cdrom/${target} 1571.8Sbouyer.endfor 1581.8Sbouyer.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660) 1591.8Sbouyer ${RM} -f cdrom/${BOOT2} 1601.36Schristos ${INSTALL} ${COPY} -m 0644 ${DESTDIR}/usr/mdec/${BOOT2} cdrom/${BOOT2} 1611.8Sbouyer ${RM} -f bootxx.${MACHINE} 1621.36Schristos ${INSTALL} ${COPY} -m 0644 ${DESTDIR}/usr/mdec/bootxx_cd9660 bootxx.${MACHINE} 1631.8Sbouyer ${CHMOD} +w bootxx.${MACHINE} 1641.8Sbouyer.if defined(CDBOOTOPTIONS) 1651.8Sbouyer ${TOOL_INSTALLBOOT} -m${MACHINE} -e ${CDBOOTOPTIONS} bootxx.${MACHINE} 1661.8Sbouyer.endif 1671.8Sbouyer.endif 1681.8Sbouyer.endif 1691.1Shubertf 1701.24Sdsl.if ${MAKEVERBOSE} >= 2 1711.24SdslPAX_v?= -v 1721.24Sdsl.else 1731.24SdslPAX_v?= 1741.24Sdsl.endif 1751.24Sdsl 1761.1Shubertf# Copy $RELEASEDIR/${MACHINE} in the CDROM dir 1771.1Shubertf# 1781.1Shubertf# XXX This could be done a lot easier if makefs(8) could 1791.1Shubertf# XXX include more than one directory on the image - HF 1801.1Shubertf# 1811.1Shubertfcopy-releasedir: 1821.18Sjmcneill ${RM} -f ${RELEASEDIR}/${CDROMS_RELEASEDIR}/${CDIMAGE} 1831.9Schristos if ${CDRELEASE}; then \ 1841.28Smartin if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then \ 1851.14Smatt echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \ 1861.9Schristos exit 1; \ 1871.9Schristos fi; \ 1881.36Schristos ${MKDIR} ${MKDIRPERM} "${CUROBJDIR}/cdrom/${MACHINE}"; \ 1891.28Smartin release_destdir="${CUROBJDIR}/cdrom/${MACHINE}"; \ 1901.15Sad cd ${RELEASEDIR}/${RELEASEMACHINEDIR}; \ 1911.9Schristos echo Copying $$(pwd) to $$release_destdir ...; \ 1921.37Schristos ${TOOL_PAX} ${PAX_TIMESTAMP} \ 1931.24Sdsl -rw -pe ${PAX_v} \ 1941.7Shubertf ${CDRELEASE_EXCLUDE} \ 1951.9Schristos . $$release_destdir; \ 1961.28Smartin cd "${CUROBJDIR}"; \ 1971.9Schristos fi 1981.9Schristos if ${CDSOURCE}; then \ 1991.9Schristos if [ ! -d ${RELEASEDIR}/source ]; then \ 2001.9Schristos echo "Missing ${RELEASEDIR}/source, aborting"; \ 2011.9Schristos exit 1; \ 2021.9Schristos fi; \ 2031.36Schristos ${MKDIR} ${MKDIRPERM} "${CUROBJDIR}/cdrom/source"; \ 2041.28Smartin release_destdir="${CUROBJDIR}/cdrom/source"; \ 2051.9Schristos cd ${RELEASEDIR}/source; \ 2061.9Schristos echo Copying $$(pwd) to $$release_destdir ...; \ 2071.37Schristos ${TOOL_PAX} ${PAX_TIMESTAMP} \ 2081.24Sdsl -rw -pe ${PAX_v} \ 2091.9Schristos . $$release_destdir; \ 2101.28Smartin cd "${CUROBJDIR}"; \ 2111.1Shubertf fi 2121.28Smartin if [ "X${CDRUNTIME}" != "X" ]; then \ 2131.15Sad release_destdir=$${curdir}/cdrom; \ 2141.15Sad cd $$release_destdir; \ 2151.15Sad cd ${DESTDIR}; \ 2161.15Sad for cde in ${CDRUNTIME}; \ 2171.15Sad do \ 2181.37Schristos ${TOOL_PAX} ${PAX_TIMESTAMP} -rw -pp ${PAX_v} \ 2191.37Schristos $${cde} $$release_destdir; \ 2201.15Sad done; \ 2211.28Smartin cd "${CUROBJDIR}"; \ 2221.15Sad fi 2231.13Ssborrill if [ "X${CDEXTRA}${CDBUILDEXTRA}" != "X" ]; then \ 2241.13Ssborrill skipflag=""; \ 2251.16Shubertf cdextra_skip="${CDEXTRA_SKIP}"; \ 2261.16Shubertf if [ "X$${cdextra_skip}" != "X" ]; then \ 2271.13Ssborrill rm -f cdskip; \ 2281.16Shubertf for skip in $${cdextra_skip}; \ 2291.13Ssborrill do \ 2301.13Ssborrill echo $${skip} >> cdskip; \ 2311.13Ssborrill done; \ 2321.28Smartin skipflag="-X ${CUROBJDIR:Q}/cdskip"; \ 2331.13Ssborrill fi; \ 2341.16Shubertf cdextra="${CDEXTRA}"; \ 2351.16Shubertf cdbuildextra="${CDBUILDEXTRA}"; \ 2361.16Shubertf for cde in $${cdextra} $${cdbuildextra}; \ 2371.13Ssborrill do \ 2381.28Smartin release_destdir="${CUROBJDIR}/cdrom"; \ 2391.13Ssborrill if [ -f $${cde} ]; then \ 2401.13Ssborrill echo Copying $${cde} to $$release_destdir ...; \ 2411.38Schristos ${INSTALL} ${COPY} -m 0644 $${cde} $${release_destdir}; \ 2421.13Ssborrill elif [ -d $${cde} ]; then \ 2431.13Ssborrill cd $${cde}; \ 2441.13Ssborrill echo Copying $$(pwd) to $$release_destdir ...; \ 2451.13Ssborrill ${TOOL_MTREE} -c $${skipflag} | \ 2461.37Schristos ${TOOL_PAX} ${PAX_TIMESTAMP} \ 2471.37Schristos -rw -pe ${PAX_v} \ 2481.37Schristos -M $$release_destdir; \ 2491.13Ssborrill else \ 2501.13Ssborrill echo "Missing $${cde}, aborting"; \ 2511.13Ssborrill exit 1; \ 2521.13Ssborrill fi; \ 2531.28Smartin cd "${CUROBJDIR}"; \ 2541.13Ssborrill done; \ 2551.11Sjnemeth fi 2561.28Smartin.if !empty(CD_SETS) 2571.36Schristos ${MKDIR} ${MKDIRPERM} "${CUROBJDIR}/cdrom/etc/mtree" 2581.28Smartin.for set in ${CD_SETS} 2591.28Smartin if [ -f ${CUROBJDIR:Q}/cdrom/etc/mtree/set.${set} ]; then \ 2601.28Smartin ${CHMOD} +w ${CUROBJDIR:Q}/cdrom/etc/mtree/set.${set}; \ 2611.28Smartin fi; \ 2621.28Smartin ${CDSETSCMD} ./maketars -i "${CUROBJDIR}/cdrom" \ 2631.29Smartin ${CD_METALOG.unpriv} ${mtunpriv} -N ${NETBSDSRCDIR}/etc \ 2641.28Smartin -F "${CUROBJDIR}/cdrom/etc/mtree" \ 2651.28Smartin -d "${DESTDIR:S,^$,/,}" ${set} 2661.28Smartin.endfor 2671.28Smartin if [ -d "${CUROBJDIR}/cdrom/var/spool/ftp/hidden" ]; then \ 2681.28Smartin ${CHMOD} +r "${CUROBJDIR}/cdrom/var/spool/ftp/hidden"; \ 2691.28Smartin fi 2701.28Smartin.endif 2711.1Shubertf 2721.1Shubertfimage: 2731.28Smartin @echo Preparing spec files for makefs... 2741.28Smartin ${RM} -f ${WORKSPEC} 2751.31Smartin if [ -d cdrom/etc/mtree ]; then \ 2761.31Smartin cat cdrom/etc/mtree/* | \ 2771.31Smartin ${TOOL_SED} -e 's/ size=[0-9]*//' \ 2781.31Smartin -e '/^\.\/etc\/gettytab/d' > ${WORKSPEC}; \ 2791.31Smartin fi 2801.31Smartin if [ -r cdrom/dev/MAKEDEV ]; then \ 2811.32Smartin ${HOST_SH} cdrom/dev/MAKEDEV -s init | \ 2821.31Smartin ${TOOL_SED} -e '/^\. type=dir/d' \ 2831.31Smartin -e 's,^\.,./dev,' >> ${WORKSPEC}; \ 2841.31Smartin fi 2851.28Smartin.if defined(SPEC_IN) 2861.28Smartin cat ${SPEC_IN} >> ${WORKSPEC} 2871.28Smartin.endif 2881.28Smartin.if defined(SECONDARY_BOOT) 2891.28Smartin echo "./${SECONDARY_BOOT} type=file uname=root gname=wheel mode=0444" \ 2901.28Smartin >> ${WORKSPEC} 2911.28Smartin.endif 2921.28Smartin.if defined(SPEC_EXTRA) 2931.28Smartin cat ${SPEC_EXTRA} >> ${WORKSPEC} 2941.28Smartin.endif 2951.31Smartin if [ -s ${WORKSPEC} ]; then specarg="-F ${WORKSPEC}"; fi; \ 2961.31Smartin ${TOOL_MAKEFS} -N ${NETBSDSRCDIR}/etc -t cd9660 $${specarg} \ 2971.34Schristos ${MAKEFS_TIMESTAMP} ${CDMAKEFSEXTRAOPTS} -o ${_CDMAKEFSOPTIONS:Q} ${CDIMAGE} cdrom 2981.8Sbouyer 2991.8Sbouyer.if ${CDRELEASE} == false 3001.15Sadrelease: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post 3011.36Schristos ${MKDIR} ${MKDIRPERM} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 3021.18Sjmcneill ${RELEASE_INSTALL} ${CDIMAGE} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 3031.1Shubertf 3041.8Sbouyeriso_image: 3051.8Sbouyer.else 3061.1Shubertfrelease: 3071.8Sbouyer 3081.15Sadiso_image: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post 3091.36Schristos ${MKDIR} ${MKDIRPERM} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 3101.18Sjmcneill ${RELEASE_INSTALL} ${CDIMAGE} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 3111.8Sbouyer.endif 3121.1Shubertf 3131.1Shubertfclean: 3141.28Smartin @if [ -d cdrom/var/spool/ftp/hidden ]; then \ 3151.28Smartin ${CHMOD} +r cdrom/var/spool/ftp/hidden; \ 3161.28Smartin fi # XXX 3171.1Shubertf ${RM} -fr cdrom 3181.1Shubertf 3191.8Sbouyerprepare_md_post: .PHONY 3201.8Sbouyerimage_md_post: .PHONY 3211.15Sadimage_md_pre: .PHONY 3221.8Sbouyer 3231.1Shubertf.include <bsd.prog.mk> 324