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 GITURL_SRC?= git://git.dragonflybsd.org/dragonfly.git
22 GITURL_DPORTS?= git://mirror-master.dragonflybsd.org/dports.git
23 MAKE_JOBS?= $$(sysctl -n hw.ncpu)
28 # XXX makeshift fix to build the right kernel for the (target) architecture
29 # We should configure this in the platform files somehow
30 .if ${MACHINE_ARCH} == "x86_64"
31 KERNCONF?= X86_64_GENERIC
34 GITREV!= sh ${.CURDIR}/../tools/gitrev.sh
36 # The label/name of the disklabel64(5) slice in the ".img" file. This is
37 # used to identify the USB device with DragonFly installation image, avoiding
38 # hardcoding the USB device name (e.g., "da8").
40 # This label is also used as the volume ID of the ".iso" file.
42 LABEL?= DragonFly_${GITREV}
44 CHROOT_CMD?= /usr/sbin/chroot ${ISOROOT} sh -c
46 ISOFILE?= ${ISODIR}/dfly.iso
47 IMGFILE?= ${ISODIR}/dfly.img
48 IMGMNT?= ${ISODIR}/mnt
51 # User may specify extra packages in addition to the defaults
53 DPORTS_EXTRA_PACKAGES?=
55 # dports packages to be built and installed on the release ISO
57 DPORTS_PACKAGES?= security/ca_root_nss \
60 net/isc-dhcp44-server \
62 security/wpa_supplicant \
63 ${DPORTS_EXTRA_PACKAGES}
65 # dports options to use when building packages
67 DPORTS_OPTIONS+= -DBATCH
68 DPORTS_OPTIONS+= dns_bind-tools_UNSET=PYTHON
71 # Specify which root skeletons are required, and let the user include
72 # their own. They are copied into ISODIR during the `customizeiso'
73 # target; each overwrites the last.
75 REQ_ROOTSKELS= ${.CURDIR}/root
76 ROOTSKELS?= ${REQ_ROOTSKELS}
79 ISOFILE?= ${ISODIR}/dfly-gui.iso
80 IMGFILE?= ${ISODIR}/dfly-gui.img
83 # NOTE: order important, do not sort package list
85 DPORTS_PACKAGES+= x11/xorg \
102 x11-fonts/terminus-font \
108 ROOTSKELS+= ${.CURDIR}/gui
111 #########################################################################
113 #########################################################################
115 release: check clean buildworld1 buildkernel1 \
116 buildiso srcs customizeiso mkiso mkimg
118 quickrel: check clean buildworld2 buildkernel2 \
119 buildiso srcs customizeiso mkiso mkimg
121 realquickrel: check clean \
122 buildiso srcs customizeiso mkiso mkimg
124 restartpkgs: check customizeiso mkiso mkimg
128 realquick: realquickrel
130 #########################################################################
131 # CORE SUPPORT TARGETS #
132 #########################################################################
135 .if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs)
137 @echo "Your machine does not have cdrtools installed. You can install it with:"
138 @echo " pkg install cdrtools"
140 @if [ ! -d ${DPORTS_PATH} ]; then \
141 echo "${DPORTS_PATH} does not exist."; \
143 echo "Please set DPORTS_PATH to the dports tree that shall be used for"; \
144 echo "package building. The default is /usr/dports. See the Makefile in"; \
145 echo "/usr if you are unfamiliar with dports."; \
148 .if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs)
151 @echo "Using ${DPORTS_PATH} as the dports tree."
153 buildworld1 buildworld2:
155 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
156 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
158 buildkernel1 buildkernel2:
160 for kernconf in ${KERNCONF}; do \
161 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
162 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
163 KERNCONF=$${kernconf}; \
166 # Unconditionally clean out ${ISOROOT} so a previous img build
167 # does not blow up a future quick iso build
169 # We install with INSTALLSTRIPPEDMODULES to make things fit into the ISO.
170 # We leave the kernel's debug variables intact.
173 -chflags -R noschg ${ISOROOT}
176 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
177 # Do not mess with any /usr/obj directories not related to
178 # buildworld, buildkernel, or nrelease.
179 ( cd ${.CURDIR}/../etc && \
180 tmpdir=`mktemp -d -t nrelease` && \
181 MAKEOBJDIRPREFIX=$${tmpdir} \
182 make -m ${.CURDIR}/../share/mk \
183 DESTDIR=${ISOROOT} distribution && \
185 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
186 ( cd ${.CURDIR}/..; \
187 for kernconf in ${KERNCONF}; do \
188 make DESTDIR=${ISOROOT} reinstallkernel KERNCONF=$${kernconf}; \
190 rm -rf ${ISOROOT}/boot/kernel.old
191 ln -sf kernel ${ISOROOT}/boot/kernel/kernel.BOOTP
192 mtree ${MTREE_FSCHG} -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist \
194 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
196 # The GUI build includes the ports tree (~1G+) while the nominal release
199 # The GUI build includes full sources while the nominal release build
200 # only includes kernel sources (~27MB).
203 .if !defined(WITHOUT_SRCS)
205 rm -f ${ISOROOT}/usr/src-sys.tgz
206 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
207 .if !empty(DPORTS_PACKAGES)
208 cd ${ISOROOT}/usr && make dports-create GITURL_DPORTS=${GITURL_DPORTS}
209 # NOTE: Adding the git gc --aggressive helps by significantly
210 # reducing the disk space required.
212 cd ${ISOROOT}/usr/dports && git gc --aggressive
214 cd ${ISOROOT}/usr && make src-create GITURL_SRC=${GITURL_SRC}
215 # XXX: git gc --aggressive
217 rm -f ${ISOROOT}/usr/src-sys.tgz
218 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
219 cd ${.CURDIR}/.. && tar --exclude .git -s '/^\./src/' \
220 -cf - ./Makefile ./Makefile.inc1 ./sys | \
221 bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2
225 # Customize the ISO by copying rootskels in reverse priority order,
226 # building packages, and doing other post-install tasks.
229 # Copy the rootskels. Allow sources to be owned by someone other
230 # than root (as is common when checked out via git).
232 .for ROOTSKEL in ${ROOTSKELS}
233 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
234 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
235 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
237 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
238 .for UPGRADE_ITEM in Makefile \
239 etc.${MACHINE_ARCH} \
242 periodic/daily/Makefile \
243 periodic/security/Makefile \
244 periodic/weekly/Makefile \
245 periodic/monthly/Makefile
246 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
249 # Setup some things & mount dports tree. Use defensive umounts and
250 # rm -rf's to allow restarts. Allow /usr/dports to be read-only.
252 -@umount ${ISOROOT}/dev
253 mount_null /dev ${ISOROOT}/dev
254 .if !empty(DPORTS_PACKAGES)
255 cp /etc/resolv.conf ${ISOROOT}/etc
256 ${CHROOT_CMD} "ldconfig -elf /lib /usr/lib /usr/lib/gcc*"
257 -@umount ${ISOROOT}/usr/distfiles
258 -@umount ${ISOROOT}/usr/dports
259 rm -rf ${ISOROOT}/usr/obj/dports
261 # Mount /usr/dports, make sure /usr/distfiles is writable.
262 # Make /usr/dports read-only for safety, else a failed umount and
263 # our rm -rf will do bad things.
265 mkdir -p ${ISOROOT}/usr/dports
266 mkdir -p ${ISOROOT}/usr/distfiles
267 mount_null -o ro ${DPORTS_PATH} ${ISOROOT}/usr/dports
268 cp /etc/shells ${ISOROOT}/usr/distfiles/.test > /dev/null 2>&1 \
269 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/distfiles
271 # Build and install packages, skip packages already installed
273 .for PKG in ${DPORTS_PACKAGES}
274 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} install"
276 .for PKG in ${DPORTS_PACKAGES}
277 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} clean"
280 # Remove packages which nothing depends on, add a whatis database
281 # for dports manual pages, create an initial locate database and
284 ${CHROOT_CMD} "yes | pkg autoremove"
285 ${CHROOT_CMD} "makewhatis /usr/local/man"
286 -umount ${ISOROOT}/usr/distfiles
287 umount ${ISOROOT}/usr/dports
288 rm -rf ${ISOROOT}/usr/dports
289 rm -rf ${ISOROOT}/usr/obj/dports
290 rm -rf ${ISOROOT}/usr/distfiles
291 rm -f ${ISOROOT}/etc/resolv.conf
294 # Finally, update the locate(8) database, allow ISODIR
295 # to be on tmpfs (fails to create locate database then)
297 -${CHROOT_CMD} /etc/periodic/weekly/310.locate
298 umount ${ISOROOT}/dev
300 # Recopy files that dports may have updated in /etc into /etc.hdd
302 cpdup ${ISOROOT}/etc/shells ${ISOROOT}/etc.hdd/shells
303 cpdup ${ISOROOT}/etc/group ${ISOROOT}/etc.hdd/group
306 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
307 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
308 vnconfig -u `cat ${ISODIR}/vn.which`; fi
309 newfs_msdos -C 400k -F 12 -L EFI -m 0xf8 ${ISOROOT}/boot/efiboot.img
310 vnconfig -l | grep "not in use" | head -n 1 | \
311 cut -f 1 -d: > ${ISODIR}/vn.which
312 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${ISOROOT}/boot/efiboot.img
313 mount_msdos /dev/`cat ${ISODIR}/vn.which` ${IMGMNT}
314 mkdir -p ${IMGMNT}/EFI/BOOT
315 cp ${ISOROOT}/boot/loader.efi ${IMGMNT}/EFI/BOOT/BOOTX64.EFI
317 ( cd ${ISOROOT}; mkisofs -R -J -o ${ISOFILE} \
318 -b boot/cdboot -no-emul-boot \
319 -eltorito-alt-boot -eltorito-platform efi \
320 -eltorito-boot boot/efiboot.img -no-emul-boot \
321 -V ${LABEL:C/(^.{32}).*/\1/} . ) # cut label to <= 32 characters
322 rm -f ${ISOROOT}/boot/efiboot.img
325 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
326 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
327 vnconfig -u `cat ${ISODIR}/vn.which`; fi
329 @echo "STEP: use an image size of ${IMGSIZE} 512-byte sectors"
331 sz=`bc -e "((${IMGSIZE}) * 512)" -equit`; truncate -s $${sz} ${IMGFILE}
333 @echo "STEP: Determine required image size in 1GB steps"
334 @echo " Leave ~600MB of unused space"
335 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
336 sz=`bc -e "(($${sz}) * 1.15 + 999999 + 600000) / 1000000" -equit | \
338 sz=`bc -e "(($${sz}) * 953)" -equit | cut -f1 -d.`; \
340 truncate -s $${sz}M ${IMGFILE};
342 @echo "STEP: determine free vn device"
343 vnconfig -l | grep "not in use" | head -n 1 | \
344 cut -f 1 -d: > ${ISODIR}/vn.which
345 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
346 @echo "STEP: set up legacy MBR"
347 fdisk -b ${ISOROOT}/boot/mbr -IB `cat ${ISODIR}/vn.which`
348 fdisk -s `cat ${ISODIR}/vn.which` >${ISODIR}/fdisk.dat
349 awk '(NR==1){printf("g c%s h%s s%s\n", $$2, $$4, $$6);}' \
350 ${ISODIR}/fdisk.dat >${ISODIR}/fdisk.conf
351 echo "p 1 239 63 257985" >>${ISODIR}/fdisk.conf
352 awk '($$1=="1:"){printf("p 2 165 258048 %lu\n", $$3 - 258528);}' \
353 ${ISODIR}/fdisk.dat >>${ISODIR}/fdisk.conf
354 echo "a 2" >>${ISODIR}/fdisk.conf
355 fdisk -iv -f ${ISODIR}/fdisk.conf `cat ${ISODIR}/vn.which`
356 rm ${ISODIR}/fdisk.conf ${ISODIR}/fdisk.dat
357 newfs_msdos -F 32 -c 2 -L EFI -m 0xf8 `cat ${ISODIR}/vn.which`s1
358 mount_msdos /dev/`cat ${ISODIR}/vn.which`s1 ${IMGMNT}
359 mkdir -p ${IMGMNT}/EFI/BOOT
360 cp ${ISOROOT}/boot/boot1.efi ${IMGMNT}/EFI/BOOT/BOOTX64.EFI
362 @echo "STEP: write standard disklabel"
363 disklabel -w -r `cat ${ISODIR}/vn.which`s2 auto
364 @echo "STEP: read disklabel back"
365 disklabel -r `cat ${ISODIR}/vn.which`s2 > ${IMGFILE}.label
366 @echo "STEP: set disklabel name"
367 echo "label: ${LABEL}" >> ${IMGFILE}.label
368 @echo "STEP: add slice parition"
369 echo "a: * * 4.2BSD" >> ${IMGFILE}.label;
370 @echo "STEP: write modified disklabel back"
371 disklabel -R -r `cat ${ISODIR}/vn.which`s2 ${IMGFILE}.label
373 disklabel -B -b ${ISOROOT}/boot/boot1_64 -s ${ISOROOT}/boot/boot2_64 \
374 `cat ${ISODIR}/vn.which`s2
375 newfs /dev/`cat ${ISODIR}/vn.which`s2a
376 mount /dev/`cat ${ISODIR}/vn.which`s2a ${IMGMNT}
377 cpdup ${ISOROOT} ${IMGMNT}
378 @echo "STEP: fixup ${IMGMNT}/etc/fstab"
379 echo "/dev/part-by-label/${LABEL}.a / 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,-C 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:part-by-label/${LABEL}.a"' >> ${IMGMNT}/boot/loader.conf.new
388 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
389 @echo "STEP: cleanup"
394 vnconfig -u `cat ${ISODIR}/vn.which`
395 rm -f ${ISODIR}/vn.which
397 @echo "STEP: done, image files are in ${ISODIR}"
402 -umount ${ISOROOT}/usr/distfiles > /dev/null 2>&1
403 -umount ${ISOROOT}/usr/dports > /dev/null 2>&1
404 -umount ${ISOROOT}/dev > /dev/null 2>&1
405 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
406 vnconfig -u `cat ${ISODIR}/vn.which`; fi
407 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
409 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
412 rm -rf ${OBJSYS}/${KERNCONF}
413 rm -rf ${ISODIR}/packages
414 rm -rf ${ISODIR}/distfiles
418 @echo " release - full build from scratch"
419 @echo " quick - attempt to do an incremental rebuild"
420 @echo " realquick - attempt to restart after world & kernel"
421 @echo " restartpkgs - attempt to restart at the pkg building stage"
422 @echo "NOTE: Add the optional 'gui' target to do a GUI release"
425 @echo " DPORTS_EXTRA_PACKAGES: add additional packages"
426 @echo " GITURL_SRC: override the Git URL to source repository"
427 @echo " GITURL_DPORTS: override the Git URL to dports repository"
428 @echo " IMGSIZE: override the size of .img (in 512-byte sectors)"
429 @echo " MAKE_JOBS: override the default value (sysctl hw.ncpu)"
431 .PHONY: release quickrel realquickrel
433 .PHONY: quick realquick
434 .PHONY: check buildworld1 buildworld2
435 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mkiso mkimg
436 .PHONY: clean realclean help all srcs
438 .include <bsd.prog.mk>