xref: /dragonfly/nrelease/Makefile (revision 702a95cc)
1bfe20b28SSascha Wildner# $DragonFly: src/nrelease/Makefile,v 1.90 2008/09/01 21:20:30 swildner Exp $
26ca9a59cSMatthew Dillon#
35b22b655SMatthew Dillon
49b29c40aSMatthew Dillon#########################################################################
59b29c40aSMatthew Dillon#				ENHANCEMENTS	 			#
69b29c40aSMatthew Dillon#########################################################################
79b29c40aSMatthew Dillon
8f4ec1279SSascha Wildner# New method e.g. 'make gui release'.  A series of enhancement
99b29c40aSMatthew Dillon# targes may be specified which set make variables which enhance
109b29c40aSMatthew Dillon# the build in various ways.
119b29c40aSMatthew Dillon#
12b9c3e754SMichael Neumanngui installer img:
139b29c40aSMatthew Dillon
149b29c40aSMatthew Dillon#########################################################################
159b29c40aSMatthew Dillon#				 SETUP		 			#
169b29c40aSMatthew Dillon#########################################################################
179b29c40aSMatthew Dillon
186ca9a59cSMatthew DillonISODIR?=	/usr/release
195ec00f8aSSascha WildnerISOROOT?=	${ISODIR}/root
206ca9a59cSMatthew DillonOBJSYS=		${.OBJDIR}/../sys
21bfe20b28SSascha Wildner
225cb6cda9SSascha WildnerMAKE_JOBS?=	$$(sysctl -n hw.ncpu)
233fff415bSSascha Wildner
24bfe20b28SSascha Wildner.if make(gui)
25bfe20b28SSascha WildnerKERNCONF ?= DFLYLIVE VKERNEL DFLYLIVE-SMP DFLYLIVE-SMP-NOAPIC
26bfe20b28SSascha Wildner.else
27*702a95ccSSimon Schubert# XXX makeshift fix to build the right kernel for the (target) architecture
28*702a95ccSSimon Schubert# We should configure this in the platform files somehow
29*702a95ccSSimon Schubert.if ${MACHINE_ARCH} == "i386"
301d3eb8c5SMatthew DillonKERNCONF ?= GENERIC VKERNEL
31*702a95ccSSimon Schubert.else
32*702a95ccSSimon SchubertKERNCONF ?= AMD64_GENERIC
33*702a95ccSSimon Schubert.endif
34bfe20b28SSascha Wildner.endif
356ca9a59cSMatthew Dillon
36cc224c64SJoerg SonnenbergerPKGSRC_PREFIX?=		/usr/pkg
37bce110a5SMatthew DillonPKGBIN_PKG_ADD?=	${PKGSRC_PREFIX}/sbin/pkg_add
3895b64753SMatthew DillonPKGBIN_PKG_DELETE?=	${PKGSRC_PREFIX}/sbin/pkg_delete
39c791834fSJoerg SonnenbergerPKGBIN_PKG_ADMIN?=	${PKGSRC_PREFIX}/sbin/pkg_admin
40bce110a5SMatthew DillonPKGBIN_MKISOFS?=	${PKGSRC_PREFIX}/bin/mkisofs
41bce110a5SMatthew DillonPKGSRC_PKG_PATH?=	${ISODIR}/packages
42af88d908SJustin C. SherrillPKGSRC_BOOTSTRAP_URL?=	http://avalon.dragonflybsd.org/DragonFly-pkgsrc-packages/i386/1.12.0-RELEASE-BUILD
434b08f3dfSMatthew DillonCVSUP_BOOTSTRAP_KIT?=	cvsup-bootstrap-20070716
44bce110a5SMatthew Dillon
45cc55a235SSimon Schubert# We use env -i in the chroot, so that environment variables won't
46cc55a235SSimon Schubert# disturb any (pkgsrc) build.  This has happened for TARGET_ARCH,
47cc55a235SSimon Schubert# which is used by gmake in completely different context.
48e2dbfa0bSThomas Nikolajsen#
49cc55a235SSimon SchubertCHROOT_CMD?=		env -i CCVER=${CCVER:Q} /usr/sbin/chroot ${ISOROOT} sh -c
50cc55a235SSimon Schubert
518abe78a1SMatthew Dillon# User may specify extra packages in addition to the defaults
5295b64753SMatthew Dillon#
538abe78a1SMatthew DillonPKGSRC_EXTRA_PACKAGES?=
548abe78a1SMatthew Dillon
558abe78a1SMatthew Dillon# Pkgsrc packages to be built and installed on the release ISO
568abe78a1SMatthew Dillon#
578abe78a1SMatthew DillonPKGSRC_PACKAGES?=	pkgtools/pkg_leaves \
588abe78a1SMatthew Dillon			pkgtools/pkg_tarup \
598abe78a1SMatthew Dillon			devel/scmgit \
60fbc26094SSascha Wildner			net/isc-dhcp4 \
61fbc26094SSascha Wildner			net/isc-dhcpd4 \
628abe78a1SMatthew Dillon			sysutils/cdrtools \
638abe78a1SMatthew Dillon			${PKGSRC_EXTRA_PACKAGES}
64fbc26094SSascha Wildner
65fbc26094SSascha Wildner# pkgsrc options to use when building packages
66fbc26094SSascha Wildner#
673fff415bSSascha WildnerPKGSRC_OPTIONS+=	MAKE_JOBS=${MAKE_JOBS}
683fff415bSSascha WildnerPKGSRC_OPTIONS+=	WRKOBJDIR=/usr/pkgobj
699ecb41e5SSascha WildnerPKGSRC_OPTIONS+=	PKG_DEFAULT_OPTIONS='dri inet6'
70fbc26094SSascha Wildner.if !make(gui)
719ecb41e5SSascha WildnerPKGSRC_OPTIONS+=	PKG_OPTIONS.scmgit=-scmgit-gui
72fbc26094SSascha Wildner.endif
738188de86SMatthew Dillon
7495b64753SMatthew Dillon# Even though buildiso wipes the packages, our check target has to run
7595b64753SMatthew Dillon# first and old packages (listed as they appear in pkg_info) must be
7695b64753SMatthew Dillon# cleaned out in order for the pkg_add -n test we use in the check target
7795b64753SMatthew Dillon# to operate properly.
7895b64753SMatthew Dillon#
79fbc26094SSascha WildnerOLD_PKGSRC_PACKAGES?=	cdrtools-2.01.01.27nb1 \
80fbc26094SSascha Wildner			cdrecord-2.00.3nb2 \
81fbc26094SSascha Wildner			bootstrap-kit-20070205 \
82fbc26094SSascha Wildner			dfuibe_installer-1.1.6 \
83fbc26094SSascha Wildner			gettext-lib-0.14.5 \
84fbc26094SSascha Wildner			dfuibe_installer-1.1.7nb1 \
85fbc26094SSascha Wildner			dfuife_curses-1.5 \
86fbc26094SSascha Wildner			gettext-lib-0.14.6 \
87fbc26094SSascha Wildner			gettext-tools-0.14.6nb1 \
88fbc26094SSascha Wildner			libaura-3.1 \
89fbc26094SSascha Wildner			libdfui-4.2 \
90fbc26094SSascha Wildner			libinstaller-5.1 \
91fbc26094SSascha Wildner			bootstrap-kit-20080211 \
92fbc26094SSascha Wildner			cdrtools-ossdvd-2.01.1.36nb2 \
93fbc26094SSascha Wildner			isc-dhcp-base-4.0.0 \
94fbc26094SSascha Wildner			isc-dhcp-server-4.0.0
9595b64753SMatthew Dillon
968188de86SMatthew Dillon# Specify which root skeletons are required, and let the user include
97e2dbfa0bSThomas Nikolajsen# their own.  They are copied into ISODIR during the `customizeiso'
988188de86SMatthew Dillon# target; each overwrites the last.
998188de86SMatthew Dillon#
100fbc26094SSascha WildnerREQ_ROOTSKELS=	${.CURDIR}/root \
101fbc26094SSascha Wildner		${.CURDIR}/installer
102cc224c64SJoerg SonnenbergerROOTSKELS?=	${REQ_ROOTSKELS}
103cc224c64SJoerg Sonnenberger
104fbc26094SSascha Wildner.if make(gui)
105bfe20b28SSascha WildnerISOFILE?=		${ISODIR}/dfly-gui.iso
106b9c3e754SMichael NeumannIMGFILE?=		${ISODIR}/dfly-gui.img
1070936984eSMatthew DillonPKGSRC_PACKAGES+=	meta-pkgs/modular-xorg-apps \
1080936984eSMatthew Dillon			meta-pkgs/modular-xorg-drivers \
1090936984eSMatthew Dillon			meta-pkgs/modular-xorg-fonts \
1100936984eSMatthew Dillon			meta-pkgs/modular-xorg-libs \
111fbc26094SSascha Wildner			wm/fluxbox \
1120936984eSMatthew Dillon			wm/fvwm \
113fbc26094SSascha Wildner			www/firefox3 \
114fbc26094SSascha Wildner			print/xpdf \
115fbc26094SSascha Wildner			shells/zsh \
116fbc26094SSascha Wildner			editors/emacs \
117fbc26094SSascha Wildner			editors/vim \
118fbc26094SSascha Wildner			chat/pidgin \
119fbc26094SSascha Wildner			chat/irssi \
120fbc26094SSascha Wildner			chat/xchat \
1210936984eSMatthew Dillon			x11/modular-xorg-server \
122fbc26094SSascha Wildner			x11/rxvt-unicode \
123fbc26094SSascha Wildner			x11/eterm \
124fbc26094SSascha Wildner			lang/perl5 \
125fbc26094SSascha Wildner			editors/nano \
126fbc26094SSascha Wildner			shells/bash \
127fbc26094SSascha Wildner			devel/exctags \
128fbc26094SSascha Wildner			archivers/zip \
129fbc26094SSascha Wildner			security/sudo \
130fbc26094SSascha Wildner			www/links-gui \
131fbc26094SSascha Wildner			net/nmap \
132fbc26094SSascha Wildner			net/wget \
133fbc26094SSascha Wildner			fonts/terminus-font \
134fbc26094SSascha Wildner			net/rsync \
135fbc26094SSascha Wildner			sysutils/idesk \
1360936984eSMatthew Dillon			time/asclock \
137fbc26094SSascha Wildner			misc/screen
138bfe20b28SSascha WildnerROOTSKELS+=		${.CURDIR}/gui
139bfe20b28SSascha Wildner.endif
140bfe20b28SSascha Wildner
1413f279b9eSSascha WildnerISOFILE ?= ${ISODIR}/dfly.iso
142b9c3e754SMichael NeumannIMGFILE ?= ${ISODIR}/dfly.img
143b9c3e754SMichael Neumann
14460b68cbbSMichael NeumannIMGMNT ?= ${ISODIR}/mnt
145a2f841edSMatthew Dillon
146a2f841edSMatthew Dillon# USB umass now probes starting at da8, so the usb stick is
147a2f841edSMatthew Dillon# probably sitting on da8.
148a2f841edSMatthew Dillon#
1499a122c9aSMatthew DillonIMGUSBDEV ?= da8
1503f279b9eSSascha Wildner
1515b22b655SMatthew Dillon# note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
1525b22b655SMatthew Dillon# the additional '/nrelease' manually, as a safety measure.
1535b22b655SMatthew Dillon#
1545b22b655SMatthew DillonNRLOBJDIR?= /usr/obj
1555b22b655SMatthew Dillon
1568188de86SMatthew Dillon#########################################################################
1578188de86SMatthew Dillon#				BASE ISO TARGETS 			#
1588188de86SMatthew Dillon#########################################################################
1596ca9a59cSMatthew Dillon
1607ebbae99SSascha Wildnerrelease:	check clean buildworld1 buildkernel1 \
16103e2a3c5SSascha Wildner		buildiso srcs customizeiso mklocatedb \
1620936984eSMatthew Dillon		mkiso mkimg
1636ca9a59cSMatthew Dillon
1647ebbae99SSascha Wildnerquickrel:	check clean buildworld2 buildkernel2 \
16503e2a3c5SSascha Wildner		buildiso srcs customizeiso mklocatedb \
1660936984eSMatthew Dillon		mkiso mkimg
1678188de86SMatthew Dillon
16803e2a3c5SSascha Wildnerrealquickrel:	check clean \
16903e2a3c5SSascha Wildner		buildiso srcs customizeiso mklocatedb \
1700936984eSMatthew Dillon		mkiso mkimg
1716ca9a59cSMatthew Dillon
17203e2a3c5SSascha Wildnerrestartpkgs:	check customizeiso mklocatedb mkiso mkimg
1735af45f85SMatthew Dillon
1749b29c40aSMatthew Dillonquick:		quickrel
1759b29c40aSMatthew Dillon
1769b29c40aSMatthew Dillonrealquick:	realquickrel
1779b29c40aSMatthew Dillon
1785af45f85SMatthew Dillon
1799b29c40aSMatthew Dillon#########################################################################
1809b29c40aSMatthew Dillon#			   CORE SUPPORT TARGETS 			#
1819b29c40aSMatthew Dillon#########################################################################
1829b29c40aSMatthew Dillon
183d2582113SChris Presseycheck:
1840936984eSMatthew Dillon.if !exists(${PKGBIN_PKG_ADMIN})
1850936984eSMatthew Dillon	@echo "You never bootstrapped pkgsrc on your machine.  You can install it with:"
1860936984eSMatthew Dillon	@echo "    make pkgsrc_bootstrap"
1870936984eSMatthew Dillon.endif
1880a1628e7SMatthew Dillon.if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
1890a1628e7SMatthew Dillon	@echo "The cvsup bootstrap kit is not installed.  You can install it with:"
190f4ec1279SSascha Wildner	@echo "    make fetch"
1910936984eSMatthew Dillon.endif
1920936984eSMatthew Dillon.if !exists (${PKGBIN_MKISOFS})
1930936984eSMatthew Dillon	@echo
1940936984eSMatthew Dillon	@echo "Your machine does not have cdrtools installed.  You can install it with:"
1950936984eSMatthew Dillon	@echo "    make pkgsrc_cdrecord"
1960a1628e7SMatthew Dillon.endif
197fbc26094SSascha Wildner.if !defined(PKGSRC_PATH)
198fbc26094SSascha Wildner	@echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for"
1995af45f85SMatthew Dillon	@echo "package building.  For example /usr/pkgsrc.  See the Makefile"
2005af45f85SMatthew Dillon	@echo "in /usr if you are unfamiliar with pkgsrc."
2010936984eSMatthew Dillon.endif
2020936984eSMatthew Dillon.if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
2030936984eSMatthew Dillon	@exit 1
2040936984eSMatthew Dillon.endif
2050936984eSMatthew Dillon.if !exists (${PKGBIN_MKISOFS})
2060936984eSMatthew Dillon	@exit 1
2070936984eSMatthew Dillon.endif
2080936984eSMatthew Dillon.if !defined(PKGSRC_PATH)
209fbc26094SSascha Wildner	@exit 1
210fbc26094SSascha Wildner.endif
2112e3f8f38SMatthew Dillon
212588a679cSSimon Schubertbuildworld1 buildworld2:
2133fff415bSSascha Wildner	cd ${.CURDIR}/..; \
2143fff415bSSascha Wildner	${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
2153fff415bSSascha Wildner		make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
2166ca9a59cSMatthew Dillon
217588a679cSSimon Schubertbuildkernel1 buildkernel2:
218bfe20b28SSascha Wildner.if make(gui)
219bfe20b28SSascha Wildner	cd ${.CURDIR}/..; \
220bfe20b28SSascha Wildner	for kernconf in ${KERNCONF}; do \
221448b21e7SSimon Schubert		${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
2223fff415bSSascha Wildner			make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
223bfe20b28SSascha Wildner			KERNCONF=$${kernconf} KERNCONFDIR=${.CURDIR}/gui/root; \
224bfe20b28SSascha Wildner	done
225bfe20b28SSascha Wildner.else
226588a679cSSimon Schubert	cd ${.CURDIR}/..; \
227588a679cSSimon Schubert	first=; \
228588a679cSSimon Schubert	for kernconf in ${KERNCONF}; do \
229448b21e7SSimon Schubert		${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
2303fff415bSSascha Wildner			make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
231588a679cSSimon Schubert			KERNCONF=$${kernconf} \
232588a679cSSimon Schubert			$${first:+-DNO_MODULES}; \
233588a679cSSimon Schubert		first=done; \
234588a679cSSimon Schubert	done
235bfe20b28SSascha Wildner.endif
2366ca9a59cSMatthew Dillon
2375b22b655SMatthew Dillon# note that we do not want to mess with any /usr/obj directories not related
2385b22b655SMatthew Dillon# to buildworld, buildkernel, or nrelease, so we must supply the proper
2395b22b655SMatthew Dillon# MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
2405b22b655SMatthew Dillon# buildkernel mechanism.
2415b22b655SMatthew Dillon#
2426ca9a59cSMatthew Dillonbuildiso:
2436ca9a59cSMatthew Dillon	if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
2445b22b655SMatthew Dillon	if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
245f4ec1279SSascha Wildner	( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
246ab64cf06SSimon Schubert	( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
247ab64cf06SSimon Schubert		make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
24821aa02d0SChris Pressey	cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
249bfe20b28SSascha Wildner.if make(gui)
250fbc26094SSascha Wildner	if [ ! -d ${ISOROOT}/kernel.smp/boot ]; then mkdir -p ${ISOROOT}/kernel.smp/boot; fi
251bfe20b28SSascha Wildner	cd ${.CURDIR}/..; \
252bfe20b28SSascha Wildner	make installkernel DESTDIR=${ISOROOT} \
253bfe20b28SSascha Wildner	KERNCONF=DFLYLIVE DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
254bfe20b28SSascha Wildner	cd ${.CURDIR}/..; \
255bfe20b28SSascha Wildner	make installkernel DESTDIR=${ISOROOT} \
256bfe20b28SSascha Wildner	KERNCONF=VKERNEL DESTKERNNAME=kernel.VKERNEL -DNO_MODULES KERNCONFDIR=${.CURDIR}/gui/root; \
257bfe20b28SSascha Wildner	cd ${.CURDIR}/..; \
258bfe20b28SSascha Wildner	make installkernel DESTDIR=${ISOROOT}/kernel.smp \
259bfe20b28SSascha Wildner	KERNCONF=DFLYLIVE-SMP DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
260bfe20b28SSascha Wildner	cd ${.CURDIR}/..; \
261bfe20b28SSascha Wildner	make installkernel DESTDIR=${ISOROOT}/kernel.smp \
262bfe20b28SSascha Wildner	KERNCONF=DFLYLIVE-SMP-NOAPIC DESTKERNNAME=kernel.noapic \
263bfe20b28SSascha Wildner		KERNCONFDIR=${.CURDIR}/gui/root -DNO_MODULES;
264bfe20b28SSascha Wildner.else
265588a679cSSimon Schubert	cd ${.CURDIR}/..; \
266588a679cSSimon Schubert	first=; \
267588a679cSSimon Schubert	for kernconf in ${KERNCONF}; do \
268588a679cSSimon Schubert		make DESTDIR=${ISOROOT} \
269588a679cSSimon Schubert			installkernel KERNCONF=$${kernconf} \
270588a679cSSimon Schubert			$${first:+DESTKERNNAME=kernel.$${kernconf}} \
271588a679cSSimon Schubert			$${first:+-DNO_MODULES}; \
272588a679cSSimon Schubert		first=done; \
273588a679cSSimon Schubert	done
274bfe20b28SSascha Wildner.endif
2753f6dbfa9SThomas Nikolajsen	ln -s kernel ${ISOROOT}/boot/kernel.BOOTP
2766ca9a59cSMatthew Dillon	mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
2776ca9a59cSMatthew Dillon	mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
2786ca9a59cSMatthew Dillon	dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
2798188de86SMatthew Dillon
280e2dbfa0bSThomas Nikolajsen# Release CD: Kernel sources (~16M) and the full pkgsrc tree (~27M)
281c19c746bSMatthew Dillon# Release DVD: Full sources (~90M) and the full pkgsrc tree (~27M)
28219d86faaSMatthew Dillon#
283e2dbfa0bSThomas Nikolajsensrcs:
284e2dbfa0bSThomas Nikolajsen.if !defined(WITHOUT_SRCS)
2851eeae16fSMatthew Dillon	rm -f ${ISOROOT}/usr/pkgsrc-git.tgz
2861eeae16fSMatthew Dillon	rm -f ${ISOROOT}/usr/pkgsrc
2871eeae16fSMatthew Dillon	mkdir -p ${ISOROOT}/usr/pkgsrc
2881eeae16fSMatthew Dillon	cd ${ISOROOT}/usr/pkgsrc && git init
2891eeae16fSMatthew Dillon	cd ${ISOROOT}/usr/pkgsrc && \
2901eeae16fSMatthew Dillon		git remote add origin git://git.dragonflybsd.org/pkgsrc.git
2911eeae16fSMatthew Dillon	cd ${ISOROOT}/usr/pkgsrc && git fetch origin
2921eeae16fSMatthew Dillon	cd ${ISOROOT}/usr/pkgsrc && git branch vendor origin/vendor
2931eeae16fSMatthew Dillon	cd ${ISOROOT}/usr/pkgsrc && git gc
294c19c746bSMatthew Dillon.if make(gui)
2951eeae16fSMatthew Dillon	rm -f ${ISOROOT}/usr/src-git.tgz
2961eeae16fSMatthew Dillon	rm -rf ${ISOROOT}/usr/src
2971eeae16fSMatthew Dillon	mkdir -p ${ISOROOT}/usr/src
2981eeae16fSMatthew Dillon	cd ${ISOROOT}/usr/src && git init
2991eeae16fSMatthew Dillon	cd ${ISOROOT}/usr/src && \
3001eeae16fSMatthew Dillon		git remote add origin git://git.dragonflybsd.org/dragonfly.git
3011eeae16fSMatthew Dillon	cd ${ISOROOT}/usr/src && git fetch origin
3021eeae16fSMatthew Dillon	cd ${ISOROOT}/usr/src && git branch master origin/master
3031eeae16fSMatthew Dillon	cd ${ISOROOT}/usr/src && git gc
304c19c746bSMatthew Dillon.else
305e2dbfa0bSThomas Nikolajsen	rm -f ${ISOROOT}/usr/src-sys.tgz
3063617b2c9SSascha Wildner	cd ${.CURDIR}/.. && tar --exclude .git --exclude CVS -s '/^\./src/' \
3073617b2c9SSascha Wildner		-czf ${ISOROOT}/usr/src-sys.tgz ./Makefile ./Makefile.inc1 ./sys
308c19c746bSMatthew Dillon.endif
30966b79064SMatthew Dillon.endif
31019d86faaSMatthew Dillon
3115af45f85SMatthew Dillon# Customize the ISO by copying rootskels in reverse priority order,
3125af45f85SMatthew Dillon# building packages, and doing other post-install tasks.
3135af45f85SMatthew Dillon#
3148188de86SMatthew Dilloncustomizeiso:
3155af45f85SMatthew Dillon	# Copy the rootskels.  Allow sources to be owned by someone other
3165af45f85SMatthew Dillon	# then root (as is common when checked out via git).
3175af45f85SMatthew Dillon	#
3188188de86SMatthew Dillon.for ROOTSKEL in ${ROOTSKELS}
3198188de86SMatthew Dillon	cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
3205af45f85SMatthew Dillon	@test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
3215af45f85SMatthew Dillon	@test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
3228188de86SMatthew Dillon.endfor
323fbc26094SSascha Wildner	(cd ${PKGSRC_PKG_PATH}; tar xzpf ${CVSUP_BOOTSTRAP_KIT}.tgz)
3240a1628e7SMatthew Dillon	cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/bin/cvsup ${ISOROOT}/usr/local/bin/cvsup
325c751e497SSascha Wildner	cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/man/man1/cvsup.1 ${ISOROOT}/usr/local/man/man1/cvsup.1
3267249926bSMatthew Dillon	pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
3274fba3387SChris Pressey.for UPGRADE_ITEM in Makefile			\
3284fba3387SChris Pressey		     etc.${MACHINE_ARCH} 	\
3294fba3387SChris Pressey		     isdn/Makefile		\
3304fba3387SChris Pressey		     rc.d/Makefile		\
3314fba3387SChris Pressey		     periodic/Makefile		\
3324fba3387SChris Pressey		     periodic/daily/Makefile	\
3334fba3387SChris Pressey		     periodic/security/Makefile	\
3344fba3387SChris Pressey		     periodic/weekly/Makefile	\
3354fba3387SChris Pressey		     periodic/monthly/Makefile
3364fba3387SChris Pressey	cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
3374fba3387SChris Pressey.endfor
3388abe78a1SMatthew Dillon	#
3398abe78a1SMatthew Dillon	# Setup some things & mount pkgsrc tree.  Use defensive umounts and
3408abe78a1SMatthew Dillon	# rm -rf's to allow restarts.  Allow /usr/pkgsrc to be read-only.
3418abe78a1SMatthew Dillon	#
3428abe78a1SMatthew Dillon	# If we did not get past the bootstrap we clean out the entire
3438abe78a1SMatthew Dillon	# /usr/pkg infrastructure.  Otherwise we attempt to pick up where
3448abe78a1SMatthew Dillon	# we left off.
3458abe78a1SMatthew Dillon	#
346fbc26094SSascha Wildner	cp -p /etc/resolv.conf ${ISOROOT}/etc
347cc55a235SSimon Schubert	${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
3488abe78a1SMatthew Dillon	-@umount ${ISOROOT}/usr/pkgsrc/distfiles
3498abe78a1SMatthew Dillon	-@umount ${ISOROOT}/usr/pkgsrc
35045e80934SMatthew Dillon	-@umount ${ISOROOT}/dev
3518abe78a1SMatthew Dillon	mkdir -p ${ISODIR}/distfiles
3528abe78a1SMatthew Dillon	rm -rf ${ISOROOT}/usr/pkgobj
3538abe78a1SMatthew Dillon	#
3541eeae16fSMatthew Dillon	# Mount /usr/pkgsrc, make sure /usr/pkgsrc/distfiles is writable.
3551eeae16fSMatthew Dillon	# Make /usr/pkgsrc read-only for safety, else a failed umount and
3561eeae16fSMatthew Dillon	# our rm -rf will do bad things.
3578abe78a1SMatthew Dillon	#
3588abe78a1SMatthew Dillon	mkdir -p ${ISOROOT}/usr/pkgobj
3593aa2328eSSimon Schubert	mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap
3608abe78a1SMatthew Dillon	mkdir -p ${ISOROOT}/usr/pkgsrc
3611eeae16fSMatthew Dillon	mount_null -o ro ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc
3620c5de895SSimon Schubert	mount_null /dev ${ISOROOT}/dev
3635af45f85SMatthew Dillon	cp /etc/shells ${ISOROOT}/usr/pkgsrc/distfiles/.test > /dev/null 2>&1 \
3645af45f85SMatthew Dillon	    || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/pkgsrc/distfiles
3658abe78a1SMatthew Dillon	#
3665af45f85SMatthew Dillon	# Bootstrap, if not already installed, and add licenses needed
367ee3561eeSMatthew Dillon	# for the gui release
3688abe78a1SMatthew Dillon	#
369c19c746bSMatthew Dillon	test -e ${ISODIR}/.didbootstrap || \
370c19c746bSMatthew Dillon	    rm -rf ${ISOROOT}/usr/pkg ${ISOROOT}/var/db/pkg \
371c19c746bSMatthew Dillon		    ${ISOROOT}/var/db/pkg.refcount
372c19c746bSMatthew Dillon	test -e ${ISODIR}/.didbootstrap || \
3738abe78a1SMatthew Dillon	    ${CHROOT_CMD} "cd /usr/pkgsrc/bootstrap;    \
3748abe78a1SMatthew Dillon		./bootstrap --workdir /usr/pkgobj/bootstrap/work"
3753fff415bSSascha Wildner.if make(gui)
376c19c746bSMatthew Dillon	test -e ${ISODIR}/.didbootstrap || \
377ee3561eeSMatthew Dillon	    echo ".ifdef BSD_PKG_MK	# added by nrelease" \
378ee3561eeSMatthew Dillon		>> ${ISOROOT}/usr/pkg/etc/mk.conf
379c19c746bSMatthew Dillon	test -e ${ISODIR}/.didbootstrap || \
380ee3561eeSMatthew Dillon	    echo "ACCEPTABLE_LICENSES+=openmotif-license" \
381ee3561eeSMatthew Dillon		>> ${ISOROOT}/usr/pkg/etc/mk.conf
382c19c746bSMatthew Dillon	test -e ${ISODIR}/.didbootstrap || \
383ee3561eeSMatthew Dillon	    echo "ACCEPTABLE_LICENSES+=vim-license" \
384ee3561eeSMatthew Dillon		>> ${ISOROOT}/usr/pkg/etc/mk.conf
385c19c746bSMatthew Dillon	test -e ${ISODIR}/.didbootstrap || \
386ee3561eeSMatthew Dillon	    echo ".endif			# added by nrelease" \
387ee3561eeSMatthew Dillon		>> ${ISOROOT}/usr/pkg/etc/mk.conf
3883fff415bSSascha Wildner.endif
389c19c746bSMatthew Dillon	test -e ${ISODIR}/.didbootstrap || sync
390c19c746bSMatthew Dillon	test -e ${ISODIR}/.didbootstrap || touch ${ISODIR}/.didbootstrap
3918abe78a1SMatthew Dillon	#
3928abe78a1SMatthew Dillon	# Build and install packages, skip packages already installed
3938abe78a1SMatthew Dillon	#
39420585f87SMatthew Dillon.for PKG in ${PKGSRC_PACKAGES}
3958abe78a1SMatthew Dillon	${CHROOT_CMD} "cd /usr/pkgsrc/${PKG} && \
3963fff415bSSascha Wildner	    (bmake check > /dev/null 2>&1 || \
3973fff415bSSascha Wildner	    bmake ${PKGSRC_OPTIONS} clean build install)"
39820585f87SMatthew Dillon.endfor
3998abe78a1SMatthew Dillon	#
4008abe78a1SMatthew Dillon	# Remove packages which nothing depends on and clean up
4018abe78a1SMatthew Dillon	#
402cc55a235SSimon Schubert	${CHROOT_CMD} "pkg_leaves | xargs pkg_delete -R"
4038abe78a1SMatthew Dillon	-umount ${ISOROOT}/usr/pkgsrc/distfiles
40445e80934SMatthew Dillon	umount ${ISOROOT}/dev
405fbc26094SSascha Wildner	umount ${ISOROOT}/usr/pkgsrc
406589a5738SSascha Wildner	rm -rf ${ISOROOT}/usr/pkgobj
407fbc26094SSascha Wildner	rm -f ${ISOROOT}/etc/resolv.conf
4083652f053SSascha Wildner	makewhatis ${ISOROOT}/usr/local/man
4093652f053SSascha Wildner	makewhatis ${ISOROOT}/usr/pkg/man
4106ca9a59cSMatthew Dillon
4110936984eSMatthew Dillon# So locate works
4120936984eSMatthew Dillon#
4138398ca17SSascha Wildnermklocatedb:
4148398ca17SSascha Wildner	( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
4158398ca17SSascha Wildner		-path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
4168398ca17SSascha Wildner		-prune -o -print | sed -e 's#^${ISOROOT}##g' | \
4178398ca17SSascha Wildner		/usr/libexec/locate.mklocatedb \
4188398ca17SSascha Wildner		-presort >${ISOROOT}/var/db/locate.database )
4198398ca17SSascha Wildner
4206ca9a59cSMatthew Dillonmkiso:
421bce110a5SMatthew Dillon	( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
42274ec6a9dSSascha Wildner		-R -J -o ${ISOFILE} \
42364bba8c7SSimon Schubert		-V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
4246ca9a59cSMatthew Dillon
425b9c3e754SMichael Neumann
426b9c3e754SMichael Neumannmkimg:
427fbc26094SSascha Wildner.if make(img)
42860b68cbbSMichael Neumann	if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
4299a122c9aSMatthew Dillon	-if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; 		\
4309a122c9aSMatthew Dillon	    vnconfig -u `cat ${ISODIR}/vn.which`; fi
4319a122c9aSMatthew Dillon	@echo "STEP: determine required image size"
43260b68cbbSMichael Neumann	sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`;			\
433e6b76e22SMichael Neumann	    sz=`bc -e "(($${sz}) / 1024) * 1.15" -equit | cut -f1 -d.`;	\
4349a122c9aSMatthew Dillon	    dd if=/dev/zero of=${IMGFILE} bs=1m count=$${sz};
4359a122c9aSMatthew Dillon	fdisk -IB -p ${IMGFILE}
4369a122c9aSMatthew Dillon	@echo "STEP: determine free vn device"
4379a122c9aSMatthew Dillon	vnconfig -l | grep "not in use" | head -n 1 | 			\
4389a122c9aSMatthew Dillon	    cut -f 1 -d: > ${ISODIR}/vn.which
4399a122c9aSMatthew Dillon	vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
4409a122c9aSMatthew Dillon	@echo "STEP: write standard disklabel"
4419a122c9aSMatthew Dillon	disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto
4429a122c9aSMatthew Dillon	@echo "STEP: read disklabel back"
4439a122c9aSMatthew Dillon	disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label
4449a122c9aSMatthew Dillon	@echo "STEP: determine number of sectors of whole disk"
44560b68cbbSMichael Neumann	secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`;		\
4469a122c9aSMatthew Dillon	    echo "  a:  $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
4479a122c9aSMatthew Dillon	@echo "STEP: write modified disklabel back"
4489a122c9aSMatthew Dillon	disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label
4499a122c9aSMatthew Dillon	rm ${IMGFILE}.label
4509a122c9aSMatthew Dillon	@echo "STEP: write bootsector"
4519a122c9aSMatthew Dillon	disklabel -B `cat ${ISODIR}/vn.which`s1
4529a122c9aSMatthew Dillon	boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which`
4539a122c9aSMatthew Dillon	newfs /dev/`cat ${ISODIR}/vn.which`s1a
4549a122c9aSMatthew Dillon	mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT}
4559a122c9aSMatthew Dillon	cpdup ${ISOROOT} ${IMGMNT}
4569a122c9aSMatthew Dillon	@echo "STEP: fixup ${IMGMNT}/etc/fstab"
4579a122c9aSMatthew Dillon	echo "/dev/${IMGUSBDEV}s1a / ufs rw 0 0" > ${IMGMNT}/etc/fstab
4589a122c9aSMatthew Dillon	echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab
4599a122c9aSMatthew Dillon	@echo "STEP: fixup ${IMGMNT}/boot/loader.conf"
4609a122c9aSMatthew Dillon	-fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new
4619a122c9aSMatthew Dillon	echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s1a"' >> ${IMGMNT}/boot/loader.conf.new
4629a122c9aSMatthew Dillon	mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
4639a122c9aSMatthew Dillon	@echo "STEP: cleanup"
4649a122c9aSMatthew Dillon	df ${IMGMNT}
4659a122c9aSMatthew Dillon	umount ${IMGMNT}
4669a122c9aSMatthew Dillon	vnconfig -u `cat ${ISODIR}/vn.which`
4679a122c9aSMatthew Dillon	rm -f ${ISODIR}/vn.which
46860b68cbbSMichael Neumann	rmdir ${IMGMNT}
4699a122c9aSMatthew Dillon	@echo "STEP: done"
470b9c3e754SMichael Neumann.endif
471b9c3e754SMichael Neumann
4726ca9a59cSMatthew Dillonclean:
473c19c746bSMatthew Dillon	-umount ${ISOROOT}/usr/pkgsrc/distfiles > /dev/null 2>&1
474c19c746bSMatthew Dillon	-umount ${ISOROOT}/usr/pkgsrc > /dev/null 2>&1
4759a122c9aSMatthew Dillon	-umount ${ISOROOT}/dev > /dev/null 2>&1
4769a122c9aSMatthew Dillon	-if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; 		\
4779a122c9aSMatthew Dillon	    vnconfig -u `cat ${ISODIR}/vn.which`; fi
4786ca9a59cSMatthew Dillon	if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
479c19c746bSMatthew Dillon	rm -rf ${ISOROOT}
480c19c746bSMatthew Dillon	rm -rf ${NRLOBJDIR}/nrelease
4819a122c9aSMatthew Dillon	rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
4826ca9a59cSMatthew Dillon
4836ca9a59cSMatthew Dillonrealclean:	clean
4843ebedc5eSMatthew Dillon	rm -rf ${OBJSYS}/${KERNCONF}
4858abe78a1SMatthew Dillon	#
486bce110a5SMatthew Dillon	# do not use PKGSRC_PKG_PATH here, we do not want to destroy an
487bce110a5SMatthew Dillon	# override location.
4888abe78a1SMatthew Dillon	#
489c19c746bSMatthew Dillon	rm -rf ${ISODIR}/packages
490c19c746bSMatthew Dillon	rm -rf ${ISODIR}/distfiles
4916ca9a59cSMatthew Dillon
492cc224c64SJoerg Sonnenbergerfetch:
4939b29c40aSMatthew Dillon	@if [ ! -d ${PKGSRC_PKG_PATH} ]; then mkdir -p ${PKGSRC_PKG_PATH}; fi
4940a1628e7SMatthew Dillon.if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
4950a1628e7SMatthew Dillon	(cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${CVSUP_BOOTSTRAP_KIT}.tgz)
4960a1628e7SMatthew Dillon.endif
497bce110a5SMatthew Dillon
498bce110a5SMatthew Dillonpkgsrc_bootstrap:
499bce110a5SMatthew Dillon.if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
5000936984eSMatthew Dillon	mkdir -p /usr/release/bootstrap
5010936984eSMatthew Dillon	(cd ${PKGSRC_PATH}/bootstrap; ./bootstrap --workdir /usr/release/bootstrap)
502bce110a5SMatthew Dillon.endif
503bce110a5SMatthew Dillon
504bce110a5SMatthew Dillonpkgsrc_cdrecord:
505bce110a5SMatthew Dillon.if !exists (${PKGBIN_MKISOFS})
5060936984eSMatthew Dillon	(cd ${PKGSRC_PATH}/sysutils/cdrtools; bmake clean build install)
507bce110a5SMatthew Dillon.endif
508cc224c64SJoerg Sonnenberger
509e2dbfa0bSThomas Nikolajsenhelp all:
5105af45f85SMatthew Dillon	@echo "make [gui] release   - complete build from scratch"
5115af45f85SMatthew Dillon	@echo "make [gui] quick     - attempt to do an incremental rebuild"
5125af45f85SMatthew Dillon	@echo "make [gui] realquick - attempt to restart after world & kernel"
5135af45f85SMatthew Dillon	@echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
5148abe78a1SMatthew Dillon	@echo ""
5158abe78a1SMatthew Dillon	@echo "Extra packages may be specified with PKGSRC_EXTRA_PACKAGES"
516588a679cSSimon Schubert
517e2dbfa0bSThomas Nikolajsen.PHONY: release quickrel realquickrel
518e2dbfa0bSThomas Nikolajsen.PHONY: installer
5199b29c40aSMatthew Dillon.PHONY: quick realquick
520e2dbfa0bSThomas Nikolajsen.PHONY: check buildworld1 buildworld2
521b9c3e754SMichael Neumann.PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso mkimg
52203e2a3c5SSascha Wildner.PHONY: clean realclean fetch help all srcs
523cc224c64SJoerg Sonnenberger
5246ca9a59cSMatthew Dillon.include <bsd.prog.mk>
525