xref: /dragonfly/nrelease/Makefile (revision 3d5a6e20)
1# $DragonFly: src/nrelease/Makefile,v 1.90 2008/09/01 21:20:30 swildner Exp $
2#
3
4#########################################################################
5#				ENHANCEMENTS	 			#
6#########################################################################
7
8# These targets are now obsolete and should not be used
9#
10installer_release: warning release
11installer_quickrel: warning quickrel
12installer_realquickrel: warning realquickrel
13installer_fetch: warning fetch
14
15# New method e.g. 'make gui release'.  A series of enhancement
16# targes may be specified which set make variables which enhance
17# the build in various ways.
18#
19gui installer img:
20
21warning:
22	@echo "WARNING: The installer_* targets are now obsolete, please"
23	@echo "use 'make blah' instead of 'make installer_blah'"
24	@echo ""
25	@echo "will continue in 10 seconds"
26	@sleep 10
27
28#########################################################################
29#				 SETUP		 			#
30#########################################################################
31
32ISODIR ?= /usr/release
33ISOROOT ?= ${ISODIR}/root
34OBJSYS= ${.OBJDIR}/../sys
35
36.if make(gui)
37KERNCONF ?= DFLYLIVE VKERNEL DFLYLIVE-SMP DFLYLIVE-SMP-NOAPIC
38.else
39KERNCONF ?= GENERIC VKERNEL
40.endif
41
42PKGSRC_PREFIX?=		/usr/pkg
43PKGBIN_PKG_ADD?=	${PKGSRC_PREFIX}/sbin/pkg_add
44PKGBIN_PKG_DELETE?=	${PKGSRC_PREFIX}/sbin/pkg_delete
45PKGBIN_PKG_ADMIN?=	${PKGSRC_PREFIX}/sbin/pkg_admin
46PKGBIN_MKISOFS?=	${PKGSRC_PREFIX}/bin/mkisofs
47PKGSRC_PKG_PATH?=	${ISODIR}/packages
48PKGSRC_DB?=		/var/db/pkg
49CVSUP_BOOTSTRAP_KIT?=	cvsup-bootstrap-20070716
50
51# We use env -i in the chroot, so that environment variables won't
52# disturb any (pkgsrc) build.  This has happened for TARGET_ARCH,
53# which is used by gmake in completely different context.
54CHROOT_CMD?=		env -i CCVER=${CCVER:Q} /usr/sbin/chroot ${ISOROOT} sh -c
55
56# pkgsrc packages to be built and installed on the release ISO
57#
58PKGSRC_PACKAGES?=	devel/scmgit \
59			net/isc-dhcp4 \
60			net/isc-dhcpd4 \
61			pkgtools/pkg_leaves \
62			sysutils/cdrtools
63
64# pkgsrc options to use when building packages
65#
66.if !make(gui)
67PKGSRC_OPTIONS?=	PKG_OPTIONS.scmgit=-scmgit-gui
68.endif
69
70# Even though buildiso wipes the packages, our check target has to run
71# first and old packages (listed as they appear in pkg_info) must be
72# cleaned out in order for the pkg_add -n test we use in the check target
73# to operate properly.
74#
75OLD_PKGSRC_PACKAGES?=	cdrtools-2.01.01.27nb1 \
76			cdrecord-2.00.3nb2 \
77			bootstrap-kit-20070205 \
78			dfuibe_installer-1.1.6 \
79			gettext-lib-0.14.5 \
80			dfuibe_installer-1.1.7nb1 \
81			dfuife_curses-1.5 \
82			gettext-lib-0.14.6 \
83			gettext-tools-0.14.6nb1 \
84			libaura-3.1 \
85			libdfui-4.2 \
86			libinstaller-5.1 \
87			bootstrap-kit-20080211 \
88			cdrtools-ossdvd-2.01.1.36nb2 \
89			isc-dhcp-base-4.0.0 \
90			isc-dhcp-server-4.0.0
91
92# Specify which root skeletons are required, and let the user include
93# their own.  They are copied into ISODIR during the `pkgcustomizeiso'
94# target; each overwrites the last.
95#
96REQ_ROOTSKELS=	${.CURDIR}/root \
97		${.CURDIR}/installer
98ROOTSKELS?=	${REQ_ROOTSKELS}
99
100.if make(gui)
101ISOFILE?=		${ISODIR}/dfly-gui.iso
102IMGFILE?=		${ISODIR}/dfly-gui.img
103PKGSRC_PACKAGES+=	meta/modular-xorg-apps \
104			meta/modular-xorg-drivers \
105			meta/modular-xorg-fonts \
106			meta/modular-xorg-libs \
107			wm/fluxbox \
108			www/firefox3 \
109			print/xpdf \
110			shells/zsh \
111			editors/emacs \
112			editors/vim \
113			chat/pidgin \
114			chat/irssi \
115			chat/xchat \
116			x11/rxvt-unicode \
117			x11/eterm \
118			lang/perl5 \
119			editors/nano \
120			shells/bash \
121			devel/exctags \
122			archivers/zip \
123			security/sudo \
124			www/links-gui \
125			net/nmap \
126			net/wget \
127			fonts/terminus-font \
128			net/rsync \
129			sysutils/idesk \
130			misc/screen
131ROOTSKELS+=		${.CURDIR}/gui
132.endif
133
134ISOFILE ?= ${ISODIR}/dfly.iso
135IMGFILE ?= ${ISODIR}/dfly.img
136
137IMGMNT ?= ${ISODIR}/mnt
138IMGUSBDEV ?= /dev/da0
139
140# note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
141# the additional '/nrelease' manually, as a safety measure.
142#
143NRLOBJDIR?= /usr/obj
144
145#########################################################################
146#				BASE ISO TARGETS 			#
147#########################################################################
148
149release:	check clean buildworld1 buildkernel1 \
150		buildiso syssrcs customizeiso mklocatedb mkiso mkimg
151
152quickrel:	check clean buildworld2 buildkernel2 \
153		buildiso syssrcs customizeiso mklocatedb mkiso mkimg
154
155realquickrel:	check clean buildiso syssrcs customizeiso mklocatedb mkiso \
156		mkimg
157
158quick:		quickrel
159
160realquick:	realquickrel
161
162#########################################################################
163#			   CORE SUPPORT TARGETS 			#
164#########################################################################
165
166check:
167.if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
168	@echo "The cvsup bootstrap kit is not installed.  You can install it with:"
169	@echo "    make fetch"
170	@exit 1
171.endif
172.if !defined(PKGSRC_PATH)
173	@echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for"
174	@echo "package building."
175	@exit 1
176.endif
177
178buildworld1 buildworld2:
179	cd ${.CURDIR}/..; ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} make -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
180
181buildkernel1 buildkernel2:
182.if make(gui)
183	cd ${.CURDIR}/..; \
184	for kernconf in ${KERNCONF}; do \
185		${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
186		make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
187			KERNCONF=$${kernconf} KERNCONFDIR=${.CURDIR}/gui/root; \
188	done
189.else
190	cd ${.CURDIR}/..; \
191	first=; \
192	for kernconf in ${KERNCONF}; do \
193		${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
194		make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
195			KERNCONF=$${kernconf} \
196			$${first:+-DNO_MODULES}; \
197		first=done; \
198	done
199.endif
200
201# note that we do not want to mess with any /usr/obj directories not related
202# to buildworld, buildkernel, or nrelease, so we must supply the proper
203# MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
204# buildkernel mechanism.
205#
206buildiso:
207	if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
208	if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
209	( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
210	( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
211		make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
212	cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
213.if make(gui)
214	if [ ! -d ${ISOROOT}/kernel.smp/boot ]; then mkdir -p ${ISOROOT}/kernel.smp/boot; fi
215	cd ${.CURDIR}/..; \
216	make installkernel DESTDIR=${ISOROOT} \
217	KERNCONF=DFLYLIVE DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
218	cd ${.CURDIR}/..; \
219	make installkernel DESTDIR=${ISOROOT} \
220	KERNCONF=VKERNEL DESTKERNNAME=kernel.VKERNEL -DNO_MODULES KERNCONFDIR=${.CURDIR}/gui/root; \
221	cd ${.CURDIR}/..; \
222	make installkernel DESTDIR=${ISOROOT}/kernel.smp \
223	KERNCONF=DFLYLIVE-SMP DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
224	cd ${.CURDIR}/..; \
225	make installkernel DESTDIR=${ISOROOT}/kernel.smp \
226	KERNCONF=DFLYLIVE-SMP-NOAPIC DESTKERNNAME=kernel.noapic \
227		KERNCONFDIR=${.CURDIR}/gui/root -DNO_MODULES;
228.else
229	cd ${.CURDIR}/..; \
230	first=; \
231	for kernconf in ${KERNCONF}; do \
232		make DESTDIR=${ISOROOT} \
233			installkernel KERNCONF=$${kernconf} \
234			$${first:+DESTKERNNAME=kernel.$${kernconf}} \
235			$${first:+-DNO_MODULES}; \
236		first=done; \
237	done
238.endif
239	ln -s kernel ${ISOROOT}/kernel.BOOTP
240	mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
241	mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
242	dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
243
244# Include kernel sources on the release CD (~14MB)
245#
246syssrcs:
247.if !defined(WITHOUT_SRCS)
248	( cd ${.CURDIR}/../..; tar -cf - src/Makefile src/Makefile.inc1 src/sys | bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2 )
249.endif
250
251customizeiso:
252.for ROOTSKEL in ${ROOTSKELS}
253	cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
254.endfor
255	(cd ${PKGSRC_PKG_PATH}; tar xzpf ${CVSUP_BOOTSTRAP_KIT}.tgz)
256	cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/bin/cvsup ${ISOROOT}/usr/local/bin/cvsup
257	cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/man/man1/cvsup.1 ${ISOROOT}/usr/local/man/man1/cvsup.1
258	pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
259.for UPGRADE_ITEM in Makefile			\
260		     etc.${MACHINE_ARCH} 	\
261		     isdn/Makefile		\
262		     rc.d/Makefile		\
263		     periodic/Makefile		\
264		     periodic/daily/Makefile	\
265		     periodic/security/Makefile	\
266		     periodic/weekly/Makefile	\
267		     periodic/monthly/Makefile
268	cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
269.endfor
270	# setup some things & mount pkgsrc tree
271	cp -p /etc/resolv.conf ${ISOROOT}/etc
272	${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
273	mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap/work
274	mkdir ${ISOROOT}/usr/pkgsrc
275	mount_null ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc
276
277	# bootstrap
278	${CHROOT_CMD} "cd /usr/pkgsrc/bootstrap; ./bootstrap --workdir /usr/pkgobj/bootstrap/work"
279	# build and install packages
280.for PKG in ${PKGSRC_PACKAGES}
281	${CHROOT_CMD} "cd /usr/pkgsrc/${PKG} && bmake WRKOBJDIR=/usr/pkgobj ${PKGSRC_OPTIONS} build install"
282.endfor
283	# remove packages which nothing depends on
284	${CHROOT_CMD} "pkg_leaves | xargs pkg_delete -R"
285	umount ${ISOROOT}/usr/pkgsrc
286	rmdir ${ISOROOT}/usr/pkgsrc
287	rm -rf ${ISOROOT}/usr/pkgobj
288	rm -f ${ISOROOT}/etc/resolv.conf
289	makewhatis ${ISOROOT}/usr/local/man
290	makewhatis ${ISOROOT}/usr/pkg/man
291
292mklocatedb:
293	( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
294		-path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
295		-prune -o -print | sed -e 's#^${ISOROOT}##g' | \
296		/usr/libexec/locate.mklocatedb \
297		-presort >${ISOROOT}/var/db/locate.database )
298
299mkiso:
300	( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
301		-R -J -o ${ISOFILE} \
302		-V DragonFly-`${.CURDIR}/../tools/gitrev.sh | cut -c -22` . )
303
304
305mkimg:
306.if make(img)
307	if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
308
309	echo "determine required image size" > /dev/null;		\
310	sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`;			\
311	echo "add 15% more space as required" > /dev/null;		\
312	sz=`bc -e "(($${sz}) / 1024) * 1.15" -equit | cut -f1 -d.`;	\
313	dd if=/dev/zero of=${IMGFILE} bs=1m count=$${sz};		\
314	fdisk -IB -p ${IMGFILE};					\
315	echo "determine free vn device" > /dev/null;			\
316	vn=`vnconfig -l | grep "not in use" | head -n 1 | cut -f 1 -d:`; \
317	vnconfig -e -s labels $${vn} ${IMGFILE}; 			\
318	echo "write standard disklabel" > /dev/null;			\
319	disklabel -w -r $${vn}s1 auto;					\
320	echo "read disklabel back" > /dev/null;				\
321	disklabel -r $${vn}s1 > ${IMGFILE}.label;			\
322	echo "determine number of sectors of whole disk" > /dev/null; 	\
323	secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`;		\
324	echo "and add a: partition" > /dev/null;			\
325	echo "  a:  $${secs} 0 4.2BSD" >> ${IMGFILE}.label;		\
326	echo "write modified disklabel back" > /dev/null;		\
327	disklabel -R -r $${vn}s1 ${IMGFILE}.label;			\
328	rm ${IMGFILE}.label;						\
329	echo "write bootsector" >  /dev/null;				\
330	disklabel -B $${vn}s1;						\
331	newfs /dev/$${vn}s1a;						\
332	mount /dev/$${vn}s1a ${IMGMNT};					\
333	cpdup -vvv ${ISOROOT} ${IMGMNT};				\
334	echo "fix /etc/fstab" > /dev/null;				\
335	echo "${IMGUSBDEV}s1a / ufs rw 0 0" > ${IMGMNT}/etc/fstab; 	\
336	echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab; 	\
337	df ${IMGMNT};							\
338	umount ${IMGMNT};						\
339	vnconfig -u $${vn};						\
340	rmdir ${IMGMNT}
341.endif
342
343clean:
344	-umount ${ISOROOT}/usr/pkgsrc
345	if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
346	if [ -d ${ISOROOT} ]; then rm -rf ${ISOROOT}/*; fi
347	if [ -d ${NRLOBJDIR}/nrelease ]; then rm -rf ${NRLOBJDIR}/nrelease; fi
348
349realclean:	clean
350	rm -rf ${OBJSYS}/${KERNCONF}
351	# do not use PKGSRC_PKG_PATH here, we do not want to destroy an
352	# override location.
353	if [ -d ${ISODIR}/packages ]; then rm -rf ${ISODIR}/packages; fi
354
355fetch:
356	@if [ ! -d ${PKGSRC_PKG_PATH} ]; then mkdir -p ${PKGSRC_PKG_PATH}; fi
357.if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
358	(cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${CVSUP_BOOTSTRAP_KIT}.tgz)
359.endif
360
361pkgsrc_bootstrap:
362	mkdir -p ${PKGSRC_PKG_PATH}
363.if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
364	(cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
365.endif
366	(cd ${PKGSRC_PKG_PATH}; tar xzpf ${PKGSRC_BOOTSTRAP_KIT}.tgz)
367	(cd ${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}/bootstrap; ./bootstrap)
368
369pkgsrc_cdrecord:
370.if !exists (${PKGBIN_MKISOFS})
371	${PKGBIN_PKG_ADD} ${PKGSRC_PKG_PATH}/cdrtools*
372.endif
373
374
375.PHONY: all release installer_release quickrel installer_quickrel realquickrel
376.PHONY: installer_fetch installer
377.PHONY: quick realquick
378.PHONY: installer_realquickrel check buildworld1 buildworld2
379.PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso mkimg
380.PHONY: clean realclean fetch
381
382.include <bsd.prog.mk>
383