xref: /freebsd/release/Makefile (revision a7623790fb345e6dc986dfd31df0ace115e6f2e4)
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 newvers.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 release ${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 disc1 bootonly dvd
122.if !defined(NODOC)
123CLEANDIRS+=    reldoc rdoc
124.endif
125beforeclean:
126	chflags -R noschg .
127.include <bsd.obj.mk>
128clean: beforeclean
129
130base.txz:
131	mkdir -p ${DISTDIR}
132	cd ${WORLDDIR} && ${IMAKE} distributeworld DISTDIR=${.OBJDIR}/${DISTDIR}
133# Set up mergemaster root database
134	sh ${.CURDIR}/scripts/mm-mtree.sh -m ${WORLDDIR} -F \
135	    "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET} ${.MAKE.JOBS:D-j${.MAKE.JOBS}}" \
136	    -D "${.OBJDIR}/${DISTDIR}/base"
137	etcupdate extract -B -M "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" \
138	    -s ${WORLDDIR} -d "${.OBJDIR}/${DISTDIR}/base/var/db/etcupdate"
139# Package all components
140	cd ${WORLDDIR} && ${IMAKE} packageworld DISTDIR=${.OBJDIR}/${DISTDIR}
141	mv ${DISTDIR}/*.txz .
142
143kernel.txz:
144	mkdir -p ${DISTDIR}
145	cd ${WORLDDIR} && ${IMAKE} distributekernel packagekernel DISTDIR=${.OBJDIR}/${DISTDIR}
146	mv ${DISTDIR}/kernel*.txz .
147
148src.txz:
149	mkdir -p ${DISTDIR}/usr
150	ln -fs ${WORLDDIR} ${DISTDIR}/usr/src
151	cd ${DISTDIR} && tar cLvf - --exclude .svn --exclude .zfs \
152	    --exclude .git --exclude @ --exclude usr/src/release/dist usr/src | \
153	    ${XZ_CMD} > ${.OBJDIR}/src.txz
154
155ports.txz:
156	mkdir -p ${DISTDIR}/usr
157	ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports
158	cd ${DISTDIR} && tar cLvf - \
159	    --exclude .git --exclude .svn \
160	    --exclude usr/ports/distfiles --exclude usr/ports/packages \
161	    --exclude 'usr/ports/INDEX*' --exclude work usr/ports | \
162	    ${XZ_CMD} > ${.OBJDIR}/ports.txz
163
164reldoc:
165	cd ${DOCDIR}/en_US.ISO8859-1/htdocs/releases/${REVISION}R && \
166	    env MAN4DIR=${WORLDDIR}/share/man/man4 \
167	    _BRANCH=${BRANCH} \
168	    ${MAKE} all install clean "FORMATS=html txt" \
169	    INSTALL_COMPRESSED='' URLS_ABSOLUTE=YES DOCDIR=${.OBJDIR}/rdoc \
170	    WEBDIR=${DOCDIR} DESTDIR=${.OBJDIR}/rdoc
171	mkdir -p reldoc
172.for i in hardware readme relnotes errata
173	ln -f ${.OBJDIR}/rdoc/${i:tl}.txt \
174		reldoc/${i:tu}.TXT
175	ln -f ${.OBJDIR}/rdoc/${i:tl}.html \
176		reldoc/${i:tu}.HTML
177.endfor
178	cp ${.OBJDIR}/rdoc/docbook.css \
179		reldoc/
180
181disc1: packagesystem
182# Install system
183	mkdir -p ${.TARGET}
184	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
185	    DESTDIR=${.OBJDIR}/${.TARGET} MK_AT=no \
186	    MK_INSTALLLIB=no MK_LIB32=no MK_MAIL=no \
187	    MK_TOOLCHAIN=no MK_PROFILE=no \
188	    MK_RESCUE=no MK_DICT=no \
189	    MK_KERNEL_SYMBOLS=no MK_TESTS=no MK_DEBUG_FILES=no \
190	    -DDB_FROM_SRC
191# Copy distfiles
192	mkdir -p ${.TARGET}/usr/freebsd-dist
193	for dist in MANIFEST $$(ls *.txz | grep -vE -- '(base|lib32)-dbg'); \
194	    do cp $${dist} ${.TARGET}/usr/freebsd-dist; \
195	done
196# Copy documentation, if generated
197.if !defined(NODOC)
198	cp reldoc/* ${.TARGET}
199.endif
200# Set up installation environment
201	ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf
202	echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf
203	echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf
204	echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf
205	echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf
206	echo kernels_autodetect=\"NO\" >> ${.TARGET}/boot/loader.conf
207	cp ${.CURDIR}/rc.local ${.TARGET}/etc
208	touch ${.TARGET}
209
210bootonly: packagesystem
211# Install system
212	mkdir -p ${.TARGET}
213	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
214	    DESTDIR=${.OBJDIR}/${.TARGET} MK_AT=no \
215	    MK_GAMES=no \
216	    MK_INSTALLLIB=no MK_LIB32=no MK_MAIL=no \
217	    MK_TOOLCHAIN=no MK_PROFILE=no \
218	    MK_RESCUE=no MK_DICT=no \
219	    MK_KERNEL_SYMBOLS=no MK_TESTS=no MK_DEBUG_FILES=no \
220	    -DDB_FROM_SRC
221# Copy manifest only (no distfiles) to get checksums
222	mkdir -p ${.TARGET}/usr/freebsd-dist
223	cp MANIFEST ${.TARGET}/usr/freebsd-dist
224# Copy documentation, if generated
225.if !defined(NODOC)
226	cp reldoc/* ${.TARGET}
227.endif
228# Set up installation environment
229	ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf
230	echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf
231	echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf
232	echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf
233	echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf
234	echo kernels_autodetect=\"NO\" >> ${.TARGET}/boot/loader.conf
235	cp ${.CURDIR}/rc.local ${.TARGET}/etc
236
237dvd: packagesystem
238# Install system
239	mkdir -p ${.TARGET}
240	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
241		DESTDIR=${.OBJDIR}/${.TARGET} MK_RESCUE=no MK_KERNEL_SYMBOLS=no \
242		MK_TESTS=no MK_DEBUG_FILES=no \
243		-DDB_FROM_SRC
244# Copy distfiles
245	mkdir -p ${.TARGET}/usr/freebsd-dist
246	for dist in MANIFEST $$(ls *.txz | grep -v -- '(base|lib32)-dbg'); \
247	    do cp $${dist} ${.TARGET}/usr/freebsd-dist; \
248	done
249# Copy documentation, if generated
250.if !defined(NODOC)
251	cp reldoc/* ${.TARGET}
252.endif
253# Set up installation environment
254	ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf
255	echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf
256	echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf
257	echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf
258	echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf
259	echo kernels_autodetect=\"NO\" >> ${.TARGET}/boot/loader.conf
260	cp ${.CURDIR}/rc.local ${.TARGET}/etc
261	touch ${.TARGET}
262
263release.iso: disc1.iso
264disc1.iso: disc1
265	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_CD ${.TARGET} disc1 ${XTRADIR}
266
267dvd1.iso: dvd pkg-stage
268	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_DVD ${.TARGET} dvd ${XTRADIR}
269
270bootonly.iso: bootonly
271	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_BO ${.TARGET} bootonly ${XTRADIR}
272
273memstick: memstick.img
274memstick.img: disc1
275	sh ${.CURDIR}/${TARGET}/make-memstick.sh disc1 ${.TARGET}
276
277mini-memstick: mini-memstick.img
278mini-memstick.img: bootonly
279	sh ${.CURDIR}/${TARGET}/make-memstick.sh bootonly ${.TARGET}
280
281packagesystem: base.txz kernel.txz ${EXTRA_PACKAGES}
282	sh ${.CURDIR}/scripts/make-manifest.sh *.txz > MANIFEST
283	touch ${.TARGET}
284
285pkg-stage:
286.if !defined(NOPKG) || empty(NOPKG)
287	env PORTSDIR=${PORTSDIR} REPOS_DIR=${.CURDIR}/pkg_repos/ \
288		sh ${.CURDIR}/scripts/pkg-stage.sh
289	mkdir -p ${.OBJDIR}/dvd/packages/repos/
290	cp ${.CURDIR}/scripts/FreeBSD_install_cdrom.conf \
291		${.OBJDIR}/dvd/packages/repos/
292.endif
293	touch ${.TARGET}
294
295cdrom: disc1.iso bootonly.iso
296dvdrom: dvd1.iso
297ftp: packagesystem
298	rm -rf ftp
299	mkdir -p ftp
300	cp *.txz MANIFEST ftp
301
302release:	real-release vm-release cloudware-release
303	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} release-done
304	true
305
306release-done:
307	touch release
308
309real-release:
310	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj
311	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS}
312
313install:	release-install vm-install
314
315release-install:
316.if defined(DESTDIR) && !empty(DESTDIR)
317	mkdir -p ${DESTDIR}
318.endif
319	cp -a ftp ${DESTDIR}/
320.for I in ${IMAGES}
321	cp -p ${I} ${DESTDIR}/${OSRELEASE}-${I}
322. if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES)
323	${XZ_CMD} -k ${DESTDIR}/${OSRELEASE}-${I}
324. endif
325.endfor
326	cd ${DESTDIR} && sha512 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA512
327	cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256
328
329.include "${.CURDIR}/Makefile.inc1"
330.include "${.CURDIR}/Makefile.vm"
331