xref: /freebsd/release/Makefile (revision a812392203d7c4c3f0db9d8a0f3391374c49c71f)
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#  WITH_COMPRESSED_IMAGES: if set, compress installation images with xz(1)
25#		(uncompressed images are not removed)
26#  WITH_VMIMAGES: if set, build virtual machine images with the release
27#  WITH_COMPRESSED_VMIMAGES: if set, compress virtual machine disk images
28#  		with xz(1) (extremely time consuming)
29#  TARGET/TARGET_ARCH: architecture of built release
30#
31
32WORLDDIR?=	${.CURDIR}/..
33PORTSDIR?=	/usr/ports
34DOCDIR?=	/usr/doc
35RELNOTES_LANG?= en_US.ISO8859-1
36XZCMD?=		/usr/bin/xz
37
38.if !defined(TARGET) || empty(TARGET)
39TARGET=		${MACHINE}
40.endif
41.if !defined(TARGET_ARCH) || empty(TARGET_ARCH)
42.if ${TARGET} == ${MACHINE}
43TARGET_ARCH=	${MACHINE_ARCH}
44.else
45TARGET_ARCH=	${TARGET}
46.endif
47.endif
48IMAKE=		${MAKE} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}
49DISTDIR=	dist
50
51# Define OSRELEASE by using newvars.sh
52.if !defined(OSRELEASE) || empty(OSRELEASE)
53.for _V in TYPE BRANCH REVISION
54${_V}!=	eval $$(awk '/^${_V}=/{print}' ${.CURDIR}/../sys/conf/newvers.sh); echo $$${_V}
55.endfor
56.for _V in ${TARGET_ARCH}
57.if !empty(TARGET:M${_V})
58OSRELEASE=	${TYPE}-${REVISION}-${BRANCH}-${TARGET}
59VOLUME_LABEL=	${REVISION:C/[.-]/_/g}_${BRANCH:C/[.-]/_/g}_${TARGET}
60.else
61OSRELEASE=	${TYPE}-${REVISION}-${BRANCH}-${TARGET}-${TARGET_ARCH}
62VOLUME_LABEL=	${REVISION:C/[.-]/_/g}_${BRANCH:C/[.-]/_/g}_${TARGET_ARCH}
63.endif
64.endfor
65.endif
66
67.if !defined(VOLUME_LABEL) || empty(VOLUME_LABEL)
68VOLUME_LABEL=	FreeBSD_Install
69.endif
70
71.if !exists(${DOCDIR})
72NODOC= true
73.endif
74.if !exists(${PORTSDIR})
75NOPORTS= true
76.endif
77
78EXTRA_PACKAGES=
79.if !defined(NOPORTS)
80EXTRA_PACKAGES+= ports.txz
81.endif
82.if !defined(NOSRC)
83EXTRA_PACKAGES+= src.txz
84.endif
85.if !defined(NODOC)
86EXTRA_PACKAGES+= reldoc
87.endif
88
89RELEASE_TARGETS= ftp
90IMAGES=
91.if exists(${.CURDIR}/${TARGET}/mkisoimages.sh)
92RELEASE_TARGETS+= cdrom
93IMAGES+=	disc1.iso bootonly.iso
94. if defined(WITH_DVD) && !empty(WITH_DVD)
95RELEASE_TARGETS+= dvdrom
96IMAGES+=	dvd1.iso
97. endif
98.endif
99.if exists(${.CURDIR}/${TARGET}/make-memstick.sh)
100RELEASE_TARGETS+= memstick.img
101RELEASE_TARGETS+= mini-memstick.img
102IMAGES+=	memstick.img
103IMAGES+=	mini-memstick.img
104.endif
105
106VMTARGETS=	vm-base vm-image
107VMFORMATS?=	vhd vmdk qcow2 raw
108VMSIZE?=	20G
109VMBASE?=	vm
110AZURECONF?=	${.CURDIR}/tools/azure.conf
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
121.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
122CLEANFILES+=	${VMBASE}.img
123. for FORMAT in ${VMFORMATS}
124CLEANFILES+=	${VMBASE}.${FORMAT}
125. endfor
126.endif
127CLEANDIRS=	dist ftp release bootonly dvd
128.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
129CLEANDIRS+=	${VMTARGETS}
130.endif
131.if exists(${.CURDIR}/${TARGET}/mk-azure.sh)
132CLEANFILES+=	${OSRELEASE}.vhd \
133		${OSRELEASE}.vhd.raw \
134		azure.img
135CLEANDIRS+=	vm-azure
136.endif
137beforeclean:
138	chflags -R noschg .
139.include <bsd.obj.mk>
140clean: beforeclean
141
142base.txz:
143	mkdir -p ${DISTDIR}
144	cd ${WORLDDIR} && ${IMAKE} distributeworld DISTDIR=${.OBJDIR}/${DISTDIR}
145# Set up mergemaster root database
146	sh ${.CURDIR}/scripts/mm-mtree.sh -m ${WORLDDIR} -F \
147	    "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" -D "${.OBJDIR}/${DISTDIR}/base"
148	etcupdate extract -B -M "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" \
149	    -s ${WORLDDIR} -d "${.OBJDIR}/${DISTDIR}/base/var/db/etcupdate"
150# Package all components
151	cd ${WORLDDIR} && ${IMAKE} packageworld DISTDIR=${.OBJDIR}/${DISTDIR}
152	mv ${DISTDIR}/*.txz .
153
154kernel.txz:
155	mkdir -p ${DISTDIR}
156	cd ${WORLDDIR} && ${IMAKE} distributekernel packagekernel DISTDIR=${.OBJDIR}/${DISTDIR}
157	mv ${DISTDIR}/kernel*.txz .
158
159src.txz:
160	mkdir -p ${DISTDIR}/usr
161	ln -fs ${WORLDDIR} ${DISTDIR}/usr/src
162	cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/src.txz --exclude .svn --exclude .zfs \
163	    --exclude .git --exclude @ --exclude usr/src/release/dist usr/src
164
165ports.txz:
166	mkdir -p ${DISTDIR}/usr
167	ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports
168	cd ${DISTDIR} && tar cLvJf ${.OBJDIR}/ports.txz \
169	    --exclude .git --exclude .svn \
170	    --exclude usr/ports/distfiles --exclude usr/ports/packages \
171	    --exclude 'usr/ports/INDEX*' --exclude work usr/ports
172
173reldoc:
174	cd ${.CURDIR}/doc && ${MAKE} all install clean 'FORMATS=html txt' \
175	    INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${.OBJDIR}/rdoc
176	mkdir -p reldoc
177.for i in hardware readme relnotes errata
178	ln -f rdoc/${RELNOTES_LANG}/${i}/article.txt reldoc/${i:tu}.TXT
179	ln -f rdoc/${RELNOTES_LANG}/${i}/article.html reldoc/${i:tu}.HTM
180.endfor
181	cp rdoc/${RELNOTES_LANG}/readme/docbook.css reldoc
182
183system: packagesystem
184# Install system
185	mkdir -p release
186	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
187		DESTDIR=${.OBJDIR}/release MK_RESCUE=no MK_KERNEL_SYMBOLS=no \
188		MK_PROFILE=no MK_SENDMAIL=no MK_TESTS=no MK_LIB32=no \
189		MK_DEBUG_FILES=no
190# Copy distfiles
191	mkdir -p release/usr/freebsd-dist
192	for dist in MANIFEST $$(ls *.txz | grep -v -- '-dbg'); \
193	    do cp $${dist} release/usr/freebsd-dist; \
194	done
195# Copy documentation, if generated
196.if !defined(NODOC)
197	cp reldoc/* release
198.endif
199# Set up installation environment
200	ln -fs /tmp/bsdinstall_etc/resolv.conf release/etc/resolv.conf
201	echo sendmail_enable=\"NONE\" > release/etc/rc.conf
202	echo hostid_enable=\"NO\" >> release/etc/rc.conf
203	echo debug.witness.trace=0 >> release/etc/sysctl.conf
204	echo vfs.mountroot.timeout=\"10\" >> release/boot/loader.conf
205	cp ${.CURDIR}/rc.local release/etc
206	touch ${.TARGET}
207
208bootonly: packagesystem
209# Install system
210	mkdir -p bootonly
211	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
212	    DESTDIR=${.OBJDIR}/bootonly MK_AMD=no MK_AT=no \
213	    MK_GAMES=no MK_GROFF=no \
214	    MK_INSTALLLIB=no MK_LIB32=no MK_MAIL=no \
215	    MK_NCP=no MK_TOOLCHAIN=no MK_PROFILE=no \
216	    MK_INSTALLIB=no MK_RESCUE=no MK_DICT=no \
217	    MK_KERNEL_SYMBOLS=no MK_TESTS=no MK_DEBUG_FILES=no
218# Copy manifest only (no distfiles) to get checksums
219	mkdir -p bootonly/usr/freebsd-dist
220	cp MANIFEST bootonly/usr/freebsd-dist
221# Copy documentation, if generated
222.if !defined(NODOC)
223	cp reldoc/* bootonly
224.endif
225# Set up installation environment
226	ln -fs /tmp/bsdinstall_etc/resolv.conf bootonly/etc/resolv.conf
227	echo sendmail_enable=\"NONE\" > bootonly/etc/rc.conf
228	echo hostid_enable=\"NO\" >> bootonly/etc/rc.conf
229	echo debug.witness.trace=0 >> bootonly/etc/sysctl.conf
230	echo vfs.mountroot.timeout=\"10\" >> bootonly/boot/loader.conf
231	cp ${.CURDIR}/rc.local bootonly/etc
232
233dvd:
234# Install system
235	mkdir -p ${.TARGET}
236	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
237		DESTDIR=${.OBJDIR}/${.TARGET} MK_RESCUE=no MK_KERNEL_SYMBOLS=no \
238		MK_TESTS=no MK_DEBUG_FILES=no
239# Copy distfiles
240	mkdir -p ${.TARGET}/usr/freebsd-dist
241	for dist in MANIFEST $$(ls *.txz | grep -v -- '-dbg'); \
242	    do cp $${dist} ${.TARGET}/usr/freebsd-dist; \
243	done
244# Copy documentation, if generated
245.if !defined(NODOC)
246	cp reldoc/* ${.TARGET}
247.endif
248# Set up installation environment
249	ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf
250	echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf
251	echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf
252	echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf
253	echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf
254	cp ${.CURDIR}/rc.local ${.TARGET}/etc
255	touch ${.TARGET}
256
257release.iso: disc1.iso
258disc1.iso: system
259	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_CD ${.TARGET} release
260
261dvd1.iso: dvd pkg-stage
262	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_DVD ${.TARGET} dvd
263
264bootonly.iso: bootonly
265	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_BO ${.TARGET} bootonly
266
267memstick: memstick.img
268memstick.img: system
269	sh ${.CURDIR}/${TARGET}/make-memstick.sh release ${.TARGET}
270
271mini-memstick: mini-memstick.img
272mini-memstick.img: system
273	sh ${.CURDIR}/${TARGET}/make-memstick.sh bootonly ${.TARGET}
274
275packagesystem: base.txz kernel.txz ${EXTRA_PACKAGES}
276	sh ${.CURDIR}/scripts/make-manifest.sh *.txz > MANIFEST
277	touch ${.TARGET}
278
279pkg-stage:
280.if !defined(NOPKG)
281	env REPOS_DIR=${.CURDIR}/pkg_repos/ \
282		sh ${.CURDIR}/scripts/pkg-stage.sh
283	mkdir -p ${.OBJDIR}/dvd/packages/repos/
284	cp ${.CURDIR}/scripts/FreeBSD_install_cdrom.conf \
285		${.OBJDIR}/dvd/packages/repos/
286.endif
287	touch ${.TARGET}
288
289cdrom: disc1.iso bootonly.iso
290dvdrom: dvd1.iso
291ftp: packagesystem
292	rm -rf ftp
293	mkdir -p ftp
294	cp *.txz MANIFEST ftp
295
296release:
297	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj
298	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS}
299.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
300	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${VMTARGETS}
301.endif
302
303install:
304.if defined(DESTDIR) && !empty(DESTDIR)
305	mkdir -p ${DESTDIR}
306.endif
307	cp -a ftp ${DESTDIR}/
308.for I in ${IMAGES}
309	cp -p ${I} ${DESTDIR}/${OSRELEASE}-${I}
310. if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES)
311	${XZCMD} -k ${DESTDIR}/${OSRELEASE}-${I}
312. endif
313.endfor
314	cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256
315	cd ${DESTDIR} && md5 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.MD5
316.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
317	mkdir -p ${DESTDIR}/vmimages
318. for FORMAT in ${VMFORMATS}
319	cp -p ${VMBASE}.${FORMAT} \
320		${DESTDIR}/vmimages/${OSRELEASE}.${FORMAT}
321. endfor
322. if defined(WITH_COMPRESSED_VMIMAGES) && !empty(WITH_COMPRESSED_VMIMAGES)
323# This is very time consuming, so defer it after the images are moved to
324# the DESTDIR.
325.  for FORMAT in ${VMFORMATS}
326	# Don't keep the originals.  There is a copy in ${.OBJDIR} if needed.
327	${XZCMD} ${DESTDIR}/vmimages/${OSRELEASE}.${FORMAT}
328.  endfor
329. endif
330	cd ${DESTDIR}/vmimages && sha256 ${OSRELEASE}* > \
331		${DESTDIR}/vmimages/CHECKSUM.SHA256
332	cd ${DESTDIR}/vmimages && md5 ${OSRELEASE}* > \
333		${DESTDIR}/vmimages/CHECKSUM.MD5
334.endif
335
336vm-base:
337.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
338. if exists(${.CURDIR}/${TARGET}/mk-vmimage.sh)
339	env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
340		${.CURDIR}/${TARGET}/mk-vmimage.sh ${.TARGET} \
341		${VMBASE}.img ${WORLDDIR} ${.OBJDIR}/${.TARGET} ${VMSIZE}
342. endif
343.endif
344	touch ${.TARGET}
345
346vm-image: vm-base
347.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
348. if exists(${.CURDIR}/${TARGET}/mk-vmimage.sh)
349.  for FORMAT in ${VMFORMATS}
350	env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} \
351		${.CURDIR}/${TARGET}/mk-vmimage.sh ${.TARGET} \
352		${VMBASE}.img ${FORMAT} ${VMBASE}.${FORMAT}
353.  endfor
354. endif
355.endif
356	touch ${.TARGET}
357
358vm-azure:
359.if exists(${.CURDIR}/${TARGET}/mk-azure.sh)
360	env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} AZURECONF=${AZURECONF} \
361		${.CURDIR}/${TARGET}/mk-azure.sh ${.TARGET} azure.img \
362		${WORLDDIR} ${.TARGET} ${VMSIZE} ${OSRELEASE}.vhd
363.endif
364	touch ${.TARGET}
365