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)
13 #########################################################################
15 #########################################################################
18 ISOROOT?= ${ISODIR}/root
19 OBJSYS= ${.OBJDIR}/../sys
21 MAKE_JOBS?= $$(sysctl -n hw.ncpu)
23 # temporary until everybody has converted to x86_64
24 .if ${MACHINE_ARCH} == "amd64"
29 # XXX makeshift fix to build the right kernel for the (target) architecture
30 # We should configure this in the platform files somehow
31 .if ${MACHINE_ARCH} == "i386"
32 KERNCONF ?= GENERIC VKERNEL
34 KERNCONF ?= X86_64_GENERIC VKERNEL64
37 PKGSRC_PREFIX?= /usr/pkg
38 PKGBIN_PKG_ADD?= ${PKGSRC_PREFIX}/sbin/pkg_add
39 PKGBIN_PKG_DELETE?= ${PKGSRC_PREFIX}/sbin/pkg_delete
40 PKGBIN_PKG_ADMIN?= ${PKGSRC_PREFIX}/sbin/pkg_admin
41 PKGBIN_MKISOFS?= ${PKGSRC_PREFIX}/bin/mkisofs
42 PKGSRC_PKG_PATH?= ${ISODIR}/packages
44 # We use env -i in the chroot, so that environment variables won't
45 # disturb any (pkgsrc) build. This has happened for TARGET_ARCH,
46 # which is used by gmake in completely different context.
48 CHROOT_CMD?= env -i CCVER=${CCVER:Q} /usr/sbin/chroot ${ISOROOT} sh -c
50 # User may specify extra packages in addition to the defaults
52 PKGSRC_EXTRA_PACKAGES?=
54 # Pkgsrc packages to be built and installed on the release ISO
56 PKGSRC_PACKAGES?= pkgtools/pkg_leaves \
65 ${PKGSRC_EXTRA_PACKAGES}
67 # pkgsrc options to use when building packages
69 PKGSRC_OPTIONS+= MAKE_JOBS=${MAKE_JOBS}
70 PKGSRC_OPTIONS+= WRKOBJDIR=/usr/pkgobj
71 PKGSRC_OPTIONS+= PKG_DEFAULT_OPTIONS='dri inet6'
73 PKGSRC_OPTIONS+= PKG_OPTIONS.scmgit=-scmgit-gui
76 # Even though buildiso wipes the packages, our check target has to run
77 # first and old packages (listed as they appear in pkg_info) must be
78 # cleaned out in order for the pkg_add -n test we use in the check target
79 # to operate properly.
81 OLD_PKGSRC_PACKAGES?= cdrtools-2.01.01.27nb1 \
83 bootstrap-kit-20070205 \
84 dfuibe_installer-1.1.6 \
86 dfuibe_installer-1.1.7nb1 \
89 gettext-tools-0.14.6nb1 \
93 bootstrap-kit-20080211 \
94 cdrtools-ossdvd-2.01.1.36nb2 \
98 # Specify which root skeletons are required, and let the user include
99 # their own. They are copied into ISODIR during the `customizeiso'
100 # target; each overwrites the last.
102 REQ_ROOTSKELS= ${.CURDIR}/root
103 ROOTSKELS?= ${REQ_ROOTSKELS}
106 ISOFILE?= ${ISODIR}/dfly-gui.iso
107 IMGFILE?= ${ISODIR}/dfly-gui.img
108 PKGSRC_PACKAGES+= meta-pkgs/modular-xorg-apps \
109 meta-pkgs/modular-xorg-drivers \
110 meta-pkgs/modular-xorg-fonts \
111 meta-pkgs/modular-xorg-libs \
122 x11/modular-xorg-server \
134 fonts/terminus-font \
139 ROOTSKELS+= ${.CURDIR}/gui
142 ISOFILE ?= ${ISODIR}/dfly.iso
143 IMGFILE ?= ${ISODIR}/dfly.img
145 IMGMNT ?= ${ISODIR}/mnt
147 # USB umass now probes starting at da8, so the usb stick is
148 # probably sitting on da8.
152 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
153 # the additional '/nrelease' manually, as a safety measure.
157 #########################################################################
159 #########################################################################
161 release: check clean buildworld1 buildkernel1 \
162 buildiso srcs customizeiso mklocatedb \
165 quickrel: check clean buildworld2 buildkernel2 \
166 buildiso srcs customizeiso mklocatedb \
169 realquickrel: check clean \
170 buildiso srcs customizeiso mklocatedb \
173 restartpkgs: check customizeiso mklocatedb mkiso mkimg
177 realquick: realquickrel
180 #########################################################################
181 # CORE SUPPORT TARGETS #
182 #########################################################################
185 .if !exists(${PKGBIN_PKG_ADMIN})
186 @echo "You never bootstrapped pkgsrc on your machine. You can install it with:"
187 @echo " make pkgsrc_bootstrap"
189 .if !exists (${PKGBIN_MKISOFS})
191 @echo "Your machine does not have cdrtools installed. You can install it with:"
192 @echo " make pkgsrc_cdrecord"
194 .if !defined(PKGSRC_PATH)
195 @echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for"
196 @echo "package building. For example /usr/pkgsrc. See the Makefile"
197 @echo "in /usr if you are unfamiliar with pkgsrc."
199 .if !exists (${PKGBIN_MKISOFS})
202 .if !defined(PKGSRC_PATH)
206 buildworld1 buildworld2:
208 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
209 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
211 buildkernel1 buildkernel2:
214 for kernconf in ${KERNCONF}; do \
215 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
216 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
217 KERNCONF=$${kernconf} \
218 $${first:+-DNO_MODULES}; \
222 # note that we do not want to mess with any /usr/obj directories not related
223 # to buildworld, buildkernel, or nrelease, so we must supply the proper
224 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
225 # buildkernel mechanism.
227 # Unconditionally clean out /usr/release/root so a previous img build
228 # does not blow up a future quick iso build
232 -chflags -R noschg ${ISOROOT}
235 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
236 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
237 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
238 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
239 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
242 for kernconf in ${KERNCONF}; do \
243 make DESTDIR=${ISOROOT} \
244 installkernel KERNCONF=$${kernconf} \
245 $${first:+DESTKERNNAME=kernel.$${kernconf}} \
246 $${first:+-DNO_MODULES}; \
249 ln -s kernel ${ISOROOT}/boot/kernel.BOOTP
250 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
251 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
252 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
254 # Release CD: Kernel sources (~16M) and the full pkgsrc tree (~27M)
255 # Release DVD: Full sources (~90M) and the full pkgsrc tree (~27M)
258 .if !defined(WITHOUT_SRCS)
259 rm -f ${ISOROOT}/usr/pkgsrc-git.tgz
260 rm -f ${ISOROOT}/usr/pkgsrc
261 mkdir -p ${ISOROOT}/usr/pkgsrc
262 cd ${ISOROOT}/usr/pkgsrc && git init
263 cd ${ISOROOT}/usr/pkgsrc && \
264 git remote add origin git://git.dragonflybsd.org/pkgsrc.git
265 cd ${ISOROOT}/usr/pkgsrc && git fetch origin
266 cd ${ISOROOT}/usr/pkgsrc && git branch vendor origin/vendor
267 cd ${ISOROOT}/usr/pkgsrc && git gc
269 rm -f ${ISOROOT}/usr/src-git.tgz
270 rm -rf ${ISOROOT}/usr/src
271 mkdir -p ${ISOROOT}/usr/src
272 cd ${ISOROOT}/usr/src && git init
273 cd ${ISOROOT}/usr/src && \
274 git remote add origin git://git.dragonflybsd.org/dragonfly.git
275 cd ${ISOROOT}/usr/src && git fetch origin
276 cd ${ISOROOT}/usr/src && git branch master origin/master
277 cd ${ISOROOT}/usr/src && git gc
279 rm -f ${ISOROOT}/usr/src-sys.tgz
280 cd ${.CURDIR}/.. && tar --exclude .git --exclude CVS -s '/^\./src/' \
281 -czf ${ISOROOT}/usr/src-sys.tgz ./Makefile ./Makefile.inc1 ./sys
285 # Customize the ISO by copying rootskels in reverse priority order,
286 # building packages, and doing other post-install tasks.
289 # Copy the rootskels. Allow sources to be owned by someone other
290 # then root (as is common when checked out via git).
292 .for ROOTSKEL in ${ROOTSKELS}
293 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
294 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
295 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
297 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
298 .for UPGRADE_ITEM in Makefile \
299 etc.${MACHINE_ARCH} \
303 periodic/daily/Makefile \
304 periodic/security/Makefile \
305 periodic/weekly/Makefile \
306 periodic/monthly/Makefile
307 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
310 # Setup some things & mount pkgsrc tree. Use defensive umounts and
311 # rm -rf's to allow restarts. Allow /usr/pkgsrc to be read-only.
313 # If we did not get past the bootstrap we clean out the entire
314 # /usr/pkg infrastructure. Otherwise we attempt to pick up where
317 cp -p /etc/resolv.conf ${ISOROOT}/etc
318 ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
319 -@umount ${ISOROOT}/usr/pkgsrc/distfiles
320 -@umount ${ISOROOT}/usr/pkgsrc
321 -@umount ${ISOROOT}/dev
322 mkdir -p ${ISODIR}/distfiles
323 rm -rf ${ISOROOT}/usr/pkgobj
325 # Mount /usr/pkgsrc, make sure /usr/pkgsrc/distfiles is writable.
326 # Make /usr/pkgsrc read-only for safety, else a failed umount and
327 # our rm -rf will do bad things.
329 mkdir -p ${ISOROOT}/usr/pkgobj
330 mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap
331 mkdir -p ${ISOROOT}/usr/pkgsrc
332 mount_null -o ro ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc
333 mount_null /dev ${ISOROOT}/dev
334 cp /etc/shells ${ISOROOT}/usr/pkgsrc/distfiles/.test > /dev/null 2>&1 \
335 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/pkgsrc/distfiles
337 # Bootstrap, if not already installed, and add licenses needed
338 # for the gui release
340 test -e ${ISODIR}/.didbootstrap || \
341 rm -rf ${ISOROOT}/usr/pkg ${ISOROOT}/var/db/pkg \
342 ${ISOROOT}/var/db/pkg.refcount
343 test -e ${ISODIR}/.didbootstrap || \
344 ${CHROOT_CMD} "cd /usr/pkgsrc/bootstrap; \
345 export share_dir=/usr/pkgobj/bootstrap/work/share; \
346 ./bootstrap --workdir /usr/pkgobj/bootstrap/work"
348 test -e ${ISODIR}/.didbootstrap || \
349 echo ".ifdef BSD_PKG_MK # added by nrelease" \
350 >> ${ISOROOT}/usr/pkg/etc/mk.conf
351 test -e ${ISODIR}/.didbootstrap || \
352 echo "ACCEPTABLE_LICENSES+=openmotif-license" \
353 >> ${ISOROOT}/usr/pkg/etc/mk.conf
354 test -e ${ISODIR}/.didbootstrap || \
355 echo "ACCEPTABLE_LICENSES+=vim-license" \
356 >> ${ISOROOT}/usr/pkg/etc/mk.conf
357 test -e ${ISODIR}/.didbootstrap || \
358 echo ".endif # added by nrelease" \
359 >> ${ISOROOT}/usr/pkg/etc/mk.conf
361 test -e ${ISODIR}/.didbootstrap || sync
362 test -e ${ISODIR}/.didbootstrap || touch ${ISODIR}/.didbootstrap
364 # Build and install packages, skip packages already installed
366 .for PKG in ${PKGSRC_PACKAGES}
367 ${CHROOT_CMD} "cd /usr/pkgsrc/${PKG} && \
368 (bmake check > /dev/null 2>&1 || \
369 bmake ${PKGSRC_OPTIONS} clean build install)"
372 # Remove packages which nothing depends on and clean up
374 ${CHROOT_CMD} "pkg_leaves | xargs pkg_delete -R"
375 -umount ${ISOROOT}/usr/pkgsrc/distfiles
376 umount ${ISOROOT}/dev
377 umount ${ISOROOT}/usr/pkgsrc
378 rm -rf ${ISOROOT}/usr/pkgobj
379 rm -f ${ISOROOT}/etc/resolv.conf
380 makewhatis ${ISOROOT}/usr/pkg/man
385 ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
386 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
387 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
388 /usr/libexec/locate.mklocatedb \
389 -presort >${ISOROOT}/var/db/locate.database )
392 ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
393 -R -J -o ${ISOFILE} \
394 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
398 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
399 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
400 vnconfig -u `cat ${ISODIR}/vn.which`; fi
401 @echo "STEP: determine required image size"
402 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
403 sz=`bc -e "(($${sz}) / 1024) * 1.15" -equit | cut -f1 -d.`; \
404 dd if=/dev/zero of=${IMGFILE} bs=1m count=$${sz};
405 fdisk -IB -p ${IMGFILE}
406 @echo "STEP: determine free vn device"
407 vnconfig -l | grep "not in use" | head -n 1 | \
408 cut -f 1 -d: > ${ISODIR}/vn.which
409 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
410 @echo "STEP: write standard disklabel"
411 disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto
412 @echo "STEP: read disklabel back"
413 disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label
414 @echo "STEP: determine number of sectors of whole disk"
415 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
416 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
417 @echo "STEP: write modified disklabel back"
418 disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label
420 @echo "STEP: write bootsector"
421 disklabel -B `cat ${ISODIR}/vn.which`s1
422 boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which`
423 newfs /dev/`cat ${ISODIR}/vn.which`s1a
424 mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT}
425 cpdup ${ISOROOT} ${IMGMNT}
426 @echo "STEP: fixup ${IMGMNT}/etc/fstab"
427 echo "/dev/${IMGUSBDEV}s1a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab
428 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab
429 @echo "STEP: fixup ${IMGMNT}/boot/loader.conf"
430 -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new
431 echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s1a"' >> ${IMGMNT}/boot/loader.conf.new
432 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
433 @echo "STEP: cleanup"
436 vnconfig -u `cat ${ISODIR}/vn.which`
437 rm -f ${ISODIR}/vn.which
442 -umount ${ISOROOT}/usr/pkgsrc/distfiles > /dev/null 2>&1
443 -umount ${ISOROOT}/usr/pkgsrc > /dev/null 2>&1
444 -umount ${ISOROOT}/dev > /dev/null 2>&1
445 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
446 vnconfig -u `cat ${ISODIR}/vn.which`; fi
447 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
449 rm -rf ${NRLOBJDIR}/nrelease
450 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
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 mkdir -p /usr/release/bootstrap
463 (cd ${PKGSRC_PATH}/bootstrap; \
464 export share_dir=/usr/release/bootstrap/share; \
465 ./bootstrap --workdir /usr/release/bootstrap)
468 .if !exists (${PKGBIN_MKISOFS})
469 (cd ${PKGSRC_PATH}/sysutils/cdrtools; bmake clean build install)
473 @echo "make [gui] release - complete build from scratch"
474 @echo "make [gui] quick - attempt to do an incremental rebuild"
475 @echo "make [gui] realquick - attempt to restart after world & kernel"
476 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
478 @echo "Extra packages may be specified with PKGSRC_EXTRA_PACKAGES"
480 .PHONY: release quickrel realquickrel
482 .PHONY: quick realquick
483 .PHONY: check buildworld1 buildworld2
484 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso mkimg
485 .PHONY: clean realclean help all srcs
487 .include <bsd.prog.mk>