1# 2# Makefile for building releases and release media. 3# 4# User-driven targets: 5# cdrom: Builds release CD-ROM media (disc1.iso) 6# dvdrom: Builds release DVD-ROM media (dvd1.iso) 7# memstick: Builds memory stick image (memstick.img) 8# mini-memstick: Builds minimal memory stick image (mini-memstick.img) 9# ftp: Sets up FTP distribution area (ftp) 10# release: Invokes real-release, vm-release, cloudware-release and oci-release targets 11# real-release: Build all media and FTP distribution area 12# vm-release: Build all virtual machine image targets 13# cloudware-release: Build all cloud hosting provider targets 14# oci-release: Build all OCI container images 15# install: Invokes the release-install, vm-install and oci-install targets 16# release-install: Copies all release installation media into ${DESTDIR} 17# vm-install: Copies all virtual machine images into ${DESTDIR} 18# cloud-install: Copies non-uploaded cloud images into ${DESTDIR} 19# oci-install: Copies all OCI container images into ${DESTDIR} 20# 21# Variables affecting the build process: 22# WORLDDIR: location of src tree -- must have built world and default kernel 23# (by default, the directory above this one) 24# PORTSDIR: location of ports tree to distribute (default: /usr/ports) 25# XTRADIR: xtra-bits-dir argument for <arch>/mkisoimages.sh 26# NOPKG: if set, do not distribute third-party packages 27# NOPORTS: if set, do not distribute ports tree 28# NOSRC: if set, do not distribute source tree 29# WITH_DVD: if set, generate dvd1.iso 30# WITH_COMPRESSED_IMAGES: if set, compress installation images with xz(1) 31# (uncompressed images are not removed) 32# WITH_VMIMAGES: if set, build virtual machine images with the release 33# WITH_COMPRESSED_VMIMAGES: if set, compress virtual machine disk images 34# with xz(1) (extremely time consuming) 35# WITH_CLOUDWARE: if set, build cloud hosting disk images with the release 36# TARGET/TARGET_ARCH: architecture of built release 37# 38 39WORLDDIR?= ${.CURDIR}/.. 40PORTSDIR?= /usr/ports 41 42.include "${WORLDDIR}/share/mk/bsd.compat.pre.mk" 43 44.if !defined(TARGET) || empty(TARGET) 45TARGET= ${MACHINE} 46.endif 47.if !defined(TARGET_ARCH) || empty(TARGET_ARCH) 48.if ${TARGET} == ${MACHINE} 49TARGET_ARCH= ${MACHINE_ARCH} 50.else 51TARGET_ARCH= ${TARGET} 52.endif 53.endif 54IMAKE= ${MAKE} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET} 55DISTDIR= dist 56 57# Define OSRELEASE by using newvers.sh 58.if !defined(OSRELEASE) || empty(OSRELEASE) 59.for _V in TYPE BRANCH REVISION 60${_V}!= eval $$(awk '/^${_V}=/{print}' ${.CURDIR}/../sys/conf/newvers.sh); echo $$${_V} 61.endfor 62.for _V in ${TARGET_ARCH} 63.if !empty(TARGET:M${_V}) 64OSRELEASE= ${TYPE}-${REVISION}-${BRANCH}-${TARGET} 65VOLUME_LABEL= ${REVISION:C/[.-]/_/g}_${BRANCH:C/[.-]/_/g}_${TARGET} 66.else 67OSRELEASE= ${TYPE}-${REVISION}-${BRANCH}-${TARGET}-${TARGET_ARCH} 68VOLUME_LABEL= ${REVISION:C/[.-]/_/g}_${BRANCH:C/[.-]/_/g}_${TARGET_ARCH} 69.endif 70.endfor 71.endif 72 73.if ${.MAKE.OS} == "FreeBSD" 74# For installing packages into the release media. 75.if defined(NO_ROOT) 76PKG_ENV+= INSTALL_AS_USER=yes 77PKG_ARGS+= -o METALOG=METALOG 78.endif 79PKG_ENV+= ASSUME_ALWAYS_YES=yes 80PKG_ARGS+= -r ${.TARGET} -o REPOS_DIR=${.CURDIR}/pkg_repos 81PKG_INSTALL= env ${PKG_ENV} ${PKG_CMD} ${PKG_ARGS} install 82PKG_CLEAN= env ${PKG_ENV} ${PKG_CMD} ${PKG_ARGS} clean -a 83.endif 84 85.if !defined(VOLUME_LABEL) || empty(VOLUME_LABEL) 86VOLUME_LABEL= FreeBSD_Install 87.endif 88 89.if !exists(${PORTSDIR}) 90NOPORTS= true 91.endif 92 93DISTRIBUTIONS= base.txz kernel.txz 94.if !defined(NOPORTS) 95DISTRIBUTIONS+= ports.txz 96.endif 97.if !defined(NOSRC) 98DISTRIBUTIONS+= src.txz 99.endif 100 101RELEASE_TARGETS= ftp 102IMAGES= 103.if exists(${.CURDIR}/${TARGET}/mkisoimages.sh) 104RELEASE_TARGETS+= cdrom 105IMAGES+= disc1.iso bootonly.iso 106. if defined(WITH_DVD) && !empty(WITH_DVD) 107RELEASE_TARGETS+= dvdrom 108IMAGES+= dvd1.iso 109. endif 110.endif 111.if exists(${.CURDIR}/${TARGET}/make-memstick.sh) 112RELEASE_TARGETS+= memstick.img 113RELEASE_TARGETS+= mini-memstick.img 114IMAGES+= memstick.img 115IMAGES+= mini-memstick.img 116.endif 117 118CLEANFILES= packagesystem *.txz MANIFEST release ${IMAGES} 119.if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES) 120. for I in ${IMAGES} 121CLEANFILES+= ${I}.xz 122. endfor 123.endif 124.if defined(WITH_DVD) && !empty(WITH_DVD) 125CLEANFILES+= pkg-stage 126.endif 127CLEANDIRS= dist ftp disc1 disc1-disc1 disc1-memstick bootonly bootonly-bootonly bootonly-memstick dvd 128beforeclean: 129 chflags -R noschg . 130.include <bsd.obj.mk> 131clean: beforeclean 132 133base.txz: 134 mkdir -p ${DISTDIR} 135 ( cd ${WORLDDIR} && ${IMAKE} -DNO_ROOT distributeworld DISTDIR=${.OBJDIR}/${DISTDIR} ) 136 # Bootstrap etcupdate(8) database. 137 sh ${WORLDDIR}/usr.sbin/etcupdate/etcupdate.sh extract -B \ 138 -m "${MAKE}" -M "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" \ 139 -s ${WORLDDIR} -d "${.OBJDIR}/${DISTDIR}/base/var/db/etcupdate" \ 140 -L /dev/null -N 141 echo "./var/db/etcupdate type=dir uname=root gname=wheel mode=0755" >> ${.OBJDIR}/${DISTDIR}/base.meta 142 sed -n 's,^\.,./var/db/etcupdate/current,p' ${.OBJDIR}/${DISTDIR}/base/var/db/etcupdate/current/METALOG \ 143 >> ${.OBJDIR}/${DISTDIR}/base.meta 144 rm ${.OBJDIR}/${DISTDIR}/base/var/db/etcupdate/current/METALOG 145# Package all components 146 ( cd ${WORLDDIR} && ${IMAKE} -DNO_ROOT packageworld DISTDIR=${.OBJDIR}/${DISTDIR} ) 147 mv ${DISTDIR}/*.txz . 148 149kernel.txz: 150 mkdir -p ${DISTDIR} 151 ( cd ${WORLDDIR} && ${IMAKE} -DNO_ROOT distributekernel DISTDIR=${.OBJDIR}/${DISTDIR} ) 152 ( cd ${WORLDDIR} && ${IMAKE} -DNO_ROOT packagekernel DISTDIR=${.OBJDIR}/${DISTDIR} ) 153 mv ${DISTDIR}/kernel*.txz . 154 155src.txz: 156 mkdir -p ${DISTDIR}/usr 157 ln -fs ${WORLDDIR} ${DISTDIR}/usr/src 158 ( cd ${DISTDIR} && ${TAR_CMD} cLvf - --exclude .svn --exclude .zfs \ 159 --exclude .git --exclude @ --exclude usr/src/release/dist usr/src | \ 160 ${XZ_CMD} > ${.OBJDIR}/src.txz ) 161 162ports.txz: 163 mkdir -p ${DISTDIR}/usr 164 ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports 165 ( cd ${DISTDIR} && ${TAR_CMD} cLvf - \ 166 --exclude .git --exclude .svn \ 167 --exclude usr/ports/distfiles --exclude usr/ports/packages \ 168 --exclude 'usr/ports/INDEX*' --exclude work usr/ports | \ 169 ${XZ_CMD} > ${.OBJDIR}/ports.txz ) 170 171disc1: packagesystem 172# Install system 173 mkdir -p ${.TARGET} 174 ( cd ${WORLDDIR} && ${IMAKE} installworld installkernel distribution \ 175 DESTDIR=${.OBJDIR}/${.TARGET} MK_AT=no \ 176 MK_INSTALLLIB=no MK_MAIL=no \ 177 ${_ALL_LIBCOMPATS:@v@MK_LIB$v=no@} \ 178 MK_TOOLCHAIN=no \ 179 MK_RESCUE=no MK_DICT=no \ 180 MK_KERNEL_SYMBOLS=no MK_TESTS=no MK_DEBUG_FILES=no \ 181 -DDB_FROM_SRC ) 182# Copy distfiles 183 mkdir -p ${.TARGET}/usr/freebsd-dist 184 for dist in MANIFEST $$(ls *.txz | grep -v container | grep -vE -- '(${base ${_ALL_libcompats}:L:ts|})-dbg'); \ 185 do cp $${dist} ${.TARGET}/usr/freebsd-dist; \ 186 done 187.if defined(NO_ROOT) 188 echo "./usr/freebsd-dist type=dir uname=root gname=wheel mode=0755" >> ${.TARGET}/METALOG 189 for dist in MANIFEST $$(ls *.txz | grep -v container | grep -vE -- '(${base ${_ALL_libcompats}:L:ts|})-dbg'); \ 190 do echo "./usr/freebsd-dist/$${dist} type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG; \ 191 done 192.endif 193.if ${.MAKE.OS} == "FreeBSD" && (!defined(NOPKG) || empty(NOPKG)) 194# Install packages onto release media. 195 ${PKG_INSTALL} wifi-firmware-kmod-release || true 196 ${PKG_CLEAN} || true 197.endif 198# Set up installation environment 199 ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf 200 echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf 201 echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf 202 echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf 203 echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf 204 echo kernels_autodetect=\"NO\" >> ${.TARGET}/boot/loader.conf 205 echo loader_menu_multi_user_prompt=\"Installer\" >> ${.TARGET}/boot/loader.conf 206 cp ${.CURDIR}/rc.local ${.TARGET}/etc 207.if defined(NO_ROOT) 208 echo "./etc/resolv.conf type=link uname=root gname=wheel mode=0644 link=/tmp/bsdinstall_etc/resolv.conf" >> ${.TARGET}/METALOG 209 echo "./etc/rc.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG 210 echo "./etc/sysctl.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG 211 echo "./boot/loader.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG 212 echo "./etc/rc.local type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG 213.endif 214 touch ${.TARGET} 215 216bootonly: packagesystem 217# Install system 218 mkdir -p ${.TARGET} 219 ( cd ${WORLDDIR} && ${IMAKE} installworld installkernel distribution \ 220 DESTDIR=${.OBJDIR}/${.TARGET} MK_AT=no \ 221 MK_GAMES=no \ 222 MK_INSTALLLIB=no MK_MAIL=no \ 223 ${_ALL_LIBCOMPATS:@v@MK_LIB$v=no@} \ 224 MK_TOOLCHAIN=no \ 225 MK_RESCUE=no MK_DICT=no \ 226 MK_KERNEL_SYMBOLS=no MK_TESTS=no MK_DEBUG_FILES=no \ 227 -DDB_FROM_SRC ) 228# Copy manifest only (no distfiles) to get checksums 229 mkdir -p ${.TARGET}/usr/freebsd-dist 230 cp MANIFEST ${.TARGET}/usr/freebsd-dist 231.if defined(NO_ROOT) 232 echo "./usr/freebsd-dist type=dir uname=root gname=wheel mode=0755" >> ${.TARGET}/METALOG 233 echo "./usr/freebsd-dist/MANIFEST type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG 234.endif 235# Set up installation environment 236 ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf 237 echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf 238 echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf 239 echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf 240 echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf 241 echo kernels_autodetect=\"NO\" >> ${.TARGET}/boot/loader.conf 242 echo loader_menu_multi_user_prompt=\"Installer\" >> ${.TARGET}/boot/loader.conf 243 cp ${.CURDIR}/rc.local ${.TARGET}/etc 244.if defined(NO_ROOT) 245 echo "./etc/resolv.conf type=link uname=root gname=wheel mode=0644 link=/tmp/bsdinstall_etc/resolv.conf" >> ${.TARGET}/METALOG 246 echo "./etc/rc.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG 247 echo "./etc/sysctl.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG 248 echo "./boot/loader.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG 249 echo "./etc/rc.local type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG 250.endif 251 252dvd: packagesystem 253# Install system 254 mkdir -p ${.TARGET} 255 ( cd ${WORLDDIR} && ${IMAKE} installworld installkernel distribution \ 256 DESTDIR=${.OBJDIR}/${.TARGET} MK_RESCUE=no MK_KERNEL_SYMBOLS=no \ 257 MK_TESTS=no MK_DEBUG_FILES=no \ 258 -DDB_FROM_SRC ) 259# Copy distfiles 260 mkdir -p ${.TARGET}/usr/freebsd-dist 261 for dist in MANIFEST $$(ls *.txz | grep -v container); \ 262 do cp $${dist} ${.TARGET}/usr/freebsd-dist; \ 263 done 264.if defined(NO_ROOT) 265 echo "./usr/freebsd-dist type=dir uname=root gname=wheel mode=0755" >> ${.TARGET}/METALOG 266 for dist in MANIFEST $$(ls *.txz | grep -v container); \ 267 do echo "./usr/freebsd-dist/$${dist} type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG; \ 268 done 269.endif 270.if ${.MAKE.OS} == "FreeBSD" && (!defined(NOPKG) || empty(NOPKG)) 271# Install packages onto release media. 272 ${PKG_INSTALL} wifi-firmware-kmod-release || true 273 ${PKG_CLEAN} || true 274.endif 275# Set up installation environment 276 ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf 277 echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf 278 echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf 279 echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf 280 echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf 281 echo kernels_autodetect=\"NO\" >> ${.TARGET}/boot/loader.conf 282 echo loader_menu_multi_user_prompt=\"Installer\" >> ${.TARGET}/boot/loader.conf 283 cp ${.CURDIR}/rc.local ${.TARGET}/etc 284.if defined(NO_ROOT) 285 echo "./etc/resolv.conf type=link uname=root gname=wheel mode=0644 link=/tmp/bsdinstall_etc/resolv.conf" >> ${.TARGET}/METALOG 286 echo "./etc/rc.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG 287 echo "./etc/sysctl.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG 288 echo "./boot/loader.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG 289 echo "./etc/rc.local type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG 290.endif 291 touch ${.TARGET} 292 293disc1-disc1 disc1-memstick: disc1 294 mkdir ${.TARGET} 295 tar -cf- -C disc1 . | tar -xf- -C ${.TARGET} 296 297bootonly-bootonly bootonly-memstick: bootonly 298 mkdir ${.TARGET} 299 tar -cf- -C bootonly . | tar -xf- -C ${.TARGET} 300 301release.iso: disc1.iso 302disc1.iso: disc1-disc1 303 cd disc1-disc1 && sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_CD ../${.TARGET} .${NO_ROOT:D/METALOG} ${XTRADIR} 304 305dvd1.iso: dvd pkg-stage 306 cd dvd && sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_DVD ../${.TARGET} .${NO_ROOT:D/METALOG} ${XTRADIR} 307 308bootonly.iso: bootonly-bootonly 309 cd bootonly-bootonly && sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_BO ../${.TARGET} .${NO_ROOT:D/METALOG} ${XTRADIR} 310 311memstick: memstick.img 312memstick.img: disc1-memstick 313 cd disc1-memstick && sh ${.CURDIR}/${TARGET}/make-memstick.sh .${NO_ROOT:D/METALOG} ../${.TARGET} 314 315mini-memstick: mini-memstick.img 316mini-memstick.img: bootonly-memstick 317 cd bootonly-memstick && sh ${.CURDIR}/${TARGET}/make-memstick.sh .${NO_ROOT:D/METALOG} ../${.TARGET} 318 319packagesystem: ${DISTRIBUTIONS} 320 sh ${.CURDIR}/scripts/make-manifest.sh $$(ls *.txz | grep -v container) > MANIFEST 321 touch ${.TARGET} 322 323pkg-stage: dvd 324# TODO: Support for -DNO_ROOT 325.if !defined(NOPKG) || empty(NOPKG) 326 env PORTSDIR=${PORTSDIR} REPOS_DIR=${.CURDIR}/pkg_repos/ \ 327 sh ${.CURDIR}/scripts/pkg-stage.sh 328 mkdir -p ${.OBJDIR}/dvd/packages/repos/ 329 cp ${.CURDIR}/scripts/FreeBSD_install_cdrom.conf \ 330 ${.OBJDIR}/dvd/packages/repos/ 331.endif 332 touch ${.TARGET} 333 334cdrom: disc1.iso bootonly.iso 335dvdrom: dvd1.iso 336ftp: packagesystem 337 rm -rf ftp 338 mkdir -p ftp 339 cp *.txz MANIFEST ftp 340 rm -f ftp/container-*.txz 341 342release: real-release vm-release cloudware-release oci-release 343 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} release-done 344 true 345 346release-done: 347 touch release 348 349real-release: 350 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj 351 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS} 352 353install: release-install vm-install oci-install .WAIT cloud-install 354 355release-install: 356.if defined(DESTDIR) && !empty(DESTDIR) 357 mkdir -p ${DESTDIR} 358.endif 359 cp -a ftp ${DESTDIR}/ 360.if !empty(IMAGES) 361.for I in ${IMAGES} 362 cp -p ${I} ${DESTDIR}/${OSRELEASE}-${I} 363. if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES) 364 ${XZ_CMD} -k ${DESTDIR}/${OSRELEASE}-${I} 365. endif 366.endfor 367 ( cd ${DESTDIR} && sha512 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA512 ) 368 ( cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256 ) 369.endif 370 371.include "${.CURDIR}/Makefile.inc1" 372.include "${.CURDIR}/Makefile.vm" 373.include "${.CURDIR}/Makefile.oci" 374