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 NCPU!= sysctl -n hw.ncpu
26 KERNCONF ?= DFLYLIVE VKERNEL DFLYLIVE-SMP DFLYLIVE-SMP-NOAPIC
28 KERNCONF ?= GENERIC VKERNEL
31 PKGSRC_PREFIX?= /usr/pkg
32 PKGBIN_PKG_ADD?= ${PKGSRC_PREFIX}/sbin/pkg_add
33 PKGBIN_PKG_DELETE?= ${PKGSRC_PREFIX}/sbin/pkg_delete
34 PKGBIN_PKG_ADMIN?= ${PKGSRC_PREFIX}/sbin/pkg_admin
35 PKGBIN_MKISOFS?= ${PKGSRC_PREFIX}/bin/mkisofs
36 PKGSRC_PKG_PATH?= ${ISODIR}/packages
37 PKGSRC_BOOTSTRAP_URL?= http://avalon.dragonflybsd.org/DragonFly-pkgsrc-packages/i386/1.12.0-RELEASE-BUILD
38 CVSUP_BOOTSTRAP_KIT?= cvsup-bootstrap-20070716
40 # We use env -i in the chroot, so that environment variables won't
41 # disturb any (pkgsrc) build. This has happened for TARGET_ARCH,
42 # which is used by gmake in completely different context.
44 CHROOT_CMD?= env -i CCVER=${CCVER:Q} /usr/sbin/chroot ${ISOROOT} sh -c
46 # User may specify extra packages in addition to the defaults
48 PKGSRC_EXTRA_PACKAGES?=
50 # Pkgsrc packages to be built and installed on the release ISO
52 PKGSRC_PACKAGES?= pkgtools/pkg_leaves \
58 ${PKGSRC_EXTRA_PACKAGES}
60 # pkgsrc options to use when building packages
62 PKGSRC_OPTIONS+= MAKE_JOBS=${MAKE_JOBS}
63 PKGSRC_OPTIONS+= WRKOBJDIR=/usr/pkgobj
64 PKGSRC_OPTIONS+= PKG_DEFAULT_OPTIONS='dri inet6'
66 PKGSRC_OPTIONS+= PKG_OPTIONS.scmgit=-scmgit-gui
69 # Even though buildiso wipes the packages, our check target has to run
70 # first and old packages (listed as they appear in pkg_info) must be
71 # cleaned out in order for the pkg_add -n test we use in the check target
72 # to operate properly.
74 OLD_PKGSRC_PACKAGES?= cdrtools-2.01.01.27nb1 \
76 bootstrap-kit-20070205 \
77 dfuibe_installer-1.1.6 \
79 dfuibe_installer-1.1.7nb1 \
82 gettext-tools-0.14.6nb1 \
86 bootstrap-kit-20080211 \
87 cdrtools-ossdvd-2.01.1.36nb2 \
91 # Specify which root skeletons are required, and let the user include
92 # their own. They are copied into ISODIR during the `customizeiso'
93 # target; each overwrites the last.
95 REQ_ROOTSKELS= ${.CURDIR}/root \
97 ROOTSKELS?= ${REQ_ROOTSKELS}
100 ISOFILE?= ${ISODIR}/dfly-gui.iso
101 IMGFILE?= ${ISODIR}/dfly-gui.img
102 PKGSRC_PACKAGES+= meta-pkgs/modular-xorg-apps \
103 meta-pkgs/modular-xorg-drivers \
104 meta-pkgs/modular-xorg-fonts \
105 meta-pkgs/modular-xorg-libs \
116 x11/modular-xorg-server \
128 fonts/terminus-font \
133 ROOTSKELS+= ${.CURDIR}/gui
136 ISOFILE ?= ${ISODIR}/dfly.iso
137 IMGFILE ?= ${ISODIR}/dfly.img
139 IMGMNT ?= ${ISODIR}/mnt
141 # USB umass now probes starting at da8, so the usb stick is
142 # probably sitting on da8.
144 IMGUSBDEV ?= /dev/da8
146 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
147 # the additional '/nrelease' manually, as a safety measure.
151 #########################################################################
153 #########################################################################
155 release: check clean buildworld1 buildkernel1 \
156 buildiso srcs customizeiso mklocatedb \
159 quickrel: check clean buildworld2 buildkernel2 \
160 buildiso srcs customizeiso mklocatedb \
163 realquickrel: check clean \
164 buildiso srcs customizeiso mklocatedb \
167 restartpkgs: check customizeiso mklocatedb mkiso mkimg
171 realquick: realquickrel
174 #########################################################################
175 # CORE SUPPORT TARGETS #
176 #########################################################################
179 .if !exists(${PKGBIN_PKG_ADMIN})
180 @echo "You never bootstrapped pkgsrc on your machine. You can install it with:"
181 @echo " make pkgsrc_bootstrap"
183 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
184 @echo "The cvsup bootstrap kit is not installed. You can install it with:"
187 .if !exists (${PKGBIN_MKISOFS})
189 @echo "Your machine does not have cdrtools installed. You can install it with:"
190 @echo " make pkgsrc_cdrecord"
192 .if !defined(PKGSRC_PATH)
193 @echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for"
194 @echo "package building. For example /usr/pkgsrc. See the Makefile"
195 @echo "in /usr if you are unfamiliar with pkgsrc."
197 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
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.
238 if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
239 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
240 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
241 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
242 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
243 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
245 if [ ! -d ${ISOROOT}/kernel.smp/boot ]; then mkdir -p ${ISOROOT}/kernel.smp/boot; fi
247 make installkernel DESTDIR=${ISOROOT} \
248 KERNCONF=DFLYLIVE DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
250 make installkernel DESTDIR=${ISOROOT} \
251 KERNCONF=VKERNEL DESTKERNNAME=kernel.VKERNEL -DNO_MODULES KERNCONFDIR=${.CURDIR}/gui/root; \
253 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
254 KERNCONF=DFLYLIVE-SMP DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
256 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
257 KERNCONF=DFLYLIVE-SMP-NOAPIC DESTKERNNAME=kernel.noapic \
258 KERNCONFDIR=${.CURDIR}/gui/root -DNO_MODULES;
262 for kernconf in ${KERNCONF}; do \
263 make DESTDIR=${ISOROOT} \
264 installkernel KERNCONF=$${kernconf} \
265 $${first:+DESTKERNNAME=kernel.$${kernconf}} \
266 $${first:+-DNO_MODULES}; \
270 ln -s kernel ${ISOROOT}/boot/kernel.BOOTP
271 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
272 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
273 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
275 # Release CD: Kernel sources (~16M) and the full pkgsrc tree (~27M)
276 # Release DVD: Full sources (~90M) and the full pkgsrc tree (~27M)
279 .if !defined(WITHOUT_SRCS)
280 rm -f ${ISOROOT}/usr/pkgsrc-all.tgz
281 cd ${PKGSRC_PATH} && tar --exclude distfiles --exclude packages --exclude work --exclude CVS --exclude .git \
282 -czf ${ISOROOT}/usr/pkgsrc-all.tgz .
284 rm -f ${ISOROOT}/usr/src-all.tgz
285 cd ${.CURDIR}/.. && tar --exclude .git --exclude CVS -s '/^\./src/' \
286 -czf ${ISOROOT}/usr/src-all.tgz .
288 rm -f ${ISOROOT}/usr/src-sys.tgz
289 cd ${.CURDIR}/.. && tar --exclude .git --exclude CVS -s '/^\./src/' \
290 -czf ${ISOROOT}/usr/src-sys.tgz ./Makefile ./Makefile.inc1 ./sys
294 # Customize the ISO by copying rootskels in reverse priority order,
295 # building packages, and doing other post-install tasks.
298 # Copy the rootskels. Allow sources to be owned by someone other
299 # then root (as is common when checked out via git).
301 .for ROOTSKEL in ${ROOTSKELS}
302 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
303 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
304 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
306 (cd ${PKGSRC_PKG_PATH}; tar xzpf ${CVSUP_BOOTSTRAP_KIT}.tgz)
307 cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/bin/cvsup ${ISOROOT}/usr/local/bin/cvsup
308 cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/man/man1/cvsup.1 ${ISOROOT}/usr/local/man/man1/cvsup.1
309 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
310 .for UPGRADE_ITEM in Makefile \
311 etc.${MACHINE_ARCH} \
315 periodic/daily/Makefile \
316 periodic/security/Makefile \
317 periodic/weekly/Makefile \
318 periodic/monthly/Makefile
319 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
322 # Setup some things & mount pkgsrc tree. Use defensive umounts and
323 # rm -rf's to allow restarts. Allow /usr/pkgsrc to be read-only.
325 # If we did not get past the bootstrap we clean out the entire
326 # /usr/pkg infrastructure. Otherwise we attempt to pick up where
329 cp -p /etc/resolv.conf ${ISOROOT}/etc
330 ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
331 -@umount ${ISOROOT}/usr/pkgsrc/distfiles
332 -@umount ${ISOROOT}/usr/pkgsrc
333 mkdir -p ${ISODIR}/distfiles
334 rm -rf ${ISOROOT}/usr/pkgobj
336 # Mount /usr/pkgsrc, make sure /usr/pkgsrc/distfiles is writable
338 mkdir -p ${ISOROOT}/usr/pkgobj
339 mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap
340 mkdir -p ${ISOROOT}/usr/pkgsrc
341 mount_null ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc
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 ./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 "ACCEPTABLE_LICENSES+=openmotif-license" \
360 >> ${ISOROOT}/usr/pkg/etc/mk.conf
361 test -e ${ISODIR}/.didbootstrap || \
362 echo "ACCEPTABLE_LICENSES+=vim-license" \
363 >> ${ISOROOT}/usr/pkg/etc/mk.conf
364 test -e ${ISODIR}/.didbootstrap || \
365 echo ".endif # added by nrelease" \
366 >> ${ISOROOT}/usr/pkg/etc/mk.conf
368 test -e ${ISODIR}/.didbootstrap || sync
369 test -e ${ISODIR}/.didbootstrap || touch ${ISODIR}/.didbootstrap
371 # Build and install packages, skip packages already installed
373 .for PKG in ${PKGSRC_PACKAGES}
374 ${CHROOT_CMD} "cd /usr/pkgsrc/${PKG} && \
375 (bmake check > /dev/null 2>&1 || \
376 bmake ${PKGSRC_OPTIONS} clean build install)"
379 # Remove packages which nothing depends on and clean up
381 ${CHROOT_CMD} "pkg_leaves | xargs pkg_delete -R"
382 -umount ${ISOROOT}/usr/pkgsrc/distfiles
383 umount ${ISOROOT}/usr/pkgsrc
384 rmdir ${ISOROOT}/usr/pkgsrc
385 rm -rf ${ISOROOT}/usr/pkgobj
386 rm -f ${ISOROOT}/etc/resolv.conf
387 makewhatis ${ISOROOT}/usr/local/man
388 makewhatis ${ISOROOT}/usr/pkg/man
393 ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
394 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
395 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
396 /usr/libexec/locate.mklocatedb \
397 -presort >${ISOROOT}/var/db/locate.database )
400 ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
401 -R -J -o ${ISOFILE} \
402 -V DragonFly-`${.CURDIR}/../tools/gitrev.sh | cut -c -22` . )
407 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
409 echo "determine required image size" > /dev/null; \
410 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
411 echo "add 15% more space as required" > /dev/null; \
412 sz=`bc -e "(($${sz}) / 1024) * 1.15" -equit | cut -f1 -d.`; \
413 dd if=/dev/zero of=${IMGFILE} bs=1m count=$${sz}; \
414 fdisk -IB -p ${IMGFILE}; \
415 echo "determine free vn device" > /dev/null; \
416 vn=`vnconfig -l | grep "not in use" | head -n 1 | cut -f 1 -d:`; \
417 vnconfig -e -s labels $${vn} ${IMGFILE}; \
418 echo "write standard disklabel" > /dev/null; \
419 disklabel -w -r $${vn}s1 auto; \
420 echo "read disklabel back" > /dev/null; \
421 disklabel -r $${vn}s1 > ${IMGFILE}.label; \
422 echo "determine number of sectors of whole disk" > /dev/null; \
423 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
424 echo "and add a: partition" > /dev/null; \
425 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label; \
426 echo "write modified disklabel back" > /dev/null; \
427 disklabel -R -r $${vn}s1 ${IMGFILE}.label; \
428 rm ${IMGFILE}.label; \
429 echo "write bootsector" > /dev/null; \
430 disklabel -B $${vn}s1; \
431 boot0cfg -B -o noupdate $${vn}; \
432 newfs /dev/$${vn}s1a; \
433 mount /dev/$${vn}s1a ${IMGMNT}; \
434 cpdup -vvv ${ISOROOT} ${IMGMNT}; \
435 echo "fix /etc/fstab" > /dev/null; \
436 echo "${IMGUSBDEV}s1a / ufs rw 0 0" > ${IMGMNT}/etc/fstab; \
437 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab; \
440 vnconfig -u $${vn}; \
445 -umount ${ISOROOT}/usr/pkgsrc/distfiles > /dev/null 2>&1
446 -umount ${ISOROOT}/usr/pkgsrc > /dev/null 2>&1
447 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
449 rm -rf ${NRLOBJDIR}/nrelease
450 rm -f ${ISODIR}/.didbootstrap
453 rm -rf ${OBJSYS}/${KERNCONF}
455 # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
458 rm -rf ${ISODIR}/packages
459 rm -rf ${ISODIR}/distfiles
462 @if [ ! -d ${PKGSRC_PKG_PATH} ]; then mkdir -p ${PKGSRC_PKG_PATH}; fi
463 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
464 (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${CVSUP_BOOTSTRAP_KIT}.tgz)
468 .if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
469 mkdir -p /usr/release/bootstrap
470 (cd ${PKGSRC_PATH}/bootstrap; ./bootstrap --workdir /usr/release/bootstrap)
474 .if !exists (${PKGBIN_MKISOFS})
475 (cd ${PKGSRC_PATH}/sysutils/cdrtools; bmake clean build install)
479 @echo "make [gui] release - complete build from scratch"
480 @echo "make [gui] quick - attempt to do an incremental rebuild"
481 @echo "make [gui] realquick - attempt to restart after world & kernel"
482 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
484 @echo "Extra packages may be specified with PKGSRC_EXTRA_PACKAGES"
486 .PHONY: release quickrel realquickrel
488 .PHONY: quick realquick
489 .PHONY: check buildworld1 buildworld2
490 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso mkimg
491 .PHONY: clean realclean fetch help all srcs
493 .include <bsd.prog.mk>