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 82.endif 83 84.if !defined(VOLUME_LABEL) || empty(VOLUME_LABEL) 85VOLUME_LABEL= FreeBSD_Install 86.endif 87 88.if !exists(${PORTSDIR}) 89NOPORTS= true 90.endif 91 92DISTRIBUTIONS= base.txz kernel.txz 93.if !defined(NOPORTS) 94DISTRIBUTIONS+= ports.txz 95.endif 96.if !defined(NOSRC) 97DISTRIBUTIONS+= src.txz 98.endif 99 100RELEASE_TARGETS= ftp 101IMAGES= 102.if exists(${.CURDIR}/${TARGET}/mkisoimages.sh) 103RELEASE_TARGETS+= cdrom 104IMAGES+= disc1.iso bootonly.iso 105. if defined(WITH_DVD) && !empty(WITH_DVD) 106RELEASE_TARGETS+= dvdrom 107IMAGES+= dvd1.iso 108. endif 109.endif 110.if exists(${.CURDIR}/${TARGET}/make-memstick.sh) 111RELEASE_TARGETS+= memstick.img 112RELEASE_TARGETS+= mini-memstick.img 113IMAGES+= memstick.img 114IMAGES+= mini-memstick.img 115.endif 116 117CLEANFILES= packagesystem *.txz MANIFEST release ${IMAGES} 118.if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES) 119. for I in ${IMAGES} 120CLEANFILES+= ${I}.xz 121. endfor 122.endif 123.if defined(WITH_DVD) && !empty(WITH_DVD) 124CLEANFILES+= pkg-stage 125.endif 126CLEANDIRS= dist ftp disc1 disc1-disc1 disc1-memstick bootonly bootonly-bootonly bootonly-memstick dvd 127beforeclean: 128 chflags -R noschg . 129.include <bsd.obj.mk> 130clean: beforeclean 131 132base.txz: 133 mkdir -p ${DISTDIR} 134 ( cd ${WORLDDIR} && ${IMAKE} distributeworld DISTDIR=${.OBJDIR}/${DISTDIR} ) 135 # Bootstrap etcupdate(8) database. 136 sh ${WORLDDIR}/usr.sbin/etcupdate/etcupdate.sh extract -B \ 137 -m "${MAKE}" -M "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" \ 138 -s ${WORLDDIR} -d "${.OBJDIR}/${DISTDIR}/base/var/db/etcupdate" \ 139 -L /dev/null ${NO_ROOT:D-N} 140.if defined(NO_ROOT) 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.endif 146# Package all components 147 ( cd ${WORLDDIR} && ${IMAKE} packageworld DISTDIR=${.OBJDIR}/${DISTDIR} ) 148 mv ${DISTDIR}/*.txz . 149 150kernel.txz: 151 mkdir -p ${DISTDIR} 152 ( cd ${WORLDDIR} && ${IMAKE} distributekernel DISTDIR=${.OBJDIR}/${DISTDIR} ) 153 ( cd ${WORLDDIR} && ${IMAKE} packagekernel DISTDIR=${.OBJDIR}/${DISTDIR} ) 154 mv ${DISTDIR}/kernel*.txz . 155 156src.txz: 157 mkdir -p ${DISTDIR}/usr 158 ln -fs ${WORLDDIR} ${DISTDIR}/usr/src 159 ( cd ${DISTDIR} && ${TAR_CMD} cLvf - --exclude .svn --exclude .zfs \ 160 --exclude .git --exclude @ --exclude usr/src/release/dist usr/src | \ 161 ${XZ_CMD} > ${.OBJDIR}/src.txz ) 162 163ports.txz: 164 mkdir -p ${DISTDIR}/usr 165 ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports 166 ( cd ${DISTDIR} && ${TAR_CMD} cLvf - \ 167 --exclude .git --exclude .svn \ 168 --exclude usr/ports/distfiles --exclude usr/ports/packages \ 169 --exclude 'usr/ports/INDEX*' --exclude work usr/ports | \ 170 ${XZ_CMD} > ${.OBJDIR}/ports.txz ) 171 172disc1: packagesystem 173# Install system 174 mkdir -p ${.TARGET} 175 ( cd ${WORLDDIR} && ${IMAKE} installworld installkernel distribution \ 176 DESTDIR=${.OBJDIR}/${.TARGET} MK_AT=no \ 177 MK_INSTALLLIB=no MK_MAIL=no \ 178 ${_ALL_LIBCOMPATS:@v@MK_LIB$v=no@} \ 179 MK_TOOLCHAIN=no \ 180 MK_RESCUE=no MK_DICT=no \ 181 MK_KERNEL_SYMBOLS=no MK_TESTS=no MK_DEBUG_FILES=no \ 182 -DDB_FROM_SRC ) 183# Copy distfiles 184 mkdir -p ${.TARGET}/usr/freebsd-dist 185 for dist in MANIFEST $$(ls *.txz | grep -v container | grep -vE -- '(${base ${_ALL_libcompats}:L:ts|})-dbg'); \ 186 do cp $${dist} ${.TARGET}/usr/freebsd-dist; \ 187 done 188.if defined(NO_ROOT) 189 echo "./usr/freebsd-dist type=dir uname=root gname=wheel mode=0755" >> ${.TARGET}/METALOG 190 for dist in MANIFEST $$(ls *.txz | grep -v container | grep -vE -- '(${base ${_ALL_libcompats}:L:ts|})-dbg'); \ 191 do echo "./usr/freebsd-dist/$${dist} type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG; \ 192 done 193.endif 194.if ${.MAKE.OS} == "FreeBSD" && (!defined(NOPKG) || empty(NOPKG)) 195# Install packages onto release media. 196 ${PKG_INSTALL} wifi-firmware-kmod-release || 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.endif 274# Set up installation environment 275 ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf 276 echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf 277 echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf 278 echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf 279 echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf 280 echo kernels_autodetect=\"NO\" >> ${.TARGET}/boot/loader.conf 281 echo loader_menu_multi_user_prompt=\"Installer\" >> ${.TARGET}/boot/loader.conf 282 cp ${.CURDIR}/rc.local ${.TARGET}/etc 283.if defined(NO_ROOT) 284 echo "./etc/resolv.conf type=link uname=root gname=wheel mode=0644 link=/tmp/bsdinstall_etc/resolv.conf" >> ${.TARGET}/METALOG 285 echo "./etc/rc.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG 286 echo "./etc/sysctl.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG 287 echo "./boot/loader.conf type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG 288 echo "./etc/rc.local type=file uname=root gname=wheel mode=0644" >> ${.TARGET}/METALOG 289.endif 290 touch ${.TARGET} 291 292disc1-disc1 disc1-memstick: disc1 293 mkdir ${.TARGET} 294 tar -cf- -C disc1 . | tar -xf- -C ${.TARGET} 295 296bootonly-bootonly bootonly-memstick: bootonly 297 mkdir ${.TARGET} 298 tar -cf- -C bootonly . | tar -xf- -C ${.TARGET} 299 300release.iso: disc1.iso 301disc1.iso: disc1-disc1 302 cd disc1-disc1 && sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_CD ../${.TARGET} .${NO_ROOT:D/METALOG} ${XTRADIR} 303 304dvd1.iso: dvd pkg-stage 305 cd dvd && sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_DVD ../${.TARGET} .${NO_ROOT:D/METALOG} ${XTRADIR} 306 307bootonly.iso: bootonly-bootonly 308 cd bootonly-bootonly && sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_BO ../${.TARGET} .${NO_ROOT:D/METALOG} ${XTRADIR} 309 310memstick: memstick.img 311memstick.img: disc1-memstick 312 cd disc1-memstick && sh ${.CURDIR}/${TARGET}/make-memstick.sh .${NO_ROOT:D/METALOG} ../${.TARGET} 313 314mini-memstick: mini-memstick.img 315mini-memstick.img: bootonly-memstick 316 cd bootonly-memstick && sh ${.CURDIR}/${TARGET}/make-memstick.sh .${NO_ROOT:D/METALOG} ../${.TARGET} 317 318packagesystem: ${DISTRIBUTIONS} 319 sh ${.CURDIR}/scripts/make-manifest.sh $$(ls *.txz | grep -v container) > MANIFEST 320 touch ${.TARGET} 321 322pkg-stage: dvd 323# TODO: Support for -DNO_ROOT 324.if !defined(NOPKG) || empty(NOPKG) 325 env PORTSDIR=${PORTSDIR} REPOS_DIR=${.CURDIR}/pkg_repos/ \ 326 sh ${.CURDIR}/scripts/pkg-stage.sh 327 mkdir -p ${.OBJDIR}/dvd/packages/repos/ 328 cp ${.CURDIR}/scripts/FreeBSD_install_cdrom.conf \ 329 ${.OBJDIR}/dvd/packages/repos/ 330.endif 331 touch ${.TARGET} 332 333cdrom: disc1.iso bootonly.iso 334dvdrom: dvd1.iso 335ftp: packagesystem 336 rm -rf ftp 337 mkdir -p ftp 338 cp *.txz MANIFEST ftp 339 rm -f ftp/container-*.txz 340 341release: real-release vm-release cloudware-release oci-release 342 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} release-done 343 true 344 345release-done: 346 touch release 347 348real-release: 349 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj 350 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS} 351 352install: release-install vm-install oci-install .WAIT cloud-install 353 354release-install: 355.if defined(DESTDIR) && !empty(DESTDIR) 356 mkdir -p ${DESTDIR} 357.endif 358 cp -a ftp ${DESTDIR}/ 359.if !empty(IMAGES) 360.for I in ${IMAGES} 361 cp -p ${I} ${DESTDIR}/${OSRELEASE}-${I} 362. if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES) 363 ${XZ_CMD} -k ${DESTDIR}/${OSRELEASE}-${I} 364. endif 365.endfor 366 ( cd ${DESTDIR} && sha512 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA512 ) 367 ( cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256 ) 368.endif 369 370.include "${.CURDIR}/Makefile.inc1" 371.include "${.CURDIR}/Makefile.vm" 372.include "${.CURDIR}/Makefile.oci" 373