Makefile.bootcd revision 1.43
11.43Smartin# $NetBSD: Makefile.bootcd,v 1.43 2019/12/20 19:46:51 martin 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.43Smartin# CDDEV_POPULATE Set to 'true' to fully populate /dev on the CD (and 261.43Smartin# safe a tmpfs union mount) 271.1Shubertf# BOOT Defaults to $DESTDIR/usr/mdec/boot 281.1Shubertf# BOOTXX_CD9660 Defaults to $DESTDIR/usr/mdec/bootxx_cd9660 291.1Shubertf# CDBOOTOPTIONS Options for installboot, eg -o console=com0,speed=9600 301.8Sbouyer# CDMAKEFSOPTIONS Options for makefs, eg bootimage=i386;bootxx,no-emul-boot 311.25Smartin# CDMAKEFSEXTRAOPTS additional options for makefs, e.g. -F specfile 321.1Shubertf# CDROMS_RELEASEDIR Where to install ${CDBASE}.iso 331.8Sbouyer# CDINSTKERNEL instkernel directory (relative to ${.CURDIR}) 341.8Sbouyer# CDKERNELS couples of the form: 351.8Sbouyer# source name_on_cd 361.15Sad# CDRUNTIME files/directories to copy from $DESTDIR onto the CD 371.28Smartin# CD_SETS sets to be extracted onto the CD 381.28Smartin# SETS_DIR where the CD_SETS are found (default provided) 391.12Ssborrill# source kernels are copied from ${CDINSTKERNEL} (or its obj dir) 401.12Ssborrill# note that as of yet, bootxx_cd9660 can't load kernel names of more than 411.12Ssborrill# 8 chars (though they can be in a sub-directory meaning the pathname is 421.12Ssborrill# longer than 8 chars) 431.1Shubertf# 441.1Shubertf 451.1ShubertfBOOT?= ${DESTDIR}/usr/mdec/boot 461.1ShubertfBOOTXX_CD9660?= ${DESTDIR}/usr/mdec/bootxx_cd9660 471.1ShubertfCDRELEASE?= false 481.9SchristosCDSOURCE?= false 491.43SmartinCDDEV_POPULATE?=false 501.8Sbouyer.if ${CDRELEASE} == false 511.8SbouyerCDROMS_RELEASEDIR?= ${MACHINE}/installation/cdrom 521.8Sbouyer.else 531.20SrizCDROMS_RELEASEDIR?= images 541.8Sbouyer.endif 551.7Shubertf.if defined(CDRELEASE_NOISOS) 561.7ShubertfCDRELEASE_EXCLUDE= -s ',./installation/cdrom.*,,gp' 571.7Shubertf.endif 581.39Smartin.if defined(CDRELEASE_NODEBUG) 591.41SmartinCDRELEASE_EXCLUDE+= -s ',./binary/sets/debug.tgz,,gp' 601.41SmartinCDRELEASE_EXCLUDE+= -s ',./binary/sets/xdebug.tgz,,gp' 611.41SmartinCDRELEASE_EXCLUDE+= -s ',./binary/sets/debug.tar.xz,,gp' 621.41SmartinCDRELEASE_EXCLUDE+= -s ',./binary/sets/xdebug.tar.xz,,gp' 631.39Smartin.endif 641.19Stsutsui.if !defined(CDRELEASE_LIVEIMAGE) 651.19StsutsuiCDRELEASE_EXCLUDE+= -s ',./installation/liveimage.*,,gp' 661.19Stsutsui.endif 671.19Stsutsui.if !defined(CDRELEASE_INSTALLIMAGE) 681.19StsutsuiCDRELEASE_EXCLUDE+= -s ',./installation/installimage.*,,gp' 691.19Stsutsui.endif 701.1Shubertf 711.28SmartinSETS_DIR?= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets 721.28Smartin 731.8Sbouyer.include <bsd.own.mk> # For PRINTOBJDIR 741.8Sbouyer.include <bsd.kernobj.mk> # For KERNSRCDIR 751.8Sbouyer 761.18SjmcneillDISTRIBVER!= ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh 771.8SbouyerDISTRIBREV!= ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s 781.28SmartinCUROBJDIR!= cd ${.CURDIR} && ${PRINTOBJDIR} 791.8SbouyerISO_VOLID!= echo NETBSD_${DISTRIBREV} | tr a-z A-Z 801.8SbouyerPUBLISHER?= The_NetBSD_Project 811.8Sbouyer.if defined(CDMAKEFSOPTIONS) 821.22Schristos_CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER},${CDMAKEFSOPTIONS} 831.8Sbouyer.else 841.22Schristos_CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER} 851.8Sbouyer.endif 861.8Sbouyer 871.34Schristos.if ${MKREPRO_TIMESTAMP:Uno} != "no" 881.34SchristosMAKEFS_TIMESTAMP=-T "${MKREPRO_TIMESTAMP}" 891.37SchristosPAX_TIMESTAMP=--timestamp "${MKREPRO_TIMESTAMP}" 901.33Schristos.endif 911.33Schristos 921.28Smartin.if ${MKUNPRIVED} == "no" 931.28SmartinCD_METALOG.unpriv= 941.31Smartinmtunpriv= 951.28Smartin.else 961.28SmartinCD_METALOG.unpriv=-M ${METALOG}.sanitised 971.29Smartinmtunpriv="-U" 981.28Smartin.endif 991.28Smartin 1001.1Shubertf# Stuff that should come from elsewhere - XXX where? - HF 1011.1ShubertfRM?= rm 1021.1ShubertfMKDIR?= mkdir -p 1031.1ShubertfCHMOD?= chmod 1041.17SchristosECHO?= echo 1051.1Shubertf 1061.18Sjmcneill.if ${CDRELEASE} == false 1071.18SjmcneillCDIMAGE= ${CDBASE}.iso 1081.18Sjmcneill.else 1091.18SjmcneillCDIMAGE= NetBSD-${DISTRIBVER}-${CDBASE:S/cd$//}.iso 1101.18Sjmcneill.endif 1111.28SmartinWORKSPEC= fs.spec 1121.1Shubertf 1131.18SjmcneillCLEANFILES+= ${CDIMAGE} 1141.8SbouyerCLEANFILES+= bootxx.${MACHINE} 1151.28SmartinCLEANFILES+= ${WORKSPEC} 1161.1Shubertf 1171.28SmartinCDSETSENV= DESTDIR=${DESTDIR:Q} \ 1181.28Smartin MACHINE=${MACHINE:Q} \ 1191.28Smartin MACHINE_ARCH=${MACHINE_ARCH:Q} \ 1201.28Smartin AWK=${TOOL_AWK:Q} \ 1211.28Smartin CKSUM=${TOOL_CKSUM:Q} \ 1221.28Smartin DB=${TOOL_DB:Q} \ 1231.28Smartin HOST_SH=${HOST_SH:Q} \ 1241.28Smartin MAKE=${MAKE:Q} \ 1251.28Smartin MKTEMP=${TOOL_MKTEMP:Q} \ 1261.28Smartin MTREE=${TOOL_MTREE:Q} \ 1271.28Smartin PAX=${TOOL_PAX:Q} \ 1281.28Smartin COMPRESS_PROGRAM=${COMPRESS_PROGRAM:Q} \ 1291.28Smartin GZIP=${GZIP_FLAGS:Q} \ 1301.28Smartin PKG_CREATE=${TOOL_PKG_CREATE:Q} \ 1311.28Smartin SED=${TOOL_SED:Q} \ 1321.28Smartin TSORT=${TSORT:Q} \ 1331.28Smartin MKRUMP=no \ 1341.28Smartin MKCOMPAT=no \ 1351.28Smartin MKDEBUG=no \ 1361.28Smartin MKDEBUGLIB=no 1371.28Smartin 1381.28SmartinCDSETSCMD= cd ${NETBSDSRCDIR}/distrib/sets && \ 1391.28Smartin ${CDSETSENV} \ 1401.28Smartin ${HOST_SH} 1411.1Shubertf 1421.1Shubertf.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib" 1431.1Shubertf 1441.8Sbouyer.if defined(CDINSTKERNEL) 1451.8Sbouyer_INSTKERNELNOBJDIR!= cd ${.CURDIR}/${CDINSTKERNEL} && ${PRINTOBJDIR} 1461.8Sbouyer.endif 1471.8Sbouyer.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660) 1481.8Sbouyer.if exists(${DESTDIR}/usr/mdec/boot.${MACHINE}) 1491.8SbouyerBOOT2=boot.${MACHINE} 1501.8Sbouyer.else 1511.8SbouyerBOOT2=boot 1521.8Sbouyer.endif 1531.8Sbouyer.endif 1541.1Shubertf 1551.1Shubertfprepare: 1561.36Schristos ${MKDIR} ${MKDIRPERM} "${CUROBJDIR}/cdrom" 1571.8Sbouyer.if defined(CDKERNELS) 1581.8Sbouyer.for kernel target in ${CDKERNELS} 1591.36Schristos ${INSTALL} ${COPY} -m 0644 ${_INSTKERNELNOBJDIR}/${kernel} cdrom/${target} 1601.8Sbouyer.endfor 1611.8Sbouyer.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660) 1621.8Sbouyer ${RM} -f cdrom/${BOOT2} 1631.36Schristos ${INSTALL} ${COPY} -m 0644 ${DESTDIR}/usr/mdec/${BOOT2} cdrom/${BOOT2} 1641.8Sbouyer ${RM} -f bootxx.${MACHINE} 1651.36Schristos ${INSTALL} ${COPY} -m 0644 ${DESTDIR}/usr/mdec/bootxx_cd9660 bootxx.${MACHINE} 1661.8Sbouyer ${CHMOD} +w bootxx.${MACHINE} 1671.8Sbouyer.if defined(CDBOOTOPTIONS) 1681.8Sbouyer ${TOOL_INSTALLBOOT} -m${MACHINE} -e ${CDBOOTOPTIONS} bootxx.${MACHINE} 1691.8Sbouyer.endif 1701.8Sbouyer.endif 1711.8Sbouyer.endif 1721.1Shubertf 1731.24Sdsl.if ${MAKEVERBOSE} >= 2 1741.24SdslPAX_v?= -v 1751.24Sdsl.else 1761.24SdslPAX_v?= 1771.24Sdsl.endif 1781.24Sdsl 1791.1Shubertf# Copy $RELEASEDIR/${MACHINE} in the CDROM dir 1801.1Shubertf# 1811.1Shubertf# XXX This could be done a lot easier if makefs(8) could 1821.1Shubertf# XXX include more than one directory on the image - HF 1831.1Shubertf# 1841.1Shubertfcopy-releasedir: 1851.18Sjmcneill ${RM} -f ${RELEASEDIR}/${CDROMS_RELEASEDIR}/${CDIMAGE} 1861.9Schristos if ${CDRELEASE}; then \ 1871.28Smartin if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then \ 1881.14Smatt echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \ 1891.9Schristos exit 1; \ 1901.9Schristos fi; \ 1911.36Schristos ${MKDIR} ${MKDIRPERM} "${CUROBJDIR}/cdrom/${MACHINE}"; \ 1921.28Smartin release_destdir="${CUROBJDIR}/cdrom/${MACHINE}"; \ 1931.15Sad cd ${RELEASEDIR}/${RELEASEMACHINEDIR}; \ 1941.9Schristos echo Copying $$(pwd) to $$release_destdir ...; \ 1951.37Schristos ${TOOL_PAX} ${PAX_TIMESTAMP} \ 1961.24Sdsl -rw -pe ${PAX_v} \ 1971.7Shubertf ${CDRELEASE_EXCLUDE} \ 1981.9Schristos . $$release_destdir; \ 1991.28Smartin cd "${CUROBJDIR}"; \ 2001.9Schristos fi 2011.9Schristos if ${CDSOURCE}; then \ 2021.9Schristos if [ ! -d ${RELEASEDIR}/source ]; then \ 2031.9Schristos echo "Missing ${RELEASEDIR}/source, aborting"; \ 2041.9Schristos exit 1; \ 2051.9Schristos fi; \ 2061.36Schristos ${MKDIR} ${MKDIRPERM} "${CUROBJDIR}/cdrom/source"; \ 2071.28Smartin release_destdir="${CUROBJDIR}/cdrom/source"; \ 2081.9Schristos cd ${RELEASEDIR}/source; \ 2091.9Schristos echo Copying $$(pwd) to $$release_destdir ...; \ 2101.37Schristos ${TOOL_PAX} ${PAX_TIMESTAMP} \ 2111.24Sdsl -rw -pe ${PAX_v} \ 2121.9Schristos . $$release_destdir; \ 2131.28Smartin cd "${CUROBJDIR}"; \ 2141.1Shubertf fi 2151.28Smartin if [ "X${CDRUNTIME}" != "X" ]; then \ 2161.15Sad release_destdir=$${curdir}/cdrom; \ 2171.15Sad cd $$release_destdir; \ 2181.15Sad cd ${DESTDIR}; \ 2191.15Sad for cde in ${CDRUNTIME}; \ 2201.15Sad do \ 2211.37Schristos ${TOOL_PAX} ${PAX_TIMESTAMP} -rw -pp ${PAX_v} \ 2221.37Schristos $${cde} $$release_destdir; \ 2231.15Sad done; \ 2241.28Smartin cd "${CUROBJDIR}"; \ 2251.15Sad fi 2261.13Ssborrill if [ "X${CDEXTRA}${CDBUILDEXTRA}" != "X" ]; then \ 2271.13Ssborrill skipflag=""; \ 2281.16Shubertf cdextra_skip="${CDEXTRA_SKIP}"; \ 2291.16Shubertf if [ "X$${cdextra_skip}" != "X" ]; then \ 2301.13Ssborrill rm -f cdskip; \ 2311.16Shubertf for skip in $${cdextra_skip}; \ 2321.13Ssborrill do \ 2331.13Ssborrill echo $${skip} >> cdskip; \ 2341.13Ssborrill done; \ 2351.28Smartin skipflag="-X ${CUROBJDIR:Q}/cdskip"; \ 2361.13Ssborrill fi; \ 2371.16Shubertf cdextra="${CDEXTRA}"; \ 2381.16Shubertf cdbuildextra="${CDBUILDEXTRA}"; \ 2391.16Shubertf for cde in $${cdextra} $${cdbuildextra}; \ 2401.13Ssborrill do \ 2411.28Smartin release_destdir="${CUROBJDIR}/cdrom"; \ 2421.13Ssborrill if [ -f $${cde} ]; then \ 2431.13Ssborrill echo Copying $${cde} to $$release_destdir ...; \ 2441.38Schristos ${INSTALL} ${COPY} -m 0644 $${cde} $${release_destdir}; \ 2451.13Ssborrill elif [ -d $${cde} ]; then \ 2461.13Ssborrill cd $${cde}; \ 2471.13Ssborrill echo Copying $$(pwd) to $$release_destdir ...; \ 2481.13Ssborrill ${TOOL_MTREE} -c $${skipflag} | \ 2491.37Schristos ${TOOL_PAX} ${PAX_TIMESTAMP} \ 2501.37Schristos -rw -pe ${PAX_v} \ 2511.37Schristos -M $$release_destdir; \ 2521.13Ssborrill else \ 2531.13Ssborrill echo "Missing $${cde}, aborting"; \ 2541.13Ssborrill exit 1; \ 2551.13Ssborrill fi; \ 2561.28Smartin cd "${CUROBJDIR}"; \ 2571.13Ssborrill done; \ 2581.11Sjnemeth fi 2591.28Smartin.if !empty(CD_SETS) 2601.36Schristos ${MKDIR} ${MKDIRPERM} "${CUROBJDIR}/cdrom/etc/mtree" 2611.28Smartin.for set in ${CD_SETS} 2621.28Smartin if [ -f ${CUROBJDIR:Q}/cdrom/etc/mtree/set.${set} ]; then \ 2631.28Smartin ${CHMOD} +w ${CUROBJDIR:Q}/cdrom/etc/mtree/set.${set}; \ 2641.28Smartin fi; \ 2651.28Smartin ${CDSETSCMD} ./maketars -i "${CUROBJDIR}/cdrom" \ 2661.29Smartin ${CD_METALOG.unpriv} ${mtunpriv} -N ${NETBSDSRCDIR}/etc \ 2671.28Smartin -F "${CUROBJDIR}/cdrom/etc/mtree" \ 2681.28Smartin -d "${DESTDIR:S,^$,/,}" ${set} 2691.28Smartin.endfor 2701.28Smartin if [ -d "${CUROBJDIR}/cdrom/var/spool/ftp/hidden" ]; then \ 2711.28Smartin ${CHMOD} +r "${CUROBJDIR}/cdrom/var/spool/ftp/hidden"; \ 2721.28Smartin fi 2731.28Smartin.endif 2741.1Shubertf 2751.43Smartin.if ${CDDEV_POPULATE} != true 2761.43SmartinDELDEV=-e '/^\.\/dev\/.*type=char/d' 2771.43Smartin.endif 2781.43Smartin 2791.1Shubertfimage: 2801.28Smartin @echo Preparing spec files for makefs... 2811.28Smartin ${RM} -f ${WORKSPEC} 2821.31Smartin if [ -d cdrom/etc/mtree ]; then \ 2831.31Smartin cat cdrom/etc/mtree/* | \ 2841.31Smartin ${TOOL_SED} -e 's/ size=[0-9]*//' \ 2851.43Smartin ${DELDEV} \ 2861.31Smartin -e '/^\.\/etc\/gettytab/d' > ${WORKSPEC}; \ 2871.31Smartin fi 2881.43Smartin if [ -r cdrom/dev/MAKEDEV ] && \ 2891.43Smartin ${CDDEV_POPULATE} == true; then \ 2901.32Smartin ${HOST_SH} cdrom/dev/MAKEDEV -s init | \ 2911.31Smartin ${TOOL_SED} -e '/^\. type=dir/d' \ 2921.31Smartin -e 's,^\.,./dev,' >> ${WORKSPEC}; \ 2931.31Smartin fi 2941.28Smartin.if defined(SPEC_IN) 2951.28Smartin cat ${SPEC_IN} >> ${WORKSPEC} 2961.28Smartin.endif 2971.28Smartin.if defined(SECONDARY_BOOT) 2981.28Smartin echo "./${SECONDARY_BOOT} type=file uname=root gname=wheel mode=0444" \ 2991.28Smartin >> ${WORKSPEC} 3001.28Smartin.endif 3011.28Smartin.if defined(SPEC_EXTRA) 3021.28Smartin cat ${SPEC_EXTRA} >> ${WORKSPEC} 3031.28Smartin.endif 3041.31Smartin if [ -s ${WORKSPEC} ]; then specarg="-F ${WORKSPEC}"; fi; \ 3051.31Smartin ${TOOL_MAKEFS} -N ${NETBSDSRCDIR}/etc -t cd9660 $${specarg} \ 3061.34Schristos ${MAKEFS_TIMESTAMP} ${CDMAKEFSEXTRAOPTS} -o ${_CDMAKEFSOPTIONS:Q} ${CDIMAGE} cdrom 3071.8Sbouyer 3081.8Sbouyer.if ${CDRELEASE} == false 3091.15Sadrelease: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post 3101.36Schristos ${MKDIR} ${MKDIRPERM} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 3111.18Sjmcneill ${RELEASE_INSTALL} ${CDIMAGE} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 3121.1Shubertf 3131.8Sbouyeriso_image: 3141.8Sbouyer.else 3151.1Shubertfrelease: 3161.8Sbouyer 3171.15Sadiso_image: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post 3181.36Schristos ${MKDIR} ${MKDIRPERM} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 3191.18Sjmcneill ${RELEASE_INSTALL} ${CDIMAGE} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 3201.8Sbouyer.endif 3211.1Shubertf 3221.1Shubertfclean: 3231.28Smartin @if [ -d cdrom/var/spool/ftp/hidden ]; then \ 3241.28Smartin ${CHMOD} +r cdrom/var/spool/ftp/hidden; \ 3251.28Smartin fi # XXX 3261.1Shubertf ${RM} -fr cdrom 3271.1Shubertf 3281.8Sbouyerprepare_md_post: .PHONY 3291.8Sbouyerimage_md_post: .PHONY 3301.15Sadimage_md_pre: .PHONY 3311.8Sbouyer 3321.1Shubertf.include <bsd.prog.mk> 333