Makefile.bootcd revision 1.48
11.48Snia# $NetBSD: Makefile.bootcd,v 1.48 2024/04/25 11:56:51 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.48SniaCDRELEASE_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.47Snia.elif ${CDBASE:M*dvd} 1271.47SniaCDIMAGE= NetBSD-${DISTRIBVER}-${CDBASE:S/dvd$//}-dvd.iso 1281.18Sjmcneill.else 1291.18SjmcneillCDIMAGE= NetBSD-${DISTRIBVER}-${CDBASE:S/cd$//}.iso 1301.18Sjmcneill.endif 1311.28SmartinWORKSPEC= fs.spec 1321.1Shubertf 1331.18SjmcneillCLEANFILES+= ${CDIMAGE} 1341.8SbouyerCLEANFILES+= bootxx.${MACHINE} 1351.28SmartinCLEANFILES+= ${WORKSPEC} 1361.1Shubertf 1371.28SmartinCDSETSENV= DESTDIR=${DESTDIR:Q} \ 1381.28Smartin MACHINE=${MACHINE:Q} \ 1391.28Smartin MACHINE_ARCH=${MACHINE_ARCH:Q} \ 1401.28Smartin AWK=${TOOL_AWK:Q} \ 1411.28Smartin CKSUM=${TOOL_CKSUM:Q} \ 1421.28Smartin DB=${TOOL_DB:Q} \ 1431.28Smartin HOST_SH=${HOST_SH:Q} \ 1441.28Smartin MAKE=${MAKE:Q} \ 1451.28Smartin MKTEMP=${TOOL_MKTEMP:Q} \ 1461.28Smartin MTREE=${TOOL_MTREE:Q} \ 1471.28Smartin PAX=${TOOL_PAX:Q} \ 1481.28Smartin COMPRESS_PROGRAM=${COMPRESS_PROGRAM:Q} \ 1491.28Smartin GZIP=${GZIP_FLAGS:Q} \ 1501.28Smartin PKG_CREATE=${TOOL_PKG_CREATE:Q} \ 1511.28Smartin SED=${TOOL_SED:Q} \ 1521.28Smartin TSORT=${TSORT:Q} \ 1531.28Smartin MKRUMP=no \ 1541.28Smartin MKCOMPAT=no \ 1551.28Smartin MKDEBUG=no \ 1561.28Smartin MKDEBUGLIB=no 1571.28Smartin 1581.28SmartinCDSETSCMD= cd ${NETBSDSRCDIR}/distrib/sets && \ 1591.28Smartin ${CDSETSENV} \ 1601.28Smartin ${HOST_SH} 1611.1Shubertf 1621.1Shubertf.include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib" 1631.1Shubertf 1641.8Sbouyer.if defined(CDINSTKERNEL) 1651.8Sbouyer_INSTKERNELNOBJDIR!= cd ${.CURDIR}/${CDINSTKERNEL} && ${PRINTOBJDIR} 1661.8Sbouyer.endif 1671.8Sbouyer.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660) 1681.8Sbouyer.if exists(${DESTDIR}/usr/mdec/boot.${MACHINE}) 1691.8SbouyerBOOT2=boot.${MACHINE} 1701.8Sbouyer.else 1711.8SbouyerBOOT2=boot 1721.8Sbouyer.endif 1731.8Sbouyer.endif 1741.1Shubertf 1751.1Shubertfprepare: 1761.36Schristos ${MKDIR} ${MKDIRPERM} "${CUROBJDIR}/cdrom" 1771.8Sbouyer.if defined(CDKERNELS) 1781.8Sbouyer.for kernel target in ${CDKERNELS} 1791.36Schristos ${INSTALL} ${COPY} -m 0644 ${_INSTKERNELNOBJDIR}/${kernel} cdrom/${target} 1801.8Sbouyer.endfor 1811.8Sbouyer.if exists(${DESTDIR}/usr/mdec/bootxx_cd9660) 1821.8Sbouyer ${RM} -f cdrom/${BOOT2} 1831.36Schristos ${INSTALL} ${COPY} -m 0644 ${DESTDIR}/usr/mdec/${BOOT2} cdrom/${BOOT2} 1841.8Sbouyer ${RM} -f bootxx.${MACHINE} 1851.36Schristos ${INSTALL} ${COPY} -m 0644 ${DESTDIR}/usr/mdec/bootxx_cd9660 bootxx.${MACHINE} 1861.8Sbouyer ${CHMOD} +w bootxx.${MACHINE} 1871.8Sbouyer.if defined(CDBOOTOPTIONS) 1881.8Sbouyer ${TOOL_INSTALLBOOT} -m${MACHINE} -e ${CDBOOTOPTIONS} bootxx.${MACHINE} 1891.8Sbouyer.endif 1901.8Sbouyer.endif 1911.8Sbouyer.endif 1921.1Shubertf 1931.24Sdsl.if ${MAKEVERBOSE} >= 2 1941.24SdslPAX_v?= -v 1951.24Sdsl.else 1961.24SdslPAX_v?= 1971.24Sdsl.endif 1981.24Sdsl 1991.1Shubertf# Copy $RELEASEDIR/${MACHINE} in the CDROM dir 2001.1Shubertf# 2011.1Shubertf# XXX This could be done a lot easier if makefs(8) could 2021.1Shubertf# XXX include more than one directory on the image - HF 2031.1Shubertf# 2041.1Shubertfcopy-releasedir: 2051.18Sjmcneill ${RM} -f ${RELEASEDIR}/${CDROMS_RELEASEDIR}/${CDIMAGE} 2061.9Schristos if ${CDRELEASE}; then \ 2071.28Smartin if [ ! -d ${RELEASEDIR}/${RELEASEMACHINEDIR} ]; then \ 2081.14Smatt echo "Missing ${RELEASEDIR}/${RELEASEMACHINEDIR}, aborting"; \ 2091.9Schristos exit 1; \ 2101.9Schristos fi; \ 2111.44Sjmcneill ${MKDIR} ${MKDIRPERM} "${CUROBJDIR}/cdrom/${RELEASEMACHINEDIR}"; \ 2121.44Sjmcneill release_destdir="${CUROBJDIR}/cdrom/${RELEASEMACHINEDIR}"; \ 2131.15Sad cd ${RELEASEDIR}/${RELEASEMACHINEDIR}; \ 2141.9Schristos echo Copying $$(pwd) to $$release_destdir ...; \ 2151.37Schristos ${TOOL_PAX} ${PAX_TIMESTAMP} \ 2161.24Sdsl -rw -pe ${PAX_v} \ 2171.7Shubertf ${CDRELEASE_EXCLUDE} \ 2181.9Schristos . $$release_destdir; \ 2191.28Smartin cd "${CUROBJDIR}"; \ 2201.9Schristos fi 2211.9Schristos if ${CDSOURCE}; then \ 2221.9Schristos if [ ! -d ${RELEASEDIR}/source ]; then \ 2231.9Schristos echo "Missing ${RELEASEDIR}/source, aborting"; \ 2241.9Schristos exit 1; \ 2251.9Schristos fi; \ 2261.36Schristos ${MKDIR} ${MKDIRPERM} "${CUROBJDIR}/cdrom/source"; \ 2271.28Smartin release_destdir="${CUROBJDIR}/cdrom/source"; \ 2281.9Schristos cd ${RELEASEDIR}/source; \ 2291.9Schristos echo Copying $$(pwd) to $$release_destdir ...; \ 2301.37Schristos ${TOOL_PAX} ${PAX_TIMESTAMP} \ 2311.24Sdsl -rw -pe ${PAX_v} \ 2321.9Schristos . $$release_destdir; \ 2331.28Smartin cd "${CUROBJDIR}"; \ 2341.1Shubertf fi 2351.28Smartin if [ "X${CDRUNTIME}" != "X" ]; then \ 2361.15Sad release_destdir=$${curdir}/cdrom; \ 2371.15Sad cd $$release_destdir; \ 2381.15Sad cd ${DESTDIR}; \ 2391.15Sad for cde in ${CDRUNTIME}; \ 2401.15Sad do \ 2411.37Schristos ${TOOL_PAX} ${PAX_TIMESTAMP} -rw -pp ${PAX_v} \ 2421.37Schristos $${cde} $$release_destdir; \ 2431.15Sad done; \ 2441.28Smartin cd "${CUROBJDIR}"; \ 2451.15Sad fi 2461.13Ssborrill if [ "X${CDEXTRA}${CDBUILDEXTRA}" != "X" ]; then \ 2471.13Ssborrill skipflag=""; \ 2481.16Shubertf cdextra_skip="${CDEXTRA_SKIP}"; \ 2491.16Shubertf if [ "X$${cdextra_skip}" != "X" ]; then \ 2501.13Ssborrill rm -f cdskip; \ 2511.16Shubertf for skip in $${cdextra_skip}; \ 2521.13Ssborrill do \ 2531.13Ssborrill echo $${skip} >> cdskip; \ 2541.13Ssborrill done; \ 2551.28Smartin skipflag="-X ${CUROBJDIR:Q}/cdskip"; \ 2561.13Ssborrill fi; \ 2571.16Shubertf cdextra="${CDEXTRA}"; \ 2581.16Shubertf cdbuildextra="${CDBUILDEXTRA}"; \ 2591.16Shubertf for cde in $${cdextra} $${cdbuildextra}; \ 2601.13Ssborrill do \ 2611.28Smartin release_destdir="${CUROBJDIR}/cdrom"; \ 2621.13Ssborrill if [ -f $${cde} ]; then \ 2631.13Ssborrill echo Copying $${cde} to $$release_destdir ...; \ 2641.38Schristos ${INSTALL} ${COPY} -m 0644 $${cde} $${release_destdir}; \ 2651.13Ssborrill elif [ -d $${cde} ]; then \ 2661.13Ssborrill cd $${cde}; \ 2671.13Ssborrill echo Copying $$(pwd) to $$release_destdir ...; \ 2681.13Ssborrill ${TOOL_MTREE} -c $${skipflag} | \ 2691.37Schristos ${TOOL_PAX} ${PAX_TIMESTAMP} \ 2701.37Schristos -rw -pe ${PAX_v} \ 2711.37Schristos -M $$release_destdir; \ 2721.13Ssborrill else \ 2731.13Ssborrill echo "Missing $${cde}, aborting"; \ 2741.13Ssborrill exit 1; \ 2751.13Ssborrill fi; \ 2761.28Smartin cd "${CUROBJDIR}"; \ 2771.13Ssborrill done; \ 2781.11Sjnemeth fi 2791.28Smartin.if !empty(CD_SETS) 2801.36Schristos ${MKDIR} ${MKDIRPERM} "${CUROBJDIR}/cdrom/etc/mtree" 2811.28Smartin.for set in ${CD_SETS} 2821.28Smartin if [ -f ${CUROBJDIR:Q}/cdrom/etc/mtree/set.${set} ]; then \ 2831.28Smartin ${CHMOD} +w ${CUROBJDIR:Q}/cdrom/etc/mtree/set.${set}; \ 2841.28Smartin fi; \ 2851.28Smartin ${CDSETSCMD} ./maketars -i "${CUROBJDIR}/cdrom" \ 2861.29Smartin ${CD_METALOG.unpriv} ${mtunpriv} -N ${NETBSDSRCDIR}/etc \ 2871.28Smartin -F "${CUROBJDIR}/cdrom/etc/mtree" \ 2881.28Smartin -d "${DESTDIR:S,^$,/,}" ${set} 2891.28Smartin.endfor 2901.28Smartin if [ -d "${CUROBJDIR}/cdrom/var/spool/ftp/hidden" ]; then \ 2911.28Smartin ${CHMOD} +r "${CUROBJDIR}/cdrom/var/spool/ftp/hidden"; \ 2921.28Smartin fi 2931.28Smartin.endif 2941.1Shubertf 2951.43Smartin.if ${CDDEV_POPULATE} != true 2961.43SmartinDELDEV=-e '/^\.\/dev\/.*type=char/d' 2971.43Smartin.endif 2981.43Smartin 2991.1Shubertfimage: 3001.28Smartin @echo Preparing spec files for makefs... 3011.28Smartin ${RM} -f ${WORKSPEC} 3021.31Smartin if [ -d cdrom/etc/mtree ]; then \ 3031.31Smartin cat cdrom/etc/mtree/* | \ 3041.31Smartin ${TOOL_SED} -e 's/ size=[0-9]*//' \ 3051.43Smartin ${DELDEV} \ 3061.31Smartin -e '/^\.\/etc\/gettytab/d' > ${WORKSPEC}; \ 3071.31Smartin fi 3081.43Smartin if [ -r cdrom/dev/MAKEDEV ] && \ 3091.43Smartin ${CDDEV_POPULATE} == true; then \ 3101.32Smartin ${HOST_SH} cdrom/dev/MAKEDEV -s init | \ 3111.31Smartin ${TOOL_SED} -e '/^\. type=dir/d' \ 3121.31Smartin -e 's,^\.,./dev,' >> ${WORKSPEC}; \ 3131.31Smartin fi 3141.28Smartin.if defined(SPEC_IN) 3151.28Smartin cat ${SPEC_IN} >> ${WORKSPEC} 3161.28Smartin.endif 3171.28Smartin.if defined(SECONDARY_BOOT) 3181.28Smartin echo "./${SECONDARY_BOOT} type=file uname=root gname=wheel mode=0444" \ 3191.28Smartin >> ${WORKSPEC} 3201.28Smartin.endif 3211.28Smartin.if defined(SPEC_EXTRA) 3221.28Smartin cat ${SPEC_EXTRA} >> ${WORKSPEC} 3231.28Smartin.endif 3241.31Smartin if [ -s ${WORKSPEC} ]; then specarg="-F ${WORKSPEC}"; fi; \ 3251.31Smartin ${TOOL_MAKEFS} -N ${NETBSDSRCDIR}/etc -t cd9660 $${specarg} \ 3261.34Schristos ${MAKEFS_TIMESTAMP} ${CDMAKEFSEXTRAOPTS} -o ${_CDMAKEFSOPTIONS:Q} ${CDIMAGE} cdrom 3271.8Sbouyer 3281.8Sbouyer.if ${CDRELEASE} == false 3291.15Sadrelease: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post 3301.36Schristos ${MKDIR} ${MKDIRPERM} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 3311.18Sjmcneill ${RELEASE_INSTALL} ${CDIMAGE} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 3321.1Shubertf 3331.8Sbouyeriso_image: 3341.8Sbouyer.else 3351.1Shubertfrelease: 3361.8Sbouyer 3371.15Sadiso_image: prepare .WAIT prepare_md_post .WAIT copy-releasedir .WAIT image_md_pre .WAIT image .WAIT image_md_post 3381.36Schristos ${MKDIR} ${MKDIRPERM} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 3391.18Sjmcneill ${RELEASE_INSTALL} ${CDIMAGE} ${RELEASEDIR}/${CDROMS_RELEASEDIR} 3401.8Sbouyer.endif 3411.1Shubertf 3421.1Shubertfclean: 3431.28Smartin @if [ -d cdrom/var/spool/ftp/hidden ]; then \ 3441.28Smartin ${CHMOD} +r cdrom/var/spool/ftp/hidden; \ 3451.28Smartin fi # XXX 3461.1Shubertf ${RM} -fr cdrom 3471.1Shubertf 3481.8Sbouyerprepare_md_post: .PHONY 3491.8Sbouyerimage_md_post: .PHONY 3501.15Sadimage_md_pre: .PHONY 3511.8Sbouyer 3521.1Shubertf.include <bsd.prog.mk> 353