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"
27 # XXX makeshift fix to build the right kernel for the (target) architecture
28 # We should configure this in the platform files somehow
29 .if ${MACHINE_ARCH} == "i386"
30 KERNCONF ?= GENERIC VKERNEL
32 KERNCONF ?= X86_64_GENERIC VKERNEL64
35 PKGSRC_PREFIX?= /usr/pkg
36 PKGBIN_PKG_ADD?= ${PKGSRC_PREFIX}/sbin/pkg_add
37 PKGBIN_PKG_DELETE?= ${PKGSRC_PREFIX}/sbin/pkg_delete
38 PKGBIN_PKG_ADMIN?= ${PKGSRC_PREFIX}/sbin/pkg_admin
39 PKGBIN_MKISOFS?= ${PKGSRC_PREFIX}/bin/mkisofs
40 PKGSRC_PKG_PATH?= ${ISODIR}/packages
42 # We use env -i in the chroot, so that environment variables won't
43 # disturb any (pkgsrc) build. This has happened for TARGET_ARCH,
44 # which is used by gmake in completely different context.
46 CHROOT_CMD?= env -i CCVER=${CCVER:Q} /usr/sbin/chroot ${ISOROOT} sh -c
48 # User may specify extra packages in addition to the defaults
50 PKGSRC_EXTRA_PACKAGES?=
52 # Pkgsrc packages to be built and installed on the release ISO
54 PKGSRC_PACKAGES?= pkgtools/pkg_leaves \
62 ${PKGSRC_EXTRA_PACKAGES}
64 # pkgsrc options to use when building packages
66 PKGSRC_OPTIONS+= MAKE_JOBS=${MAKE_JOBS}
67 PKGSRC_OPTIONS+= WRKOBJDIR=/usr/pkgobj
68 PKGSRC_OPTIONS+= PKG_DEFAULT_OPTIONS='dri inet6'
70 PKGSRC_OPTIONS+= PKG_OPTIONS.scmgit=-scmgit-gui
73 # Even though buildiso wipes the packages, our check target has to run
74 # first and old packages (listed as they appear in pkg_info) must be
75 # cleaned out in order for the pkg_add -n test we use in the check target
76 # to operate properly.
78 OLD_PKGSRC_PACKAGES?= cdrtools-2.01.01.27nb1 \
80 bootstrap-kit-20070205 \
81 dfuibe_installer-1.1.6 \
83 dfuibe_installer-1.1.7nb1 \
86 gettext-tools-0.14.6nb1 \
90 bootstrap-kit-20080211 \
91 cdrtools-ossdvd-2.01.1.36nb2 \
95 # Specify which root skeletons are required, and let the user include
96 # their own. They are copied into ISODIR during the `customizeiso'
97 # target; each overwrites the last.
99 REQ_ROOTSKELS= ${.CURDIR}/root
100 ROOTSKELS?= ${REQ_ROOTSKELS}
103 ISOFILE?= ${ISODIR}/dfly-gui.iso
104 IMGFILE?= ${ISODIR}/dfly-gui.img
105 PKGSRC_PACKAGES+= meta-pkgs/modular-xorg-apps \
106 meta-pkgs/modular-xorg-drivers \
107 meta-pkgs/modular-xorg-fonts \
108 meta-pkgs/modular-xorg-libs \
119 x11/modular-xorg-server \
131 fonts/terminus-font \
136 ROOTSKELS+= ${.CURDIR}/gui
139 ISOFILE ?= ${ISODIR}/dfly.iso
140 IMGFILE ?= ${ISODIR}/dfly.img
142 IMGMNT ?= ${ISODIR}/mnt
144 # USB umass now probes starting at da8, so the usb stick is
145 # probably sitting on da8.
149 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
150 # the additional '/nrelease' manually, as a safety measure.
154 #########################################################################
156 #########################################################################
158 release: check clean buildworld1 buildkernel1 \
159 buildiso srcs customizeiso mklocatedb \
162 quickrel: check clean buildworld2 buildkernel2 \
163 buildiso srcs customizeiso mklocatedb \
166 realquickrel: check clean \
167 buildiso srcs customizeiso mklocatedb \
170 restartpkgs: check customizeiso mklocatedb mkiso mkimg
174 realquick: realquickrel
177 #########################################################################
178 # CORE SUPPORT TARGETS #
179 #########################################################################
182 .if !exists(${PKGBIN_PKG_ADMIN})
183 @echo "You never bootstrapped pkgsrc on your machine. You can install it with:"
184 @echo " make pkgsrc_bootstrap"
186 .if !exists (${PKGBIN_MKISOFS})
188 @echo "Your machine does not have cdrtools installed. You can install it with:"
189 @echo " make pkgsrc_cdrecord"
191 .if !defined(PKGSRC_PATH)
192 @echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for"
193 @echo "package building. For example /usr/pkgsrc. See the Makefile"
194 @echo "in /usr if you are unfamiliar with pkgsrc."
196 .if !exists (${PKGBIN_MKISOFS})
199 .if !defined(PKGSRC_PATH)
203 buildworld1 buildworld2:
205 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
206 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
208 buildkernel1 buildkernel2:
211 for kernconf in ${KERNCONF}; do \
212 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
213 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
214 KERNCONF=$${kernconf} \
215 $${first:+-DNO_MODULES}; \
219 # note that we do not want to mess with any /usr/obj directories not related
220 # to buildworld, buildkernel, or nrelease, so we must supply the proper
221 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
222 # buildkernel mechanism.
224 # Unconditionally clean out /usr/release/root so a previous img build
225 # does not blow up a future quick iso build
229 -chflags -R noschg ${ISOROOT}
232 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
233 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
234 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
235 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
236 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
239 for kernconf in ${KERNCONF}; do \
240 make DESTDIR=${ISOROOT} \
241 installkernel KERNCONF=$${kernconf} \
242 $${first:+DESTKERNNAME=kernel.$${kernconf}} \
243 $${first:+-DNO_MODULES}; \
246 ln -s kernel ${ISOROOT}/boot/kernel.BOOTP
247 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
248 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
249 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
251 # Release CD: Kernel sources (~16M) and the full pkgsrc tree (~27M)
252 # Release DVD: Full sources (~90M) and the full pkgsrc tree (~27M)
255 .if !defined(WITHOUT_SRCS)
256 rm -f ${ISOROOT}/usr/pkgsrc-git.tgz
257 rm -f ${ISOROOT}/usr/pkgsrc
258 mkdir -p ${ISOROOT}/usr/pkgsrc
259 cd ${ISOROOT}/usr/pkgsrc && git init
260 cd ${ISOROOT}/usr/pkgsrc && \
261 git remote add origin git://git.dragonflybsd.org/pkgsrc.git
262 cd ${ISOROOT}/usr/pkgsrc && git fetch origin
263 cd ${ISOROOT}/usr/pkgsrc && git branch vendor origin/vendor
264 cd ${ISOROOT}/usr/pkgsrc && git gc
266 rm -f ${ISOROOT}/usr/src-git.tgz
267 rm -rf ${ISOROOT}/usr/src
268 mkdir -p ${ISOROOT}/usr/src
269 cd ${ISOROOT}/usr/src && git init
270 cd ${ISOROOT}/usr/src && \
271 git remote add origin git://git.dragonflybsd.org/dragonfly.git
272 cd ${ISOROOT}/usr/src && git fetch origin
273 cd ${ISOROOT}/usr/src && git branch master origin/master
274 cd ${ISOROOT}/usr/src && git gc
276 rm -f ${ISOROOT}/usr/src-sys.tgz
277 cd ${.CURDIR}/.. && tar --exclude .git --exclude CVS -s '/^\./src/' \
278 -czf ${ISOROOT}/usr/src-sys.tgz ./Makefile ./Makefile.inc1 ./sys
282 # Customize the ISO by copying rootskels in reverse priority order,
283 # building packages, and doing other post-install tasks.
286 # Copy the rootskels. Allow sources to be owned by someone other
287 # then root (as is common when checked out via git).
289 .for ROOTSKEL in ${ROOTSKELS}
290 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
291 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
292 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
294 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
295 .for UPGRADE_ITEM in Makefile \
296 etc.${MACHINE_ARCH} \
300 periodic/daily/Makefile \
301 periodic/security/Makefile \
302 periodic/weekly/Makefile \
303 periodic/monthly/Makefile
304 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
307 # Setup some things & mount pkgsrc tree. Use defensive umounts and
308 # rm -rf's to allow restarts. Allow /usr/pkgsrc to be read-only.
310 # If we did not get past the bootstrap we clean out the entire
311 # /usr/pkg infrastructure. Otherwise we attempt to pick up where
314 cp -p /etc/resolv.conf ${ISOROOT}/etc
315 ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
316 -@umount ${ISOROOT}/usr/pkgsrc/distfiles
317 -@umount ${ISOROOT}/usr/pkgsrc
318 -@umount ${ISOROOT}/dev
319 mkdir -p ${ISODIR}/distfiles
320 rm -rf ${ISOROOT}/usr/pkgobj
322 # Mount /usr/pkgsrc, make sure /usr/pkgsrc/distfiles is writable.
323 # Make /usr/pkgsrc read-only for safety, else a failed umount and
324 # our rm -rf will do bad things.
326 mkdir -p ${ISOROOT}/usr/pkgobj
327 mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap
328 mkdir -p ${ISOROOT}/usr/pkgsrc
329 mount_null -o ro ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc
330 mount_null /dev ${ISOROOT}/dev
331 cp /etc/shells ${ISOROOT}/usr/pkgsrc/distfiles/.test > /dev/null 2>&1 \
332 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/pkgsrc/distfiles
334 # Bootstrap, if not already installed, and add licenses needed
335 # for the gui release
337 test -e ${ISODIR}/.didbootstrap || \
338 rm -rf ${ISOROOT}/usr/pkg ${ISOROOT}/var/db/pkg \
339 ${ISOROOT}/var/db/pkg.refcount
340 test -e ${ISODIR}/.didbootstrap || \
341 ${CHROOT_CMD} "cd /usr/pkgsrc/bootstrap; \
342 ./bootstrap --workdir /usr/pkgobj/bootstrap/work"
344 test -e ${ISODIR}/.didbootstrap || \
345 echo ".ifdef BSD_PKG_MK # added by nrelease" \
346 >> ${ISOROOT}/usr/pkg/etc/mk.conf
347 test -e ${ISODIR}/.didbootstrap || \
348 echo "ACCEPTABLE_LICENSES+=openmotif-license" \
349 >> ${ISOROOT}/usr/pkg/etc/mk.conf
350 test -e ${ISODIR}/.didbootstrap || \
351 echo "ACCEPTABLE_LICENSES+=vim-license" \
352 >> ${ISOROOT}/usr/pkg/etc/mk.conf
353 test -e ${ISODIR}/.didbootstrap || \
354 echo ".endif # added by nrelease" \
355 >> ${ISOROOT}/usr/pkg/etc/mk.conf
357 test -e ${ISODIR}/.didbootstrap || sync
358 test -e ${ISODIR}/.didbootstrap || touch ${ISODIR}/.didbootstrap
360 # Build and install packages, skip packages already installed
362 .for PKG in ${PKGSRC_PACKAGES}
363 ${CHROOT_CMD} "cd /usr/pkgsrc/${PKG} && \
364 (bmake check > /dev/null 2>&1 || \
365 bmake ${PKGSRC_OPTIONS} clean build install)"
368 # Remove packages which nothing depends on and clean up
370 ${CHROOT_CMD} "pkg_leaves | xargs pkg_delete -R"
371 -umount ${ISOROOT}/usr/pkgsrc/distfiles
372 umount ${ISOROOT}/dev
373 umount ${ISOROOT}/usr/pkgsrc
374 rm -rf ${ISOROOT}/usr/pkgobj
375 rm -f ${ISOROOT}/etc/resolv.conf
376 makewhatis ${ISOROOT}/usr/pkg/man
381 ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
382 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
383 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
384 /usr/libexec/locate.mklocatedb \
385 -presort >${ISOROOT}/var/db/locate.database )
388 ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
389 -R -J -o ${ISOFILE} \
390 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
395 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
396 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
397 vnconfig -u `cat ${ISODIR}/vn.which`; fi
398 @echo "STEP: determine required image size"
399 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
400 sz=`bc -e "(($${sz}) / 1024) * 1.15" -equit | cut -f1 -d.`; \
401 dd if=/dev/zero of=${IMGFILE} bs=1m count=$${sz};
402 fdisk -IB -p ${IMGFILE}
403 @echo "STEP: determine free vn device"
404 vnconfig -l | grep "not in use" | head -n 1 | \
405 cut -f 1 -d: > ${ISODIR}/vn.which
406 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
407 @echo "STEP: write standard disklabel"
408 disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto
409 @echo "STEP: read disklabel back"
410 disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label
411 @echo "STEP: determine number of sectors of whole disk"
412 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
413 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
414 @echo "STEP: write modified disklabel back"
415 disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label
417 @echo "STEP: write bootsector"
418 disklabel -B `cat ${ISODIR}/vn.which`s1
419 boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which`
420 newfs /dev/`cat ${ISODIR}/vn.which`s1a
421 mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT}
422 cpdup ${ISOROOT} ${IMGMNT}
423 @echo "STEP: fixup ${IMGMNT}/etc/fstab"
424 echo "/dev/${IMGUSBDEV}s1a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab
425 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab
426 @echo "STEP: fixup ${IMGMNT}/boot/loader.conf"
427 -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new
428 echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s1a"' >> ${IMGMNT}/boot/loader.conf.new
429 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
430 @echo "STEP: cleanup"
433 vnconfig -u `cat ${ISODIR}/vn.which`
434 rm -f ${ISODIR}/vn.which
440 -umount ${ISOROOT}/usr/pkgsrc/distfiles > /dev/null 2>&1
441 -umount ${ISOROOT}/usr/pkgsrc > /dev/null 2>&1
442 -umount ${ISOROOT}/dev > /dev/null 2>&1
443 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
444 vnconfig -u `cat ${ISODIR}/vn.which`; fi
445 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
447 rm -rf ${NRLOBJDIR}/nrelease
448 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
451 rm -rf ${OBJSYS}/${KERNCONF}
453 # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
456 rm -rf ${ISODIR}/packages
457 rm -rf ${ISODIR}/distfiles
460 mkdir -p /usr/release/bootstrap
461 (cd ${PKGSRC_PATH}/bootstrap; ./bootstrap --workdir /usr/release/bootstrap)
464 .if !exists (${PKGBIN_MKISOFS})
465 (cd ${PKGSRC_PATH}/sysutils/cdrtools; bmake clean build install)
469 @echo "make [gui] release - complete build from scratch"
470 @echo "make [gui] quick - attempt to do an incremental rebuild"
471 @echo "make [gui] realquick - attempt to restart after world & kernel"
472 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
474 @echo "Extra packages may be specified with PKGSRC_EXTRA_PACKAGES"
476 .PHONY: release quickrel realquickrel
478 .PHONY: quick realquick
479 .PHONY: check buildworld1 buildworld2
480 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso mkimg
481 .PHONY: clean realclean help all srcs
483 .include <bsd.prog.mk>