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 #########################################################################
18 ISOROOT?= ${ISODIR}/root
19 OBJSYS= ${.OBJDIR}/../sys
20 GITHOST?= git.dragonflybsd.org
22 MAKE_JOBS?= $$(sysctl -n hw.ncpu)
24 # temporary until everybody has converted to x86_64
25 .if ${MACHINE_ARCH} == "amd64"
27 .if defined(.PARSEDIR)
30 # LEGACY MAKE - REMOVE FOR DFLY 3.6
35 # XXX makeshift fix to build the right kernel for the (target) architecture
36 # We should configure this in the platform files somehow
37 .if ${MACHINE_ARCH} == "i386"
40 KERNCONF ?= X86_64_GENERIC
43 CHROOT_CMD?= /usr/sbin/chroot ${ISOROOT} sh -c
45 # User may specify extra packages in addition to the defaults
47 DPORTS_EXTRA_PACKAGES?=
49 # dports packages to be built and installed on the release ISO
53 DPORTS_PACKAGES?= devel/git \
55 net/isc-dhcp42-client \
56 net/isc-dhcp42-server \
58 ${PKGSRC_EXTRA_PACKAGES}
60 # dports options to use when building packages
62 DPORTS_OPTIONS+= -DBATCH
64 DPORTS_OPTIONS.devel_git+= -DWITHOUT_CONTRIB -DWITHOUT_PERL
67 # Specify which root skeletons are required, and let the user include
68 # their own. They are copied into ISODIR during the `customizeiso'
69 # target; each overwrites the last.
71 REQ_ROOTSKELS= ${.CURDIR}/root
72 ROOTSKELS?= ${REQ_ROOTSKELS}
75 # LIST OF PACKAGES NOT INCLUDED DUE TO BUILD ISSUES:
76 # chat/pidgin textproc/enchant dependency is broken
77 # x11/rxvt-unicode broken configure
78 # net/nmap tries to access openssl/md2.h which does not
80 # sysutils/idesk dying on link __sync_fetch_and_add_4
82 ISOFILE?= ${ISODIR}/dfly-gui.iso
83 IMGFILE?= ${ISODIR}/dfly-gui.img
85 # NOTE: order important, do not sort package list
87 # Apps we want in the gui build but which have problems building:
88 # chat/xchat link error on x86-64, something about ___progname
92 PKGSRC_PACKAGES+= meta-pkgs/modular-xorg-libs \
93 meta-pkgs/modular-xorg-fonts \
94 meta-pkgs/modular-xorg-apps \
95 meta-pkgs/modular-xorg-drivers \
105 x11/modular-xorg-server \
115 fonts/terminus-font \
122 ROOTSKELS+= ${.CURDIR}/gui
125 ISOFILE ?= ${ISODIR}/dfly.iso
126 IMGFILE ?= ${ISODIR}/dfly.img
128 IMGMNT ?= ${ISODIR}/mnt
130 # USB umass now probes starting at da8, so the usb stick is
131 # probably sitting on da8.
135 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
136 # the additional '/nrelease' manually, as a safety measure.
140 #########################################################################
142 #########################################################################
144 release: check clean buildworld1 buildkernel1 \
145 buildiso srcs customizeiso mkiso mkimg
147 quickrel: check clean buildworld2 buildkernel2 \
148 buildiso srcs customizeiso mkiso mkimg
150 realquickrel: check clean \
151 buildiso srcs customizeiso mkiso mkimg
153 restartpkgs: check customizeiso mkiso mkimg
157 realquick: realquickrel
160 #########################################################################
161 # CORE SUPPORT TARGETS #
162 #########################################################################
165 .if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs)
167 @echo "Your machine does not have cdrtools installed. You can install it with:"
168 @echo " pkg install cdrecord"
170 .if !defined(DPORTS_PATH)
171 @echo "Please set DPORTS_PATH to the dports tree that shall be used for"
172 @echo "package building. For example /usr/dports. See the Makefile"
173 @echo "in /usr if you are unfamiliar with dports."
175 .if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs)
178 .if !defined(DPORTS_PATH)
182 buildworld1 buildworld2:
184 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
185 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
187 buildkernel1 buildkernel2:
189 for kernconf in ${KERNCONF}; do \
190 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
191 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
192 KERNCONF=$${kernconf}; \
195 # note that we do not want to mess with any /usr/obj directories not related
196 # to buildworld, buildkernel, or nrelease, so we must supply the proper
197 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
198 # buildkernel mechanism.
200 # Unconditionally clean out ${ISOROOT} so a previous img build
201 # does not blow up a future quick iso build
203 # We install with INSTALLSTRIPPEDMODULES to make things fit into the ISO.
204 # We leave the kernel's debug variables intact.
208 -chflags -R noschg ${ISOROOT}
211 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
212 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
213 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
214 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
215 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
217 for kernconf in ${KERNCONF}; do \
218 make DESTDIR=${ISOROOT} installkernel KERNCONF=$${kernconf}; \
220 rm -rf ${ISOROOT}/boot/kernel.old
221 ln -s kernel ${ISOROOT}/boot/kernel/kernel.BOOTP
222 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
223 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
224 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
226 # The GUI build includes the pkgsrc tree (~1G+) while the nominal release
229 # The GUI build includes full sources while the nominal release build
230 # only includes kernel sources (~27MB).
233 .if !defined(WITHOUT_SRCS)
235 rm -f ${ISOROOT}/usr/src-sys.tgz
236 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
237 cd ${ISOROOT}/usr && make pkgsrc-create-repo GITHOST=${GITHOST}
238 # NOTE: Adding the git gc --aggressive helps by significantly
239 # reducing the disk space required.
241 cd ${ISOROOT}/usr/pkgsrc && git gc --aggressive
242 cd ${ISOROOT}/usr && make src-create-repo GITHOST=${GITHOST}
244 rm -f ${ISOROOT}/usr/src-sys.tgz
245 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
246 cd ${.CURDIR}/.. && tar --exclude .git -s '/^\./src/' \
247 -cf - ./Makefile ./Makefile.inc1 ./sys | \
248 bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2
252 # Customize the ISO by copying rootskels in reverse priority order,
253 # building packages, and doing other post-install tasks.
256 # Copy the rootskels. Allow sources to be owned by someone other
257 # than root (as is common when checked out via git).
259 .for ROOTSKEL in ${ROOTSKELS}
260 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
261 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
262 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
264 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
265 .for UPGRADE_ITEM in Makefile \
266 etc.${MACHINE_ARCH} \
269 periodic/daily/Makefile \
270 periodic/security/Makefile \
271 periodic/weekly/Makefile \
272 periodic/monthly/Makefile
273 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
276 # Setup some things & mount dports tree. Use defensive umounts and
277 # rm -rf's to allow restarts. Allow /usr/dports to be read-only.
279 cp -p /etc/resolv.conf ${ISOROOT}/etc
280 ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
281 -@umount ${ISOROOT}/usr/distfiles
282 -@umount ${ISOROOT}/usr/dports
283 -@umount ${ISOROOT}/dev
284 rm -rf ${ISOROOT}/usr/obj/dports
286 # Mount /usr/dports, make sure /usr/distfiles is writable.
287 # Make /usr/dports read-only for safety, else a failed umount and
288 # our rm -rf will do bad things.
290 mkdir -p ${ISOROOT}/usr/dports
291 mkdir -p ${ISOROOT}/usr/distfiles
292 mount_null -o ro ${DPORTS_PATH} ${ISOROOT}/usr/dports
293 mount_null /dev ${ISOROOT}/dev
294 cp /etc/shells ${ISOROOT}/usr/distfiles/.test > /dev/null 2>&1 \
295 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/distfiles
297 # Build and install packages, skip packages already installed
299 .for PKG in ${DPORTS_PACKAGES}
300 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} ${DPORTS_OPTIONS.${PKG:S/\//_/g}} install"
302 .for PKG in ${DPORTS_PACKAGES}
303 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} clean"
306 # Remove packages which nothing depends on, add a whatis database
307 # for dports manual pages, create an initial locate database and
310 ${CHROOT_CMD} "yes | pkg autoremove"
311 ${CHROOT_CMD} "makewhatis /usr/local/man"
312 -umount ${ISOROOT}/usr/distfiles
313 umount ${ISOROOT}/usr/dports
314 rm -rf ${ISOROOT}/usr/dports
315 rm -rf ${ISOROOT}/usr/obj/dports
316 rm -rf ${ISOROOT}/usr/distfiles
317 rm -f ${ISOROOT}/etc/resolv.conf
321 ${CHROOT_CMD} "echo PACKAGESITE: http://avalon.dragonflybsd.org/dports/$$\\{ABI\\}/RELEASE >/usr/local/etc/pkg.conf"
323 # Finally, update the locate(8) database
325 ${CHROOT_CMD} /etc/periodic/weekly/310.locate
326 umount ${ISOROOT}/dev
328 # Recopy files that pkgsrc may have updated in /etc into /etc.hdd
330 cpdup ${ISOROOT}/etc/shells ${ISOROOT}/etc.hdd/shells
331 cpdup ${ISOROOT}/etc/group ${ISOROOT}/etc.hdd/group
334 ( cd ${ISOROOT}; mkisofs -b boot/cdboot -no-emul-boot \
335 -R -J -o ${ISOFILE} \
336 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
339 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
340 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
341 vnconfig -u `cat ${ISODIR}/vn.which`; fi
343 @echo "STEP: use an image size of ${IMGSIZE} 512-byte sectors"
345 sz=`bc -e "((${IMGSIZE}) * 512)" -equit`; truncate -s $${sz} ${IMGFILE}
347 @echo "STEP: Determine required image size in 1GB steps"
348 @echo " Leave ~600MB of unused space"
349 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
350 sz=`bc -e "(($${sz}) * 1.15 + 999999 + 600000) / 1000000" -equit | \
352 sz=`bc -e "(($${sz}) * 953)" -equit | cut -f1 -d.`; \
354 truncate -s $${sz}M ${IMGFILE};
356 fdisk -IB -p ${IMGFILE}
357 @echo "STEP: determine free vn device"
358 vnconfig -l | grep "not in use" | head -n 1 | \
359 cut -f 1 -d: > ${ISODIR}/vn.which
360 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
361 @echo "STEP: write standard disklabel"
362 disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto
363 @echo "STEP: read disklabel back"
364 disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label
365 @echo "STEP: determine number of sectors of whole disk"
366 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
367 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
368 @echo "STEP: write modified disklabel back"
369 disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label
371 @echo "STEP: write bootsector"
372 disklabel -B `cat ${ISODIR}/vn.which`s1
373 boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which`
374 newfs /dev/`cat ${ISODIR}/vn.which`s1a
375 mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT}
376 cpdup ${ISOROOT} ${IMGMNT}
377 @echo "STEP: fixup ${IMGMNT}/etc/fstab"
378 echo "/dev/${IMGUSBDEV}s1a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab
379 echo "dummy /tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
380 echo "dummy /var/tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
381 echo "dummy /var/run tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
382 echo "dummy /usr/obj tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
383 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab
384 @echo "STEP: fixup ${IMGMNT}/boot/loader.conf"
385 -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new
386 echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s1a"' >> ${IMGMNT}/boot/loader.conf.new
387 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
388 @echo "STEP: cleanup"
391 vnconfig -u `cat ${ISODIR}/vn.which`
392 rm -f ${ISODIR}/vn.which
397 -umount ${ISOROOT}/usr/distfiles > /dev/null 2>&1
398 -umount ${ISOROOT}/usr/dports > /dev/null 2>&1
399 -umount ${ISOROOT}/dev > /dev/null 2>&1
400 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
401 vnconfig -u `cat ${ISODIR}/vn.which`; fi
402 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
404 rm -rf ${NRLOBJDIR}/nrelease
405 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
408 rm -rf ${OBJSYS}/${KERNCONF}
409 rm -rf ${ISODIR}/packages
410 rm -rf ${ISODIR}/distfiles
413 @echo "make [gui] release - complete build from scratch"
414 @echo "make [gui] quick - attempt to do an incremental rebuild"
415 @echo "make [gui] realquick - attempt to restart after world & kernel"
416 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
418 @echo "DPORTS_EXTRA_PACKAGES may be used to add additional pkgs"
419 @echo "GITHOST may be used to override git.dragonflybsd.org"
420 @echo "IMGSIZE may be used to override the .img (in 512-byte sectors)"
422 .PHONY: release quickrel realquickrel
424 .PHONY: quick realquick
425 .PHONY: check buildworld1 buildworld2
426 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mkiso mkimg
427 .PHONY: clean realclean help all srcs
429 .include <bsd.prog.mk>