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 #########################################################################
18 ISOROOT?= ${ISODIR}/root
19 OBJSYS= ${.OBJDIR}/../sys
20 GITHOST?= git.dragonflybsd.org
22 MAKE_JOBS?= $$(sysctl -n hw.ncpu)
24 # temporary until everybody has converted to x86_64
25 .if ${MACHINE_ARCH} == "amd64"
27 .if defined(.PARSEDIR)
30 # LEGACY MAKE - REMOVE FOR DFLY 3.6
35 # XXX makeshift fix to build the right kernel for the (target) architecture
36 # We should configure this in the platform files somehow
37 .if ${MACHINE_ARCH} == "i386"
40 KERNCONF ?= X86_64_GENERIC
43 PKGSRC_PREFIX?= /usr/pkg
44 PKGBIN_PKG_ADD?= ${PKGSRC_PREFIX}/sbin/pkg_add
45 PKGBIN_PKG_DELETE?= ${PKGSRC_PREFIX}/sbin/pkg_delete
46 PKGBIN_PKG_ADMIN?= ${PKGSRC_PREFIX}/sbin/pkg_admin
47 PKGBIN_MKISOFS?= ${PKGSRC_PREFIX}/bin/mkisofs
49 # We use env -i in the chroot, so that environment variables won't
50 # disturb any (pkgsrc) build. This has happened for TARGET_ARCH,
51 # which is used by gmake in completely different context.
53 CHROOT_CMD?= env -i CCVER=${CCVER:Q} /usr/sbin/chroot ${ISOROOT} sh -c
55 # User may specify extra packages in addition to the defaults
57 PKGSRC_EXTRA_PACKAGES?=
59 # Pkgsrc packages to be built and installed on the release ISO
61 PKGSRC_PACKAGES?= pkgtools/pkg_leaves \
71 ${PKGSRC_EXTRA_PACKAGES}
73 # dports packages to be built and installed on the release ISO
75 DPORTS_PACKAGES+= ports-mgmt/pkg
77 # pkgsrc options to use when building packages
79 PKGSRC_OPTIONS+= MAKE_JOBS=${MAKE_JOBS}
80 PKGSRC_OPTIONS+= WRKOBJDIR=/usr/pkgobj
81 PKGSRC_OPTIONS+= PKG_DEFAULT_OPTIONS='dri inet6'
83 PKGSRC_OPTIONS+= PKG_OPTIONS.scmgit='-python'
86 # Even though buildiso wipes the packages, our check target has to run
87 # first and old packages (listed as they appear in pkg_info) must be
88 # cleaned out in order for the pkg_add -n test we use in the check target
89 # to operate properly.
91 OLD_PKGSRC_PACKAGES?= cdrtools-2.01.01.27nb1 \
93 bootstrap-kit-20070205 \
94 dfuibe_installer-1.1.6 \
96 dfuibe_installer-1.1.7nb1 \
99 gettext-tools-0.14.6nb1 \
103 bootstrap-kit-20080211 \
104 cdrtools-ossdvd-2.01.1.36nb2 \
105 isc-dhcp-base-4.0.0 \
106 isc-dhcp-server-4.0.0
108 # Specify which root skeletons are required, and let the user include
109 # their own. They are copied into ISODIR during the `customizeiso'
110 # target; each overwrites the last.
112 REQ_ROOTSKELS= ${.CURDIR}/root
113 ROOTSKELS?= ${REQ_ROOTSKELS}
115 # LIST OF PACKAGES NOT INCLUDED DUE TO BUILD ISSUES:
116 # chat/pidgin textproc/enchant dependency is broken
117 # x11/rxvt-unicode broken configure
118 # net/nmap tries to access openssl/md2.h which does not
120 # sysutils/idesk dying on link __sync_fetch_and_add_4
123 ISOFILE?= ${ISODIR}/dfly-gui.iso
124 IMGFILE?= ${ISODIR}/dfly-gui.img
126 # NOTE: order important, do not sort package list
128 # Apps we want in the gui build but which have problems building:
129 # chat/xchat link error on x86-64, something about ___progname
133 PKGSRC_PACKAGES+= meta-pkgs/modular-xorg-libs \
134 meta-pkgs/modular-xorg-fonts \
135 meta-pkgs/modular-xorg-apps \
136 meta-pkgs/modular-xorg-drivers \
146 x11/modular-xorg-server \
156 fonts/terminus-font \
163 ROOTSKELS+= ${.CURDIR}/gui
166 ISOFILE ?= ${ISODIR}/dfly.iso
167 IMGFILE ?= ${ISODIR}/dfly.img
169 IMGMNT ?= ${ISODIR}/mnt
171 # USB umass now probes starting at da8, so the usb stick is
172 # probably sitting on da8.
176 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
177 # the additional '/nrelease' manually, as a safety measure.
181 #########################################################################
183 #########################################################################
185 release: check clean buildworld1 buildkernel1 \
186 buildiso srcs customizeiso mkiso mkimg
188 quickrel: check clean buildworld2 buildkernel2 \
189 buildiso srcs customizeiso mkiso mkimg
191 realquickrel: check clean \
192 buildiso srcs customizeiso mkiso mkimg
194 restartpkgs: check customizeiso mkiso mkimg
198 realquick: realquickrel
201 #########################################################################
202 # CORE SUPPORT TARGETS #
203 #########################################################################
206 .if !exists(${PKGBIN_PKG_ADMIN})
207 @echo "You never bootstrapped pkgsrc on your machine. You can install it with:"
208 @echo " make pkgsrc_bootstrap"
210 .if !exists (${PKGBIN_MKISOFS})
212 @echo "Your machine does not have cdrtools installed. You can install it with:"
213 @echo " make pkgsrc_cdrecord"
215 .if !defined(PKGSRC_PATH)
216 @echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for"
217 @echo "package building. For example /usr/pkgsrc. See the Makefile"
218 @echo "in /usr if you are unfamiliar with pkgsrc."
220 .if !defined(DPORTS_PATH)
221 @echo "Please set DPORTS_PATH to the dports tree that shall be used for"
222 @echo "package building. For example /usr/dports. See the Makefile"
223 @echo "in /usr if you are unfamiliar with dports."
225 .if !exists (${PKGBIN_MKISOFS})
228 .if !defined(PKGSRC_PATH)
231 .if !defined(DPORTS_PATH)
235 buildworld1 buildworld2:
237 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
238 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
240 buildkernel1 buildkernel2:
242 for kernconf in ${KERNCONF}; do \
243 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
244 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
245 KERNCONF=$${kernconf}; \
248 # note that we do not want to mess with any /usr/obj directories not related
249 # to buildworld, buildkernel, or nrelease, so we must supply the proper
250 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
251 # buildkernel mechanism.
253 # Unconditionally clean out ${ISOROOT} so a previous img build
254 # does not blow up a future quick iso build
256 # We install with INSTALLSTRIPPEDMODULES to make things fit into the ISO.
257 # We leave the kernel's debug variables intact.
261 -chflags -R noschg ${ISOROOT}
264 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
265 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
266 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
267 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
268 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
270 for kernconf in ${KERNCONF}; do \
271 make DESTDIR=${ISOROOT} installkernel KERNCONF=$${kernconf}; \
273 rm -rf ${ISOROOT}/boot/kernel.old
274 ln -s kernel ${ISOROOT}/boot/kernel/kernel.BOOTP
275 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
276 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
277 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
279 # The GUI build includes the pkgsrc tree (~1G+) while the nominal release
282 # The GUI build includes full sources while the nominal release build
283 # only includes kernel sources (~27MB).
286 .if !defined(WITHOUT_SRCS)
288 rm -f ${ISOROOT}/usr/src-sys.tgz
289 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
290 cd ${ISOROOT}/usr && make pkgsrc-create-repo GITHOST=${GITHOST}
291 # NOTE: Adding the git gc --aggressive helps by significantly
292 # reducing the disk space required.
294 cd ${ISOROOT}/usr/pkgsrc && git gc --aggressive
295 cd ${ISOROOT}/usr && make src-create-repo GITHOST=${GITHOST}
297 rm -f ${ISOROOT}/usr/src-sys.tgz
298 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
299 cd ${.CURDIR}/.. && tar --exclude .git -s '/^\./src/' \
300 -cf - ./Makefile ./Makefile.inc1 ./sys | \
301 bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2
305 # Customize the ISO by copying rootskels in reverse priority order,
306 # building packages, and doing other post-install tasks.
309 # Copy the rootskels. Allow sources to be owned by someone other
310 # than root (as is common when checked out via git).
312 .for ROOTSKEL in ${ROOTSKELS}
313 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
314 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
315 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
317 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
318 .for UPGRADE_ITEM in Makefile \
319 etc.${MACHINE_ARCH} \
322 periodic/daily/Makefile \
323 periodic/security/Makefile \
324 periodic/weekly/Makefile \
325 periodic/monthly/Makefile
326 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
329 # Setup some things & mount pkgsrc tree. Use defensive umounts and
330 # rm -rf's to allow restarts. Allow /usr/pkgsrc to be read-only.
332 # If we did not get past the bootstrap we clean out the entire
333 # /usr/pkg infrastructure. Otherwise we attempt to pick up where
336 cp -p /etc/resolv.conf ${ISOROOT}/etc
337 ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
338 -@umount ${ISOROOT}/usr/pkgsrc/distfiles
339 -@umount ${ISOROOT}/usr/distfiles
340 -@umount ${ISOROOT}/usr/pkgsrc
341 -@umount ${ISOROOT}/usr/dports
342 -@umount ${ISOROOT}/dev
343 mkdir -p ${ISODIR}/distfiles
344 rm -rf ${ISOROOT}/usr/pkgobj
345 rm -rf ${ISOROOT}/usr/obj/dports
347 # Mount /usr/pkgsrc, make sure /usr/pkgsrc/distfiles is writable.
348 # Make /usr/pkgsrc read-only for safety, else a failed umount and
349 # our rm -rf will do bad things.
351 mkdir -p ${ISOROOT}/usr/pkgobj
352 mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap
353 mkdir -p ${ISOROOT}/usr/pkgsrc
354 mkdir -p ${ISOROOT}/usr/dports
355 mkdir -p ${ISOROOT}/usr/distfiles
356 mount_null -o ro ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc
357 mount_null -o ro ${DPORTS_PATH} ${ISOROOT}/usr/dports
358 mount_null /dev ${ISOROOT}/dev
359 cp /etc/shells ${ISOROOT}/usr/pkgsrc/distfiles/.test > /dev/null 2>&1 \
360 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/pkgsrc/distfiles
361 mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/distfiles
363 # Bootstrap, if not already installed, and add licenses needed
364 # for the gui release
366 test -e ${ISODIR}/.didbootstrap || \
367 rm -rf ${ISOROOT}/usr/pkg ${ISOROOT}/var/db/pkg \
368 ${ISOROOT}/var/db/pkg.refcount
369 test -e ${ISODIR}/.didbootstrap || \
370 ${CHROOT_CMD} "cd /usr/pkgsrc/bootstrap; \
371 export share_dir=/usr/pkgobj/bootstrap/work/share; \
372 env USE_DESTDIR=no ./bootstrap --workdir /usr/pkgobj/bootstrap/work"
373 test -e ${ISODIR}/.didbootstrap || \
374 echo ".ifdef BSD_PKG_MK # added by nrelease" \
375 >> ${ISOROOT}/usr/pkg/etc/mk.conf
376 test -e ${ISODIR}/.didbootstrap || \
377 echo "PKG_DEFAULT_OPTIONS=dri inet6" \
378 >> ${ISOROOT}/usr/pkg/etc/mk.conf
380 test -e ${ISODIR}/.didbootstrap || \
381 echo "ACCEPTABLE_LICENSES+=openmotif-license" \
382 >> ${ISOROOT}/usr/pkg/etc/mk.conf
383 test -e ${ISODIR}/.didbootstrap || \
384 echo "ACCEPTABLE_LICENSES+=vim-license" \
385 >> ${ISOROOT}/usr/pkg/etc/mk.conf
387 test -e ${ISODIR}/.didbootstrap || \
388 echo ".endif # added by nrelease" \
389 >> ${ISOROOT}/usr/pkg/etc/mk.conf
390 test -e ${ISODIR}/.didbootstrap || sync
391 test -e ${ISODIR}/.didbootstrap || touch ${ISODIR}/.didbootstrap
393 # Build and install packages, skip packages already installed
395 .for PKG in ${PKGSRC_PACKAGES}
396 ${CHROOT_CMD} "cd /usr/pkgsrc/${PKG} && \
397 (bmake check > /dev/null 2>&1 || \
398 env USE_DESTDIR=no bmake ${PKGSRC_OPTIONS} clean build install)"
400 .for PKG in ${DPORTS_PACKAGES}
401 chroot ${ISOROOT} sh -c "cd /usr/dports/${PKG} && make && make install"
403 .for PKG in ${DPORTS_PACKAGES}
404 chroot ${ISOROOT} sh -c "cd /usr/dports/${PKG} && make clean"
407 # Remove packages which nothing depends on, add a whatis database
408 # for pkgsrc manual pages, create an initial locate database and
411 ${CHROOT_CMD} "pkg_leaves | xargs pkg_delete -R"
412 ${CHROOT_CMD} "yes | pkg autoremove"
413 ${CHROOT_CMD} "makewhatis /usr/pkg/man"
414 -umount ${ISOROOT}/usr/pkgsrc/distfiles
415 -umount ${ISOROOT}/usr/distfiles
416 umount ${ISOROOT}/usr/pkgsrc
417 umount ${ISOROOT}/usr/dports
418 rm -rf ${ISOROOT}/usr/pkgobj
419 rm -rf ${ISOROOT}/usr/dports
420 rm -rf ${ISOROOT}/usr/obj/dports
421 rm -rf ${ISOROOT}/usr/distfiles
422 rm -f ${ISOROOT}/etc/resolv.conf
426 ${CHROOT_CMD} "echo PACKAGESITE: http://avalon.dragonflybsd.org/dports/$$\\{ABI\\}/RELEASE >/usr/local/etc/pkg.conf"
428 # Finally, update the locate(8) database
430 ${CHROOT_CMD} /etc/periodic/weekly/310.locate
431 umount ${ISOROOT}/dev
433 # Recopy files that pkgsrc may have updated in /etc into /etc.hdd
435 cpdup ${ISOROOT}/etc/shells ${ISOROOT}/etc.hdd/shells
436 cpdup ${ISOROOT}/etc/group ${ISOROOT}/etc.hdd/group
439 ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
440 -R -J -o ${ISOFILE} \
441 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
444 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
445 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
446 vnconfig -u `cat ${ISODIR}/vn.which`; fi
448 @echo "STEP: use an image size of ${IMGSIZE} 512-byte sectors"
450 sz=`bc -e "((${IMGSIZE}) * 512)" -equit`; truncate -s $${sz} ${IMGFILE}
452 @echo "STEP: Determine required image size in 1GB steps"
453 @echo " Leave ~600MB of unused space"
454 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
455 sz=`bc -e "(($${sz}) * 1.15 + 999999 + 600000) / 1000000" -equit | \
457 sz=`bc -e "(($${sz}) * 953)" -equit | cut -f1 -d.`; \
459 truncate -s $${sz}M ${IMGFILE};
461 fdisk -IB -p ${IMGFILE}
462 @echo "STEP: determine free vn device"
463 vnconfig -l | grep "not in use" | head -n 1 | \
464 cut -f 1 -d: > ${ISODIR}/vn.which
465 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
466 @echo "STEP: write standard disklabel"
467 disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto
468 @echo "STEP: read disklabel back"
469 disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label
470 @echo "STEP: determine number of sectors of whole disk"
471 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
472 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
473 @echo "STEP: write modified disklabel back"
474 disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label
476 @echo "STEP: write bootsector"
477 disklabel -B `cat ${ISODIR}/vn.which`s1
478 boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which`
479 newfs /dev/`cat ${ISODIR}/vn.which`s1a
480 mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT}
481 cpdup ${ISOROOT} ${IMGMNT}
482 @echo "STEP: fixup ${IMGMNT}/etc/fstab"
483 echo "/dev/${IMGUSBDEV}s1a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab
484 echo "dummy /tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
485 echo "dummy /var/tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
486 echo "dummy /var/run tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
487 echo "dummy /usr/obj tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
488 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab
489 @echo "STEP: fixup ${IMGMNT}/boot/loader.conf"
490 -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new
491 echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s1a"' >> ${IMGMNT}/boot/loader.conf.new
492 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
493 @echo "STEP: cleanup"
496 vnconfig -u `cat ${ISODIR}/vn.which`
497 rm -f ${ISODIR}/vn.which
502 -umount ${ISOROOT}/usr/pkgsrc/distfiles > /dev/null 2>&1
503 -umount ${ISOROOT}/usr/distfiles > /dev/null 2>&1
504 -umount ${ISOROOT}/usr/pkgsrc > /dev/null 2>&1
505 -umount ${ISOROOT}/usr/dports > /dev/null 2>&1
506 -umount ${ISOROOT}/dev > /dev/null 2>&1
507 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
508 vnconfig -u `cat ${ISODIR}/vn.which`; fi
509 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
511 rm -rf ${NRLOBJDIR}/nrelease
512 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
515 rm -rf ${OBJSYS}/${KERNCONF}
516 rm -rf ${ISODIR}/packages
517 rm -rf ${ISODIR}/distfiles
520 mkdir -p ${ISODIR}/bootstrap
521 (cd ${PKGSRC_PATH}/bootstrap; \
522 export share_dir=${ISODIR}/bootstrap/share; \
523 ./bootstrap --workdir ${ISODIR}/bootstrap)
526 .if !exists (${PKGBIN_MKISOFS})
527 (cd ${PKGSRC_PATH}/sysutils/cdrtools; bmake clean build install)
531 @echo "make [gui] release - complete build from scratch"
532 @echo "make [gui] quick - attempt to do an incremental rebuild"
533 @echo "make [gui] realquick - attempt to restart after world & kernel"
534 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
536 @echo "PKGSRC_EXTRA_PACKAGES may be used to add additional pkgs"
537 @echo "GITHOST may be used to override git.dragonflybsd.org"
538 @echo "IMGSIZE may be used to override the .img (in 512-byte sectors)"
540 .PHONY: release quickrel realquickrel
542 .PHONY: quick realquick
543 .PHONY: check buildworld1 buildworld2
544 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mkiso mkimg
545 .PHONY: clean realclean help all srcs
547 .include <bsd.prog.mk>