xref: /freebsd/release/Makefile (revision 955a3f9ad586f38395e66127f9f2f4afbf3d5a94)
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#  XTRADIR:  xtra-bits-dir argument for <arch>/mkisoimages.sh
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#  WITH_DVD: if set, generate dvd1.iso
28#  WITH_COMPRESSED_IMAGES: if set, compress installation images with xz(1)
29#		(uncompressed images are not removed)
30#  WITH_VMIMAGES: if set, build virtual machine images with the release
31#  WITH_COMPRESSED_VMIMAGES: if set, compress virtual machine disk images
32#  		with xz(1) (extremely time consuming)
33#  WITH_CLOUDWARE: if set, build cloud hosting disk images with the release
34#  TARGET/TARGET_ARCH: architecture of built release
35#
36
37WORLDDIR?=	${.CURDIR}/..
38PORTSDIR?=	/usr/ports
39RELNOTES_LANG?= en_US.ISO8859-1
40
41.if !defined(TARGET) || empty(TARGET)
42TARGET=		${MACHINE}
43.endif
44.if !defined(TARGET_ARCH) || empty(TARGET_ARCH)
45.if ${TARGET} == ${MACHINE}
46TARGET_ARCH=	${MACHINE_ARCH}
47.else
48TARGET_ARCH=	${TARGET}
49.endif
50.endif
51IMAKE=		${MAKE} TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}
52DISTDIR=	dist
53
54# Define OSRELEASE by using newvers.sh
55.if !defined(OSRELEASE) || empty(OSRELEASE)
56.for _V in TYPE BRANCH REVISION
57${_V}!=	eval $$(awk '/^${_V}=/{print}' ${.CURDIR}/../sys/conf/newvers.sh); echo $$${_V}
58.endfor
59.for _V in ${TARGET_ARCH}
60.if !empty(TARGET:M${_V})
61OSRELEASE=	${TYPE}-${REVISION}-${BRANCH}-${TARGET}
62VOLUME_LABEL=	${REVISION:C/[.-]/_/g}_${BRANCH:C/[.-]/_/g}_${TARGET}
63.else
64OSRELEASE=	${TYPE}-${REVISION}-${BRANCH}-${TARGET}-${TARGET_ARCH}
65VOLUME_LABEL=	${REVISION:C/[.-]/_/g}_${BRANCH:C/[.-]/_/g}_${TARGET_ARCH}
66.endif
67.endfor
68.endif
69
70.if !defined(VOLUME_LABEL) || empty(VOLUME_LABEL)
71VOLUME_LABEL=	FreeBSD_Install
72.endif
73
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
86RELEASE_TARGETS= ftp
87IMAGES=
88.if exists(${.CURDIR}/${TARGET}/mkisoimages.sh)
89RELEASE_TARGETS+= cdrom
90IMAGES+=	disc1.iso bootonly.iso
91. if defined(WITH_DVD) && !empty(WITH_DVD)
92RELEASE_TARGETS+= dvdrom
93IMAGES+=	dvd1.iso
94. endif
95.endif
96.if exists(${.CURDIR}/${TARGET}/make-memstick.sh)
97RELEASE_TARGETS+= memstick.img
98RELEASE_TARGETS+= mini-memstick.img
99IMAGES+=	memstick.img
100IMAGES+=	mini-memstick.img
101.endif
102
103CLEANFILES=	packagesystem *.txz MANIFEST release ${IMAGES}
104.if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES)
105. for I in ${IMAGES}
106CLEANFILES+=	${I}.xz
107. endfor
108.endif
109.if defined(WITH_DVD) && !empty(WITH_DVD)
110CLEANFILES+=	pkg-stage
111.endif
112CLEANDIRS=	dist ftp disc1 bootonly dvd
113beforeclean:
114	chflags -R noschg .
115.include <bsd.obj.mk>
116clean: beforeclean
117
118base.txz:
119	mkdir -p ${DISTDIR}
120	cd ${WORLDDIR} && ${IMAKE} distributeworld DISTDIR=${.OBJDIR}/${DISTDIR}
121# Set up mergemaster root database
122	sh ${.CURDIR}/scripts/mm-mtree.sh -m ${WORLDDIR} -F \
123	    "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET} ${.MAKE.JOBS:D-j${.MAKE.JOBS}}" \
124	    -D "${.OBJDIR}/${DISTDIR}/base"
125	etcupdate extract -B -M "TARGET_ARCH=${TARGET_ARCH} TARGET=${TARGET}" \
126	    -s ${WORLDDIR} -d "${.OBJDIR}/${DISTDIR}/base/var/db/etcupdate"
127# Package all components
128	cd ${WORLDDIR} && ${IMAKE} packageworld DISTDIR=${.OBJDIR}/${DISTDIR}
129	mv ${DISTDIR}/*.txz .
130
131kernel.txz:
132	mkdir -p ${DISTDIR}
133	cd ${WORLDDIR} && ${IMAKE} distributekernel packagekernel DISTDIR=${.OBJDIR}/${DISTDIR}
134	mv ${DISTDIR}/kernel*.txz .
135
136src.txz:
137	mkdir -p ${DISTDIR}/usr
138	ln -fs ${WORLDDIR} ${DISTDIR}/usr/src
139	cd ${DISTDIR} && tar cLvf - --exclude .svn --exclude .zfs \
140	    --exclude .git --exclude @ --exclude usr/src/release/dist usr/src | \
141	    ${XZ_CMD} > ${.OBJDIR}/src.txz
142
143ports.txz:
144	mkdir -p ${DISTDIR}/usr
145	ln -fs ${PORTSDIR} ${DISTDIR}/usr/ports
146	cd ${DISTDIR} && tar cLvf - \
147	    --exclude .git --exclude .svn \
148	    --exclude usr/ports/distfiles --exclude usr/ports/packages \
149	    --exclude 'usr/ports/INDEX*' --exclude work usr/ports | \
150	    ${XZ_CMD} > ${.OBJDIR}/ports.txz
151
152disc1: packagesystem
153# Install system
154	mkdir -p ${.TARGET}
155	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
156	    DESTDIR=${.OBJDIR}/${.TARGET} MK_AT=no \
157	    MK_INSTALLLIB=no MK_LIB32=no MK_MAIL=no \
158	    MK_TOOLCHAIN=no MK_PROFILE=no \
159	    MK_RESCUE=no MK_DICT=no \
160	    MK_KERNEL_SYMBOLS=no MK_TESTS=no MK_DEBUG_FILES=no \
161	    -DDB_FROM_SRC
162# Copy distfiles
163	mkdir -p ${.TARGET}/usr/freebsd-dist
164	for dist in MANIFEST $$(ls *.txz | grep -vE -- '(base|lib32)-dbg'); \
165	    do cp $${dist} ${.TARGET}/usr/freebsd-dist; \
166	done
167# Set up installation environment
168	ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf
169	echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf
170	echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf
171	echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf
172	echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf
173	echo kernels_autodetect=\"NO\" >> ${.TARGET}/boot/loader.conf
174	cp ${.CURDIR}/rc.local ${.TARGET}/etc
175	touch ${.TARGET}
176
177bootonly: packagesystem
178# Install system
179	mkdir -p ${.TARGET}
180	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
181	    DESTDIR=${.OBJDIR}/${.TARGET} MK_AT=no \
182	    MK_GAMES=no \
183	    MK_INSTALLLIB=no MK_LIB32=no MK_MAIL=no \
184	    MK_TOOLCHAIN=no MK_PROFILE=no \
185	    MK_RESCUE=no MK_DICT=no \
186	    MK_KERNEL_SYMBOLS=no MK_TESTS=no MK_DEBUG_FILES=no \
187	    -DDB_FROM_SRC
188# Copy manifest only (no distfiles) to get checksums
189	mkdir -p ${.TARGET}/usr/freebsd-dist
190	cp MANIFEST ${.TARGET}/usr/freebsd-dist
191# Set up installation environment
192	ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf
193	echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf
194	echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf
195	echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf
196	echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf
197	echo kernels_autodetect=\"NO\" >> ${.TARGET}/boot/loader.conf
198	cp ${.CURDIR}/rc.local ${.TARGET}/etc
199
200dvd: packagesystem
201# Install system
202	mkdir -p ${.TARGET}
203	cd ${WORLDDIR} && ${IMAKE} installkernel installworld distribution \
204		DESTDIR=${.OBJDIR}/${.TARGET} MK_RESCUE=no MK_KERNEL_SYMBOLS=no \
205		MK_TESTS=no MK_DEBUG_FILES=no \
206		-DDB_FROM_SRC
207# Copy distfiles
208	mkdir -p ${.TARGET}/usr/freebsd-dist
209	for dist in MANIFEST $$(ls *.txz | grep -v -- '(base|lib32)-dbg'); \
210	    do cp $${dist} ${.TARGET}/usr/freebsd-dist; \
211	done
212# Set up installation environment
213	ln -fs /tmp/bsdinstall_etc/resolv.conf ${.TARGET}/etc/resolv.conf
214	echo sendmail_enable=\"NONE\" > ${.TARGET}/etc/rc.conf
215	echo hostid_enable=\"NO\" >> ${.TARGET}/etc/rc.conf
216	echo debug.witness.trace=0 >> ${.TARGET}/etc/sysctl.conf
217	echo vfs.mountroot.timeout=\"10\" >> ${.TARGET}/boot/loader.conf
218	echo kernels_autodetect=\"NO\" >> ${.TARGET}/boot/loader.conf
219	cp ${.CURDIR}/rc.local ${.TARGET}/etc
220	touch ${.TARGET}
221
222release.iso: disc1.iso
223disc1.iso: disc1
224	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_CD ${.TARGET} disc1 ${XTRADIR}
225
226dvd1.iso: dvd pkg-stage
227	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_DVD ${.TARGET} dvd ${XTRADIR}
228
229bootonly.iso: bootonly
230	sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b ${VOLUME_LABEL}_BO ${.TARGET} bootonly ${XTRADIR}
231
232memstick: memstick.img
233memstick.img: disc1
234	sh ${.CURDIR}/${TARGET}/make-memstick.sh disc1 ${.TARGET}
235
236mini-memstick: mini-memstick.img
237mini-memstick.img: bootonly
238	sh ${.CURDIR}/${TARGET}/make-memstick.sh bootonly ${.TARGET}
239
240packagesystem: base.txz kernel.txz ${EXTRA_PACKAGES}
241	sh ${.CURDIR}/scripts/make-manifest.sh *.txz > MANIFEST
242	touch ${.TARGET}
243
244pkg-stage:
245.if !defined(NOPKG) || empty(NOPKG)
246	env PORTSDIR=${PORTSDIR} REPOS_DIR=${.CURDIR}/pkg_repos/ \
247		sh ${.CURDIR}/scripts/pkg-stage.sh
248	mkdir -p ${.OBJDIR}/dvd/packages/repos/
249	cp ${.CURDIR}/scripts/FreeBSD_install_cdrom.conf \
250		${.OBJDIR}/dvd/packages/repos/
251.endif
252	touch ${.TARGET}
253
254cdrom: disc1.iso bootonly.iso
255dvdrom: dvd1.iso
256ftp: packagesystem
257	rm -rf ftp
258	mkdir -p ftp
259	cp *.txz MANIFEST ftp
260
261release:	real-release vm-release cloudware-release
262	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} release-done
263	true
264
265release-done:
266	touch release
267
268real-release:
269	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} obj
270	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${RELEASE_TARGETS}
271
272install:	release-install vm-install
273
274release-install:
275.if defined(DESTDIR) && !empty(DESTDIR)
276	mkdir -p ${DESTDIR}
277.endif
278	cp -a ftp ${DESTDIR}/
279.if !empty(IMAGES)
280.for I in ${IMAGES}
281	cp -p ${I} ${DESTDIR}/${OSRELEASE}-${I}
282. if defined(WITH_COMPRESSED_IMAGES) && !empty(WITH_COMPRESSED_IMAGES)
283	${XZ_CMD} -k ${DESTDIR}/${OSRELEASE}-${I}
284. endif
285.endfor
286	cd ${DESTDIR} && sha512 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA512
287	cd ${DESTDIR} && sha256 ${OSRELEASE}* > ${DESTDIR}/CHECKSUM.SHA256
288.endif
289
290.include "${.CURDIR}/Makefile.inc1"
291.include "${.CURDIR}/Makefile.vm"
292