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 # XXX makeshift fix to build the right kernel for the (target) architecture
26 # We should configure this in the platform files somehow
27 .if ${MACHINE_ARCH} == "i386"
30 KERNCONF ?= X86_64_GENERIC
33 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-dhcp42-client \
46 net/isc-dhcp42-server \
48 ${DPORTS_EXTRA_PACKAGES}
50 # dports options to use when building packages
52 DPORTS_OPTIONS+= -DBATCH
54 DPORTS_OPTIONS.devel_git+= -DWITHOUT_CONTRIB -DWITHOUT_PERL
57 # Specify which root skeletons are required, and let the user include
58 # their own. They are copied into ISODIR during the `customizeiso'
59 # target; each overwrites the last.
61 REQ_ROOTSKELS= ${.CURDIR}/root
62 ROOTSKELS?= ${REQ_ROOTSKELS}
65 # LIST OF PACKAGES NOT INCLUDED DUE TO BUILD ISSUES:
66 # chat/pidgin textproc/enchant dependency is broken
67 # x11/rxvt-unicode broken configure
68 # net/nmap tries to access openssl/md2.h which does not
70 # sysutils/idesk dying on link __sync_fetch_and_add_4
72 ISOFILE?= ${ISODIR}/dfly-gui.iso
73 IMGFILE?= ${ISODIR}/dfly-gui.img
75 # NOTE: order important, do not sort package list
77 # Apps we want in the gui build but which have problems building:
78 # chat/xchat link error on x86-64, something about ___progname
82 PKGSRC_PACKAGES+= meta-pkgs/modular-xorg-libs \
83 meta-pkgs/modular-xorg-fonts \
84 meta-pkgs/modular-xorg-apps \
85 meta-pkgs/modular-xorg-drivers \
95 x11/modular-xorg-server \
105 fonts/terminus-font \
112 ROOTSKELS+= ${.CURDIR}/gui
115 ISOFILE ?= ${ISODIR}/dfly.iso
116 IMGFILE ?= ${ISODIR}/dfly.img
118 IMGMNT ?= ${ISODIR}/mnt
120 # USB umass now probes starting at da8, so the usb stick is
121 # probably sitting on da8.
125 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
126 # the additional '/nrelease' manually, as a safety measure.
130 #########################################################################
132 #########################################################################
134 release: check clean buildworld1 buildkernel1 \
135 buildiso srcs customizeiso mkiso mkimg
137 quickrel: check clean buildworld2 buildkernel2 \
138 buildiso srcs customizeiso mkiso mkimg
140 realquickrel: check clean \
141 buildiso srcs customizeiso mkiso mkimg
143 restartpkgs: check customizeiso mkiso mkimg
147 realquick: realquickrel
150 #########################################################################
151 # CORE SUPPORT TARGETS #
152 #########################################################################
155 .if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs)
157 @echo "Your machine does not have cdrtools installed. You can install it with:"
158 @echo " pkg install cdrecord"
160 .if !defined(DPORTS_PATH)
161 @echo "Please set DPORTS_PATH to the dports tree that shall be used for"
162 @echo "package building. For example /usr/dports. See the Makefile"
163 @echo "in /usr if you are unfamiliar with dports."
165 .if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs)
168 .if !defined(DPORTS_PATH)
172 buildworld1 buildworld2:
174 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
175 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
177 buildkernel1 buildkernel2:
179 for kernconf in ${KERNCONF}; do \
180 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
181 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
182 KERNCONF=$${kernconf}; \
185 # note that we do not want to mess with any /usr/obj directories not related
186 # to buildworld, buildkernel, or nrelease, so we must supply the proper
187 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
188 # buildkernel mechanism.
190 # Unconditionally clean out ${ISOROOT} so a previous img build
191 # does not blow up a future quick iso build
193 # We install with INSTALLSTRIPPEDMODULES to make things fit into the ISO.
194 # We leave the kernel's debug variables intact.
198 -chflags -R noschg ${ISOROOT}
201 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
202 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
203 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
204 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
205 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
207 for kernconf in ${KERNCONF}; do \
208 make DESTDIR=${ISOROOT} installkernel KERNCONF=$${kernconf}; \
210 rm -rf ${ISOROOT}/boot/kernel.old
211 ln -s kernel ${ISOROOT}/boot/kernel/kernel.BOOTP
212 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
213 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
214 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
216 # The GUI build includes the pkgsrc tree (~1G+) while the nominal release
219 # The GUI build includes full sources while the nominal release build
220 # only includes kernel sources (~27MB).
223 .if !defined(WITHOUT_SRCS)
225 rm -f ${ISOROOT}/usr/src-sys.tgz
226 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
227 cd ${ISOROOT}/usr && make pkgsrc-create-repo GITHOST=${GITHOST}
228 # NOTE: Adding the git gc --aggressive helps by significantly
229 # reducing the disk space required.
231 cd ${ISOROOT}/usr/pkgsrc && git gc --aggressive
232 cd ${ISOROOT}/usr && make src-create-repo GITHOST=${GITHOST}
234 rm -f ${ISOROOT}/usr/src-sys.tgz
235 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
236 cd ${.CURDIR}/.. && tar --exclude .git -s '/^\./src/' \
237 -cf - ./Makefile ./Makefile.inc1 ./sys | \
238 bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2
242 # Customize the ISO by copying rootskels in reverse priority order,
243 # building packages, and doing other post-install tasks.
246 # Copy the rootskels. Allow sources to be owned by someone other
247 # than root (as is common when checked out via git).
249 .for ROOTSKEL in ${ROOTSKELS}
250 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
251 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
252 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
254 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
255 .for UPGRADE_ITEM in Makefile \
256 etc.${MACHINE_ARCH} \
259 periodic/daily/Makefile \
260 periodic/security/Makefile \
261 periodic/weekly/Makefile \
262 periodic/monthly/Makefile
263 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
266 # Setup some things & mount dports tree. Use defensive umounts and
267 # rm -rf's to allow restarts. Allow /usr/dports to be read-only.
269 cp -p /etc/resolv.conf ${ISOROOT}/etc
270 ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
271 -@umount ${ISOROOT}/usr/distfiles
272 -@umount ${ISOROOT}/usr/dports
273 -@umount ${ISOROOT}/dev
274 rm -rf ${ISOROOT}/usr/obj/dports
276 # Mount /usr/dports, make sure /usr/distfiles is writable.
277 # Make /usr/dports read-only for safety, else a failed umount and
278 # our rm -rf will do bad things.
280 mkdir -p ${ISOROOT}/usr/dports
281 mkdir -p ${ISOROOT}/usr/distfiles
282 mount_null -o ro ${DPORTS_PATH} ${ISOROOT}/usr/dports
283 mount_null /dev ${ISOROOT}/dev
284 cp /etc/shells ${ISOROOT}/usr/distfiles/.test > /dev/null 2>&1 \
285 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/distfiles
287 # Build and install packages, skip packages already installed
289 .for PKG in ${DPORTS_PACKAGES}
290 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} ${DPORTS_OPTIONS.${PKG:S/\//_/g}} install"
292 .for PKG in ${DPORTS_PACKAGES}
293 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} clean"
296 # Remove packages which nothing depends on, add a whatis database
297 # for dports manual pages, create an initial locate database and
300 ${CHROOT_CMD} "yes | pkg autoremove"
301 ${CHROOT_CMD} "makewhatis /usr/local/man"
302 -umount ${ISOROOT}/usr/distfiles
303 umount ${ISOROOT}/usr/dports
304 rm -rf ${ISOROOT}/usr/dports
305 rm -rf ${ISOROOT}/usr/obj/dports
306 rm -rf ${ISOROOT}/usr/distfiles
307 rm -f ${ISOROOT}/etc/resolv.conf
311 cp -p ${ISOROOT}/usr/local/etc/pkg.conf.sample ${ISOROOT}/usr/local/etc/pkg.conf
313 # Finally, update the locate(8) database
315 ${CHROOT_CMD} /etc/periodic/weekly/310.locate
316 umount ${ISOROOT}/dev
318 # Recopy files that dports may have updated in /etc into /etc.hdd
320 cpdup ${ISOROOT}/etc/shells ${ISOROOT}/etc.hdd/shells
321 cpdup ${ISOROOT}/etc/group ${ISOROOT}/etc.hdd/group
324 ( cd ${ISOROOT}; mkisofs -b boot/cdboot -no-emul-boot \
325 -R -J -o ${ISOFILE} \
326 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
329 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
330 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
331 vnconfig -u `cat ${ISODIR}/vn.which`; fi
333 @echo "STEP: use an image size of ${IMGSIZE} 512-byte sectors"
335 sz=`bc -e "((${IMGSIZE}) * 512)" -equit`; truncate -s $${sz} ${IMGFILE}
337 @echo "STEP: Determine required image size in 1GB steps"
338 @echo " Leave ~600MB of unused space"
339 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
340 sz=`bc -e "(($${sz}) * 1.15 + 999999 + 600000) / 1000000" -equit | \
342 sz=`bc -e "(($${sz}) * 953)" -equit | cut -f1 -d.`; \
344 truncate -s $${sz}M ${IMGFILE};
346 fdisk -IB -p ${IMGFILE}
347 @echo "STEP: determine free vn device"
348 vnconfig -l | grep "not in use" | head -n 1 | \
349 cut -f 1 -d: > ${ISODIR}/vn.which
350 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
351 @echo "STEP: write standard disklabel"
352 disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto
353 @echo "STEP: read disklabel back"
354 disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label
355 @echo "STEP: determine number of sectors of whole disk"
356 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
357 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
358 @echo "STEP: write modified disklabel back"
359 disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label
361 @echo "STEP: write bootsector"
362 disklabel -B `cat ${ISODIR}/vn.which`s1
363 boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which`
364 newfs /dev/`cat ${ISODIR}/vn.which`s1a
365 mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT}
366 cpdup ${ISOROOT} ${IMGMNT}
367 @echo "STEP: fixup ${IMGMNT}/etc/fstab"
368 echo "/dev/${IMGUSBDEV}s1a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab
369 echo "dummy /tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
370 echo "dummy /var/tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
371 echo "dummy /var/run tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
372 echo "dummy /usr/obj tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab
373 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab
374 @echo "STEP: fixup ${IMGMNT}/boot/loader.conf"
375 -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new
376 echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s1a"' >> ${IMGMNT}/boot/loader.conf.new
377 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
378 @echo "STEP: cleanup"
383 vnconfig -u `cat ${ISODIR}/vn.which`
384 rm -f ${ISODIR}/vn.which
391 -umount ${ISOROOT}/usr/distfiles > /dev/null 2>&1
392 -umount ${ISOROOT}/usr/dports > /dev/null 2>&1
393 -umount ${ISOROOT}/dev > /dev/null 2>&1
394 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
395 vnconfig -u `cat ${ISODIR}/vn.which`; fi
396 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
398 rm -rf ${NRLOBJDIR}/nrelease
399 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
402 rm -rf ${OBJSYS}/${KERNCONF}
403 rm -rf ${ISODIR}/packages
404 rm -rf ${ISODIR}/distfiles
407 @echo "make [gui] release - complete build from scratch"
408 @echo "make [gui] quick - attempt to do an incremental rebuild"
409 @echo "make [gui] realquick - attempt to restart after world & kernel"
410 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
412 @echo "DPORTS_EXTRA_PACKAGES may be used to add additional pkgs"
413 @echo "GITHOST may be used to override git.dragonflybsd.org"
414 @echo "IMGSIZE may be used to override the .img (in 512-byte sectors)"
416 .PHONY: release quickrel realquickrel
418 .PHONY: quick realquick
419 .PHONY: check buildworld1 buildworld2
420 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mkiso mkimg
421 .PHONY: clean realclean help all srcs
423 .include <bsd.prog.mk>