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.
11 #########################################################################
13 #########################################################################
16 ISOROOT?= ${ISODIR}/root
17 OBJSYS= ${.OBJDIR}/../sys
19 MAKE_JOBS?= $$(sysctl -n hw.ncpu)
21 # temporary until everybody has converted to x86_64
22 .if ${MACHINE_ARCH} == "amd64"
28 KERNCONF ?= DFLYLIVE VKERNEL DFLYLIVE-SMP DFLYLIVE-SMP-NOAPIC
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 VKERNEL
35 KERNCONF ?= X86_64_GENERIC VKERNEL64
39 PKGSRC_PREFIX?= /usr/pkg
40 PKGBIN_PKG_ADD?= ${PKGSRC_PREFIX}/sbin/pkg_add
41 PKGBIN_PKG_DELETE?= ${PKGSRC_PREFIX}/sbin/pkg_delete
42 PKGBIN_PKG_ADMIN?= ${PKGSRC_PREFIX}/sbin/pkg_admin
43 PKGBIN_MKISOFS?= ${PKGSRC_PREFIX}/bin/mkisofs
44 PKGSRC_PKG_PATH?= ${ISODIR}/packages
46 # We use env -i in the chroot, so that environment variables won't
47 # disturb any (pkgsrc) build. This has happened for TARGET_ARCH,
48 # which is used by gmake in completely different context.
50 CHROOT_CMD?= env -i CCVER=${CCVER:Q} /usr/sbin/chroot ${ISOROOT} sh -c
52 # User may specify extra packages in addition to the defaults
54 PKGSRC_EXTRA_PACKAGES?=
56 # Pkgsrc packages to be built and installed on the release ISO
58 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}
107 ISOFILE?= ${ISODIR}/dfly-gui.iso
108 IMGFILE?= ${ISODIR}/dfly-gui.img
109 PKGSRC_PACKAGES+= meta-pkgs/modular-xorg-apps \
110 meta-pkgs/modular-xorg-drivers \
111 meta-pkgs/modular-xorg-fonts \
112 meta-pkgs/modular-xorg-libs \
123 x11/modular-xorg-server \
135 fonts/terminus-font \
140 ROOTSKELS+= ${.CURDIR}/gui
143 ISOFILE ?= ${ISODIR}/dfly.iso
144 IMGFILE ?= ${ISODIR}/dfly.img
146 IMGMNT ?= ${ISODIR}/mnt
148 # USB umass now probes starting at da8, so the usb stick is
149 # probably sitting on da8.
153 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
154 # the additional '/nrelease' manually, as a safety measure.
158 #########################################################################
160 #########################################################################
162 release: check clean buildworld1 buildkernel1 \
163 buildiso srcs customizeiso mklocatedb \
166 quickrel: check clean buildworld2 buildkernel2 \
167 buildiso srcs customizeiso mklocatedb \
170 realquickrel: check clean \
171 buildiso srcs customizeiso mklocatedb \
174 restartpkgs: check customizeiso mklocatedb mkiso mkimg
178 realquick: realquickrel
181 #########################################################################
182 # CORE SUPPORT TARGETS #
183 #########################################################################
186 .if !exists(${PKGBIN_PKG_ADMIN})
187 @echo "You never bootstrapped pkgsrc on your machine. You can install it with:"
188 @echo " make pkgsrc_bootstrap"
190 .if !exists (${PKGBIN_MKISOFS})
192 @echo "Your machine does not have cdrtools installed. You can install it with:"
193 @echo " make pkgsrc_cdrecord"
195 .if !defined(PKGSRC_PATH)
196 @echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for"
197 @echo "package building. For example /usr/pkgsrc. See the Makefile"
198 @echo "in /usr if you are unfamiliar with pkgsrc."
200 .if !exists (${PKGBIN_MKISOFS})
203 .if !defined(PKGSRC_PATH)
207 buildworld1 buildworld2:
209 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
210 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
212 buildkernel1 buildkernel2:
215 for kernconf in ${KERNCONF}; do \
216 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
217 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
218 KERNCONF=$${kernconf} KERNCONFDIR=${.CURDIR}/gui/root; \
223 for kernconf in ${KERNCONF}; do \
224 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
225 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
226 KERNCONF=$${kernconf} \
227 $${first:+-DNO_MODULES}; \
232 # note that we do not want to mess with any /usr/obj directories not related
233 # to buildworld, buildkernel, or nrelease, so we must supply the proper
234 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
235 # buildkernel mechanism.
237 # Unconditionally clean out /usr/release/root so a previous img build
238 # does not blow up a future quick iso build
242 -chflags -R noschg ${ISOROOT}
245 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
246 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
247 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
248 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
249 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
251 if [ ! -d ${ISOROOT}/kernel.smp/boot ]; then mkdir -p ${ISOROOT}/kernel.smp/boot; fi
253 make installkernel DESTDIR=${ISOROOT} \
254 KERNCONF=DFLYLIVE DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
256 make installkernel DESTDIR=${ISOROOT} \
257 KERNCONF=VKERNEL DESTKERNNAME=kernel.VKERNEL -DNO_MODULES KERNCONFDIR=${.CURDIR}/gui/root; \
259 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
260 KERNCONF=DFLYLIVE-SMP DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
262 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
263 KERNCONF=DFLYLIVE-SMP-NOAPIC DESTKERNNAME=kernel.noapic \
264 KERNCONFDIR=${.CURDIR}/gui/root -DNO_MODULES;
268 for kernconf in ${KERNCONF}; do \
269 make DESTDIR=${ISOROOT} \
270 installkernel KERNCONF=$${kernconf} \
271 $${first:+DESTKERNNAME=kernel.$${kernconf}} \
272 $${first:+-DNO_MODULES}; \
276 ln -s kernel ${ISOROOT}/boot/kernel.BOOTP
277 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
278 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
279 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
281 # Release CD: Kernel sources (~16M) and the full pkgsrc tree (~27M)
282 # Release DVD: Full sources (~90M) and the full pkgsrc tree (~27M)
285 .if !defined(WITHOUT_SRCS)
286 rm -f ${ISOROOT}/usr/pkgsrc-git.tgz
287 rm -f ${ISOROOT}/usr/pkgsrc
288 mkdir -p ${ISOROOT}/usr/pkgsrc
289 cd ${ISOROOT}/usr/pkgsrc && git init
290 cd ${ISOROOT}/usr/pkgsrc && \
291 git remote add origin git://git.dragonflybsd.org/pkgsrc.git
292 cd ${ISOROOT}/usr/pkgsrc && git fetch origin
293 cd ${ISOROOT}/usr/pkgsrc && git branch vendor origin/vendor
294 cd ${ISOROOT}/usr/pkgsrc && git gc
296 rm -f ${ISOROOT}/usr/src-git.tgz
297 rm -rf ${ISOROOT}/usr/src
298 mkdir -p ${ISOROOT}/usr/src
299 cd ${ISOROOT}/usr/src && git init
300 cd ${ISOROOT}/usr/src && \
301 git remote add origin git://git.dragonflybsd.org/dragonfly.git
302 cd ${ISOROOT}/usr/src && git fetch origin
303 cd ${ISOROOT}/usr/src && git branch master origin/master
304 cd ${ISOROOT}/usr/src && git gc
306 rm -f ${ISOROOT}/usr/src-sys.tgz
307 cd ${.CURDIR}/.. && tar --exclude .git --exclude CVS -s '/^\./src/' \
308 -czf ${ISOROOT}/usr/src-sys.tgz ./Makefile ./Makefile.inc1 ./sys
312 # Customize the ISO by copying rootskels in reverse priority order,
313 # building packages, and doing other post-install tasks.
316 # Copy the rootskels. Allow sources to be owned by someone other
317 # then root (as is common when checked out via git).
319 .for ROOTSKEL in ${ROOTSKELS}
320 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
321 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
322 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
324 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
325 .for UPGRADE_ITEM in Makefile \
326 etc.${MACHINE_ARCH} \
330 periodic/daily/Makefile \
331 periodic/security/Makefile \
332 periodic/weekly/Makefile \
333 periodic/monthly/Makefile
334 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
337 # Setup some things & mount pkgsrc tree. Use defensive umounts and
338 # rm -rf's to allow restarts. Allow /usr/pkgsrc to be read-only.
340 # If we did not get past the bootstrap we clean out the entire
341 # /usr/pkg infrastructure. Otherwise we attempt to pick up where
344 cp -p /etc/resolv.conf ${ISOROOT}/etc
345 ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
346 -@umount ${ISOROOT}/usr/pkgsrc/distfiles
347 -@umount ${ISOROOT}/usr/pkgsrc
348 -@umount ${ISOROOT}/dev
349 mkdir -p ${ISODIR}/distfiles
350 rm -rf ${ISOROOT}/usr/pkgobj
352 # Mount /usr/pkgsrc, make sure /usr/pkgsrc/distfiles is writable.
353 # Make /usr/pkgsrc read-only for safety, else a failed umount and
354 # our rm -rf will do bad things.
356 mkdir -p ${ISOROOT}/usr/pkgobj
357 mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap
358 mkdir -p ${ISOROOT}/usr/pkgsrc
359 mount_null -o ro ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc
360 mount_null /dev ${ISOROOT}/dev
361 cp /etc/shells ${ISOROOT}/usr/pkgsrc/distfiles/.test > /dev/null 2>&1 \
362 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/pkgsrc/distfiles
364 # Bootstrap, if not already installed, and add licenses needed
365 # for the gui release
367 test -e ${ISODIR}/.didbootstrap || \
368 rm -rf ${ISOROOT}/usr/pkg ${ISOROOT}/var/db/pkg \
369 ${ISOROOT}/var/db/pkg.refcount
370 test -e ${ISODIR}/.didbootstrap || \
371 ${CHROOT_CMD} "cd /usr/pkgsrc/bootstrap; \
372 ./bootstrap --workdir /usr/pkgobj/bootstrap/work"
374 test -e ${ISODIR}/.didbootstrap || \
375 echo ".ifdef BSD_PKG_MK # added by nrelease" \
376 >> ${ISOROOT}/usr/pkg/etc/mk.conf
377 test -e ${ISODIR}/.didbootstrap || \
378 echo "ACCEPTABLE_LICENSES+=openmotif-license" \
379 >> ${ISOROOT}/usr/pkg/etc/mk.conf
380 test -e ${ISODIR}/.didbootstrap || \
381 echo "ACCEPTABLE_LICENSES+=vim-license" \
382 >> ${ISOROOT}/usr/pkg/etc/mk.conf
383 test -e ${ISODIR}/.didbootstrap || \
384 echo ".endif # added by nrelease" \
385 >> ${ISOROOT}/usr/pkg/etc/mk.conf
387 test -e ${ISODIR}/.didbootstrap || sync
388 test -e ${ISODIR}/.didbootstrap || touch ${ISODIR}/.didbootstrap
390 # Build and install packages, skip packages already installed
392 .for PKG in ${PKGSRC_PACKAGES}
393 ${CHROOT_CMD} "cd /usr/pkgsrc/${PKG} && \
394 (bmake check > /dev/null 2>&1 || \
395 bmake ${PKGSRC_OPTIONS} clean build install)"
398 # Remove packages which nothing depends on and clean up
400 ${CHROOT_CMD} "pkg_leaves | xargs pkg_delete -R"
401 -umount ${ISOROOT}/usr/pkgsrc/distfiles
402 umount ${ISOROOT}/dev
403 umount ${ISOROOT}/usr/pkgsrc
404 rm -rf ${ISOROOT}/usr/pkgobj
405 rm -f ${ISOROOT}/etc/resolv.conf
406 makewhatis ${ISOROOT}/usr/pkg/man
411 ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
412 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
413 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
414 /usr/libexec/locate.mklocatedb \
415 -presort >${ISOROOT}/var/db/locate.database )
418 ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
419 -R -J -o ${ISOFILE} \
420 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
425 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
426 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
427 vnconfig -u `cat ${ISODIR}/vn.which`; fi
428 @echo "STEP: determine required image size"
429 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
430 sz=`bc -e "(($${sz}) / 1024) * 1.15" -equit | cut -f1 -d.`; \
431 dd if=/dev/zero of=${IMGFILE} bs=1m count=$${sz};
432 fdisk -IB -p ${IMGFILE}
433 @echo "STEP: determine free vn device"
434 vnconfig -l | grep "not in use" | head -n 1 | \
435 cut -f 1 -d: > ${ISODIR}/vn.which
436 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
437 @echo "STEP: write standard disklabel"
438 disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto
439 @echo "STEP: read disklabel back"
440 disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label
441 @echo "STEP: determine number of sectors of whole disk"
442 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
443 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
444 @echo "STEP: write modified disklabel back"
445 disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label
447 @echo "STEP: write bootsector"
448 disklabel -B `cat ${ISODIR}/vn.which`s1
449 boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which`
450 newfs /dev/`cat ${ISODIR}/vn.which`s1a
451 mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT}
452 cpdup ${ISOROOT} ${IMGMNT}
453 @echo "STEP: fixup ${IMGMNT}/etc/fstab"
454 echo "/dev/${IMGUSBDEV}s1a / ufs rw,noatime 0 1" > ${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
470 -umount ${ISOROOT}/usr/pkgsrc/distfiles > /dev/null 2>&1
471 -umount ${ISOROOT}/usr/pkgsrc > /dev/null 2>&1
472 -umount ${ISOROOT}/dev > /dev/null 2>&1
473 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
474 vnconfig -u `cat ${ISODIR}/vn.which`; fi
475 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
477 rm -rf ${NRLOBJDIR}/nrelease
478 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
481 rm -rf ${OBJSYS}/${KERNCONF}
483 # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
486 rm -rf ${ISODIR}/packages
487 rm -rf ${ISODIR}/distfiles
490 mkdir -p /usr/release/bootstrap
491 (cd ${PKGSRC_PATH}/bootstrap; ./bootstrap --workdir /usr/release/bootstrap)
494 .if !exists (${PKGBIN_MKISOFS})
495 (cd ${PKGSRC_PATH}/sysutils/cdrtools; bmake clean build install)
499 @echo "make [gui] release - complete build from scratch"
500 @echo "make [gui] quick - attempt to do an incremental rebuild"
501 @echo "make [gui] realquick - attempt to restart after world & kernel"
502 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
504 @echo "Extra packages may be specified with PKGSRC_EXTRA_PACKAGES"
506 .PHONY: release quickrel realquickrel
508 .PHONY: quick realquick
509 .PHONY: check buildworld1 buildworld2
510 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso mkimg
511 .PHONY: clean realclean help all srcs
513 .include <bsd.prog.mk>