xref: /freebsd/release/Makefile (revision 6829dae12bb055451fa467da4589c43bd03b1e64)
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#  XTRADIR:  xtra-bits-dir argument for <arch>/mkisoimages.sh
25#  NOPKG:    if set, do not distribute third-party packages
26#  NOPORTS:  if set, do not distribute ports tree
27#  NOSRC:    if set, do not distribute source tree
28#  NODOC:    if set, do not generate release documentation
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
41DOCDIR?=	/usr/doc
42RELNOTES_LANG?= en_US.ISO8859-1
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. if !defined(SVN) || empty(SVN)
94.  for S in svn svnlite
95.   for D in /usr/local/bin /usr/bin
96.    if(exists(${D}/${S}))
97SVN?=	${D}/${S}
98.    endif
99.   endfor
100.  endfor
101. endif
102.endif
103
104RELEASE_TARGETS= ftp
105IMAGES=
106.if exists(${.CURDIR}/${TARGET}/mkisoimages.sh)
107RELEASE_TARGETS+= cdrom
108IMAGES+=	disc1.iso bootonly.iso
109. if defined(WITH_DVD) && !empty(WITH_DVD)
110RELEASE_TARGETS+= dvdrom
111IMAGES+=	dvd1.iso
112. endif
113.endif
114.if exists(${.CURDIR}/${TARGET}/make-memstick.sh)
115RELEASE_TARGETS+= memstick.img
116RELEASE_TARGETS+= mini-memstick.img
117IMAGES+=	memstick.img
118IMAGES+=	mini-memstick.img
119.endif
120
121CLEANFILES=	packagesystem *.txz MANIFEST release ${IMAGES}
122.if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES)
123. for I in ${IMAGES}
124CLEANFILES+=	${I}.xz
125. endfor
126.endif
127.if defined(WITH_DVD) && !empty(WITH_DVD)
128CLEANFILES+=	pkg-stage
129.endif
130CLEANDIRS=	dist ftp disc1 bootonly dvd
131.if !defined(NODOC)
132CLEANDIRS+=    reldoc rdoc
133.endif
134beforeclean:
135	chflags -R noschg .
136.include <bsd.obj.mk>
137clean: beforeclean
138
139base.txz:
140	mkdir -p ${DISTDIR}
141	cd ${WORLDDIR} && ${IMAKE} distributeworld DISTDIR=${.OBJDIR}/${DISTDIR}
142# Set up mergemaster root database
143	sh ${.CURDIR}/scripts/mm-mtree.sh -m ${WORLDDIR} -F \
144	    "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET} ${.MAKE.JOBS:D-j${.MAKE.JOBS}}" \
145	    -D "${.OBJDIR}/${DISTDIR}/base"
146	etcupdate extract -B -M "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" \
147	    -s ${WORLDDIR} -d "${.OBJDIR}/${DISTDIR}/base/var/db/etcupdate"
148# Package all components
149	cd ${WORLDDIR} && ${IMAKE} packageworld DISTDIR=${.OBJDIR}/${DISTDIR}
150	mv ${DISTDIR}/*.txz .
151
152kernel.txz:
153	mkdir -p ${DISTDIR}
154	cd ${WORLDDIR} && ${IMAKE} distributekernel packagekernel DISTDIR=${.OBJDIR}/${DISTDIR}
155	mv ${DISTDIR}/kernel*.txz .
156
157src.txz:
158	mkdir -p ${DISTDIR}/usr
159	ln -fs ${WORLDDIR} ${DISTDIR}/usr/src
160	cd ${DISTDIR} && tar cLvf - --exclude .svn --exclude .zfs \
161	    --exclude .git --exclude @ --exclude usr/src/release/dist usr/src | \
162	    ${XZ_CMD} > ${.OBJDIR}/src.txz
163
164ports.txz:
165	mkdir -p ${DISTDIR}/usr
166	ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports
167	cd ${DISTDIR} && tar cLvf - \
168	    --exclude .git --exclude .svn \
169	    --exclude usr/ports/distfiles --exclude usr/ports/packages \
170	    --exclude 'usr/ports/INDEX*' --exclude work usr/ports | \
171	    ${XZ_CMD} > ${.OBJDIR}/ports.txz
172
173reldoc:
174	cd ${DOCDIR}/en_US.ISO8859-1/htdocs/releases/${REVISION}R && \
175	    env MAN4DIR=${WORLDDIR}/share/man/man4 \
176	    SVN=${SVN} \
177	    _BRANCH=${BRANCH} \
178	    ${MAKE} all install clean "FORMATS=html txt" \
179	    INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${.OBJDIR}/rdoc \
180	    WEBDIR=${DOCDIR} DESTDIR=${.OBJDIR}/rdoc
181	mkdir -p reldoc
182.for i in hardware readme relnotes errata
183	ln -f ${.OBJDIR}/rdoc/${i:tl}.txt \
184		reldoc/${i:tu}.TXT
185	ln -f ${.OBJDIR}/rdoc/${i:tl}.html \
186		reldoc/${i:tu}.HTML
187.endfor
188	cp ${.OBJDIR}/rdoc/docbook.css \
189		reldoc/
190
191disc1: packagesystem
192# Install system
193	mkdir -p ${.TARGET}
194	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
195	    DESTDIR=${.OBJDIR}/${.TARGET} MK_AMD=no MK_AT=no \
196	    MK_INSTALLLIB=no MK_LIB32=no MK_MAIL=no \
197	    MK_TOOLCHAIN=no MK_PROFILE=no \
198	    MK_RESCUE=no MK_DICT=no \
199	    MK_KERNEL_SYMBOLS=no MK_TESTS=no MK_DEBUG_FILES=no \
200	    -DDB_FROM_SRC
201# Copy distfiles
202	mkdir -p ${.TARGET}/usr/freebsd-dist
203	for dist in MANIFEST $$(ls *.txz | grep -vE -- '(base|lib32)-dbg'); \
204	    do cp $${dist} ${.TARGET}/usr/freebsd-dist; \
205	done
206# Copy documentation, if generated
207.if !defined(NODOC)
208	cp reldoc/* ${.TARGET}
209.endif
210# Set up installation environment
211	ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf
212	echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf
213	echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf
214	echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf
215	echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf
216	echo kernels_autodetect=\"NO\" >> ${.TARGET}/boot/loader.conf
217	cp ${.CURDIR}/rc.local ${.TARGET}/etc
218	touch ${.TARGET}
219
220bootonly: packagesystem
221# Install system
222	mkdir -p ${.TARGET}
223	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
224	    DESTDIR=${.OBJDIR}/${.TARGET} MK_AMD=no MK_AT=no \
225	    MK_GAMES=no \
226	    MK_INSTALLLIB=no MK_LIB32=no MK_MAIL=no \
227	    MK_TOOLCHAIN=no MK_PROFILE=no \
228	    MK_RESCUE=no MK_DICT=no \
229	    MK_KERNEL_SYMBOLS=no MK_TESTS=no MK_DEBUG_FILES=no \
230	    -DDB_FROM_SRC
231# Copy manifest only (no distfiles) to get checksums
232	mkdir -p ${.TARGET}/usr/freebsd-dist
233	cp MANIFEST ${.TARGET}/usr/freebsd-dist
234# Copy documentation, if generated
235.if !defined(NODOC)
236	cp reldoc/* ${.TARGET}
237.endif
238# Set up installation environment
239	ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf
240	echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf
241	echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf
242	echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf
243	echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf
244	echo kernels_autodetect=\"NO\" >> ${.TARGET}/boot/loader.conf
245	cp ${.CURDIR}/rc.local ${.TARGET}/etc
246
247dvd: packagesystem
248# Install system
249	mkdir -p ${.TARGET}
250	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
251		DESTDIR=${.OBJDIR}/${.TARGET} MK_RESCUE=no MK_KERNEL_SYMBOLS=no \
252		MK_TESTS=no MK_DEBUG_FILES=no \
253		-DDB_FROM_SRC
254# Copy distfiles
255	mkdir -p ${.TARGET}/usr/freebsd-dist
256	for dist in MANIFEST $$(ls *.txz | grep -v -- '(base|lib32)-dbg'); \
257	    do cp $${dist} ${.TARGET}/usr/freebsd-dist; \
258	done
259# Copy documentation, if generated
260.if !defined(NODOC)
261	cp reldoc/* ${.TARGET}
262.endif
263# Set up installation environment
264	ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf
265	echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf
266	echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf
267	echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf
268	echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf
269	echo kernels_autodetect=\"NO\" >> ${.TARGET}/boot/loader.conf
270	cp ${.CURDIR}/rc.local ${.TARGET}/etc
271	touch ${.TARGET}
272
273release.iso: disc1.iso
274disc1.iso: disc1
275	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_CD ${.TARGET} disc1 ${XTRADIR}
276
277dvd1.iso: dvd pkg-stage
278	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_DVD ${.TARGET} dvd ${XTRADIR}
279
280bootonly.iso: bootonly
281	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_BO ${.TARGET} bootonly ${XTRADIR}
282
283memstick: memstick.img
284memstick.img: disc1
285	sh ${.CURDIR}/${TARGET}/make-memstick.sh disc1 ${.TARGET}
286
287mini-memstick: mini-memstick.img
288mini-memstick.img: bootonly
289	sh ${.CURDIR}/${TARGET}/make-memstick.sh bootonly ${.TARGET}
290
291packagesystem: base.txz kernel.txz ${EXTRA_PACKAGES}
292	sh ${.CURDIR}/scripts/make-manifest.sh *.txz > MANIFEST
293	touch ${.TARGET}
294
295pkg-stage:
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.for I in ${IMAGES}
331	cp -p ${I} ${DESTDIR}/${OSRELEASE}-${I}
332. if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES)
333	${XZ_CMD} -k ${DESTDIR}/${OSRELEASE}-${I}
334. endif
335.endfor
336	cd ${DESTDIR} && sha512 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA512
337	cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256
338
339.include "${.CURDIR}/Makefile.vm"
340