xref: /dragonfly/nrelease/Makefile (revision 851524ec)
1# $DragonFly: src/nrelease/Makefile,v 1.35 2005/06/29 17:24:35 swildner Exp $
2#
3
4ISODIR ?= /usr/release
5ISOFILE ?= ${ISODIR}/dfly.iso
6ISOROOT = ${ISODIR}/root
7OBJSYS= ${.OBJDIR}/../sys
8KERNCONF ?= GENERIC
9
10# Specify which packages are required on the ISO, and let the user
11# specify additional packages to include.  During the `pkgaddiso'
12# target, the packages are obtained from PACKAGES_LOC.
13#
14REQ_PACKAGES= cdrtools-2.01 cvsup-without-gui-16.1h
15REL_PACKAGES?= ${REQ_PACKAGES} ${EXTRA_PACKAGES}
16.if defined(PACKAGES)
17PACKAGES_LOC?= ${PACKAGES}/All
18.else
19PACKAGES_LOC?= /usr/ports/packages/All
20.endif
21
22# Specify which root skeletons are required, and let the user include
23# their own.  They are copied into ISODIR during the `pkgcustomizeiso'
24# target; each overwrites the last.
25#
26REQ_ROOTSKELS= ${.CURDIR}/root
27ROOTSKELS?= ${REQ_ROOTSKELS} ${EXTRA_ROOTSKELS}
28
29# note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
30# the additional '/nrelease' manually, as a safety measure.
31#
32NRLOBJDIR?= /usr/obj
33
34WORLD_CCVER ?= ${CCVER}
35KERNEL_CCVER ?= ${CCVER}
36
37#########################################################################
38#				BASE ISO TARGETS 			#
39#########################################################################
40
41release:	check clean buildworld1 buildkernel1 \
42		buildiso customizeiso pkgaddiso mklocatedb mkiso
43
44quickrel:	check clean buildworld2 buildkernel2 \
45		buildiso customizeiso pkgaddiso mklocatedb mkiso
46
47realquickrel:	check clean \
48		buildiso customizeiso pkgaddiso mklocatedb mkiso
49
50#########################################################################
51#			ISO TARGETS WITH INSTALLER			#
52#########################################################################
53
54INSTALLER_PKGS= libaura-3.1 libdfui-4.1 libinstaller-5.1 \
55		dfuibe_installer-1.1.6 dfuife_curses-1.5 \
56		thttpd-notimeout-2.24 dfuife_cgi-1.4
57INSTALLER_SKELS= installer
58
59INSTALLER_ENV= EXTRA_PACKAGES="${INSTALLER_PKGS} ${EXTRA_PACKAGES}" \
60		EXTRA_ROOTSKELS="${INSTALLER_SKELS} ${EXTRA_ROOTSKELS}"
61
62installer_check:
63		@${INSTALLER_ENV} ${MAKE} check
64
65installer_fetchpkgs:
66		@${INSTALLER_ENV} ${MAKE} fetchpkgs
67
68installer_release:
69		${INSTALLER_ENV} ${MAKE} release
70
71installer_quickrel:
72		${INSTALLER_ENV} ${MAKE} quickrel
73
74installer_realquickrel:
75		${INSTALLER_ENV} ${MAKE} realquickrel
76
77#########################################################################
78#				HELPER TARGETS				#
79#########################################################################
80
81check:
82	@if [ ! -f /usr/local/bin/mkisofs ]; then \
83		echo "You need to install the sysutils/cdrtools port for"; \
84		echo "this target"; \
85		exit 1; \
86	fi
87.for PKG in ${REL_PACKAGES}
88	@if [ ! -f ${PACKAGES_LOC}/${PKG}.tgz ]; then \
89		echo "Unable to find ${PACKAGES_LOC}/${PKG}.tgz."; \
90		echo "(Perhaps you need to download or build it first?)"; \
91		echo ""; \
92		echo "If you are trying to build the installer, the"; \
93		echo "required packages can be obtained from:"; \
94		echo ""; \
95		echo "    http://www.bsdinstaller.org/packages/"; \
96		echo ""; \
97		echo "They can be automatically downloaded by issuing"; \
98		echo "'make installer_fetchpkgs' from this directory."; \
99		echo ""; \
100		exit 1; \
101	fi
102.endfor
103	@echo "check: all preqs found"
104
105fetchpkgs:
106.for PKG in ${REL_PACKAGES}
107	@if [ ! -f ${PACKAGES_LOC}/${PKG}.tgz ]; then \
108		cd ${PACKAGES_LOC} && \
109		echo "fetching ${PKG}..." && \
110		fetch http://www.bsdinstaller.org/packages/${PKG}.tgz; \
111	fi
112.endfor
113
114buildworld1:
115	( cd ${.CURDIR}/..; CCVER=${WORLD_CCVER} make buildworld )
116
117buildworld2:
118	( cd ${.CURDIR}/..; CCVER=${WORLD_CCVER} make quickworld )
119
120buildkernel1:
121	( cd ${.CURDIR}/..; CCVER=${KERNEL_CCVER} make buildkernel KERNCONF=${KERNCONF} )
122
123buildkernel2:
124	( cd ${.CURDIR}/..; CCVER=${KERNEL_CCVER} make quickkernel KERNCONF=${KERNCONF} )
125
126# note that we do not want to mess with any /usr/obj directories not related
127# to buildworld, buildkernel, or nrelease, so we must supply the proper
128# MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
129# buildkernel mechanism.
130#
131buildiso:
132	if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
133	if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
134	( cd ${.CURDIR}/..; make DESTDIR=${ISOROOT} installworld )
135	( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease make DESTDIR=${ISOROOT} distribution )
136	cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
137	( cd ${.CURDIR}/..; make DESTDIR=${ISOROOT} \
138		installkernel KERNCONF=${KERNCONF} )
139	ln -s kernel ${ISOROOT}/kernel.BOOTP
140	mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
141	mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
142	dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
143
144customizeiso:
145.for ROOTSKEL in ${ROOTSKELS}
146	cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
147.endfor
148	rm -rf `find ${ISOROOT} -type d -name CVS -print`
149	rm -rf ${ISOROOT}/usr/local/share/pristine
150	pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
151
152pkgcleaniso:
153	rm -f ${ISOROOT}/tmp/chrootscript
154	echo "#!/bin/sh" > ${ISOROOT}/tmp/chrootscript
155.for PKG in ${REL_PACKAGES}
156	echo "pkg_delete -f ${PKG}" >> ${ISOROOT}/tmp/chrootscript
157.endfor
158	chmod a+x ${ISOROOT}/tmp/chrootscript
159	chroot ${ISOROOT}/ /tmp/chrootscript || exit 0
160	rm ${ISOROOT}/tmp/chrootscript
161
162pkgaddiso:
163	rm -f ${ISOROOT}/tmp/chrootscript
164	echo "#!/bin/sh" > ${ISOROOT}/tmp/chrootscript
165.for PKG in ${REL_PACKAGES}
166	if [ ! -d ${ISOROOT}/var/db/pkg/${PKG} ]; then \
167		cp ${PACKAGES_LOC}/${PKG}.tgz ${ISOROOT}/tmp/${PKG}.tgz; \
168		echo "echo 'Installing package ${PKG}...' && \\" >> \
169		    ${ISOROOT}/tmp/chrootscript; \
170		echo "pkg_add /tmp/${PKG}.tgz && \\" >> \
171		    ${ISOROOT}/tmp/chrootscript; \
172	fi
173.endfor
174	echo "echo 'All packages added successfully!'" >> \
175	    ${ISOROOT}/tmp/chrootscript
176	chmod a+x ${ISOROOT}/tmp/chrootscript
177	chroot ${ISOROOT}/ /tmp/chrootscript
178	rm ${ISOROOT}/tmp/chrootscript
179.for PKG in ${REL_PACKAGES}
180	rm -f ${ISOROOT}/tmp/${PKG}.tgz
181.endfor
182
183mklocatedb:
184	( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
185		-path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
186		-prune -o -print | sed -e 's#^${ISOROOT}##g' | \
187		/usr/libexec/locate.mklocatedb \
188		-presort >${ISOROOT}/var/db/locate.database )
189
190mkiso:
191	( cd ${ISOROOT}; mkisofs -b boot/cdboot -no-emul-boot \
192		-R -J -V DragonFly -o ${ISOFILE} . )
193
194clean:
195	if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
196	if [ -d ${ISOROOT} ]; then rm -rf ${ISOROOT}/*; fi
197	if [ -d ${NRLOBJDIR}/nrelease ]; then rm -rf ${NRLOBJDIR}/nrelease; fi
198
199realclean:	clean
200	rm -rf ${OBJSYS}/${KERNCONF}
201
202.include <bsd.prog.mk>
203