1 # $DragonFly: src/nrelease/Makefile,v 1.90 2008/09/01 21:20:30 swildner Exp $
4 #########################################################################
6 #########################################################################
8 # New method e.g. 'make gui release'. A series of enhancement
9 # targes may be specified which set make variables which enhance
10 # the build in various ways.
14 #########################################################################
16 #########################################################################
19 ISOROOT?= ${ISODIR}/root
20 OBJSYS= ${.OBJDIR}/../sys
22 MAKE_JOBS?= $$(sysctl -n hw.ncpu)
24 # temporary until everybody has converted to x86_64
25 .if ${MACHINE_ARCH} == "amd64"
31 KERNCONF ?= DFLYLIVE VKERNEL DFLYLIVE-SMP DFLYLIVE-SMP-NOAPIC
33 # XXX makeshift fix to build the right kernel for the (target) architecture
34 # We should configure this in the platform files somehow
35 .if ${MACHINE_ARCH} == "i386"
36 KERNCONF ?= GENERIC VKERNEL
38 KERNCONF ?= X86_64_GENERIC VKERNEL64
42 PKGSRC_PREFIX?= /usr/pkg
43 PKGBIN_PKG_ADD?= ${PKGSRC_PREFIX}/sbin/pkg_add
44 PKGBIN_PKG_DELETE?= ${PKGSRC_PREFIX}/sbin/pkg_delete
45 PKGBIN_PKG_ADMIN?= ${PKGSRC_PREFIX}/sbin/pkg_admin
46 PKGBIN_MKISOFS?= ${PKGSRC_PREFIX}/bin/mkisofs
47 PKGSRC_PKG_PATH?= ${ISODIR}/packages
48 PKGSRC_BOOTSTRAP_URL?= http://avalon.dragonflybsd.org/DragonFly-pkgsrc-packages/i386/1.12.0-RELEASE-BUILD
50 # We use env -i in the chroot, so that environment variables won't
51 # disturb any (pkgsrc) build. This has happened for TARGET_ARCH,
52 # which is used by gmake in completely different context.
54 CHROOT_CMD?= env -i CCVER=${CCVER:Q} /usr/sbin/chroot ${ISOROOT} sh -c
56 # User may specify extra packages in addition to the defaults
58 PKGSRC_EXTRA_PACKAGES?=
60 # Pkgsrc packages to be built and installed on the release ISO
62 PKGSRC_PACKAGES?= pkgtools/pkg_leaves \
70 ${PKGSRC_EXTRA_PACKAGES}
72 # pkgsrc options to use when building packages
74 PKGSRC_OPTIONS+= MAKE_JOBS=${MAKE_JOBS}
75 PKGSRC_OPTIONS+= WRKOBJDIR=/usr/pkgobj
76 PKGSRC_OPTIONS+= PKG_DEFAULT_OPTIONS='dri inet6'
78 PKGSRC_OPTIONS+= PKG_OPTIONS.scmgit=-scmgit-gui
81 # Even though buildiso wipes the packages, our check target has to run
82 # first and old packages (listed as they appear in pkg_info) must be
83 # cleaned out in order for the pkg_add -n test we use in the check target
84 # to operate properly.
86 OLD_PKGSRC_PACKAGES?= cdrtools-2.01.01.27nb1 \
88 bootstrap-kit-20070205 \
89 dfuibe_installer-1.1.6 \
91 dfuibe_installer-1.1.7nb1 \
94 gettext-tools-0.14.6nb1 \
98 bootstrap-kit-20080211 \
99 cdrtools-ossdvd-2.01.1.36nb2 \
100 isc-dhcp-base-4.0.0 \
101 isc-dhcp-server-4.0.0
103 # Specify which root skeletons are required, and let the user include
104 # their own. They are copied into ISODIR during the `customizeiso'
105 # target; each overwrites the last.
107 REQ_ROOTSKELS= ${.CURDIR}/root
108 ROOTSKELS?= ${REQ_ROOTSKELS}
111 ISOFILE?= ${ISODIR}/dfly-gui.iso
112 IMGFILE?= ${ISODIR}/dfly-gui.img
113 PKGSRC_PACKAGES+= meta-pkgs/modular-xorg-apps \
114 meta-pkgs/modular-xorg-drivers \
115 meta-pkgs/modular-xorg-fonts \
116 meta-pkgs/modular-xorg-libs \
127 x11/modular-xorg-server \
139 fonts/terminus-font \
144 ROOTSKELS+= ${.CURDIR}/gui
147 ISOFILE ?= ${ISODIR}/dfly.iso
148 IMGFILE ?= ${ISODIR}/dfly.img
150 IMGMNT ?= ${ISODIR}/mnt
152 # USB umass now probes starting at da8, so the usb stick is
153 # probably sitting on da8.
157 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
158 # the additional '/nrelease' manually, as a safety measure.
162 #########################################################################
164 #########################################################################
166 release: check clean buildworld1 buildkernel1 \
167 buildiso srcs customizeiso mklocatedb \
170 quickrel: check clean buildworld2 buildkernel2 \
171 buildiso srcs customizeiso mklocatedb \
174 realquickrel: check clean \
175 buildiso srcs customizeiso mklocatedb \
178 restartpkgs: check customizeiso mklocatedb mkiso mkimg
182 realquick: realquickrel
185 #########################################################################
186 # CORE SUPPORT TARGETS #
187 #########################################################################
190 .if !exists(${PKGBIN_PKG_ADMIN})
191 @echo "You never bootstrapped pkgsrc on your machine. You can install it with:"
192 @echo " make pkgsrc_bootstrap"
194 .if !exists (${PKGBIN_MKISOFS})
196 @echo "Your machine does not have cdrtools installed. You can install it with:"
197 @echo " make pkgsrc_cdrecord"
199 .if !defined(PKGSRC_PATH)
200 @echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for"
201 @echo "package building. For example /usr/pkgsrc. See the Makefile"
202 @echo "in /usr if you are unfamiliar with pkgsrc."
204 .if !exists (${PKGBIN_MKISOFS})
207 .if !defined(PKGSRC_PATH)
211 buildworld1 buildworld2:
213 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
214 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
216 buildkernel1 buildkernel2:
219 for kernconf in ${KERNCONF}; do \
220 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
221 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
222 KERNCONF=$${kernconf} KERNCONFDIR=${.CURDIR}/gui/root; \
227 for kernconf in ${KERNCONF}; do \
228 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
229 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
230 KERNCONF=$${kernconf} \
231 $${first:+-DNO_MODULES}; \
236 # note that we do not want to mess with any /usr/obj directories not related
237 # to buildworld, buildkernel, or nrelease, so we must supply the proper
238 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
239 # buildkernel mechanism.
241 # Unconditionally clean out /usr/release/root so a previous img build
242 # does not blow up a future quick iso build
246 -chflags -R noschg ${ISOROOT}
249 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
250 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
251 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
252 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
253 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
255 if [ ! -d ${ISOROOT}/kernel.smp/boot ]; then mkdir -p ${ISOROOT}/kernel.smp/boot; fi
257 make installkernel DESTDIR=${ISOROOT} \
258 KERNCONF=DFLYLIVE DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
260 make installkernel DESTDIR=${ISOROOT} \
261 KERNCONF=VKERNEL DESTKERNNAME=kernel.VKERNEL -DNO_MODULES KERNCONFDIR=${.CURDIR}/gui/root; \
263 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
264 KERNCONF=DFLYLIVE-SMP DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
266 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
267 KERNCONF=DFLYLIVE-SMP-NOAPIC DESTKERNNAME=kernel.noapic \
268 KERNCONFDIR=${.CURDIR}/gui/root -DNO_MODULES;
272 for kernconf in ${KERNCONF}; do \
273 make DESTDIR=${ISOROOT} \
274 installkernel KERNCONF=$${kernconf} \
275 $${first:+DESTKERNNAME=kernel.$${kernconf}} \
276 $${first:+-DNO_MODULES}; \
280 ln -s kernel ${ISOROOT}/boot/kernel.BOOTP
281 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
282 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
284 # Release CD: Kernel sources (~16M) and the full pkgsrc tree (~27M)
285 # Release DVD: Full sources (~90M) and the full pkgsrc tree (~27M)
288 .if !defined(WITHOUT_SRCS)
289 rm -f ${ISOROOT}/usr/pkgsrc-git.tgz
290 rm -f ${ISOROOT}/usr/pkgsrc
291 mkdir -p ${ISOROOT}/usr/pkgsrc
292 cd ${ISOROOT}/usr/pkgsrc && git init
293 cd ${ISOROOT}/usr/pkgsrc && \
294 git remote add origin git://git.dragonflybsd.org/pkgsrc.git
295 cd ${ISOROOT}/usr/pkgsrc && git fetch origin
296 cd ${ISOROOT}/usr/pkgsrc && git branch vendor origin/vendor
297 cd ${ISOROOT}/usr/pkgsrc && git gc
299 rm -f ${ISOROOT}/usr/src-git.tgz
300 rm -rf ${ISOROOT}/usr/src
301 mkdir -p ${ISOROOT}/usr/src
302 cd ${ISOROOT}/usr/src && git init
303 cd ${ISOROOT}/usr/src && \
304 git remote add origin git://git.dragonflybsd.org/dragonfly.git
305 cd ${ISOROOT}/usr/src && git fetch origin
306 cd ${ISOROOT}/usr/src && git branch master origin/master
307 cd ${ISOROOT}/usr/src && git gc
309 rm -f ${ISOROOT}/usr/src-sys.tgz
310 cd ${.CURDIR}/.. && tar --exclude .git --exclude CVS -s '/^\./src/' \
311 -czf ${ISOROOT}/usr/src-sys.tgz ./Makefile ./Makefile.inc1 ./sys
315 # Customize the ISO by copying rootskels in reverse priority order,
316 # building packages, and doing other post-install tasks.
319 # Copy the rootskels. Allow sources to be owned by someone other
320 # then root (as is common when checked out via git).
322 .for ROOTSKEL in ${ROOTSKELS}
323 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
324 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
325 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
327 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
328 .for UPGRADE_ITEM in Makefile \
329 etc.${MACHINE_ARCH} \
333 periodic/daily/Makefile \
334 periodic/security/Makefile \
335 periodic/weekly/Makefile \
336 periodic/monthly/Makefile
337 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
340 # Setup some things & mount pkgsrc tree. Use defensive umounts and
341 # rm -rf's to allow restarts. Allow /usr/pkgsrc to be read-only.
343 # If we did not get past the bootstrap we clean out the entire
344 # /usr/pkg infrastructure. Otherwise we attempt to pick up where
347 cp -p /etc/resolv.conf ${ISOROOT}/etc
348 ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
349 -@umount ${ISOROOT}/usr/pkgsrc/distfiles
350 -@umount ${ISOROOT}/usr/pkgsrc
351 -@umount ${ISOROOT}/dev
352 mkdir -p ${ISODIR}/distfiles
353 rm -rf ${ISOROOT}/usr/pkgobj
355 # Mount /usr/pkgsrc, make sure /usr/pkgsrc/distfiles is writable.
356 # Make /usr/pkgsrc read-only for safety, else a failed umount and
357 # our rm -rf will do bad things.
359 mkdir -p ${ISOROOT}/usr/pkgobj
360 mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap
361 mkdir -p ${ISOROOT}/usr/pkgsrc
362 mount_null -o ro ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc
363 mount_null /dev ${ISOROOT}/dev
364 cp /etc/shells ${ISOROOT}/usr/pkgsrc/distfiles/.test > /dev/null 2>&1 \
365 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/pkgsrc/distfiles
367 # Bootstrap, if not already installed, and add licenses needed
368 # for the gui release
370 test -e ${ISODIR}/.didbootstrap || \
371 rm -rf ${ISOROOT}/usr/pkg ${ISOROOT}/var/db/pkg \
372 ${ISOROOT}/var/db/pkg.refcount
373 test -e ${ISODIR}/.didbootstrap || \
374 ${CHROOT_CMD} "cd /usr/pkgsrc/bootstrap; \
375 ./bootstrap --workdir /usr/pkgobj/bootstrap/work"
377 test -e ${ISODIR}/.didbootstrap || \
378 echo ".ifdef BSD_PKG_MK # added by nrelease" \
379 >> ${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
386 test -e ${ISODIR}/.didbootstrap || \
387 echo ".endif # added by nrelease" \
388 >> ${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 bmake ${PKGSRC_OPTIONS} clean build install)"
401 # Remove packages which nothing depends on and clean up
403 ${CHROOT_CMD} "pkg_leaves | xargs pkg_delete -R"
404 -umount ${ISOROOT}/usr/pkgsrc/distfiles
405 umount ${ISOROOT}/dev
406 umount ${ISOROOT}/usr/pkgsrc
407 rm -rf ${ISOROOT}/usr/pkgobj
408 rm -f ${ISOROOT}/etc/resolv.conf
409 makewhatis ${ISOROOT}/usr/pkg/man
414 ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
415 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
416 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
417 /usr/libexec/locate.mklocatedb \
418 -presort >${ISOROOT}/var/db/locate.database )
421 ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
422 -R -J -o ${ISOFILE} \
423 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
428 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
429 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
430 vnconfig -u `cat ${ISODIR}/vn.which`; fi
431 @echo "STEP: determine required image size"
432 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
433 sz=`bc -e "(($${sz}) / 1024) * 1.15" -equit | cut -f1 -d.`; \
434 dd if=/dev/zero of=${IMGFILE} bs=1m count=$${sz};
435 fdisk -IB -p ${IMGFILE}
436 @echo "STEP: determine free vn device"
437 vnconfig -l | grep "not in use" | head -n 1 | \
438 cut -f 1 -d: > ${ISODIR}/vn.which
439 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
440 @echo "STEP: write standard disklabel"
441 disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto
442 @echo "STEP: read disklabel back"
443 disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label
444 @echo "STEP: determine number of sectors of whole disk"
445 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
446 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
447 @echo "STEP: write modified disklabel back"
448 disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label
450 @echo "STEP: write bootsector"
451 disklabel -B `cat ${ISODIR}/vn.which`s1
452 boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which`
453 newfs /dev/`cat ${ISODIR}/vn.which`s1a
454 mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT}
455 cpdup ${ISOROOT} ${IMGMNT}
456 @echo "STEP: fixup ${IMGMNT}/etc/fstab"
457 echo "/dev/${IMGUSBDEV}s1a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab
458 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab
459 @echo "STEP: fixup ${IMGMNT}/boot/loader.conf"
460 -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new
461 echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s1a"' >> ${IMGMNT}/boot/loader.conf.new
462 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
463 @echo "STEP: cleanup"
466 vnconfig -u `cat ${ISODIR}/vn.which`
467 rm -f ${ISODIR}/vn.which
473 -umount ${ISOROOT}/usr/pkgsrc/distfiles > /dev/null 2>&1
474 -umount ${ISOROOT}/usr/pkgsrc > /dev/null 2>&1
475 -umount ${ISOROOT}/dev > /dev/null 2>&1
476 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
477 vnconfig -u `cat ${ISODIR}/vn.which`; fi
478 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
480 rm -rf ${NRLOBJDIR}/nrelease
481 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
484 rm -rf ${OBJSYS}/${KERNCONF}
486 # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
489 rm -rf ${ISODIR}/packages
490 rm -rf ${ISODIR}/distfiles
493 mkdir -p /usr/release/bootstrap
494 (cd ${PKGSRC_PATH}/bootstrap; ./bootstrap --workdir /usr/release/bootstrap)
497 .if !exists (${PKGBIN_MKISOFS})
498 (cd ${PKGSRC_PATH}/sysutils/cdrtools; bmake clean build install)
502 @echo "make [gui] release - complete build from scratch"
503 @echo "make [gui] quick - attempt to do an incremental rebuild"
504 @echo "make [gui] realquick - attempt to restart after world & kernel"
505 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
507 @echo "Extra packages may be specified with PKGSRC_EXTRA_PACKAGES"
509 .PHONY: release quickrel realquickrel
511 .PHONY: quick realquick
512 .PHONY: check buildworld1 buildworld2
513 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso mkimg
514 .PHONY: clean realclean help all srcs
516 .include <bsd.prog.mk>