1 #########################################################################
3 #########################################################################
5 # New method e.g. 'make gui release'. A series of enhancement
6 # targets 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
18 ISODIR?= /usr/obj/release
19 ISOROOT?= ${ISODIR}/root
20 OBJSYS= ${.OBJDIR}/../sys
21 GITHOST?= git.dragonflybsd.org
22 GITHOST_DPORTS?=mirror-master.dragonflybsd.org
24 MAKE_JOBS?= $$(sysctl -n hw.ncpu)
26 # XXX makeshift fix to build the right kernel for the (target) architecture
27 # We should configure this in the platform files somehow
28 .if ${MACHINE_ARCH} == "x86_64"
29 KERNCONF ?= X86_64_GENERIC
32 CHROOT_CMD?= /usr/sbin/chroot ${ISOROOT} sh -c
35 # User may specify extra packages in addition to the defaults
37 DPORTS_EXTRA_PACKAGES?=
39 # dports packages to be built and installed on the release ISO
43 DPORTS_PACKAGES?= devel/git \
45 net/isc-dhcp43-server \
47 ${DPORTS_EXTRA_PACKAGES}
49 # dports options to use when building packages
51 DPORTS_OPTIONS+= -DBATCH
53 DPORTS_OPTIONS.devel_git+= -DWITH_GUI
55 DPORTS_OPTIONS.devel_git+= -DWITHOUT_CONTRIB -DWITHOUT_PERL
59 # Specify which root skeletons are required, and let the user include
60 # their own. They are copied into ISODIR during the `customizeiso'
61 # target; each overwrites the last.
63 REQ_ROOTSKELS= ${.CURDIR}/root
64 ROOTSKELS?= ${REQ_ROOTSKELS}
67 # LIST OF PACKAGES NOT INCLUDED DUE TO BUILD ISSUES:
68 # chat/pidgin textproc/enchant dependency is broken
69 # x11/rxvt-unicode broken configure
70 # net/nmap tries to access openssl/md2.h which does not
72 # sysutils/idesk dying on link __sync_fetch_and_add_4
74 ISOFILE?= ${ISODIR}/dfly-gui.iso
75 IMGFILE?= ${ISODIR}/dfly-gui.img
77 # NOTE: order important, do not sort package list
80 DPORTS_PACKAGES+= x11/xorg \
97 x11-fonts/terminus-font \
103 ROOTSKELS+= ${.CURDIR}/gui
106 ISOFILE ?= ${ISODIR}/dfly.iso
107 IMGFILE ?= ${ISODIR}/dfly.img
109 IMGMNT ?= ${ISODIR}/mnt
111 # USB umass now probes starting at da8, so the usb stick is
112 # probably sitting on da8.
116 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
117 # the additional '/nrelease' manually, as a safety measure.
121 #########################################################################
123 #########################################################################
125 release: check clean buildworld1 buildkernel1 \
126 buildiso srcs customizeiso mkiso mkimg
128 quickrel: check clean buildworld2 buildkernel2 \
129 buildiso srcs customizeiso mkiso mkimg
131 realquickrel: check clean \
132 buildiso srcs customizeiso mkiso mkimg
134 restartpkgs: check customizeiso mkiso mkimg
138 realquick: realquickrel
140 #########################################################################
141 # CORE SUPPORT TARGETS #
142 #########################################################################
145 .if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs)
147 @echo "Your machine does not have cdrtools installed. You can install it with:"
148 @echo " pkg install cdrtools"
150 @if [ ! -d ${DPORTS_PATH} ]; then \
151 echo "${DPORTS_PATH} does not exist."; \
153 echo "Please set DPORTS_PATH to the dports tree that shall be used for"; \
154 echo "package building. The default is /usr/dports. See the Makefile in"; \
155 echo "/usr if you are unfamiliar with dports."; \
158 .if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs)
161 @echo "Using ${DPORTS_PATH} as the dports tree."
163 buildworld1 buildworld2:
165 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
166 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
168 buildkernel1 buildkernel2:
170 for kernconf in ${KERNCONF}; do \
171 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
172 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
173 KERNCONF=$${kernconf}; \
176 # note that we do not want to mess with any /usr/obj directories not related
177 # to buildworld, buildkernel, or nrelease, so we must supply the proper
178 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
179 # buildkernel mechanism.
181 # Unconditionally clean out ${ISOROOT} so a previous img build
182 # does not blow up a future quick iso build
184 # We install with INSTALLSTRIPPEDMODULES to make things fit into the ISO.
185 # We leave the kernel's debug variables intact.
188 -chflags -R noschg ${ISOROOT}
191 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
192 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
193 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
194 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
195 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
197 for kernconf in ${KERNCONF}; do \
198 make DESTDIR=${ISOROOT} reinstallkernel KERNCONF=$${kernconf}; \
200 rm -rf ${ISOROOT}/boot/kernel.old
201 ln -sf kernel ${ISOROOT}/boot/kernel/kernel.BOOTP
202 ( cd ${.CURDIR}/..; make DESTDIR=${ISOROOT} initrd )
203 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
204 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
206 # The GUI build includes the ports tree (~1G+) while the nominal release
209 # The GUI build includes full sources while the nominal release build
210 # only includes kernel sources (~27MB).
213 .if !defined(WITHOUT_SRCS)
215 rm -f ${ISOROOT}/usr/src-sys.tgz
216 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
217 .if !empty(DPORTS_PACKAGES)
218 cd ${ISOROOT}/usr && make dports-create GITHOST_DPORTS=${GITHOST_DPORTS}
219 # NOTE: Adding the git gc --aggressive helps by significantly
220 # reducing the disk space required.
222 cd ${ISOROOT}/usr/dports && git gc --aggressive
224 cd ${ISOROOT}/usr && make src-create-repo GITHOST=${GITHOST}
225 # XXX: git gc --aggressive
227 rm -f ${ISOROOT}/usr/src-sys.tgz
228 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
229 cd ${.CURDIR}/.. && tar --exclude .git -s '/^\./src/' \
230 -cf - ./Makefile ./Makefile.inc1 \
231 ./crypto/libressl/include ./sys | \
232 bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2
236 # Customize the ISO by copying rootskels in reverse priority order,
237 # building packages, and doing other post-install tasks.
240 # Copy the rootskels. Allow sources to be owned by someone other
241 # than root (as is common when checked out via git).
243 .for ROOTSKEL in ${ROOTSKELS}
244 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
245 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
246 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
248 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
249 .for UPGRADE_ITEM in Makefile \
250 etc.${MACHINE_ARCH} \
253 periodic/daily/Makefile \
254 periodic/security/Makefile \
255 periodic/weekly/Makefile \
256 periodic/monthly/Makefile
257 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
260 # Setup some things & mount dports tree. Use defensive umounts and
261 # rm -rf's to allow restarts. Allow /usr/dports to be read-only.
263 -@umount ${ISOROOT}/dev
264 mount_null /dev ${ISOROOT}/dev
265 .if !empty(DPORTS_PACKAGES)
266 cp /etc/resolv.conf ${ISOROOT}/etc
267 ${CHROOT_CMD} "ldconfig -elf /lib /usr/lib /usr/lib/gcc*"
268 -@umount ${ISOROOT}/usr/distfiles
269 -@umount ${ISOROOT}/usr/dports
270 rm -rf ${ISOROOT}/usr/obj/dports
272 # Mount /usr/dports, make sure /usr/distfiles is writable.
273 # Make /usr/dports read-only for safety, else a failed umount and
274 # our rm -rf will do bad things.
276 mkdir -p ${ISOROOT}/usr/dports
277 mkdir -p ${ISOROOT}/usr/distfiles
278 mount_null -o ro ${DPORTS_PATH} ${ISOROOT}/usr/dports
279 cp /etc/shells ${ISOROOT}/usr/distfiles/.test > /dev/null 2>&1 \
280 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/distfiles
282 # Build and install packages, skip packages already installed
284 .for PKG in ${DPORTS_PACKAGES}
285 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} ${DPORTS_OPTIONS.${PKG:S/\//_/g}} install"
287 .for PKG in ${DPORTS_PACKAGES}
288 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} clean"
291 # Remove packages which nothing depends on, add a whatis database
292 # for dports manual pages, create an initial locate database and
295 ${CHROOT_CMD} "yes | pkg autoremove"
296 ${CHROOT_CMD} "makewhatis /usr/local/man"
297 -umount ${ISOROOT}/usr/distfiles
298 umount ${ISOROOT}/usr/dports
299 rm -rf ${ISOROOT}/usr/dports
300 rm -rf ${ISOROOT}/usr/obj/dports
301 rm -rf ${ISOROOT}/usr/distfiles
302 rm -f ${ISOROOT}/etc/resolv.conf
305 # Finally, update the locate(8) database, allow ISODIR
306 # to be on tmpfs (fails to create locate database then)
308 -${CHROOT_CMD} /etc/periodic/weekly/310.locate
309 umount ${ISOROOT}/dev
311 # Recopy files that dports may have updated in /etc into /etc.hdd
313 cpdup ${ISOROOT}/etc/shells ${ISOROOT}/etc.hdd/shells
314 cpdup ${ISOROOT}/etc/group ${ISOROOT}/etc.hdd/group
317 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
318 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
319 vnconfig -u `cat ${ISODIR}/vn.which`; fi
320 newfs_msdos -C 400k -F 12 -L EFI -m 0xf8 ${ISOROOT}/boot/efiboot.img
321 vnconfig -l | grep "not in use" | head -n 1 | \
322 cut -f 1 -d: > ${ISODIR}/vn.which
323 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${ISOROOT}/boot/efiboot.img
324 mount_msdos /dev/`cat ${ISODIR}/vn.which` ${IMGMNT}
325 mkdir -p ${IMGMNT}/EFI/BOOT
326 cp ${ISOROOT}/boot/loader.efi ${IMGMNT}/EFI/BOOT/BOOTX64.EFI
328 ( cd ${ISOROOT}; mkisofs -R -J -o ${ISOFILE} \
329 -b boot/cdboot -no-emul-boot \
330 -eltorito-alt-boot -eltorito-platform efi -eltorito-boot boot/efiboot.img -no-emul-boot \
331 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
332 rm -f ${ISOROOT}/boot/efiboot.img
335 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
336 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
337 vnconfig -u `cat ${ISODIR}/vn.which`; fi
339 @echo "STEP: use an image size of ${IMGSIZE} 512-byte sectors"
341 sz=`bc -e "((${IMGSIZE}) * 512)" -equit`; truncate -s $${sz} ${IMGFILE}
343 @echo "STEP: Determine required image size in 1GB steps"
344 @echo " Leave ~600MB of unused space"
345 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
346 sz=`bc -e "(($${sz}) * 1.15 + 999999 + 600000) / 1000000" -equit | \
348 sz=`bc -e "(($${sz}) * 953)" -equit | cut -f1 -d.`; \
350 truncate -s $${sz}M ${IMGFILE};
352 @echo "STEP: determine free vn device"
353 vnconfig -l | grep "not in use" | head -n 1 | \
354 cut -f 1 -d: > ${ISODIR}/vn.which
355 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
356 @echo "STEP: set up legacy MBR"
357 fdisk -IB `cat ${ISODIR}/vn.which`
358 fdisk -s `cat ${ISODIR}/vn.which` >${ISODIR}/fdisk.dat
359 awk '(NR==1){printf("g c%s h%s s%s\n", $$2, $$4, $$6);}' \
360 ${ISODIR}/fdisk.dat >${ISODIR}/fdisk.conf
361 echo "p 1 239 63 257985" >>${ISODIR}/fdisk.conf
362 awk '($$1=="1:"){printf("p 2 165 258048 %lu\n", $$3 - 258528);}' \
363 ${ISODIR}/fdisk.dat >>${ISODIR}/fdisk.conf
364 echo "a 2" >>${ISODIR}/fdisk.conf
365 fdisk -iv -f ${ISODIR}/fdisk.conf `cat ${ISODIR}/vn.which`
366 rm ${ISODIR}/fdisk.conf ${ISODIR}/fdisk.dat
367 newfs_msdos -F 32 -c 2 -L EFI -m 0xf8 `cat ${ISODIR}/vn.which`s1
368 mount_msdos /dev/`cat ${ISODIR}/vn.which`s1 ${IMGMNT}
369 mkdir -p ${IMGMNT}/EFI/BOOT
370 cp ${ISOROOT}/boot/boot1.efi ${IMGMNT}/EFI/BOOT/BOOTX64.EFI
372 @echo "STEP: write standard disklabel"
373 disklabel -w -r `cat ${ISODIR}/vn.which`s2 auto
374 @echo "STEP: read disklabel back"
375 disklabel -r `cat ${ISODIR}/vn.which`s2 > ${IMGFILE}.label
376 @echo "STEP: determine number of sectors of whole disk"
377 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
378 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
379 @echo "STEP: write modified disklabel back"
380 disklabel -R -r `cat ${ISODIR}/vn.which`s2 ${IMGFILE}.label
382 disklabel -B `cat ${ISODIR}/vn.which`s2
383 newfs /dev/`cat ${ISODIR}/vn.which`s2a
384 mount /dev/`cat ${ISODIR}/vn.which`s2a ${IMGMNT}
385 cpdup ${ISOROOT} ${IMGMNT}
386 @echo "STEP: fixup ${IMGMNT}/etc/fstab"
387 echo "/dev/${IMGUSBDEV}s2a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab
388 echo "dummy /tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
389 echo "dummy /var/tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
390 echo "dummy /var/run tmpfs rw,-C 0 0" >> ${IMGMNT}/etc/fstab
391 echo "dummy /usr/obj tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
392 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab
393 @echo "STEP: fixup ${IMGMNT}/boot/loader.conf"
394 -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new
395 echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s2a"' >> ${IMGMNT}/boot/loader.conf.new
396 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
397 @echo "STEP: cleanup"
402 vnconfig -u `cat ${ISODIR}/vn.which`
403 rm -f ${ISODIR}/vn.which
410 -umount ${ISOROOT}/usr/distfiles > /dev/null 2>&1
411 -umount ${ISOROOT}/usr/dports > /dev/null 2>&1
412 -umount ${ISOROOT}/dev > /dev/null 2>&1
413 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
414 vnconfig -u `cat ${ISODIR}/vn.which`; fi
415 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
417 rm -rf ${NRLOBJDIR}/nrelease
418 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
421 rm -rf ${OBJSYS}/${KERNCONF}
422 rm -rf ${ISODIR}/packages
423 rm -rf ${ISODIR}/distfiles
426 @echo "make [gui] release - complete build from scratch"
427 @echo "make [gui] quick - attempt to do an incremental rebuild"
428 @echo "make [gui] realquick - attempt to restart after world & kernel"
429 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
431 @echo "DPORTS_EXTRA_PACKAGES may be used to add additional pkgs"
432 @echo "GITHOST may be used to override git.dragonflybsd.org"
433 @echo "GITHOST_DPORTS may be used to override mirror-master.dragonflybsd.org"
434 @echo "IMGSIZE may be used to override the .img (in 512-byte sectors)"
435 @echo "MAKE_JOBS may be used to override the default value (sysctl hw.ncpu)"
437 .PHONY: release quickrel realquickrel
439 .PHONY: quick realquick
440 .PHONY: check buildworld1 buildworld2
441 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mkiso mkimg
442 .PHONY: clean realclean help all srcs
444 .include <bsd.prog.mk>