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