1 #########################################################################
3 #########################################################################
5 # New method e.g. 'make gui release'. A series of enhancement
6 # targes may be specified which set make variables which enhance
7 # the build in various ways.
9 # img is now the default (produces both the .iso and .img)
11 gui installer img nopkgs:
13 #########################################################################
15 #########################################################################
17 DPORTS_PATH?= /usr/dports
19 ISOROOT?= ${ISODIR}/root
20 OBJSYS= ${.OBJDIR}/../sys
21 GITHOST?= git.dragonflybsd.org
22 GITHOST_DPORTS?=mirror-master.dragonflybsd.org
24 MAKE_JOBS?= $$(sysctl -n hw.ncpu)
26 # XXX makeshift fix to build the right kernel for the (target) architecture
27 # We should configure this in the platform files somehow
28 .if ${MACHINE_ARCH} == "i386"
31 KERNCONF ?= X86_64_GENERIC
34 CHROOT_CMD?= /usr/sbin/chroot ${ISOROOT} sh -c
36 # User may specify extra packages in addition to the defaults
38 DPORTS_EXTRA_PACKAGES?=
40 # dports packages to be built and installed on the release ISO
44 DPORTS_PACKAGES?= devel/git \
46 net/isc-dhcp42-server \
48 ${DPORTS_EXTRA_PACKAGES}
50 # dports options to use when building packages
52 DPORTS_OPTIONS+= -DBATCH
54 DPORTS_OPTIONS.devel_git+= WITH="GUI"
56 DPORTS_OPTIONS.devel_git+= WITHOUT="CONTRIB PERL"
59 # Specify which root skeletons are required, and let the user include
60 # their own. They are copied into ISODIR during the `customizeiso'
61 # target; each overwrites the last.
63 REQ_ROOTSKELS= ${.CURDIR}/root
64 ROOTSKELS?= ${REQ_ROOTSKELS}
67 # LIST OF PACKAGES NOT INCLUDED DUE TO BUILD ISSUES:
68 # chat/pidgin textproc/enchant dependency is broken
69 # x11/rxvt-unicode broken configure
70 # net/nmap tries to access openssl/md2.h which does not
72 # sysutils/idesk dying on link __sync_fetch_and_add_4
74 ISOFILE?= ${ISODIR}/dfly-gui.iso
75 IMGFILE?= ${ISODIR}/dfly-gui.img
77 # NOTE: order important, do not sort package list
79 # Apps we want in the gui build but which have problems building:
80 # chat/xchat link error on x86-64, something about ___progname
84 DPORTS_PACKAGES+= x11/xorg \
101 x11-fonts/terminus-font \
107 ROOTSKELS+= ${.CURDIR}/gui
110 ISOFILE ?= ${ISODIR}/dfly.iso
111 IMGFILE ?= ${ISODIR}/dfly.img
113 IMGMNT ?= ${ISODIR}/mnt
115 # USB umass now probes starting at da8, so the usb stick is
116 # probably sitting on da8.
120 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
121 # the additional '/nrelease' manually, as a safety measure.
125 #########################################################################
127 #########################################################################
129 release: check clean buildworld1 buildkernel1 \
130 buildiso srcs customizeiso mkiso mkimg
132 quickrel: check clean buildworld2 buildkernel2 \
133 buildiso srcs customizeiso mkiso mkimg
135 realquickrel: check clean \
136 buildiso srcs customizeiso mkiso mkimg
138 restartpkgs: check customizeiso mkiso mkimg
142 realquick: realquickrel
145 #########################################################################
146 # CORE SUPPORT TARGETS #
147 #########################################################################
150 .if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs)
152 @echo "Your machine does not have cdrtools installed. You can install it with:"
153 @echo " pkg install cdrtools"
155 @if [ ! -d ${DPORTS_PATH} ]; then \
156 echo "${DPORTS_PATH} does not exist."; \
158 echo "Please set DPORTS_PATH to the dports tree that shall be used for"; \
159 echo "package building. The default is /usr/dports. See the Makefile in"; \
160 echo "/usr if you are unfamiliar with dports."; \
163 .if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs)
166 @echo "Using ${DPORTS_PATH} as the dports tree."
168 buildworld1 buildworld2:
170 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
171 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
173 buildkernel1 buildkernel2:
175 for kernconf in ${KERNCONF}; do \
176 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
177 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
178 KERNCONF=$${kernconf}; \
181 # note that we do not want to mess with any /usr/obj directories not related
182 # to buildworld, buildkernel, or nrelease, so we must supply the proper
183 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
184 # buildkernel mechanism.
186 # Unconditionally clean out ${ISOROOT} so a previous img build
187 # does not blow up a future quick iso build
189 # We install with INSTALLSTRIPPEDMODULES to make things fit into the ISO.
190 # We leave the kernel's debug variables intact.
194 -chflags -R noschg ${ISOROOT}
197 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
198 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
199 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
200 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
201 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
203 for kernconf in ${KERNCONF}; do \
204 make DESTDIR=${ISOROOT} reinstallkernel KERNCONF=$${kernconf}; \
206 rm -rf ${ISOROOT}/boot/kernel.old
207 ln -sf kernel ${ISOROOT}/boot/kernel/kernel.BOOTP
208 # This next mkinitrd has to be the INSTALLED version because else we
209 # can't rely on the -c option being present, but it needs to be run
210 # OUTSIDE of the chroot because it might want to load vn(4) and can't
211 # do so from inside of it.
213 ${ISOROOT}/sbin/mkinitrd -c ${ISOROOT}/usr/share/initrd -b ${ISOROOT}/boot
214 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
215 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
216 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
218 # The GUI build includes the ports tree (~1G+) while the nominal release
221 # The GUI build includes full sources while the nominal release build
222 # only includes kernel sources (~27MB).
225 .if !defined(WITHOUT_SRCS)
227 rm -f ${ISOROOT}/usr/src-sys.tgz
228 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
229 cd ${ISOROOT}/usr && make dports-create GITHOST_DPORTS=${GITHOST_DPORTS}
230 # NOTE: Adding the git gc --aggressive helps by significantly
231 # reducing the disk space required.
233 cd ${ISOROOT}/usr/dports && git gc --aggressive
234 cd ${ISOROOT}/usr && make src-create-repo GITHOST=${GITHOST}
235 # XXX: git gc --aggressive
237 rm -f ${ISOROOT}/usr/src-sys.tgz
238 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
239 cd ${.CURDIR}/.. && tar --exclude .git -s '/^\./src/' \
240 -cf - ./Makefile ./Makefile.inc1 ./sys | \
241 bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2
245 # Customize the ISO by copying rootskels in reverse priority order,
246 # building packages, and doing other post-install tasks.
249 # Copy the rootskels. Allow sources to be owned by someone other
250 # than root (as is common when checked out via git).
252 .for ROOTSKEL in ${ROOTSKELS}
253 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
254 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
255 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
257 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
258 .for UPGRADE_ITEM in Makefile \
259 etc.${MACHINE_ARCH} \
262 periodic/daily/Makefile \
263 periodic/security/Makefile \
264 periodic/weekly/Makefile \
265 periodic/monthly/Makefile
266 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
269 # Setup some things & mount dports tree. Use defensive umounts and
270 # rm -rf's to allow restarts. Allow /usr/dports to be read-only.
272 cp /etc/resolv.conf ${ISOROOT}/etc
273 ${CHROOT_CMD} "ldconfig -elf /lib /usr/lib /usr/lib/gcc* /usr/lib/compat"
274 -@umount ${ISOROOT}/usr/distfiles
275 -@umount ${ISOROOT}/usr/dports
276 -@umount ${ISOROOT}/dev
277 rm -rf ${ISOROOT}/usr/obj/dports
279 # Mount /usr/dports, make sure /usr/distfiles is writable.
280 # Make /usr/dports read-only for safety, else a failed umount and
281 # our rm -rf will do bad things.
283 mkdir -p ${ISOROOT}/usr/dports
284 mkdir -p ${ISOROOT}/usr/distfiles
285 mount_null -o ro ${DPORTS_PATH} ${ISOROOT}/usr/dports
286 mount_null /dev ${ISOROOT}/dev
287 cp /etc/shells ${ISOROOT}/usr/distfiles/.test > /dev/null 2>&1 \
288 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/distfiles
290 # Build and install packages, skip packages already installed
292 .for PKG in ${DPORTS_PACKAGES}
293 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} ${DPORTS_OPTIONS.${PKG:S/\//_/g}} install"
295 .for PKG in ${DPORTS_PACKAGES}
296 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} clean"
299 # Remove packages which nothing depends on, add a whatis database
300 # for dports manual pages, create an initial locate database and
303 ${CHROOT_CMD} "yes | pkg autoremove"
304 ${CHROOT_CMD} "makewhatis /usr/local/man"
305 -umount ${ISOROOT}/usr/distfiles
306 umount ${ISOROOT}/usr/dports
307 rm -rf ${ISOROOT}/usr/dports
308 rm -rf ${ISOROOT}/usr/obj/dports
309 rm -rf ${ISOROOT}/usr/distfiles
310 rm -f ${ISOROOT}/etc/resolv.conf
312 # Finally, update the locate(8) database
314 ${CHROOT_CMD} /etc/periodic/weekly/310.locate
315 umount ${ISOROOT}/dev
317 # Recopy files that dports may have updated in /etc into /etc.hdd
319 cpdup ${ISOROOT}/etc/shells ${ISOROOT}/etc.hdd/shells
320 cpdup ${ISOROOT}/etc/group ${ISOROOT}/etc.hdd/group
323 ( cd ${ISOROOT}; mkisofs -b boot/cdboot -no-emul-boot \
324 -R -J -o ${ISOFILE} \
325 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
328 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
329 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
330 vnconfig -u `cat ${ISODIR}/vn.which`; fi
332 @echo "STEP: use an image size of ${IMGSIZE} 512-byte sectors"
334 sz=`bc -e "((${IMGSIZE}) * 512)" -equit`; truncate -s $${sz} ${IMGFILE}
336 @echo "STEP: Determine required image size in 1GB steps"
337 @echo " Leave ~600MB of unused space"
338 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
339 sz=`bc -e "(($${sz}) * 1.15 + 999999 + 600000) / 1000000" -equit | \
341 sz=`bc -e "(($${sz}) * 953)" -equit | cut -f1 -d.`; \
343 truncate -s $${sz}M ${IMGFILE};
345 fdisk -IB -p ${IMGFILE}
346 @echo "STEP: determine free vn device"
347 vnconfig -l | grep "not in use" | head -n 1 | \
348 cut -f 1 -d: > ${ISODIR}/vn.which
349 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
350 @echo "STEP: write standard disklabel"
351 disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto
352 @echo "STEP: read disklabel back"
353 disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label
354 @echo "STEP: determine number of sectors of whole disk"
355 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
356 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
357 @echo "STEP: write modified disklabel back"
358 disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label
360 @echo "STEP: write bootsector"
361 disklabel -B `cat ${ISODIR}/vn.which`s1
362 boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which`
363 newfs /dev/`cat ${ISODIR}/vn.which`s1a
364 mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT}
365 cpdup ${ISOROOT} ${IMGMNT}
366 @echo "STEP: fixup ${IMGMNT}/etc/fstab"
367 echo "/dev/${IMGUSBDEV}s1a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab
368 echo "dummy /tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
369 echo "dummy /var/tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
370 echo "dummy /var/run tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
371 echo "dummy /usr/obj tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
372 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab
373 @echo "STEP: fixup ${IMGMNT}/boot/loader.conf"
374 -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new
375 echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s1a"' >> ${IMGMNT}/boot/loader.conf.new
376 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
377 @echo "STEP: cleanup"
382 vnconfig -u `cat ${ISODIR}/vn.which`
383 rm -f ${ISODIR}/vn.which
390 -umount ${ISOROOT}/usr/distfiles > /dev/null 2>&1
391 -umount ${ISOROOT}/usr/dports > /dev/null 2>&1
392 -umount ${ISOROOT}/dev > /dev/null 2>&1
393 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
394 vnconfig -u `cat ${ISODIR}/vn.which`; fi
395 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
397 rm -rf ${NRLOBJDIR}/nrelease
398 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
401 rm -rf ${OBJSYS}/${KERNCONF}
402 rm -rf ${ISODIR}/packages
403 rm -rf ${ISODIR}/distfiles
406 @echo "make [gui] release - complete build from scratch"
407 @echo "make [gui] quick - attempt to do an incremental rebuild"
408 @echo "make [gui] realquick - attempt to restart after world & kernel"
409 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
411 @echo "DPORTS_EXTRA_PACKAGES may be used to add additional pkgs"
412 @echo "GITHOST may be used to override git.dragonflybsd.org"
413 @echo "GITHOST_DPORTS may be used to override mirror-master.dragonflybsd.org"
414 @echo "IMGSIZE may be used to override the .img (in 512-byte sectors)"
416 .PHONY: release quickrel realquickrel
418 .PHONY: quick realquick
419 .PHONY: check buildworld1 buildworld2
420 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mkiso mkimg
421 .PHONY: clean realclean help all srcs
423 .include <bsd.prog.mk>