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)
11 gui installer img nopkgs:
13 #########################################################################
15 #########################################################################
17 DPORTS_PATH?= /usr/dports
19 ISOROOT?= ${ISODIR}/root
20 OBJSYS= ${.OBJDIR}/../sys
21 GITHOST?= git.dragonflybsd.org
23 MAKE_JOBS?= $$(sysctl -n hw.ncpu)
25 # temporary until everybody has converted to x86_64
26 .if ${MACHINE_ARCH} == "amd64"
28 .if defined(.PARSEDIR)
31 # LEGACY MAKE - REMOVE FOR DFLY 3.6
36 # XXX makeshift fix to build the right kernel for the (target) architecture
37 # We should configure this in the platform files somehow
38 .if ${MACHINE_ARCH} == "i386"
41 KERNCONF ?= X86_64_GENERIC
44 CHROOT_CMD?= /usr/sbin/chroot ${ISOROOT} sh -c
46 # User may specify extra packages in addition to the defaults
48 DPORTS_EXTRA_PACKAGES?=
50 # dports packages to be built and installed on the release ISO
54 DPORTS_PACKAGES?= devel/git \
56 net/isc-dhcp42-client \
57 net/isc-dhcp42-server \
59 ${PKGSRC_EXTRA_PACKAGES}
61 # dports options to use when building packages
63 DPORTS_OPTIONS+= -DBATCH
65 DPORTS_OPTIONS.devel_git+= -DWITHOUT_CONTRIB -DWITHOUT_PERL
68 # Specify which root skeletons are required, and let the user include
69 # their own. They are copied into ISODIR during the `customizeiso'
70 # target; each overwrites the last.
72 REQ_ROOTSKELS= ${.CURDIR}/root
73 ROOTSKELS?= ${REQ_ROOTSKELS}
76 # LIST OF PACKAGES NOT INCLUDED DUE TO BUILD ISSUES:
77 # chat/pidgin textproc/enchant dependency is broken
78 # x11/rxvt-unicode broken configure
79 # net/nmap tries to access openssl/md2.h which does not
81 # sysutils/idesk dying on link __sync_fetch_and_add_4
83 ISOFILE?= ${ISODIR}/dfly-gui.iso
84 IMGFILE?= ${ISODIR}/dfly-gui.img
86 # NOTE: order important, do not sort package list
88 # Apps we want in the gui build but which have problems building:
89 # chat/xchat link error on x86-64, something about ___progname
93 PKGSRC_PACKAGES+= meta-pkgs/modular-xorg-libs \
94 meta-pkgs/modular-xorg-fonts \
95 meta-pkgs/modular-xorg-apps \
96 meta-pkgs/modular-xorg-drivers \
106 x11/modular-xorg-server \
116 fonts/terminus-font \
123 ROOTSKELS+= ${.CURDIR}/gui
126 ISOFILE ?= ${ISODIR}/dfly.iso
127 IMGFILE ?= ${ISODIR}/dfly.img
129 IMGMNT ?= ${ISODIR}/mnt
131 # USB umass now probes starting at da8, so the usb stick is
132 # probably sitting on da8.
136 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
137 # the additional '/nrelease' manually, as a safety measure.
141 #########################################################################
143 #########################################################################
145 release: check clean buildworld1 buildkernel1 \
146 buildiso srcs customizeiso mkiso mkimg
148 quickrel: check clean buildworld2 buildkernel2 \
149 buildiso srcs customizeiso mkiso mkimg
151 realquickrel: check clean \
152 buildiso srcs customizeiso mkiso mkimg
154 restartpkgs: check customizeiso mkiso mkimg
158 realquick: realquickrel
161 #########################################################################
162 # CORE SUPPORT TARGETS #
163 #########################################################################
166 .if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs)
168 @echo "Your machine does not have cdrtools installed. You can install it with:"
169 @echo " pkg install cdrecord"
171 .if !defined(DPORTS_PATH)
172 @echo "Please set DPORTS_PATH to the dports tree that shall be used for"
173 @echo "package building. For example /usr/dports. See the Makefile"
174 @echo "in /usr if you are unfamiliar with dports."
176 .if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs)
179 .if !defined(DPORTS_PATH)
183 buildworld1 buildworld2:
185 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
186 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
188 buildkernel1 buildkernel2:
190 for kernconf in ${KERNCONF}; do \
191 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
192 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
193 KERNCONF=$${kernconf}; \
196 # note that we do not want to mess with any /usr/obj directories not related
197 # to buildworld, buildkernel, or nrelease, so we must supply the proper
198 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
199 # buildkernel mechanism.
201 # Unconditionally clean out ${ISOROOT} so a previous img build
202 # does not blow up a future quick iso build
204 # We install with INSTALLSTRIPPEDMODULES to make things fit into the ISO.
205 # We leave the kernel's debug variables intact.
209 -chflags -R noschg ${ISOROOT}
212 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
213 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
214 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
215 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
216 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
218 for kernconf in ${KERNCONF}; do \
219 make DESTDIR=${ISOROOT} installkernel KERNCONF=$${kernconf}; \
221 rm -rf ${ISOROOT}/boot/kernel.old
222 ln -s kernel ${ISOROOT}/boot/kernel/kernel.BOOTP
223 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
224 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
225 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
227 # The GUI build includes the pkgsrc tree (~1G+) while the nominal release
230 # The GUI build includes full sources while the nominal release build
231 # only includes kernel sources (~27MB).
234 .if !defined(WITHOUT_SRCS)
236 rm -f ${ISOROOT}/usr/src-sys.tgz
237 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
238 cd ${ISOROOT}/usr && make pkgsrc-create-repo GITHOST=${GITHOST}
239 # NOTE: Adding the git gc --aggressive helps by significantly
240 # reducing the disk space required.
242 cd ${ISOROOT}/usr/pkgsrc && git gc --aggressive
243 cd ${ISOROOT}/usr && make src-create-repo GITHOST=${GITHOST}
245 rm -f ${ISOROOT}/usr/src-sys.tgz
246 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
247 cd ${.CURDIR}/.. && tar --exclude .git -s '/^\./src/' \
248 -cf - ./Makefile ./Makefile.inc1 ./sys | \
249 bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2
253 # Customize the ISO by copying rootskels in reverse priority order,
254 # building packages, and doing other post-install tasks.
257 # Copy the rootskels. Allow sources to be owned by someone other
258 # than root (as is common when checked out via git).
260 .for ROOTSKEL in ${ROOTSKELS}
261 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
262 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
263 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
265 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
266 .for UPGRADE_ITEM in Makefile \
267 etc.${MACHINE_ARCH} \
270 periodic/daily/Makefile \
271 periodic/security/Makefile \
272 periodic/weekly/Makefile \
273 periodic/monthly/Makefile
274 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
277 # Setup some things & mount dports tree. Use defensive umounts and
278 # rm -rf's to allow restarts. Allow /usr/dports to be read-only.
280 cp -p /etc/resolv.conf ${ISOROOT}/etc
281 ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
282 -@umount ${ISOROOT}/usr/distfiles
283 -@umount ${ISOROOT}/usr/dports
284 -@umount ${ISOROOT}/dev
285 rm -rf ${ISOROOT}/usr/obj/dports
287 # Mount /usr/dports, make sure /usr/distfiles is writable.
288 # Make /usr/dports read-only for safety, else a failed umount and
289 # our rm -rf will do bad things.
291 mkdir -p ${ISOROOT}/usr/dports
292 mkdir -p ${ISOROOT}/usr/distfiles
293 mount_null -o ro ${DPORTS_PATH} ${ISOROOT}/usr/dports
294 mount_null /dev ${ISOROOT}/dev
295 cp /etc/shells ${ISOROOT}/usr/distfiles/.test > /dev/null 2>&1 \
296 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/distfiles
298 # Build and install packages, skip packages already installed
300 .for PKG in ${DPORTS_PACKAGES}
301 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} ${DPORTS_OPTIONS.${PKG:S/\//_/g}} install"
303 .for PKG in ${DPORTS_PACKAGES}
304 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} clean"
307 # Remove packages which nothing depends on, add a whatis database
308 # for dports manual pages, create an initial locate database and
311 ${CHROOT_CMD} "yes | pkg autoremove"
312 ${CHROOT_CMD} "makewhatis /usr/local/man"
313 -umount ${ISOROOT}/usr/distfiles
314 umount ${ISOROOT}/usr/dports
315 rm -rf ${ISOROOT}/usr/dports
316 rm -rf ${ISOROOT}/usr/obj/dports
317 rm -rf ${ISOROOT}/usr/distfiles
318 rm -f ${ISOROOT}/etc/resolv.conf
322 ${CHROOT_CMD} "echo PACKAGESITE: http://avalon.dragonflybsd.org/dports/$$\\{ABI\\}/RELEASE >/usr/local/etc/pkg.conf"
324 # Finally, update the locate(8) database
326 ${CHROOT_CMD} /etc/periodic/weekly/310.locate
327 umount ${ISOROOT}/dev
329 # Recopy files that pkgsrc may have updated in /etc into /etc.hdd
331 cpdup ${ISOROOT}/etc/shells ${ISOROOT}/etc.hdd/shells
332 cpdup ${ISOROOT}/etc/group ${ISOROOT}/etc.hdd/group
335 ( cd ${ISOROOT}; mkisofs -b boot/cdboot -no-emul-boot \
336 -R -J -o ${ISOFILE} \
337 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
340 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
341 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
342 vnconfig -u `cat ${ISODIR}/vn.which`; fi
344 @echo "STEP: use an image size of ${IMGSIZE} 512-byte sectors"
346 sz=`bc -e "((${IMGSIZE}) * 512)" -equit`; truncate -s $${sz} ${IMGFILE}
348 @echo "STEP: Determine required image size in 1GB steps"
349 @echo " Leave ~600MB of unused space"
350 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
351 sz=`bc -e "(($${sz}) * 1.15 + 999999 + 600000) / 1000000" -equit | \
353 sz=`bc -e "(($${sz}) * 953)" -equit | cut -f1 -d.`; \
355 truncate -s $${sz}M ${IMGFILE};
357 fdisk -IB -p ${IMGFILE}
358 @echo "STEP: determine free vn device"
359 vnconfig -l | grep "not in use" | head -n 1 | \
360 cut -f 1 -d: > ${ISODIR}/vn.which
361 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
362 @echo "STEP: write standard disklabel"
363 disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto
364 @echo "STEP: read disklabel back"
365 disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label
366 @echo "STEP: determine number of sectors of whole disk"
367 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
368 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
369 @echo "STEP: write modified disklabel back"
370 disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label
372 @echo "STEP: write bootsector"
373 disklabel -B `cat ${ISODIR}/vn.which`s1
374 boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which`
375 newfs /dev/`cat ${ISODIR}/vn.which`s1a
376 mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT}
377 cpdup ${ISOROOT} ${IMGMNT}
378 @echo "STEP: fixup ${IMGMNT}/etc/fstab"
379 echo "/dev/${IMGUSBDEV}s1a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab
380 echo "dummy /tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
381 echo "dummy /var/tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
382 echo "dummy /var/run tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
383 echo "dummy /usr/obj tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
384 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab
385 @echo "STEP: fixup ${IMGMNT}/boot/loader.conf"
386 -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new
387 echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s1a"' >> ${IMGMNT}/boot/loader.conf.new
388 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
389 @echo "STEP: cleanup"
392 vnconfig -u `cat ${ISODIR}/vn.which`
393 rm -f ${ISODIR}/vn.which
398 -umount ${ISOROOT}/usr/distfiles > /dev/null 2>&1
399 -umount ${ISOROOT}/usr/dports > /dev/null 2>&1
400 -umount ${ISOROOT}/dev > /dev/null 2>&1
401 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
402 vnconfig -u `cat ${ISODIR}/vn.which`; fi
403 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
405 rm -rf ${NRLOBJDIR}/nrelease
406 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
409 rm -rf ${OBJSYS}/${KERNCONF}
410 rm -rf ${ISODIR}/packages
411 rm -rf ${ISODIR}/distfiles
414 @echo "make [gui] release - complete build from scratch"
415 @echo "make [gui] quick - attempt to do an incremental rebuild"
416 @echo "make [gui] realquick - attempt to restart after world & kernel"
417 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
419 @echo "DPORTS_EXTRA_PACKAGES may be used to add additional pkgs"
420 @echo "GITHOST may be used to override git.dragonflybsd.org"
421 @echo "IMGSIZE may be used to override the .img (in 512-byte sectors)"
423 .PHONY: release quickrel realquickrel
425 .PHONY: quick realquick
426 .PHONY: check buildworld1 buildworld2
427 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mkiso mkimg
428 .PHONY: clean realclean help all srcs
430 .include <bsd.prog.mk>