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