Makefile.bootcd revision 1.46
11.46Snia# $NetBSD: Makefile.bootcd,v 1.46 2024/04/23 20:37:07 nia 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.45Snia.if defined(CDRELEASE_NOCOMPAT) 591.45Snia. for sufx in tgz tar.xz 601.45SniaCDRELEASE_EXCLUDE+= -s ',./binary/sets/base32.${sufx},,gp' 611.46SniaCDRELEASE_EXCLUDE+= -s ',./binary/sets/base64.${sufx},,gp' 621.45Snia. endfor 631.45Snia.endif 641.39Smartin.if defined(CDRELEASE_NODEBUG) 651.45Snia. for sufx in tgz tar.xz 661.45SniaCDRELEASE_EXCLUDE+= -s ',./binary/sets/debug.${sufx},,gp' 671.45SniaCDRELEASE_EXCLUDE+= -s ',./binary/sets/debug32.${sufx},,gp' 681.45SniaCDRELEASE_EXCLUDE+= -s ',./binary/sets/debug64.${sufx},,gp' 691.45SniaCDRELEASE_EXCLUDE+= -s ',./binary/sets/xdebug.${sufx},,gp' 701.45Snia. endfor 711.39Smartin.endif 721.46Snia.if defined(CDRELEASE_NOHTML) 731.46Snia. for sufx in tgz tar.xz 741.46SniaCDRELEASE_EXCLUDE+= -s ',./binary/sets/manhtml.${sufx},,gp' 751.46Snia. endfor 761.46Snia.endif 771.46Snia.if defined(CDRELEASE_NOTESTS) 781.46Snia. for sufx in tgz tar.xz 791.46SniaCDRELEASE_EXCLUDE+= -s ',./binary/sets/tests.${sufx},,gp' 801.46Snia. endfor 811.46Snia.endif 821.19Stsutsui.if !defined(CDRELEASE_LIVEIMAGE) 831.19StsutsuiCDRELEASE_EXCLUDE+= -s ',./installation/liveimage.*,,gp' 841.19Stsutsui.endif 851.19Stsutsui.if !defined(CDRELEASE_INSTALLIMAGE) 861.19StsutsuiCDRELEASE_EXCLUDE+= -s ',./installation/installimage.*,,gp' 871.19Stsutsui.endif 881.1Shubertf 891.28SmartinSETS_DIR?= ${RELEASEDIR}/${RELEASEMACHINEDIR}/binary/sets 901.28Smartin 911.8Sbouyer.include <bsd.own.mk> # For PRINTOBJDIR 921.8Sbouyer.include <bsd.kernobj.mk> # For KERNSRCDIR 931.8Sbouyer 941.18SjmcneillDISTRIBVER!= ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh 951.8SbouyerDISTRIBREV!= ${HOST_SH} ${KERNSRCDIR}/conf/osrelease.sh -s 961.28SmartinCUROBJDIR!= cd ${.CURDIR} && ${PRINTOBJDIR} 971.8SbouyerISO_VOLID!= echo NETBSD_${DISTRIBREV} | tr a-z A-Z 981.8SbouyerPUBLISHER?= The_NetBSD_Project 991.8Sbouyer.if defined(CDMAKEFSOPTIONS) 1001.22Schristos_CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER},${CDMAKEFSOPTIONS} 1011.8Sbouyer.else 1021.22Schristos_CDMAKEFSOPTIONS= rockridge,label=${ISO_VOLID},publisher=${PUBLISHER} 1031.8Sbouyer.endif 1041.8Sbouyer 1051.34Schristos.if ${MKREPRO_TIMESTAMP:Uno} != "no" 1061.34SchristosMAKEFS_TIMESTAMP=-T "${MKREPRO_TIMESTAMP}" 1071.37SchristosPAX_TIMESTAMP=--timestamp "${MKREPRO_TIMESTAMP}" 1081.33Schristos.endif 1091.33Schristos 1101.28Smartin.if ${MKUNPRIVED} == "no" 1111.28SmartinCD_METALOG.unpriv= 1121.31Smartinmtunpriv= 1131.28Smartin.else 1141.28SmartinCD_METALOG.unpriv=-M ${METALOG}.sanitised 1151.29Smartinmtunpriv="-U" 1161.28Smartin.endif 1171.28Smartin 1181.1Shubertf# Stuff that should come from elsewhere - XXX where? - HF 1191.1ShubertfRM?= rm 1201.1ShubertfMKDIR?= mkdir -p 1211.1ShubertfCHMOD?= chmod 1221.17SchristosECHO?= echo 1231.1Shubertf 1241.18Sjmcneill.if ${CDRELEASE} == false 1251.18SjmcneillCDIMAGE= ${CDBASE}.iso 1261.18Sjmcneill.else 1271.18SjmcneillCDIMAGE= NetBSD-${DISTRIBVER}-${CDBASE:S/cd$//}.iso 1281.18Sjmcneill.endif 1291.28SmartinWORKSPEC= fs.spec 1301.1Shubertf 1311.18SjmcneillCLEANFILES+= ${CDIMAGE} 1321.8SbouyerCLEANFILES+= bootxx.${MACHINE} 1331.28SmartinCLEANFILES+= ${WORKSPEC} 1341.1Shubertf 1351.28SmartinCDSETSENV= DESTDIR=${DESTDIR:Q} \ 1361.28Smartin MACHINE=${MACHINE:Q} \ 1371.28Smartin MACHINE_ARCH=${MACHINE_ARCH:Q} \ 1381.28Smartin AWK=${TOOL_AWK:Q} \ 1391.28Smartin CKSUM=${TOOL_CKSUM:Q} \ 1401.28Smartin DB=${TOOL_DB:Q} \ 1411.28Smartin HOST_SH=${HOST_SH:Q} \ 1421.28Smartin MAKE=${MAKE:Q} \ 1431.28Smartin MKTEMP=${TOOL_MKTEMP:Q} \ 1441.28Smartin MTREE=${TOOL_MTREE:Q} \ 1451.28Smartin PAX=${TOOL_PAX:Q} \ 1461.28Smartin COMPRESS_PROGRAM=${COMPRESS_PROGRAM:Q} \ 1471.28Smartin GZIP=${GZIP_FLAGS:Q} \ 1481.28Smartin PKG_CREATE=${TOOL_PKG_CREATE:Q} \ 1491.28Smartin SED=${TOOL_SED:Q} \ 1501.28Smartin TSORT=${TSORT:Q} \ 1511.28Smartin MKRUMP=no \ 1521.28Smartin MKCOMPAT=no \ 1531.28Smartin MKDEBUG=no \ 1541.28Smartin MKDEBUGLIB=no 1551.28Smartin 1561.28SmartinCDSETSCMD= cd ${NETBSDSRCDIR}/distrib/sets && \ 1571.28Smartin ${CDSETSENV} \ 1581.28Smartin ${HOST_SH} 1591.1Shubertf 1601.1Shubertf.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib" 1611.1Shubertf 1621.8Sbouyer.if defined(CDINSTKERNEL) 1631.8Sbouyer_INSTKERNELNOBJDIR!= cd ${.CURDIR}/${CDINSTKERNEL} && ${PRINTOBJDIR} 1641.8Sbouyer.endif 1651.8Sbouyer.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660) 1661.8Sbouyer.if exists(${DESTDIR}/usr/mdec/boot.${MACHINE}) 1671.8SbouyerBOOT2=boot.${MACHINE} 1681.8Sbouyer.else 1691.8SbouyerBOOT2=boot 1701.8Sbouyer.endif 1711.8Sbouyer.endif 1721.1Shubertf 1731.1Shubertfprepare: 1741.36Schristos ${MKDIR} ${MKDIRPERM} "${CUROBJDIR}/cdrom" 1751.8Sbouyer.if defined(CDKERNELS) 1761.8Sbouyer.for kernel target in ${CDKERNELS} 1771.36Schristos ${INSTALL} ${COPY} -m 0644 ${_INSTKERNELNOBJDIR}/${kernel} cdrom/${target} 1781.8Sbouyer.endfor 1791.8Sbouyer.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660) 1801.8Sbouyer ${RM} -f cdrom/${BOOT2} 1811.36Schristos ${INSTALL} ${COPY} -m 0644 ${DESTDIR}/usr/mdec/${BOOT2} cdrom/${BOOT2} 1821.8Sbouyer ${RM} -f bootxx.${MACHINE} 1831.36Schristos ${INSTALL} ${COPY} -m 0644 ${DESTDIR}/usr/mdec/bootxx_cd9660 bootxx.${MACHINE} 1841.8Sbouyer ${CHMOD} +w bootxx.${MACHINE} 1851.8Sbouyer.if defined(CDBOOTOPTIONS) 1861.8Sbouyer ${TOOL_INSTALLBOOT} -m${MACHINE} -e ${CDBOOTOPTIONS} bootxx.${MACHINE} 1871.8Sbouyer.endif 1881.8Sbouyer.endif 1891.8Sbouyer.endif 1901.1Shubertf 1911.24Sdsl.if ${MAKEVERBOSE} >= 2 1921.24SdslPAX_v?= -v 1931.24Sdsl.else 1941.24SdslPAX_v?= 1951.24Sdsl.endif 1961.24Sdsl 1971.1Shubertf# Copy $RELEASEDIR/${MACHINE} in the CDROM dir 1981.1Shubertf# 1991.1Shubertf# XXX This could be done a lot easier if makefs(8) could 2001.1Shubertf# XXX include more than one directory on the image - HF 2011.1Shubertf# 2021.1Shubertfcopy-releasedir: 2031.18Sjmcneill ${RM} -f ${RELEASEDIR}/${CDROMS_RELEASEDIR}/${CDIMAGE} 2041.9Schristos if ${CDRELEASE}; then \ 2051.28Smartin if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then \ 2061.14Smatt echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \ 2071.9Schristos exit 1; \ 2081.9Schristos fi; \ 2091.44Sjmcneill ${MKDIR} ${MKDIRPERM} "${CUROBJDIR}/cdrom/${RELEASEMACHINEDIR}"; \ 2101.44Sjmcneill release_destdir="${CUROBJDIR}/cdrom/${RELEASEMACHINEDIR}"; \ 2111.15Sad cd ${RELEASEDIR}/${RELEASEMACHINEDIR}; \ 2121.9Schristos echo Copying $$(pwd) to $$release_destdir ...; \ 2131.37Schristos ${TOOL_PAX} ${PAX_TIMESTAMP} \ 2141.24Sdsl -rw -pe ${PAX_v} \ 2151.7Shubertf ${CDRELEASE_EXCLUDE} \ 2161.9Schristos . $$release_destdir; \ 2171.28Smartin cd "${CUROBJDIR}"; \ 2181.9Schristos fi 2191.9Schristos if ${CDSOURCE}; then \ 2201.9Schristos if [ ! -d ${RELEASEDIR}/source ]; then \ 2211.9Schristos echo "Missing ${RELEASEDIR}/source, aborting"; \ 2221.9Schristos exit 1; \ 2231.9Schristos fi; \ 2241.36Schristos ${MKDIR} ${MKDIRPERM} "${CUROBJDIR}/cdrom/source"; \ 2251.28Smartin release_destdir="${CUROBJDIR}/cdrom/source"; \ 2261.9Schristos cd ${RELEASEDIR}/source; \ 2271.9Schristos echo Copying $$(pwd) to $$release_destdir ...; \ 2281.37Schristos ${TOOL_PAX} ${PAX_TIMESTAMP} \ 2291.24Sdsl -rw -pe ${PAX_v} \ 2301.9Schristos . $$release_destdir; \ 2311.28Smartin cd "${CUROBJDIR}"; \ 2321.1Shubertf fi 2331.28Smartin if [ "X${CDRUNTIME}" != "X" ]; then \ 2341.15Sad release_destdir=$${curdir}/cdrom; \ 2351.15Sad cd $$release_destdir; \ 2361.15Sad cd ${DESTDIR}; \ 2371.15Sad for cde in ${CDRUNTIME}; \ 2381.15Sad do \ 2391.37Schristos ${TOOL_PAX} ${PAX_TIMESTAMP} -rw -pp ${PAX_v} \ 2401.37Schristos $${cde} $$release_destdir; \ 2411.15Sad done; \ 2421.28Smartin cd "${CUROBJDIR}"; \ 2431.15Sad fi 2441.13Ssborrill if [ "X${CDEXTRA}${CDBUILDEXTRA}" != "X" ]; then \ 2451.13Ssborrill skipflag=""; \ 2461.16Shubertf cdextra_skip="${CDEXTRA_SKIP}"; \ 2471.16Shubertf if [ "X$${cdextra_skip}" != "X" ]; then \ 2481.13Ssborrill rm -f cdskip; \ 2491.16Shubertf for skip in $${cdextra_skip}; \ 2501.13Ssborrill do \ 2511.13Ssborrill echo $${skip} >> cdskip; \ 2521.13Ssborrill done; \ 2531.28Smartin skipflag="-X ${CUROBJDIR:Q}/cdskip"; \ 2541.13Ssborrill fi; \ 2551.16Shubertf cdextra="${CDEXTRA}"; \ 2561.16Shubertf cdbuildextra="${CDBUILDEXTRA}"; \ 2571.16Shubertf for cde in $${cdextra} $${cdbuildextra}; \ 2581.13Ssborrill do \ 2591.28Smartin release_destdir="${CUROBJDIR}/cdrom"; \ 2601.13Ssborrill if [ -f $${cde} ]; then \ 2611.13Ssborrill echo Copying $${cde} to $$release_destdir ...; \ 2621.38Schristos ${INSTALL} ${COPY} -m 0644 $${cde} $${release_destdir}; \ 2631.13Ssborrill elif [ -d $${cde} ]; then \ 2641.13Ssborrill cd $${cde}; \ 2651.13Ssborrill echo Copying $$(pwd) to $$release_destdir ...; \ 2661.13Ssborrill ${TOOL_MTREE} -c $${skipflag} | \ 2671.37Schristos ${TOOL_PAX} ${PAX_TIMESTAMP} \ 2681.37Schristos -rw -pe ${PAX_v} \ 2691.37Schristos -M $$release_destdir; \ 2701.13Ssborrill else \ 2711.13Ssborrill echo "Missing $${cde}, aborting"; \ 2721.13Ssborrill exit 1; \ 2731.13Ssborrill fi; \ 2741.28Smartin cd "${CUROBJDIR}"; \ 2751.13Ssborrill done; \ 2761.11Sjnemeth fi 2771.28Smartin.if !empty(CD_SETS) 2781.36Schristos ${MKDIR} ${MKDIRPERM} "${CUROBJDIR}/cdrom/etc/mtree" 2791.28Smartin.for set in ${CD_SETS} 2801.28Smartin if [ -f ${CUROBJDIR:Q}/cdrom/etc/mtree/set.${set} ]; then \ 2811.28Smartin ${CHMOD} +w ${CUROBJDIR:Q}/cdrom/etc/mtree/set.${set}; \ 2821.28Smartin fi; \ 2831.28Smartin ${CDSETSCMD} ./maketars -i "${CUROBJDIR}/cdrom" \ 2841.29Smartin ${CD_METALOG.unpriv} ${mtunpriv} -N ${NETBSDSRCDIR}/etc \ 2851.28Smartin -F "${CUROBJDIR}/cdrom/etc/mtree" \ 2861.28Smartin -d "${DESTDIR:S,^$,/,}" ${set} 2871.28Smartin.endfor 2881.28Smartin if [ -d "${CUROBJDIR}/cdrom/var/spool/ftp/hidden" ]; then \ 2891.28Smartin ${CHMOD} +r "${CUROBJDIR}/cdrom/var/spool/ftp/hidden"; \ 2901.28Smartin fi 2911.28Smartin.endif 2921.1Shubertf 2931.43Smartin.if ${CDDEV_POPULATE} != true 2941.43SmartinDELDEV=-e '/^\.\/dev\/.*type=char/d' 2951.43Smartin.endif 2961.43Smartin 2971.1Shubertfimage: 2981.28Smartin @echo Preparing spec files for makefs... 2991.28Smartin ${RM} -f ${WORKSPEC} 3001.31Smartin if [ -d cdrom/etc/mtree ]; then \ 3011.31Smartin cat cdrom/etc/mtree/* | \ 3021.31Smartin ${TOOL_SED} -e 's/ size=[0-9]*//' \ 3031.43Smartin ${DELDEV} \ 3041.31Smartin -e '/^\.\/etc\/gettytab/d' > ${WORKSPEC}; \ 3051.31Smartin fi 3061.43Smartin if [ -r cdrom/dev/MAKEDEV ] && \ 3071.43Smartin ${CDDEV_POPULATE} == true; then \ 3081.32Smartin ${HOST_SH} cdrom/dev/MAKEDEV -s init | \ 3091.31Smartin ${TOOL_SED} -e '/^\. type=dir/d' \ 3101.31Smartin -e 's,^\.,./dev,' >> ${WORKSPEC}; \ 3111.31Smartin fi 3121.28Smartin.if defined(SPEC_IN) 3131.28Smartin cat ${SPEC_IN} >> ${WORKSPEC} 3141.28Smartin.endif 3151.28Smartin.if defined(SECONDARY_BOOT) 3161.28Smartin echo "./${SECONDARY_BOOT} type=file uname=root gname=wheel mode=0444" \ 3171.28Smartin >> ${WORKSPEC} 3181.28Smartin.endif 3191.28Smartin.if defined(SPEC_EXTRA) 3201.28Smartin cat ${SPEC_EXTRA} >> ${WORKSPEC} 3211.28Smartin.endif 3221.31Smartin if [ -s ${WORKSPEC} ]; then specarg="-F ${WORKSPEC}"; fi; \ 3231.31Smartin ${TOOL_MAKEFS} -N ${NETBSDSRCDIR}/etc -t cd9660 $${specarg} \ 3241.34Schristos ${MAKEFS_TIMESTAMP} ${CDMAKEFSEXTRAOPTS} -o ${_CDMAKEFSOPTIONS:Q} ${CDIMAGE} cdrom 3251.8Sbouyer 3261.8Sbouyer.if ${CDRELEASE} == false 3271.15Sadrelease: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post 3281.36Schristos ${MKDIR} ${MKDIRPERM} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 3291.18Sjmcneill ${RELEASE_INSTALL} ${CDIMAGE} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 3301.1Shubertf 3311.8Sbouyeriso_image: 3321.8Sbouyer.else 3331.1Shubertfrelease: 3341.8Sbouyer 3351.15Sadiso_image: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post 3361.36Schristos ${MKDIR} ${MKDIRPERM} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 3371.18Sjmcneill ${RELEASE_INSTALL} ${CDIMAGE} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 3381.8Sbouyer.endif 3391.1Shubertf 3401.1Shubertfclean: 3411.28Smartin @if [ -d cdrom/var/spool/ftp/hidden ]; then \ 3421.28Smartin ${CHMOD} +r cdrom/var/spool/ftp/hidden; \ 3431.28Smartin fi # XXX 3441.1Shubertf ${RM} -fr cdrom 3451.1Shubertf 3461.8Sbouyerprepare_md_post: .PHONY 3471.8Sbouyerimage_md_post: .PHONY 3481.15Sadimage_md_pre: .PHONY 3491.8Sbouyer 3501.1Shubertf.include <bsd.prog.mk> 351