xref: /dragonfly/nrelease/Makefile (revision 20d2e8bd)
19b29c40aSMatthew Dillon#########################################################################
29b29c40aSMatthew Dillon#				ENHANCEMENTS				#
39b29c40aSMatthew Dillon#########################################################################
49b29c40aSMatthew Dillon
5f4ec1279SSascha Wildner# New method e.g. 'make gui release'.  A series of enhancement
64931b8b1SSascha Wildner# targets may be specified which set make variables which enhance
79b29c40aSMatthew Dillon# the build in various ways.
89b29c40aSMatthew Dillon#
91a8bb5ebSMatthew Dillon# img is now the default (produces both the .iso and .img)
101a8bb5ebSMatthew Dillon#
1188821fa4SMatthew Dillongui installer img nopkgs:
129b29c40aSMatthew Dillon
139b29c40aSMatthew Dillon#########################################################################
149b29c40aSMatthew Dillon#				 SETUP					#
159b29c40aSMatthew Dillon#########################################################################
169b29c40aSMatthew Dillon
17bd0ab7aaSMatthew DillonDPORTS_PATH?=	/usr/dports
18a291abfbSMatthew DillonISODIR?=	/usr/obj/release
195ec00f8aSSascha WildnerISOROOT?=	${ISODIR}/root
206ca9a59cSMatthew DillonOBJSYS=		${.OBJDIR}/../sys
218126e4efSAaron LIGITURL_SRC?=	git://git.dragonflybsd.org/dragonfly.git
228126e4efSAaron LIGITURL_DPORTS?=	git://mirror-master.dragonflybsd.org/dports.git
235cb6cda9SSascha WildnerMAKE_JOBS?=	$$(sysctl -n hw.ncpu)
243fff415bSSascha Wildner
25702a95ccSSimon Schubert# XXX makeshift fix to build the right kernel for the (target) architecture
26702a95ccSSimon Schubert# We should configure this in the platform files somehow
27dd7331feSSascha Wildner.if ${MACHINE_ARCH} == "x86_64"
2891856cf5SSascha WildnerKERNCONF ?= X86_64_GENERIC
29702a95ccSSimon Schubert.endif
306ca9a59cSMatthew Dillon
31c36c5990SSascha WildnerCHROOT_CMD?=		/usr/sbin/chroot ${ISOROOT} sh -c
32cc55a235SSimon Schubert
33165b1c14SSascha Wildner.if !make(nopkgs)
348abe78a1SMatthew Dillon# User may specify extra packages in addition to the defaults
3595b64753SMatthew Dillon#
36c36c5990SSascha WildnerDPORTS_EXTRA_PACKAGES?=
37fbc26094SSascha Wildner
382f36664eSSascha Wildner# dports packages to be built and installed on the release ISO
392f36664eSSascha Wildner#
40c36c5990SSascha WildnerDPORTS_PACKAGES?=	devel/git \
410e561611SJustin C. Sherrill			dns/bind-tools \
42*20d2e8bdSAntonio Huete Jimenez			net/isc-dhcp44-server \
43c36c5990SSascha Wildner			sysutils/cdrtools \
4444c4f44aSSascha Wildner			${DPORTS_EXTRA_PACKAGES}
45c36c5990SSascha Wildner
46c36c5990SSascha Wildner# dports options to use when building packages
47c36c5990SSascha Wildner#
48c36c5990SSascha WildnerDPORTS_OPTIONS+=		-DBATCH
49255a0279SMichael Neumann.if make(gui)
50cd98d260SSascha WildnerDPORTS_OPTIONS.devel_git+=	-DWITH_GUI
51255a0279SMichael Neumann.else
52cd98d260SSascha WildnerDPORTS_OPTIONS.devel_git+=	-DWITHOUT_CONTRIB -DWITHOUT_PERL
53fbc26094SSascha Wildner.endif
54165b1c14SSascha Wildner.endif
558188de86SMatthew Dillon
568188de86SMatthew Dillon# Specify which root skeletons are required, and let the user include
57e2dbfa0bSThomas Nikolajsen# their own.  They are copied into ISODIR during the `customizeiso'
588188de86SMatthew Dillon# target; each overwrites the last.
598188de86SMatthew Dillon#
608f51ac0bSSascha WildnerREQ_ROOTSKELS=	${.CURDIR}/root
61cc224c64SJoerg SonnenbergerROOTSKELS?=	${REQ_ROOTSKELS}
62cc224c64SJoerg Sonnenberger
63255a0279SMichael Neumann.if make(gui)
64c843f8b0SMatthew Dillon# LIST OF PACKAGES NOT INCLUDED DUE TO BUILD ISSUES:
65c843f8b0SMatthew Dillon#	chat/pidgin		textproc/enchant dependency is broken
66c843f8b0SMatthew Dillon#	x11/rxvt-unicode	broken configure
67c843f8b0SMatthew Dillon#	net/nmap		tries to access openssl/md2.h which does not
68c843f8b0SMatthew Dillon#				exist.
69c843f8b0SMatthew Dillon#	sysutils/idesk		dying on link __sync_fetch_and_add_4
70c843f8b0SMatthew Dillon#
71bfe20b28SSascha WildnerISOFILE?=		${ISODIR}/dfly-gui.iso
72b9c3e754SMichael NeumannIMGFILE?=		${ISODIR}/dfly-gui.img
7388821fa4SMatthew Dillon
740e176309SMatthew Dillon# NOTE: order important, do not sort package list
750e176309SMatthew Dillon#
7688821fa4SMatthew Dillon.if !make(nopkgs)
77255a0279SMichael NeumannDPORTS_PACKAGES+=	x11/xorg \
78255a0279SMichael Neumann			x11-wm/fluxbox \
79255a0279SMichael Neumann			x11-wm/fvwm \
8030e27f66SMatthew Dillon			www/firefox \
81255a0279SMichael Neumann			graphics/xpdf \
82fbc26094SSascha Wildner			shells/zsh \
83fbc26094SSascha Wildner			editors/emacs \
84fbc26094SSascha Wildner			editors/vim \
85255a0279SMichael Neumann			irc/irssi \
86fbc26094SSascha Wildner			lang/perl5 \
87fbc26094SSascha Wildner			editors/nano \
88fbc26094SSascha Wildner			shells/bash \
89255a0279SMichael Neumann			devel/ctags \
90fbc26094SSascha Wildner			archivers/zip \
91fbc26094SSascha Wildner			security/sudo \
92255a0279SMichael Neumann			www/links \
93255a0279SMichael Neumann			ftp/wget \
94255a0279SMichael Neumann			x11-fonts/terminus-font \
95fbc26094SSascha Wildner			net/rsync \
96255a0279SMichael Neumann			x11-clocks/asclock \
97255a0279SMichael Neumann			sysutils/screen
9888821fa4SMatthew Dillon.endif
9988821fa4SMatthew Dillon
100bfe20b28SSascha WildnerROOTSKELS+=		${.CURDIR}/gui
101bfe20b28SSascha Wildner.endif
102bfe20b28SSascha Wildner
1033f279b9eSSascha WildnerISOFILE ?= ${ISODIR}/dfly.iso
104b9c3e754SMichael NeumannIMGFILE ?= ${ISODIR}/dfly.img
105b9c3e754SMichael Neumann
10660b68cbbSMichael NeumannIMGMNT ?= ${ISODIR}/mnt
107a2f841edSMatthew Dillon
108a2f841edSMatthew Dillon# USB umass now probes starting at da8, so the usb stick is
109a2f841edSMatthew Dillon# probably sitting on da8.
110a2f841edSMatthew Dillon#
1119a122c9aSMatthew DillonIMGUSBDEV ?= da8
1123f279b9eSSascha Wildner
1135b22b655SMatthew Dillon# note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
1145b22b655SMatthew Dillon# the additional '/nrelease' manually, as a safety measure.
1155b22b655SMatthew Dillon#
1165b22b655SMatthew DillonNRLOBJDIR?= /usr/obj
1175b22b655SMatthew Dillon
1188188de86SMatthew Dillon#########################################################################
1198188de86SMatthew Dillon#				BASE ISO TARGETS			#
1208188de86SMatthew Dillon#########################################################################
1216ca9a59cSMatthew Dillon
1227ebbae99SSascha Wildnerrelease:	check clean buildworld1 buildkernel1 \
12331d5c88cSSascha Wildner		buildiso srcs customizeiso mkiso mkimg
1246ca9a59cSMatthew Dillon
1257ebbae99SSascha Wildnerquickrel:	check clean buildworld2 buildkernel2 \
12631d5c88cSSascha Wildner		buildiso srcs customizeiso mkiso mkimg
1278188de86SMatthew Dillon
12803e2a3c5SSascha Wildnerrealquickrel:	check clean \
12931d5c88cSSascha Wildner		buildiso srcs customizeiso mkiso mkimg
1306ca9a59cSMatthew Dillon
13131d5c88cSSascha Wildnerrestartpkgs:	check customizeiso mkiso mkimg
1325af45f85SMatthew Dillon
1339b29c40aSMatthew Dillonquick:		quickrel
1349b29c40aSMatthew Dillon
1359b29c40aSMatthew Dillonrealquick:	realquickrel
1369b29c40aSMatthew Dillon
1379b29c40aSMatthew Dillon#########################################################################
1389b29c40aSMatthew Dillon#			   CORE SUPPORT TARGETS 			#
1399b29c40aSMatthew Dillon#########################################################################
1409b29c40aSMatthew Dillon
141d2582113SChris Presseycheck:
142c36c5990SSascha Wildner.if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs)
1430936984eSMatthew Dillon	@echo
1440936984eSMatthew Dillon	@echo "Your machine does not have cdrtools installed.  You can install it with:"
145218b6b69SMarkus Pfeiffer	@echo "    pkg install cdrtools"
1460936984eSMatthew Dillon.endif
147aa3eeb12SSascha Wildner	@if [ ! -d ${DPORTS_PATH} ]; then \
148aa3eeb12SSascha Wildner		echo "${DPORTS_PATH} does not exist."; \
149aa3eeb12SSascha Wildner		echo ""; \
150aa3eeb12SSascha Wildner		echo "Please set DPORTS_PATH to the dports tree that shall be used for"; \
151aa3eeb12SSascha Wildner		echo "package building. The default is /usr/dports. See the Makefile in"; \
152aa3eeb12SSascha Wildner		echo "/usr if you are unfamiliar with dports."; \
153aa3eeb12SSascha Wildner		/usr/bin/false; \
154aa3eeb12SSascha Wildner	fi
155c36c5990SSascha Wildner.if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs)
1563da8e88fSJohn Marino	@/usr/bin/false
157fbc26094SSascha Wildner.endif
158aa3eeb12SSascha Wildner	@echo "Using ${DPORTS_PATH} as the dports tree."
1592e3f8f38SMatthew Dillon
160588a679cSSimon Schubertbuildworld1 buildworld2:
1613fff415bSSascha Wildner	cd ${.CURDIR}/..; \
1623fff415bSSascha Wildner	${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
1633fff415bSSascha Wildner		make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
1646ca9a59cSMatthew Dillon
165588a679cSSimon Schubertbuildkernel1 buildkernel2:
166588a679cSSimon Schubert	cd ${.CURDIR}/..; \
167588a679cSSimon Schubert	for kernconf in ${KERNCONF}; do \
168448b21e7SSimon Schubert		${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
1693fff415bSSascha Wildner			make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
170ee7f6ff2SSascha Wildner			KERNCONF=$${kernconf}; \
171588a679cSSimon Schubert	done
1726ca9a59cSMatthew Dillon
1735b22b655SMatthew Dillon# note that we do not want to mess with any /usr/obj directories not related
1745b22b655SMatthew Dillon# to buildworld, buildkernel, or nrelease, so we must supply the proper
1755b22b655SMatthew Dillon# MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
1765b22b655SMatthew Dillon# buildkernel mechanism.
1775b22b655SMatthew Dillon#
1782b43b38cSSascha Wildner# Unconditionally clean out ${ISOROOT} so a previous img build
17992b0ebb9SMatthew Dillon# does not blow up a future quick iso build
18092b0ebb9SMatthew Dillon#
181fe70af21SMatthew Dillon# We install with INSTALLSTRIPPEDMODULES to make things fit into the ISO.
182fe70af21SMatthew Dillon# We leave the kernel's debug variables intact.
183fe70af21SMatthew Dillon#
1846ca9a59cSMatthew Dillonbuildiso:
18592b0ebb9SMatthew Dillon	-chflags -R noschg ${ISOROOT}
18692b0ebb9SMatthew Dillon	rm -rf ${ISOROOT}
18792b0ebb9SMatthew Dillon	mkdir -p ${ISOROOT}
1885b22b655SMatthew Dillon	if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
189f4ec1279SSascha Wildner	( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
190ab64cf06SSimon Schubert	( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
191ab64cf06SSimon Schubert		make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
19221aa02d0SChris Pressey	cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
193588a679cSSimon Schubert	cd ${.CURDIR}/..; \
194588a679cSSimon Schubert	for kernconf in ${KERNCONF}; do \
1951c9d98d0SAntonio Huete Jimenez		make DESTDIR=${ISOROOT} reinstallkernel KERNCONF=$${kernconf}; \
196588a679cSSimon Schubert	done
19791856cf5SSascha Wildner	rm -rf ${ISOROOT}/boot/kernel.old
1981c9d98d0SAntonio Huete Jimenez	ln -sf kernel ${ISOROOT}/boot/kernel/kernel.BOOTP
199e79a303fSAaron LI	( cd ${.CURDIR}/..; make DESTDIR=${ISOROOT} initrd )
2006ca9a59cSMatthew Dillon	mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
2016ca9a59cSMatthew Dillon	dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
2028188de86SMatthew Dillon
203255a0279SMichael Neumann# The GUI build includes the ports tree (~1G+) while the nominal release
204fe70af21SMatthew Dillon# build does not.
205fe70af21SMatthew Dillon#
206fe70af21SMatthew Dillon# The GUI build includes full sources while the nominal release build
207fe70af21SMatthew Dillon# only includes kernel sources (~27MB).
20819d86faaSMatthew Dillon#
209e2dbfa0bSThomas Nikolajsensrcs:
210e2dbfa0bSThomas Nikolajsen.if !defined(WITHOUT_SRCS)
211255a0279SMichael Neumann.if make(gui)
2123342e40aSMatthew Dillon	rm -f ${ISOROOT}/usr/src-sys.tgz
2133342e40aSMatthew Dillon	rm -f ${ISOROOT}/usr/src-sys.tar.bz2
214165b1c14SSascha Wildner.if !empty(DPORTS_PACKAGES)
2158126e4efSAaron LI	cd ${ISOROOT}/usr && make dports-create GITURL_DPORTS=${GITURL_DPORTS}
216c59cfa66SSascha Wildner	# NOTE: Adding the git gc --aggressive helps by significantly
217c59cfa66SSascha Wildner	#	reducing the disk space required.
218c59cfa66SSascha Wildner	#
219255a0279SMichael Neumann	cd ${ISOROOT}/usr/dports && git gc --aggressive
220165b1c14SSascha Wildner.endif
2218126e4efSAaron LI	cd ${ISOROOT}/usr && make src-create-repo GITURL_SRC=${GITURL_SRC}
222255a0279SMichael Neumann	# XXX: git gc --aggressive
223c19c746bSMatthew Dillon.else
224e2dbfa0bSThomas Nikolajsen	rm -f ${ISOROOT}/usr/src-sys.tgz
225fe70af21SMatthew Dillon	rm -f ${ISOROOT}/usr/src-sys.tar.bz2
226cacf78aaSSascha Wildner	cd ${.CURDIR}/.. && tar --exclude .git -s '/^\./src/' \
227cebb579bSMatthew Dillon		-cf - ./Makefile ./Makefile.inc1 \
228cebb579bSMatthew Dillon		./crypto/libressl/include ./sys | \
229fe70af21SMatthew Dillon		bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2
230c19c746bSMatthew Dillon.endif
23166b79064SMatthew Dillon.endif
23219d86faaSMatthew Dillon
2335af45f85SMatthew Dillon# Customize the ISO by copying rootskels in reverse priority order,
2345af45f85SMatthew Dillon# building packages, and doing other post-install tasks.
2355af45f85SMatthew Dillon#
2368188de86SMatthew Dilloncustomizeiso:
2375af45f85SMatthew Dillon	# Copy the rootskels.  Allow sources to be owned by someone other
2383cf4b4a1SSascha Wildner	# than root (as is common when checked out via git).
2395af45f85SMatthew Dillon	#
2408188de86SMatthew Dillon.for ROOTSKEL in ${ROOTSKELS}
2418188de86SMatthew Dillon	cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
2425af45f85SMatthew Dillon	@test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
2435af45f85SMatthew Dillon	@test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
2448188de86SMatthew Dillon.endfor
2457249926bSMatthew Dillon	pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
2464fba3387SChris Pressey.for UPGRADE_ITEM in Makefile			\
2474fba3387SChris Pressey		     etc.${MACHINE_ARCH} 	\
2484fba3387SChris Pressey		     rc.d/Makefile		\
2494fba3387SChris Pressey		     periodic/Makefile		\
2504fba3387SChris Pressey		     periodic/daily/Makefile	\
2514fba3387SChris Pressey		     periodic/security/Makefile	\
2524fba3387SChris Pressey		     periodic/weekly/Makefile	\
2534fba3387SChris Pressey		     periodic/monthly/Makefile
2544fba3387SChris Pressey	cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
2554fba3387SChris Pressey.endfor
2568abe78a1SMatthew Dillon	#
257c36c5990SSascha Wildner	# Setup some things & mount dports tree.  Use defensive umounts and
258c36c5990SSascha Wildner	# rm -rf's to allow restarts.  Allow /usr/dports to be read-only.
2598abe78a1SMatthew Dillon	#
260165b1c14SSascha Wildner	-@umount ${ISOROOT}/dev
261165b1c14SSascha Wildner	mount_null /dev ${ISOROOT}/dev
262165b1c14SSascha Wildner.if !empty(DPORTS_PACKAGES)
2631c9d98d0SAntonio Huete Jimenez	cp /etc/resolv.conf ${ISOROOT}/etc
2649af692c6SSascha Wildner	${CHROOT_CMD} "ldconfig -elf /lib /usr/lib /usr/lib/gcc*"
2655e885f07SSascha Wildner	-@umount ${ISOROOT}/usr/distfiles
2662f36664eSSascha Wildner	-@umount ${ISOROOT}/usr/dports
2672f36664eSSascha Wildner	rm -rf ${ISOROOT}/usr/obj/dports
2688abe78a1SMatthew Dillon	#
269c36c5990SSascha Wildner	# Mount /usr/dports, make sure /usr/distfiles is writable.
270c36c5990SSascha Wildner	# Make /usr/dports read-only for safety, else a failed umount and
2711eeae16fSMatthew Dillon	# our rm -rf will do bad things.
2728abe78a1SMatthew Dillon	#
2732f36664eSSascha Wildner	mkdir -p ${ISOROOT}/usr/dports
2745e885f07SSascha Wildner	mkdir -p ${ISOROOT}/usr/distfiles
2752f36664eSSascha Wildner	mount_null -o ro ${DPORTS_PATH} ${ISOROOT}/usr/dports
276c36c5990SSascha Wildner	cp /etc/shells ${ISOROOT}/usr/distfiles/.test > /dev/null 2>&1 \
277c36c5990SSascha Wildner	    || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/distfiles
2788abe78a1SMatthew Dillon	#
2798abe78a1SMatthew Dillon	# Build and install packages, skip packages already installed
2808abe78a1SMatthew Dillon	#
281c36c5990SSascha Wildner.for PKG in ${DPORTS_PACKAGES}
282c36c5990SSascha Wildner	${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} ${DPORTS_OPTIONS.${PKG:S/\//_/g}} install"
28320585f87SMatthew Dillon.endfor
2842f36664eSSascha Wildner.for PKG in ${DPORTS_PACKAGES}
285c36c5990SSascha Wildner	${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} clean"
2862f36664eSSascha Wildner.endfor
2878abe78a1SMatthew Dillon	#
28831d5c88cSSascha Wildner	# Remove packages which nothing depends on, add a whatis database
289c36c5990SSascha Wildner	# for dports manual pages, create an initial locate database and
29031d5c88cSSascha Wildner	# clean up
2918abe78a1SMatthew Dillon	#
2922f36664eSSascha Wildner	${CHROOT_CMD} "yes | pkg autoremove"
293c36c5990SSascha Wildner	${CHROOT_CMD} "makewhatis /usr/local/man"
2945e885f07SSascha Wildner	-umount ${ISOROOT}/usr/distfiles
2952f36664eSSascha Wildner	umount ${ISOROOT}/usr/dports
2965e885f07SSascha Wildner	rm -rf ${ISOROOT}/usr/dports
2972f36664eSSascha Wildner	rm -rf ${ISOROOT}/usr/obj/dports
2985e885f07SSascha Wildner	rm -rf ${ISOROOT}/usr/distfiles
299fbc26094SSascha Wildner	rm -f ${ISOROOT}/etc/resolv.conf
300165b1c14SSascha Wildner.endif
3012f36664eSSascha Wildner	#
302b34d3b9bSzrj	# Finally, update the locate(8) database, allow ISODIR
303b34d3b9bSzrj	# to be on tmpfs (fails to create locate database then)
3042f36664eSSascha Wildner	#
305b34d3b9bSzrj	-${CHROOT_CMD} /etc/periodic/weekly/310.locate
30631d5c88cSSascha Wildner	umount ${ISOROOT}/dev
307d68fa6c5SMatthew Dillon	#
30844c4f44aSSascha Wildner	# Recopy files that dports may have updated in /etc into /etc.hdd
309d68fa6c5SMatthew Dillon	#
310d68fa6c5SMatthew Dillon	cpdup ${ISOROOT}/etc/shells ${ISOROOT}/etc.hdd/shells
311d68fa6c5SMatthew Dillon	cpdup ${ISOROOT}/etc/group ${ISOROOT}/etc.hdd/group
3128398ca17SSascha Wildner
3136ca9a59cSMatthew Dillonmkiso:
3145fa778d7SSascha Wildner	if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
3155fa778d7SSascha Wildner	-if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; 		\
3165fa778d7SSascha Wildner	    vnconfig -u `cat ${ISODIR}/vn.which`; fi
3175fa778d7SSascha Wildner	newfs_msdos -C 400k -F 12 -L EFI -m 0xf8 ${ISOROOT}/boot/efiboot.img
3185fa778d7SSascha Wildner	vnconfig -l | grep "not in use" | head -n 1 | 			\
3195fa778d7SSascha Wildner	    cut -f 1 -d: > ${ISODIR}/vn.which
3205fa778d7SSascha Wildner	vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${ISOROOT}/boot/efiboot.img
3215fa778d7SSascha Wildner	mount_msdos /dev/`cat ${ISODIR}/vn.which` ${IMGMNT}
3225fa778d7SSascha Wildner	mkdir -p ${IMGMNT}/EFI/BOOT
3235fa778d7SSascha Wildner	cp ${ISOROOT}/boot/loader.efi ${IMGMNT}/EFI/BOOT/BOOTX64.EFI
3245fa778d7SSascha Wildner	umount ${IMGMNT}
3255fa778d7SSascha Wildner	( cd ${ISOROOT}; mkisofs -R -J -o ${ISOFILE} \
3265fa778d7SSascha Wildner		-b boot/cdboot -no-emul-boot \
3275fa778d7SSascha Wildner		-eltorito-alt-boot -eltorito-platform efi -eltorito-boot boot/efiboot.img -no-emul-boot \
32864bba8c7SSimon Schubert		-V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
3295fa778d7SSascha Wildner	rm -f ${ISOROOT}/boot/efiboot.img
330b9c3e754SMichael Neumann
331b9c3e754SMichael Neumannmkimg:
33260b68cbbSMichael Neumann	if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
3339a122c9aSMatthew Dillon	-if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; 		\
3349a122c9aSMatthew Dillon	    vnconfig -u `cat ${ISODIR}/vn.which`; fi
335fe70af21SMatthew Dillon.ifdef IMGSIZE
336fe70af21SMatthew Dillon	@echo "STEP: use an image size of ${IMGSIZE} 512-byte sectors"
337fe70af21SMatthew Dillon	rm -f ${IMGFILE}
338fe70af21SMatthew Dillon	sz=`bc -e "((${IMGSIZE}) * 512)" -equit`; truncate -s $${sz} ${IMGFILE}
339fe70af21SMatthew Dillon.else
3403342e40aSMatthew Dillon	@echo "STEP: Determine required image size in 1GB steps"
3413342e40aSMatthew Dillon	@echo "      Leave ~600MB of unused space"
34260b68cbbSMichael Neumann	sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`;			\
3433342e40aSMatthew Dillon	    sz=`bc -e "(($${sz}) * 1.15 + 999999 + 600000) / 1000000" -equit | \
344fe70af21SMatthew Dillon	    cut -f1 -d.`;						\
345c843f8b0SMatthew Dillon	    sz=`bc -e "(($${sz}) * 953)" -equit | cut -f1 -d.`;		\
346fe70af21SMatthew Dillon	    rm -f ${IMGFILE};						\
347fe70af21SMatthew Dillon	    truncate -s $${sz}M ${IMGFILE};
348fe70af21SMatthew Dillon.endif
3499a122c9aSMatthew Dillon	@echo "STEP: determine free vn device"
3509a122c9aSMatthew Dillon	vnconfig -l | grep "not in use" | head -n 1 | 			\
3519a122c9aSMatthew Dillon	    cut -f 1 -d: > ${ISODIR}/vn.which
3529a122c9aSMatthew Dillon	vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
3535fa778d7SSascha Wildner	@echo "STEP: set up legacy MBR"
3545fa778d7SSascha Wildner	fdisk -IB `cat ${ISODIR}/vn.which`
3555fa778d7SSascha Wildner	fdisk -s `cat ${ISODIR}/vn.which` >${ISODIR}/fdisk.dat
3565fa778d7SSascha Wildner	awk '(NR==1){printf("g c%s h%s s%s\n", $$2, $$4, $$6);}' \
3575fa778d7SSascha Wildner	    ${ISODIR}/fdisk.dat >${ISODIR}/fdisk.conf
3585fa778d7SSascha Wildner	echo "p 1 239 63 257985" >>${ISODIR}/fdisk.conf
3595fa778d7SSascha Wildner	awk '($$1=="1:"){printf("p 2 165 258048 %lu\n", $$3 - 258528);}' \
3605fa778d7SSascha Wildner	    ${ISODIR}/fdisk.dat >>${ISODIR}/fdisk.conf
3615fa778d7SSascha Wildner	echo "a 2" >>${ISODIR}/fdisk.conf
3625fa778d7SSascha Wildner	fdisk -iv -f ${ISODIR}/fdisk.conf `cat ${ISODIR}/vn.which`
3635fa778d7SSascha Wildner	rm ${ISODIR}/fdisk.conf ${ISODIR}/fdisk.dat
3645fa778d7SSascha Wildner	newfs_msdos -F 32 -c 2 -L EFI -m 0xf8 `cat ${ISODIR}/vn.which`s1
3655fa778d7SSascha Wildner	mount_msdos /dev/`cat ${ISODIR}/vn.which`s1 ${IMGMNT}
3665fa778d7SSascha Wildner	mkdir -p ${IMGMNT}/EFI/BOOT
3675fa778d7SSascha Wildner	cp ${ISOROOT}/boot/boot1.efi ${IMGMNT}/EFI/BOOT/BOOTX64.EFI
3685fa778d7SSascha Wildner	umount ${IMGMNT}
3699a122c9aSMatthew Dillon	@echo "STEP: write standard disklabel"
3705fa778d7SSascha Wildner	disklabel -w -r `cat ${ISODIR}/vn.which`s2 auto
3719a122c9aSMatthew Dillon	@echo "STEP: read disklabel back"
3725fa778d7SSascha Wildner	disklabel -r `cat ${ISODIR}/vn.which`s2 > ${IMGFILE}.label
3739a122c9aSMatthew Dillon	@echo "STEP: determine number of sectors of whole disk"
37460b68cbbSMichael Neumann	secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`;		\
3759a122c9aSMatthew Dillon	    echo "  a:  $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
3769a122c9aSMatthew Dillon	@echo "STEP: write modified disklabel back"
3775fa778d7SSascha Wildner	disklabel -R -r `cat ${ISODIR}/vn.which`s2 ${IMGFILE}.label
3789a122c9aSMatthew Dillon	rm ${IMGFILE}.label
3795fa778d7SSascha Wildner	disklabel -B `cat ${ISODIR}/vn.which`s2
3805fa778d7SSascha Wildner	newfs /dev/`cat ${ISODIR}/vn.which`s2a
3815fa778d7SSascha Wildner	mount /dev/`cat ${ISODIR}/vn.which`s2a ${IMGMNT}
3829a122c9aSMatthew Dillon	cpdup ${ISOROOT} ${IMGMNT}
3839a122c9aSMatthew Dillon	@echo "STEP: fixup ${IMGMNT}/etc/fstab"
3845fa778d7SSascha Wildner	echo "/dev/${IMGUSBDEV}s2a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab
3853342e40aSMatthew Dillon	echo "dummy /tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
3863342e40aSMatthew Dillon	echo "dummy /var/tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
387d4c25c30SSascha Wildner	echo "dummy /var/run tmpfs rw,-C 0 0" >> ${IMGMNT}/etc/fstab
3883342e40aSMatthew Dillon	echo "dummy /usr/obj tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
3899a122c9aSMatthew Dillon	echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab
3909a122c9aSMatthew Dillon	@echo "STEP: fixup ${IMGMNT}/boot/loader.conf"
3919a122c9aSMatthew Dillon	-fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new
3925fa778d7SSascha Wildner	echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s2a"' >> ${IMGMNT}/boot/loader.conf.new
3939a122c9aSMatthew Dillon	mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
3949a122c9aSMatthew Dillon	@echo "STEP: cleanup"
3959a122c9aSMatthew Dillon	df ${IMGMNT}
396836f3129SMatthew Dillon	sync
397836f3129SMatthew Dillon	sleep 1
3989a122c9aSMatthew Dillon	umount ${IMGMNT}
3999a122c9aSMatthew Dillon	vnconfig -u `cat ${ISODIR}/vn.which`
4009a122c9aSMatthew Dillon	rm -f ${ISODIR}/vn.which
40160b68cbbSMichael Neumann	rmdir ${IMGMNT}
4029a122c9aSMatthew Dillon	@echo "STEP: done"
403b9c3e754SMichael Neumann
4046ca9a59cSMatthew Dillonclean:
405836f3129SMatthew Dillon	sync
406836f3129SMatthew Dillon	sleep 1
4075e885f07SSascha Wildner	-umount ${ISOROOT}/usr/distfiles > /dev/null 2>&1
4082f36664eSSascha Wildner	-umount ${ISOROOT}/usr/dports > /dev/null 2>&1
4099a122c9aSMatthew Dillon	-umount ${ISOROOT}/dev > /dev/null 2>&1
4109a122c9aSMatthew Dillon	-if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; 		\
4119a122c9aSMatthew Dillon	    vnconfig -u `cat ${ISODIR}/vn.which`; fi
4126ca9a59cSMatthew Dillon	if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
413c19c746bSMatthew Dillon	rm -rf ${ISOROOT}
414c19c746bSMatthew Dillon	rm -rf ${NRLOBJDIR}/nrelease
4159a122c9aSMatthew Dillon	rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
4166ca9a59cSMatthew Dillon
4176ca9a59cSMatthew Dillonrealclean:	clean
4183ebedc5eSMatthew Dillon	rm -rf ${OBJSYS}/${KERNCONF}
419c19c746bSMatthew Dillon	rm -rf ${ISODIR}/packages
420c19c746bSMatthew Dillon	rm -rf ${ISODIR}/distfiles
4216ca9a59cSMatthew Dillon
422e2dbfa0bSThomas Nikolajsenhelp all:
4238126e4efSAaron LI	@echo "Targets:"
4248126e4efSAaron LI	@echo "  release     - full build from scratch"
4258126e4efSAaron LI	@echo "  quick       - attempt to do an incremental rebuild"
4268126e4efSAaron LI	@echo "  realquick   - attempt to restart after world & kernel"
4278126e4efSAaron LI	@echo "  restartpkgs - attempt to restart at the pkg building stage"
4288126e4efSAaron LI	@echo "NOTE: Add the optional 'gui' target to do a GUI release"
4298abe78a1SMatthew Dillon	@echo ""
4308126e4efSAaron LI	@echo "Variables:"
4318126e4efSAaron LI	@echo "  DPORTS_EXTRA_PACKAGES: add additional packages"
4328126e4efSAaron LI	@echo "  GITURL_SRC: override the Git URL to source repository"
4338126e4efSAaron LI	@echo "  GITURL_DPORTS: override the Git URL to dports repository"
4348126e4efSAaron LI	@echo "  IMGSIZE: override the size of .img (in 512-byte sectors)"
4358126e4efSAaron LI	@echo "  MAKE_JOBS: override the default value (sysctl hw.ncpu)"
436588a679cSSimon Schubert
437e2dbfa0bSThomas Nikolajsen.PHONY: release quickrel realquickrel
438e2dbfa0bSThomas Nikolajsen.PHONY: installer
4399b29c40aSMatthew Dillon.PHONY: quick realquick
440e2dbfa0bSThomas Nikolajsen.PHONY: check buildworld1 buildworld2
44131d5c88cSSascha Wildner.PHONY: buildkernel1 buildkernel2 buildiso customizeiso mkiso mkimg
442796fd273SYONETANI Tomokazu.PHONY: clean realclean help all srcs
443cc224c64SJoerg Sonnenberger
4446ca9a59cSMatthew Dillon.include <bsd.prog.mk>
445