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"
30 # XXX makeshift fix to build the right kernel for the (target) architecture
31 # We should configure this in the platform files somehow
32 .if ${MACHINE_ARCH} == "i386"
33 KERNCONF ?= GENERIC GENERIC_SMP
35 KERNCONF ?= X86_64_GENERIC X86_64_GENERIC_SMP
38 PKGSRC_PREFIX?= /usr/pkg
39 PKGBIN_PKG_ADD?= ${PKGSRC_PREFIX}/sbin/pkg_add
40 PKGBIN_PKG_DELETE?= ${PKGSRC_PREFIX}/sbin/pkg_delete
41 PKGBIN_PKG_ADMIN?= ${PKGSRC_PREFIX}/sbin/pkg_admin
42 PKGBIN_MKISOFS?= ${PKGSRC_PREFIX}/bin/mkisofs
43 PKGSRC_PKG_PATH?= ${ISODIR}/packages
45 # We use env -i in the chroot, so that environment variables won't
46 # disturb any (pkgsrc) build. This has happened for TARGET_ARCH,
47 # which is used by gmake in completely different context.
49 CHROOT_CMD?= env -i CCVER=${CCVER:Q} /usr/sbin/chroot ${ISOROOT} sh -c
51 # User may specify extra packages in addition to the defaults
53 PKGSRC_EXTRA_PACKAGES?=
55 # Pkgsrc packages to be built and installed on the release ISO
57 PKGSRC_PACKAGES?= pkgtools/pkg_leaves \
66 ${PKGSRC_EXTRA_PACKAGES}
68 # pkgsrc options to use when building packages
70 PKGSRC_OPTIONS+= MAKE_JOBS=${MAKE_JOBS}
71 PKGSRC_OPTIONS+= WRKOBJDIR=/usr/pkgobj
72 PKGSRC_OPTIONS+= PKG_DEFAULT_OPTIONS='dri inet6'
74 PKGSRC_OPTIONS+= PKG_OPTIONS.scmgit=-scmgit-gui
77 # Even though buildiso wipes the packages, our check target has to run
78 # first and old packages (listed as they appear in pkg_info) must be
79 # cleaned out in order for the pkg_add -n test we use in the check target
80 # to operate properly.
82 OLD_PKGSRC_PACKAGES?= cdrtools-2.01.01.27nb1 \
84 bootstrap-kit-20070205 \
85 dfuibe_installer-1.1.6 \
87 dfuibe_installer-1.1.7nb1 \
90 gettext-tools-0.14.6nb1 \
94 bootstrap-kit-20080211 \
95 cdrtools-ossdvd-2.01.1.36nb2 \
99 # Specify which root skeletons are required, and let the user include
100 # their own. They are copied into ISODIR during the `customizeiso'
101 # target; each overwrites the last.
103 REQ_ROOTSKELS= ${.CURDIR}/root
104 ROOTSKELS?= ${REQ_ROOTSKELS}
106 # LIST OF PACKAGES NOT INCLUDED DUE TO BUILD ISSUES:
107 # chat/pidgin textproc/enchant dependency is broken
108 # x11/rxvt-unicode broken configure
109 # net/nmap tries to access openssl/md2.h which does not
111 # sysutils/idesk dying on link __sync_fetch_and_add_4
114 ISOFILE?= ${ISODIR}/dfly-gui.iso
115 IMGFILE?= ${ISODIR}/dfly-gui.img
117 # NOTE: order important, do not sort package list
119 # Apps we want in the gui build but which have problems building:
120 # chat/xchat link error on x86-64, something about ___progname
124 PKGSRC_PACKAGES+= meta-pkgs/modular-xorg-libs \
125 meta-pkgs/modular-xorg-fonts \
126 meta-pkgs/modular-xorg-apps \
127 meta-pkgs/modular-xorg-drivers \
137 x11/modular-xorg-server \
147 fonts/terminus-font \
153 ROOTSKELS+= ${.CURDIR}/gui
156 ISOFILE ?= ${ISODIR}/dfly.iso
157 IMGFILE ?= ${ISODIR}/dfly.img
159 IMGMNT ?= ${ISODIR}/mnt
161 # USB umass now probes starting at da8, so the usb stick is
162 # probably sitting on da8.
166 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
167 # the additional '/nrelease' manually, as a safety measure.
171 #########################################################################
173 #########################################################################
175 release: check clean buildworld1 buildkernel1 \
176 buildiso srcs customizeiso mkiso mkimg
178 quickrel: check clean buildworld2 buildkernel2 \
179 buildiso srcs customizeiso mkiso mkimg
181 realquickrel: check clean \
182 buildiso srcs customizeiso mkiso mkimg
184 restartpkgs: check customizeiso mkiso mkimg
188 realquick: realquickrel
191 #########################################################################
192 # CORE SUPPORT TARGETS #
193 #########################################################################
196 .if !exists(${PKGBIN_PKG_ADMIN})
197 @echo "You never bootstrapped pkgsrc on your machine. You can install it with:"
198 @echo " make pkgsrc_bootstrap"
200 .if !exists (${PKGBIN_MKISOFS})
202 @echo "Your machine does not have cdrtools installed. You can install it with:"
203 @echo " make pkgsrc_cdrecord"
205 .if !defined(PKGSRC_PATH)
206 @echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for"
207 @echo "package building. For example /usr/pkgsrc. See the Makefile"
208 @echo "in /usr if you are unfamiliar with pkgsrc."
210 .if !exists (${PKGBIN_MKISOFS})
213 .if !defined(PKGSRC_PATH)
217 buildworld1 buildworld2:
219 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
220 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
222 buildkernel1 buildkernel2:
224 for kernconf in ${KERNCONF}; do \
225 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
226 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
227 KERNCONF=$${kernconf}; \
230 # note that we do not want to mess with any /usr/obj directories not related
231 # to buildworld, buildkernel, or nrelease, so we must supply the proper
232 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
233 # buildkernel mechanism.
235 # Unconditionally clean out /usr/release/root so a previous img build
236 # does not blow up a future quick iso build
238 # We install with INSTALLSTRIPPEDMODULES to make things fit into the ISO.
239 # We leave the kernel's debug variables intact.
243 -chflags -R noschg ${ISOROOT}
246 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
247 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
248 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
249 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
250 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
252 for kernconf in ${KERNCONF}; do \
253 make DESTDIR=${ISOROOT} installkernel \
254 KERNCONF=$${kernconf} \
255 DESTKERNDIR=/boot/kernel.$${kernconf} \
256 INSTALLSTRIPPEDMODULES=y; \
257 ln -s kernel ${ISOROOT}/boot/kernel.$${kernconf}/kernel.BOOTP; \
258 rm -rf ${ISOROOT}/boot/kernel.$${kernconf}.old; \
260 .if ${MACHINE_ARCH} == "i386"
261 mv ${ISOROOT}/boot/kernel.GENERIC ${ISOROOT}/boot/kernel.UP
262 mv ${ISOROOT}/boot/kernel.GENERIC_SMP ${ISOROOT}/boot/kernel.SMP
264 mv ${ISOROOT}/boot/kernel.X86_64_GENERIC ${ISOROOT}/boot/kernel.UP
265 mv ${ISOROOT}/boot/kernel.X86_64_GENERIC_SMP ${ISOROOT}/boot/kernel.SMP
267 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
268 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
269 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
271 # The GUI build includes the pkgsrc tree (~1G+) while the nominal release
274 # The GUI build includes full sources while the nominal release build
275 # only includes kernel sources (~27MB).
278 .if !defined(WITHOUT_SRCS)
280 rm -f ${ISOROOT}/usr/src-sys.tgz
281 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
282 cd ${ISOROOT}/usr && make pkgsrc-create-repo GITHOST=${GITHOST}
283 cd ${ISOROOT}/usr && make src-create-repo GITHOST=${GITHOST}
285 rm -f ${ISOROOT}/usr/src-sys.tgz
286 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
287 cd ${.CURDIR}/.. && tar --exclude .git -s '/^\./src/' \
288 -cf - ./Makefile ./Makefile.inc1 ./sys | \
289 bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2
293 # Customize the ISO by copying rootskels in reverse priority order,
294 # building packages, and doing other post-install tasks.
297 # Copy the rootskels. Allow sources to be owned by someone other
298 # than root (as is common when checked out via git).
300 .for ROOTSKEL in ${ROOTSKELS}
301 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
302 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
303 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
305 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
306 .for UPGRADE_ITEM in Makefile \
307 etc.${MACHINE_ARCH} \
311 periodic/daily/Makefile \
312 periodic/security/Makefile \
313 periodic/weekly/Makefile \
314 periodic/monthly/Makefile
315 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
318 # Setup some things & mount pkgsrc tree. Use defensive umounts and
319 # rm -rf's to allow restarts. Allow /usr/pkgsrc to be read-only.
321 # If we did not get past the bootstrap we clean out the entire
322 # /usr/pkg infrastructure. Otherwise we attempt to pick up where
325 cp -p /etc/resolv.conf ${ISOROOT}/etc
326 ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
327 -@umount ${ISOROOT}/usr/pkgsrc/distfiles
328 -@umount ${ISOROOT}/usr/pkgsrc
329 -@umount ${ISOROOT}/dev
330 mkdir -p ${ISODIR}/distfiles
331 rm -rf ${ISOROOT}/usr/pkgobj
333 # Mount /usr/pkgsrc, make sure /usr/pkgsrc/distfiles is writable.
334 # Make /usr/pkgsrc read-only for safety, else a failed umount and
335 # our rm -rf will do bad things.
337 mkdir -p ${ISOROOT}/usr/pkgobj
338 mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap
339 mkdir -p ${ISOROOT}/usr/pkgsrc
340 mount_null -o ro ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc
341 mount_null /dev ${ISOROOT}/dev
342 cp /etc/shells ${ISOROOT}/usr/pkgsrc/distfiles/.test > /dev/null 2>&1 \
343 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/pkgsrc/distfiles
345 # Bootstrap, if not already installed, and add licenses needed
346 # for the gui release
348 test -e ${ISODIR}/.didbootstrap || \
349 rm -rf ${ISOROOT}/usr/pkg ${ISOROOT}/var/db/pkg \
350 ${ISOROOT}/var/db/pkg.refcount
351 test -e ${ISODIR}/.didbootstrap || \
352 ${CHROOT_CMD} "cd /usr/pkgsrc/bootstrap; \
353 export share_dir=/usr/pkgobj/bootstrap/work/share; \
354 env USE_DESTDIR=no ./bootstrap --workdir /usr/pkgobj/bootstrap/work"
355 test -e ${ISODIR}/.didbootstrap || \
356 echo ".ifdef BSD_PKG_MK # added by nrelease" \
357 >> ${ISOROOT}/usr/pkg/etc/mk.conf
358 test -e ${ISODIR}/.didbootstrap || \
359 echo "PKG_DEFAULT_OPTIONS='dri inet6'" \
360 >> ${ISOROOT}/usr/pkg/etc/mk.conf
362 test -e ${ISODIR}/.didbootstrap || \
363 echo "ACCEPTABLE_LICENSES+=openmotif-license" \
364 >> ${ISOROOT}/usr/pkg/etc/mk.conf
365 test -e ${ISODIR}/.didbootstrap || \
366 echo "ACCEPTABLE_LICENSES+=vim-license" \
367 >> ${ISOROOT}/usr/pkg/etc/mk.conf
369 test -e ${ISODIR}/.didbootstrap || \
370 echo ".endif # added by nrelease" \
371 >> ${ISOROOT}/usr/pkg/etc/mk.conf
372 test -e ${ISODIR}/.didbootstrap || sync
373 test -e ${ISODIR}/.didbootstrap || touch ${ISODIR}/.didbootstrap
375 # Build and install packages, skip packages already installed
377 .for PKG in ${PKGSRC_PACKAGES}
378 ${CHROOT_CMD} "cd /usr/pkgsrc/${PKG} && \
379 (bmake check > /dev/null 2>&1 || \
380 env USE_DESTDIR=no bmake ${PKGSRC_OPTIONS} clean build install)"
383 # Remove packages which nothing depends on, add a whatis database
384 # for pkgsrc manual pages, create an initial locate database and
387 ${CHROOT_CMD} "pkg_leaves | xargs pkg_delete -R"
388 ${CHROOT_CMD} "makewhatis /usr/pkg/man"
389 -umount ${ISOROOT}/usr/pkgsrc/distfiles
390 umount ${ISOROOT}/usr/pkgsrc
391 rm -rf ${ISOROOT}/usr/pkgobj
392 rm -f ${ISOROOT}/etc/resolv.conf
393 ${CHROOT_CMD} /etc/periodic/weekly/310.locate
394 umount ${ISOROOT}/dev
396 # Recopy files that pkgsrc may have updated in /etc into /etc.hdd
398 cpdup ${ISOROOT}/etc/shells ${ISOROOT}/etc.hdd/shells
399 cpdup ${ISOROOT}/etc/group ${ISOROOT}/etc.hdd/group
401 # no iso is generated for gui builds, just img.
405 ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
406 -R -J -o ${ISOFILE} \
407 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
411 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
412 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
413 vnconfig -u `cat ${ISODIR}/vn.which`; fi
415 @echo "STEP: use an image size of ${IMGSIZE} 512-byte sectors"
417 sz=`bc -e "((${IMGSIZE}) * 512)" -equit`; truncate -s $${sz} ${IMGFILE}
419 @echo "STEP: Determine required image size in 1GB steps"
420 @echo " Leave ~600MB of unused space"
421 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
422 sz=`bc -e "(($${sz}) * 1.15 + 999999 + 600000) / 1000000" -equit | \
424 sz=`bc -e "(($${sz}) * 953)" -equit | cut -f1 -d.`; \
426 truncate -s $${sz}M ${IMGFILE};
428 fdisk -IB -p ${IMGFILE}
429 @echo "STEP: determine free vn device"
430 vnconfig -l | grep "not in use" | head -n 1 | \
431 cut -f 1 -d: > ${ISODIR}/vn.which
432 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
433 @echo "STEP: write standard disklabel"
434 disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto
435 @echo "STEP: read disklabel back"
436 disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label
437 @echo "STEP: determine number of sectors of whole disk"
438 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
439 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
440 @echo "STEP: write modified disklabel back"
441 disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label
443 @echo "STEP: write bootsector"
444 disklabel -B `cat ${ISODIR}/vn.which`s1
445 boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which`
446 newfs /dev/`cat ${ISODIR}/vn.which`s1a
447 mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT}
448 cpdup ${ISOROOT} ${IMGMNT}
449 @echo "STEP: fixup ${IMGMNT}/etc/fstab"
450 echo "/dev/${IMGUSBDEV}s1a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab
451 echo "dummy /tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
452 echo "dummy /var/tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
453 echo "dummy /var/run tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
454 echo "dummy /usr/obj tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
455 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab
456 @echo "STEP: fixup ${IMGMNT}/boot/loader.conf"
457 -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new
458 echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s1a"' >> ${IMGMNT}/boot/loader.conf.new
459 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
460 @echo "STEP: cleanup"
463 vnconfig -u `cat ${ISODIR}/vn.which`
464 rm -f ${ISODIR}/vn.which
469 -umount ${ISOROOT}/usr/pkgsrc/distfiles > /dev/null 2>&1
470 -umount ${ISOROOT}/usr/pkgsrc > /dev/null 2>&1
471 -umount ${ISOROOT}/dev > /dev/null 2>&1
472 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
473 vnconfig -u `cat ${ISODIR}/vn.which`; fi
474 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
476 rm -rf ${NRLOBJDIR}/nrelease
477 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
480 rm -rf ${OBJSYS}/${KERNCONF}
482 # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
485 rm -rf ${ISODIR}/packages
486 rm -rf ${ISODIR}/distfiles
489 mkdir -p /usr/release/bootstrap
490 (cd ${PKGSRC_PATH}/bootstrap; \
491 export share_dir=/usr/release/bootstrap/share; \
492 ./bootstrap --workdir /usr/release/bootstrap)
495 .if !exists (${PKGBIN_MKISOFS})
496 (cd ${PKGSRC_PATH}/sysutils/cdrtools; bmake clean build install)
500 @echo "make [gui] release - complete build from scratch"
501 @echo "make [gui] quick - attempt to do an incremental rebuild"
502 @echo "make [gui] realquick - attempt to restart after world & kernel"
503 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
505 @echo "PKGSRC_EXTRA_PACKAGES may be used to add additional pkgs"
506 @echo "GITHOST may be used to override git.dragonflybsd.org"
507 @echo "IMGSIZE may be used to override the .img (in 512-byte sectors)"
509 .PHONY: release quickrel realquickrel
511 .PHONY: quick realquick
512 .PHONY: check buildworld1 buildworld2
513 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mkiso mkimg
514 .PHONY: clean realclean help all srcs
516 .include <bsd.prog.mk>