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# DOCDIR: location of doc tree (default: /usr/doc) 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# NODOC: if set, do not generate release documentation 28# WITH_DVD: if set, generate dvd1.iso 29# WITH_COMPRESSED_IMAGES: if set, compress installation images with xz(1) 30# (uncompressed images are not removed) 31# WITH_VMIMAGES: if set, build virtual machine images with the release 32# WITH_COMPRESSED_VMIMAGES: if set, compress virtual machine disk images 33# with xz(1) (extremely time consuming) 34# WITH_CLOUDWARE: if set, build cloud hosting disk images with the release 35# TARGET/TARGET_ARCH: architecture of built release 36# 37 38WORLDDIR?= ${.CURDIR}/.. 39PORTSDIR?= /usr/ports 40DOCDIR?= /usr/doc 41RELNOTES_LANG?= en_US.ISO8859-1 42XZCMD?= /usr/bin/xz 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 newvars.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 !defined(VOLUME_LABEL) || empty(VOLUME_LABEL) 74VOLUME_LABEL= FreeBSD_Install 75.endif 76 77.if !exists(${DOCDIR}) 78NODOC= true 79.endif 80.if !exists(${PORTSDIR}) 81NOPORTS= true 82.endif 83 84EXTRA_PACKAGES= 85.if !defined(NOPORTS) 86EXTRA_PACKAGES+= ports.txz 87.endif 88.if !defined(NOSRC) 89EXTRA_PACKAGES+= src.txz 90.endif 91.if !defined(NODOC) 92EXTRA_PACKAGES+= reldoc 93.endif 94 95RELEASE_TARGETS= ftp 96IMAGES= 97.if exists(${.CURDIR}/${TARGET}/mkisoimages.sh) 98RELEASE_TARGETS+= cdrom 99IMAGES+= disc1.iso bootonly.iso 100. if defined(WITH_DVD) && !empty(WITH_DVD) 101RELEASE_TARGETS+= dvdrom 102IMAGES+= dvd1.iso 103. endif 104.endif 105.if exists(${.CURDIR}/${TARGET}/make-memstick.sh) 106RELEASE_TARGETS+= memstick.img 107RELEASE_TARGETS+= mini-memstick.img 108IMAGES+= memstick.img 109IMAGES+= mini-memstick.img 110.endif 111 112CLEANFILES= packagesystem *.txz MANIFEST system ${IMAGES} 113.if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES) 114. for I in ${IMAGES} 115CLEANFILES+= ${I}.xz 116. endfor 117.endif 118.if defined(WITH_DVD) && !empty(WITH_DVD) 119CLEANFILES+= pkg-stage 120.endif 121CLEANDIRS= dist ftp release bootonly dvd 122beforeclean: 123 chflags -R noschg . 124.include <bsd.obj.mk> 125clean: beforeclean 126 127base.txz: 128 mkdir -p ${DISTDIR} 129 cd ${WORLDDIR} && ${IMAKE} distributeworld DISTDIR=${.OBJDIR}/${DISTDIR} 130# Set up mergemaster root database 131 sh ${.CURDIR}/scripts/mm-mtree.sh -m ${WORLDDIR} -F \ 132 "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" -D "${.OBJDIR}/${DISTDIR}/base" 133 etcupdate extract -B -M "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" \ 134 -s ${WORLDDIR} -d "${.OBJDIR}/${DISTDIR}/base/var/db/etcupdate" 135# Package all components 136 cd ${WORLDDIR} && ${IMAKE} packageworld DISTDIR=${.OBJDIR}/${DISTDIR} 137 mv ${DISTDIR}/*.txz . 138 139kernel.txz: 140 mkdir -p ${DISTDIR} 141 cd ${WORLDDIR} && ${IMAKE} distributekernel packagekernel DISTDIR=${.OBJDIR}/${DISTDIR} 142 mv ${DISTDIR}/kernel*.txz . 143 144src.txz: 145 mkdir -p ${DISTDIR}/usr 146 ln -fs ${WORLDDIR} ${DISTDIR}/usr/src 147 cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/src.txz --exclude .svn --exclude .zfs \ 148 --exclude .git --exclude @ --exclude usr/src/release/dist usr/src 149 150ports.txz: 151 mkdir -p ${DISTDIR}/usr 152 ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports 153 cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/ports.txz \ 154 --exclude .git --exclude .svn \ 155 --exclude usr/ports/distfiles --exclude usr/ports/packages \ 156 --exclude 'usr/ports/INDEX*' --exclude work usr/ports 157 158reldoc: 159 cd ${.CURDIR}/doc && ${MAKE} all install clean 'FORMATS=html txt' \ 160 INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${.OBJDIR}/rdoc 161 mkdir -p reldoc 162.for i in hardware readme relnotes errata 163 ln -f rdoc/${RELNOTES_LANG}/${i}/article.txt reldoc/${i:tu}.TXT 164 ln -f rdoc/${RELNOTES_LANG}/${i}/article.html reldoc/${i:tu}.HTM 165.endfor 166 cp rdoc/${RELNOTES_LANG}/readme/docbook.css reldoc 167 168system: packagesystem 169# Install system 170 mkdir -p release 171 cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \ 172 DESTDIR=${.OBJDIR}/release MK_RESCUE=no MK_KERNEL_SYMBOLS=no \ 173 MK_PROFILE=no MK_SENDMAIL=no MK_TESTS=no MK_LIB32=no \ 174 MK_DEBUG_FILES=no 175# Copy distfiles 176 mkdir -p release/usr/freebsd-dist 177 for dist in MANIFEST $$(ls *.txz | grep -v -- '-dbg'); \ 178 do cp $${dist} release/usr/freebsd-dist; \ 179 done 180# Copy documentation, if generated 181.if !defined(NODOC) 182 cp reldoc/* release 183.endif 184# Set up installation environment 185 ln -fs /tmp/bsdinstall_etc/resolv.conf release/etc/resolv.conf 186 echo sendmail_enable=\"NONE\" > release/etc/rc.conf 187 echo hostid_enable=\"NO\" >> release/etc/rc.conf 188 echo debug.witness.trace=0 >> release/etc/sysctl.conf 189 echo vfs.mountroot.timeout=\"10\" >> release/boot/loader.conf 190 cp ${.CURDIR}/rc.local release/etc 191 touch ${.TARGET} 192 193bootonly: packagesystem 194# Install system 195 mkdir -p bootonly 196 cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \ 197 DESTDIR=${.OBJDIR}/bootonly MK_AMD=no MK_AT=no \ 198 MK_GAMES=no MK_GROFF=no \ 199 MK_INSTALLLIB=no MK_LIB32=no MK_MAIL=no \ 200 MK_NCP=no MK_TOOLCHAIN=no MK_PROFILE=no \ 201 MK_INSTALLIB=no MK_RESCUE=no MK_DICT=no \ 202 MK_KERNEL_SYMBOLS=no MK_TESTS=no MK_DEBUG_FILES=no 203# Copy manifest only (no distfiles) to get checksums 204 mkdir -p bootonly/usr/freebsd-dist 205 cp MANIFEST bootonly/usr/freebsd-dist 206# Copy documentation, if generated 207.if !defined(NODOC) 208 cp reldoc/* bootonly 209.endif 210# Set up installation environment 211 ln -fs /tmp/bsdinstall_etc/resolv.conf bootonly/etc/resolv.conf 212 echo sendmail_enable=\"NONE\" > bootonly/etc/rc.conf 213 echo hostid_enable=\"NO\" >> bootonly/etc/rc.conf 214 echo debug.witness.trace=0 >> bootonly/etc/sysctl.conf 215 echo vfs.mountroot.timeout=\"10\" >> bootonly/boot/loader.conf 216 cp ${.CURDIR}/rc.local bootonly/etc 217 218dvd: 219# Install system 220 mkdir -p ${.TARGET} 221 cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \ 222 DESTDIR=${.OBJDIR}/${.TARGET} MK_RESCUE=no MK_KERNEL_SYMBOLS=no \ 223 MK_TESTS=no MK_DEBUG_FILES=no 224# Copy distfiles 225 mkdir -p ${.TARGET}/usr/freebsd-dist 226 for dist in MANIFEST $$(ls *.txz | grep -v -- '-dbg'); \ 227 do cp $${dist} ${.TARGET}/usr/freebsd-dist; \ 228 done 229# Copy documentation, if generated 230.if !defined(NODOC) 231 cp reldoc/* ${.TARGET} 232.endif 233# Set up installation environment 234 ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf 235 echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf 236 echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf 237 echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf 238 echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf 239 cp ${.CURDIR}/rc.local ${.TARGET}/etc 240 touch ${.TARGET} 241 242release.iso: disc1.iso 243disc1.iso: system 244 sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_CD ${.TARGET} release 245 246dvd1.iso: dvd pkg-stage 247 sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_DVD ${.TARGET} dvd 248 249bootonly.iso: bootonly 250 sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_BO ${.TARGET} bootonly 251 252memstick: memstick.img 253memstick.img: system 254 sh ${.CURDIR}/${TARGET}/make-memstick.sh release ${.TARGET} 255 256mini-memstick: mini-memstick.img 257mini-memstick.img: system 258 sh ${.CURDIR}/${TARGET}/make-memstick.sh bootonly ${.TARGET} 259 260packagesystem: base.txz kernel.txz ${EXTRA_PACKAGES} 261 sh ${.CURDIR}/scripts/make-manifest.sh *.txz > MANIFEST 262 touch ${.TARGET} 263 264pkg-stage: 265.if !defined(NOPKG) 266 env REPOS_DIR=${.CURDIR}/pkg_repos/ \ 267 sh ${.CURDIR}/scripts/pkg-stage.sh 268 mkdir -p ${.OBJDIR}/dvd/packages/repos/ 269 cp ${.CURDIR}/scripts/FreeBSD_install_cdrom.conf \ 270 ${.OBJDIR}/dvd/packages/repos/ 271.endif 272 touch ${.TARGET} 273 274cdrom: disc1.iso bootonly.iso 275dvdrom: dvd1.iso 276ftp: packagesystem 277 rm -rf ftp 278 mkdir -p ftp 279 cp *.txz MANIFEST ftp 280 281release: real-release vm-release cloudware-release 282 @true 283 284real-release: 285 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj 286 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS} 287 288install: release-install vm-install 289 290release-install: 291.if defined(DESTDIR) && !empty(DESTDIR) 292 mkdir -p ${DESTDIR} 293.endif 294 cp -a ftp ${DESTDIR}/ 295.for I in ${IMAGES} 296 cp -p ${I} ${DESTDIR}/${OSRELEASE}-${I} 297. if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES) 298 ${XZCMD} -k ${DESTDIR}/${OSRELEASE}-${I} 299. endif 300.endfor 301 cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256 302 cd ${DESTDIR} && md5 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.MD5 303 304.include "${.CURDIR}/Makefile.vm" 305