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