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: Build all media and FTP distribution area 12# install: Copies all release media into ${DESTDIR} 13# 14# Variables affecting the build process: 15# WORLDDIR: location of src tree -- must have built world and default kernel 16# (by default, the directory above this one) 17# PORTSDIR: location of ports tree to distribute (default: /usr/ports) 18# DOCDIR: location of doc tree (default: /usr/doc) 19# NOPKG: if set, do not distribute third-party packages 20# NOPORTS: if set, do not distribute ports tree 21# NOSRC: if set, do not distribute source tree 22# NODOC: if set, do not generate release documentation 23# WITH_DVD: if set, generate dvd1.iso 24# TARGET/TARGET_ARCH: architecture of built release 25# 26 27WORLDDIR?= ${.CURDIR}/.. 28PORTSDIR?= /usr/ports 29DOCDIR?= /usr/doc 30RELNOTES_LANG?= en_US.ISO8859-1 31 32.if !defined(TARGET) || empty(TARGET) 33TARGET= ${MACHINE} 34.endif 35.if !defined(TARGET_ARCH) || empty(TARGET_ARCH) 36.if ${TARGET} == ${MACHINE} 37TARGET_ARCH= ${MACHINE_ARCH} 38.else 39TARGET_ARCH= ${TARGET} 40.endif 41.endif 42IMAKE= ${MAKE} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET} 43DISTDIR= dist 44 45# Define OSRELEASE by using newvars.sh 46.if !defined(OSRELEASE) || empty(OSRELEASE) 47.for _V in TYPE BRANCH REVISION 48${_V}!= eval $$(awk '/^${_V}=/{print}' ${.CURDIR}/../sys/conf/newvers.sh); echo $$${_V} 49.endfor 50.for _V in ${TARGET_ARCH} 51.if !empty(TARGET:M${_V}) 52OSRELEASE= ${TYPE}-${REVISION}-${BRANCH}-${TARGET} 53.else 54OSRELEASE= ${TYPE}-${REVISION}-${BRANCH}-${TARGET}-${TARGET_ARCH} 55.endif 56.endfor 57.endif 58 59.if !exists(${DOCDIR}) 60NODOC= true 61.endif 62.if !exists(${PORTSDIR}) 63NOPORTS= true 64.endif 65 66EXTRA_PACKAGES= 67.if !defined(NOPORTS) 68EXTRA_PACKAGES+= ports.txz 69.endif 70.if !defined(NOSRC) 71EXTRA_PACKAGES+= src.txz 72.endif 73.if !defined(NODOC) 74EXTRA_PACKAGES+= reldoc 75.endif 76 77RELEASE_TARGETS= ftp 78IMAGES= 79.if exists(${.CURDIR}/${TARGET}/mkisoimages.sh) 80RELEASE_TARGETS+= cdrom 81IMAGES+= disc1.iso bootonly.iso 82. if defined(WITH_DVD) && !empty(WITH_DVD) 83RELEASE_TARGETS+= dvdrom 84IMAGES+= dvd1.iso 85. endif 86.endif 87.if exists(${.CURDIR}/${TARGET}/make-memstick.sh) 88RELEASE_TARGETS+= memstick.img 89RELEASE_TARGETS+= mini-memstick.img 90IMAGES+= memstick.img 91IMAGES+= mini-memstick.img 92.endif 93 94CLEANFILES= packagesystem *.txz MANIFEST system ${IMAGES} 95CLEANDIRS= dist ftp release bootonly dvd 96beforeclean: 97 chflags -R noschg . 98.include <bsd.obj.mk> 99clean: beforeclean 100 101base.txz: 102 mkdir -p ${DISTDIR} 103 cd ${WORLDDIR} && ${IMAKE} distributeworld DISTDIR=${.OBJDIR}/${DISTDIR} 104# Set up mergemaster root database 105 sh ${.CURDIR}/scripts/mm-mtree.sh -m ${WORLDDIR} -F \ 106 "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" -D "${.OBJDIR}/${DISTDIR}/base" 107 etcupdate extract -B -M "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" \ 108 -s ${WORLDDIR} -d "${.OBJDIR}/${DISTDIR}/base/var/db/etcupdate" 109# Package all components 110 cd ${WORLDDIR} && ${IMAKE} packageworld DISTDIR=${.OBJDIR}/${DISTDIR} 111 mv ${DISTDIR}/*.txz . 112 113kernel.txz: 114 mkdir -p ${DISTDIR} 115 cd ${WORLDDIR} && ${IMAKE} distributekernel packagekernel DISTDIR=${.OBJDIR}/${DISTDIR} 116 mv ${DISTDIR}/kernel*.txz . 117 118src.txz: 119 mkdir -p ${DISTDIR}/usr 120 ln -fs ${WORLDDIR} ${DISTDIR}/usr/src 121 cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/src.txz --exclude .svn --exclude .zfs \ 122 --exclude .git --exclude @ --exclude usr/src/release/dist usr/src 123 124ports.txz: 125 mkdir -p ${DISTDIR}/usr 126 ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports 127 cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/ports.txz \ 128 --exclude .git --exclude .svn \ 129 --exclude usr/ports/distfiles --exclude usr/ports/packages \ 130 --exclude 'usr/ports/INDEX*' --exclude work usr/ports 131 132reldoc: 133 cd ${.CURDIR}/doc && ${MAKE} all install clean 'FORMATS=html txt' \ 134 INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${.OBJDIR}/rdoc 135 mkdir -p reldoc 136.for i in hardware readme relnotes errata 137 ln -f rdoc/${RELNOTES_LANG}/${i}/article.txt reldoc/${i:tu}.TXT 138 ln -f rdoc/${RELNOTES_LANG}/${i}/article.html reldoc/${i:tu}.HTM 139.endfor 140 cp rdoc/${RELNOTES_LANG}/readme/docbook.css reldoc 141 142system: packagesystem 143# Install system 144 mkdir -p release 145 cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \ 146 DESTDIR=${.OBJDIR}/release WITHOUT_RESCUE=1 WITHOUT_KERNEL_SYMBOLS=1 \ 147 WITHOUT_PROFILE=1 WITHOUT_SENDMAIL=1 WITHOUT_ATF=1 WITHOUT_LIB32=1 148# Copy distfiles 149 mkdir -p release/usr/freebsd-dist 150 cp *.txz MANIFEST release/usr/freebsd-dist 151# Copy documentation, if generated 152.if !defined(NODOC) 153 cp reldoc/* release 154.endif 155# Set up installation environment 156 ln -fs /tmp/bsdinstall_etc/resolv.conf release/etc/resolv.conf 157 echo sendmail_enable=\"NONE\" > release/etc/rc.conf 158 echo hostid_enable=\"NO\" >> release/etc/rc.conf 159 cp ${.CURDIR}/rc.local release/etc 160 touch ${.TARGET} 161 162bootonly: packagesystem 163# Install system 164 mkdir -p bootonly 165 cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \ 166 DESTDIR=${.OBJDIR}/bootonly WITHOUT_AMD=1 WITHOUT_AT=1 \ 167 WITHOUT_GAMES=1 WITHOUT_GROFF=1 \ 168 WITHOUT_INSTALLLIB=1 WITHOUT_LIB32=1 WITHOUT_MAIL=1 \ 169 WITHOUT_NCP=1 WITHOUT_TOOLCHAIN=1 WITHOUT_PROFILE=1 \ 170 WITHOUT_INSTALLIB=1 WITHOUT_RESCUE=1 WITHOUT_DICT=1 \ 171 WITHOUT_KERNEL_SYMBOLS=1 172# Copy manifest only (no distfiles) to get checksums 173 mkdir -p bootonly/usr/freebsd-dist 174 cp MANIFEST bootonly/usr/freebsd-dist 175# Copy documentation, if generated 176.if !defined(NODOC) 177 cp reldoc/* bootonly 178.endif 179# Set up installation environment 180 ln -fs /tmp/bsdinstall_etc/resolv.conf bootonly/etc/resolv.conf 181 echo sendmail_enable=\"NONE\" > bootonly/etc/rc.conf 182 echo hostid_enable=\"NO\" >> bootonly/etc/rc.conf 183 cp ${.CURDIR}/rc.local bootonly/etc 184 185dvd: 186# Install system 187 mkdir -p ${.TARGET} 188 cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \ 189 DESTDIR=${.OBJDIR}/${.TARGET} WITHOUT_RESCUE=1 WITHOUT_KERNEL_SYMBOLS=1 190# Copy distfiles 191 mkdir -p ${.TARGET}/usr/freebsd-dist 192 cp *.txz MANIFEST ${.TARGET}/usr/freebsd-dist 193# Copy documentation, if generated 194.if !defined(NODOC) 195 cp reldoc/* ${.TARGET} 196.endif 197# Set up installation environment 198 ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf 199 echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf 200 echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf 201 cp ${.CURDIR}/rc.local ${.TARGET}/etc 202 touch ${.TARGET} 203 204release.iso: disc1.iso 205disc1.iso: system 206 sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.TARGET} release 207 208dvd1.iso: dvd pkg-stage 209 sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.TARGET} dvd 210 211bootonly.iso: bootonly 212 sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.TARGET} bootonly 213 214memstick: memstick.img 215memstick.img: system 216 sh ${.CURDIR}/${TARGET}/make-memstick.sh release ${.TARGET} 217 218mini-memstick: mini-memstick.img 219mini-memstick.img: system 220 sh ${.CURDIR}/${TARGET}/make-memstick.sh bootonly ${.TARGET} 221 222packagesystem: base.txz kernel.txz ${EXTRA_PACKAGES} 223 sh ${.CURDIR}/scripts/make-manifest.sh *.txz > MANIFEST 224 touch ${.TARGET} 225 226pkg-stage: 227.if !defined(NOPKG) 228 env REPOS_DIR=${.CURDIR}/pkg_repos/ \ 229 sh ${.CURDIR}/scripts/pkg-stage.sh 230 mkdir -p ${.OBJDIR}/dvd/packages/repos/ 231 cp ${.CURDIR}/scripts/FreeBSD_install_cdrom.conf \ 232 ${.OBJDIR}/dvd/packages/repos/ 233.endif 234 touch ${.TARGET} 235 236cdrom: disc1.iso bootonly.iso 237dvdrom: dvd1.iso 238ftp: packagesystem 239 rm -rf ftp 240 mkdir -p ftp 241 cp *.txz MANIFEST ftp 242 243release: 244 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj 245 ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS} 246 247install: 248.if defined(DESTDIR) && !empty(DESTDIR) 249 mkdir -p ${DESTDIR} 250.endif 251 cp -a ftp ${DESTDIR}/ 252.for I in ${IMAGES} 253 cp -p ${I} ${DESTDIR}/${OSRELEASE}-${I} 254.endfor 255 cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256 256 cd ${DESTDIR} && md5 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.MD5 257