1######################################################################### 2# ENHANCEMENTS # 3######################################################################### 4 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. 8# 9# img is now the default (produces both the .iso and .img) 10# 11gui installer img nopkgs: 12 13######################################################################### 14# SETUP # 15######################################################################### 16 17DPORTS_PATH?= /usr/dports 18ISODIR?= /usr/release 19ISOROOT?= ${ISODIR}/root 20OBJSYS= ${.OBJDIR}/../sys 21GITHOST?= git.dragonflybsd.org 22GITHOST_DPORTS?=mirror-master.dragonflybsd.org 23 24MAKE_JOBS?= $$(sysctl -n hw.ncpu) 25 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} == "i386" 29KERNCONF ?= GENERIC 30.else 31KERNCONF ?= X86_64_GENERIC 32.endif 33 34CHROOT_CMD?= /usr/sbin/chroot ${ISOROOT} sh -c 35 36.if !make(nopkgs) 37# User may specify extra packages in addition to the defaults 38# 39DPORTS_EXTRA_PACKAGES?= 40 41# dports packages to be built and installed on the release ISO 42# 43# MISSING: csup 44# 45DPORTS_PACKAGES?= devel/git \ 46 dns/bind-tools \ 47 net/isc-dhcp42-server \ 48 sysutils/cdrtools \ 49 ${DPORTS_EXTRA_PACKAGES} 50 51# dports options to use when building packages 52# 53DPORTS_OPTIONS+= -DBATCH 54.if make(gui) 55DPORTS_OPTIONS.devel_git+= -DWITH_GUI 56.else 57DPORTS_OPTIONS.devel_git+= -DWITHOUT_CONTRIB -DWITHOUT_PERL 58.endif 59.endif 60 61# Specify which root skeletons are required, and let the user include 62# their own. They are copied into ISODIR during the `customizeiso' 63# target; each overwrites the last. 64# 65REQ_ROOTSKELS= ${.CURDIR}/root 66ROOTSKELS?= ${REQ_ROOTSKELS} 67 68.if make(gui) 69# LIST OF PACKAGES NOT INCLUDED DUE TO BUILD ISSUES: 70# chat/pidgin textproc/enchant dependency is broken 71# x11/rxvt-unicode broken configure 72# net/nmap tries to access openssl/md2.h which does not 73# exist. 74# sysutils/idesk dying on link __sync_fetch_and_add_4 75# 76ISOFILE?= ${ISODIR}/dfly-gui.iso 77IMGFILE?= ${ISODIR}/dfly-gui.img 78 79# NOTE: order important, do not sort package list 80# 81# Apps we want in the gui build but which have problems building: 82# chat/xchat link error on x86-64, something about ___progname 83# 84# 85.if !make(nopkgs) 86DPORTS_PACKAGES+= x11/xorg \ 87 x11-wm/fluxbox \ 88 x11-wm/fvwm \ 89 www/firefox \ 90 graphics/xpdf \ 91 shells/zsh \ 92 editors/emacs \ 93 editors/vim \ 94 irc/irssi \ 95 lang/perl5 \ 96 editors/nano \ 97 shells/bash \ 98 devel/ctags \ 99 archivers/zip \ 100 security/sudo \ 101 www/links \ 102 ftp/wget \ 103 x11-fonts/terminus-font \ 104 net/rsync \ 105 x11-clocks/asclock \ 106 sysutils/screen 107.endif 108 109ROOTSKELS+= ${.CURDIR}/gui 110.endif 111 112ISOFILE ?= ${ISODIR}/dfly.iso 113IMGFILE ?= ${ISODIR}/dfly.img 114 115IMGMNT ?= ${ISODIR}/mnt 116 117# USB umass now probes starting at da8, so the usb stick is 118# probably sitting on da8. 119# 120IMGUSBDEV ?= da8 121 122# note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add 123# the additional '/nrelease' manually, as a safety measure. 124# 125NRLOBJDIR?= /usr/obj 126 127######################################################################### 128# BASE ISO TARGETS # 129######################################################################### 130 131release: check clean buildworld1 buildkernel1 \ 132 buildiso srcs customizeiso mkiso mkimg 133 134quickrel: check clean buildworld2 buildkernel2 \ 135 buildiso srcs customizeiso mkiso mkimg 136 137realquickrel: check clean \ 138 buildiso srcs customizeiso mkiso mkimg 139 140restartpkgs: check customizeiso mkiso mkimg 141 142quick: quickrel 143 144realquick: realquickrel 145 146 147######################################################################### 148# CORE SUPPORT TARGETS # 149######################################################################### 150 151check: 152.if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs) 153 @echo 154 @echo "Your machine does not have cdrtools installed. You can install it with:" 155 @echo " pkg install cdrtools" 156.endif 157 @if [ ! -d ${DPORTS_PATH} ]; then \ 158 echo "${DPORTS_PATH} does not exist."; \ 159 echo ""; \ 160 echo "Please set DPORTS_PATH to the dports tree that shall be used for"; \ 161 echo "package building. The default is /usr/dports. See the Makefile in"; \ 162 echo "/usr if you are unfamiliar with dports."; \ 163 /usr/bin/false; \ 164 fi 165.if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs) 166 @/usr/bin/false 167.endif 168 @echo "Using ${DPORTS_PATH} as the dports tree." 169 170buildworld1 buildworld2: 171 cd ${.CURDIR}/..; \ 172 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \ 173 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//} 174 175buildkernel1 buildkernel2: 176 cd ${.CURDIR}/..; \ 177 for kernconf in ${KERNCONF}; do \ 178 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \ 179 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \ 180 KERNCONF=$${kernconf}; \ 181 done 182 183# note that we do not want to mess with any /usr/obj directories not related 184# to buildworld, buildkernel, or nrelease, so we must supply the proper 185# MAKEOBJDIRPREFIX for targets that are not run through the buildworld and 186# buildkernel mechanism. 187# 188# Unconditionally clean out ${ISOROOT} so a previous img build 189# does not blow up a future quick iso build 190# 191# We install with INSTALLSTRIPPEDMODULES to make things fit into the ISO. 192# We leave the kernel's debug variables intact. 193# 194buildiso: 195 -rm -rf ${ISOROOT} 196 -chflags -R noschg ${ISOROOT} 197 rm -rf ${ISOROOT} 198 mkdir -p ${ISOROOT} 199 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi 200 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld ) 201 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \ 202 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution ) 203 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd 204 cd ${.CURDIR}/..; \ 205 for kernconf in ${KERNCONF}; do \ 206 make DESTDIR=${ISOROOT} reinstallkernel KERNCONF=$${kernconf}; \ 207 done 208 rm -rf ${ISOROOT}/boot/kernel.old 209 ln -sf kernel ${ISOROOT}/boot/kernel/kernel.BOOTP 210 # This next mkinitrd has to be the INSTALLED version because else we 211 # can't rely on the -c option being present, but it needs to be run 212 # OUTSIDE of the chroot because it might want to load vn(4) and can't 213 # do so from inside of it. 214 # 215 ${ISOROOT}/sbin/mkinitrd -c ${ISOROOT}/usr/share/initrd -b ${ISOROOT}/boot 216 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/ 217 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var 218 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev 219 220# The GUI build includes the ports tree (~1G+) while the nominal release 221# build does not. 222# 223# The GUI build includes full sources while the nominal release build 224# only includes kernel sources (~27MB). 225# 226srcs: 227.if !defined(WITHOUT_SRCS) 228.if make(gui) 229 rm -f ${ISOROOT}/usr/src-sys.tgz 230 rm -f ${ISOROOT}/usr/src-sys.tar.bz2 231.if !empty(DPORTS_PACKAGES) 232 cd ${ISOROOT}/usr && make dports-create GITHOST_DPORTS=${GITHOST_DPORTS} 233 # NOTE: Adding the git gc --aggressive helps by significantly 234 # reducing the disk space required. 235 # 236 cd ${ISOROOT}/usr/dports && git gc --aggressive 237.endif 238 cd ${ISOROOT}/usr && make src-create-repo GITHOST=${GITHOST} 239 # XXX: git gc --aggressive 240.else 241 rm -f ${ISOROOT}/usr/src-sys.tgz 242 rm -f ${ISOROOT}/usr/src-sys.tar.bz2 243 cd ${.CURDIR}/.. && tar --exclude .git -s '/^\./src/' \ 244 -cf - ./Makefile ./Makefile.inc1 ./sys | \ 245 bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2 246.endif 247.endif 248 249# Customize the ISO by copying rootskels in reverse priority order, 250# building packages, and doing other post-install tasks. 251# 252customizeiso: 253 # Copy the rootskels. Allow sources to be owned by someone other 254 # than root (as is common when checked out via git). 255 # 256.for ROOTSKEL in ${ROOTSKELS} 257 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT} 258 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel" 259 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel)) 260.endfor 261 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd 262.for UPGRADE_ITEM in Makefile \ 263 etc.${MACHINE_ARCH} \ 264 rc.d/Makefile \ 265 periodic/Makefile \ 266 periodic/daily/Makefile \ 267 periodic/security/Makefile \ 268 periodic/weekly/Makefile \ 269 periodic/monthly/Makefile 270 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM} 271.endfor 272 # 273 # Setup some things & mount dports tree. Use defensive umounts and 274 # rm -rf's to allow restarts. Allow /usr/dports to be read-only. 275 # 276 -@umount ${ISOROOT}/dev 277 mount_null /dev ${ISOROOT}/dev 278.if !empty(DPORTS_PACKAGES) 279 cp /etc/resolv.conf ${ISOROOT}/etc 280 ${CHROOT_CMD} "ldconfig -elf /lib /usr/lib /usr/lib/gcc* /usr/lib/compat" 281 -@umount ${ISOROOT}/usr/distfiles 282 -@umount ${ISOROOT}/usr/dports 283 rm -rf ${ISOROOT}/usr/obj/dports 284 # 285 # Mount /usr/dports, make sure /usr/distfiles is writable. 286 # Make /usr/dports read-only for safety, else a failed umount and 287 # our rm -rf will do bad things. 288 # 289 mkdir -p ${ISOROOT}/usr/dports 290 mkdir -p ${ISOROOT}/usr/distfiles 291 mount_null -o ro ${DPORTS_PATH} ${ISOROOT}/usr/dports 292 cp /etc/shells ${ISOROOT}/usr/distfiles/.test > /dev/null 2>&1 \ 293 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/distfiles 294 # 295 # Build and install packages, skip packages already installed 296 # 297.for PKG in ${DPORTS_PACKAGES} 298 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} ${DPORTS_OPTIONS.${PKG:S/\//_/g}} install" 299.endfor 300.for PKG in ${DPORTS_PACKAGES} 301 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} clean" 302.endfor 303 # 304 # Remove packages which nothing depends on, add a whatis database 305 # for dports manual pages, create an initial locate database and 306 # clean up 307 # 308 ${CHROOT_CMD} "yes | pkg autoremove" 309 ${CHROOT_CMD} "makewhatis /usr/local/man" 310 -umount ${ISOROOT}/usr/distfiles 311 umount ${ISOROOT}/usr/dports 312 rm -rf ${ISOROOT}/usr/dports 313 rm -rf ${ISOROOT}/usr/obj/dports 314 rm -rf ${ISOROOT}/usr/distfiles 315 rm -f ${ISOROOT}/etc/resolv.conf 316.endif 317 # 318 # Finally, update the locate(8) database 319 # 320 ${CHROOT_CMD} /etc/periodic/weekly/310.locate 321 umount ${ISOROOT}/dev 322 # 323 # Recopy files that dports may have updated in /etc into /etc.hdd 324 # 325 cpdup ${ISOROOT}/etc/shells ${ISOROOT}/etc.hdd/shells 326 cpdup ${ISOROOT}/etc/group ${ISOROOT}/etc.hdd/group 327 328mkiso: 329 ( cd ${ISOROOT}; mkisofs -b boot/cdboot -no-emul-boot \ 330 -R -J -o ${ISOFILE} \ 331 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . ) 332 333mkimg: 334 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi 335 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \ 336 vnconfig -u `cat ${ISODIR}/vn.which`; fi 337.ifdef IMGSIZE 338 @echo "STEP: use an image size of ${IMGSIZE} 512-byte sectors" 339 rm -f ${IMGFILE} 340 sz=`bc -e "((${IMGSIZE}) * 512)" -equit`; truncate -s $${sz} ${IMGFILE} 341.else 342 @echo "STEP: Determine required image size in 1GB steps" 343 @echo " Leave ~600MB of unused space" 344 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \ 345 sz=`bc -e "(($${sz}) * 1.15 + 999999 + 600000) / 1000000" -equit | \ 346 cut -f1 -d.`; \ 347 sz=`bc -e "(($${sz}) * 953)" -equit | cut -f1 -d.`; \ 348 rm -f ${IMGFILE}; \ 349 truncate -s $${sz}M ${IMGFILE}; 350.endif 351 fdisk -IB -p ${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: write standard disklabel" 357 disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto 358 @echo "STEP: read disklabel back" 359 disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label 360 @echo "STEP: determine number of sectors of whole disk" 361 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \ 362 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label; 363 @echo "STEP: write modified disklabel back" 364 disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label 365 rm ${IMGFILE}.label 366 @echo "STEP: write bootsector" 367 disklabel -B `cat ${ISODIR}/vn.which`s1 368 boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which` 369 newfs /dev/`cat ${ISODIR}/vn.which`s1a 370 mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT} 371 cpdup ${ISOROOT} ${IMGMNT} 372 @echo "STEP: fixup ${IMGMNT}/etc/fstab" 373 echo "/dev/${IMGUSBDEV}s1a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab 374 echo "dummy /tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab 375 echo "dummy /var/tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab 376 echo "dummy /var/run tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab 377 echo "dummy /usr/obj tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab 378 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab 379 @echo "STEP: fixup ${IMGMNT}/boot/loader.conf" 380 -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new 381 echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s1a"' >> ${IMGMNT}/boot/loader.conf.new 382 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf 383 @echo "STEP: cleanup" 384 df ${IMGMNT} 385 sync 386 sleep 1 387 umount ${IMGMNT} 388 vnconfig -u `cat ${ISODIR}/vn.which` 389 rm -f ${ISODIR}/vn.which 390 rmdir ${IMGMNT} 391 @echo "STEP: done" 392 393clean: 394 sync 395 sleep 1 396 -umount ${ISOROOT}/usr/distfiles > /dev/null 2>&1 397 -umount ${ISOROOT}/usr/dports > /dev/null 2>&1 398 -umount ${ISOROOT}/dev > /dev/null 2>&1 399 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \ 400 vnconfig -u `cat ${ISODIR}/vn.which`; fi 401 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi 402 rm -rf ${ISOROOT} 403 rm -rf ${NRLOBJDIR}/nrelease 404 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which 405 406realclean: clean 407 rm -rf ${OBJSYS}/${KERNCONF} 408 rm -rf ${ISODIR}/packages 409 rm -rf ${ISODIR}/distfiles 410 411help all: 412 @echo "make [gui] release - complete build from scratch" 413 @echo "make [gui] quick - attempt to do an incremental rebuild" 414 @echo "make [gui] realquick - attempt to restart after world & kernel" 415 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage" 416 @echo "" 417 @echo "DPORTS_EXTRA_PACKAGES may be used to add additional pkgs" 418 @echo "GITHOST may be used to override git.dragonflybsd.org" 419 @echo "GITHOST_DPORTS may be used to override mirror-master.dragonflybsd.org" 420 @echo "IMGSIZE may be used to override the .img (in 512-byte sectors)" 421 422.PHONY: release quickrel realquickrel 423.PHONY: installer 424.PHONY: quick realquick 425.PHONY: check buildworld1 buildworld2 426.PHONY: buildkernel1 buildkernel2 buildiso customizeiso mkiso mkimg 427.PHONY: clean realclean help all srcs 428 429.include <bsd.prog.mk> 430