1######################################################################### 2# ENHANCEMENTS # 3######################################################################### 4 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. 8# 9# img is now the default (produces both the .iso and .img) 10# 11gui installer img nopkgs: 12 13######################################################################### 14# SETUP # 15######################################################################### 16 17ISODIR?= /usr/release 18ISOROOT?= ${ISODIR}/root 19OBJSYS= ${.OBJDIR}/../sys 20GITHOST?= git.dragonflybsd.org 21 22MAKE_JOBS?= $$(sysctl -n hw.ncpu) 23 24# temporary until everybody has converted to x86_64 25.if ${MACHINE_ARCH} == "amd64" 26MACHINE_ARCH= x86_64 27.makeenv MACHINE_ARCH 28.endif 29 30# XXX makeshift fix to build the right kernel for the (target) architecture 31# We should configure this in the platform files somehow 32.if ${MACHINE_ARCH} == "i386" 33KERNCONF ?= GENERIC 34.else 35KERNCONF ?= X86_64_GENERIC 36.endif 37 38PKGSRC_PREFIX?= /usr/pkg 39PKGBIN_PKG_ADD?= ${PKGSRC_PREFIX}/sbin/pkg_add 40PKGBIN_PKG_DELETE?= ${PKGSRC_PREFIX}/sbin/pkg_delete 41PKGBIN_PKG_ADMIN?= ${PKGSRC_PREFIX}/sbin/pkg_admin 42PKGBIN_MKISOFS?= ${PKGSRC_PREFIX}/bin/mkisofs 43PKGSRC_PKG_PATH?= ${ISODIR}/packages 44 45# We use env -i in the chroot, so that environment variables won't 46# disturb any (pkgsrc) build. This has happened for TARGET_ARCH, 47# which is used by gmake in completely different context. 48# 49CHROOT_CMD?= env -i CCVER=${CCVER:Q} /usr/sbin/chroot ${ISOROOT} sh -c 50 51# User may specify extra packages in addition to the defaults 52# 53PKGSRC_EXTRA_PACKAGES?= 54 55# Pkgsrc packages to be built and installed on the release ISO 56# 57PKGSRC_PACKAGES?= pkgtools/pkg_leaves \ 58 pkgtools/pkg_tarup \ 59 pkgtools/pkgin \ 60 devel/scmgit \ 61 net/bind96 \ 62 net/isc-dhcp4 \ 63 net/isc-dhcpd4 \ 64 sysutils/cdrtools \ 65 net/csup \ 66 ${PKGSRC_EXTRA_PACKAGES} 67 68# pkgsrc options to use when building packages 69# 70PKGSRC_OPTIONS+= MAKE_JOBS=${MAKE_JOBS} 71PKGSRC_OPTIONS+= WRKOBJDIR=/usr/pkgobj 72PKGSRC_OPTIONS+= PKG_DEFAULT_OPTIONS='dri inet6' 73.if !make(gui) 74PKGSRC_OPTIONS+= PKG_OPTIONS.scmgit='-python -scmgit-gui' 75.endif 76 77# Even though buildiso wipes the packages, our check target has to run 78# first and old packages (listed as they appear in pkg_info) must be 79# cleaned out in order for the pkg_add -n test we use in the check target 80# to operate properly. 81# 82OLD_PKGSRC_PACKAGES?= cdrtools-2.01.01.27nb1 \ 83 cdrecord-2.00.3nb2 \ 84 bootstrap-kit-20070205 \ 85 dfuibe_installer-1.1.6 \ 86 gettext-lib-0.14.5 \ 87 dfuibe_installer-1.1.7nb1 \ 88 dfuife_curses-1.5 \ 89 gettext-lib-0.14.6 \ 90 gettext-tools-0.14.6nb1 \ 91 libaura-3.1 \ 92 libdfui-4.2 \ 93 libinstaller-5.1 \ 94 bootstrap-kit-20080211 \ 95 cdrtools-ossdvd-2.01.1.36nb2 \ 96 isc-dhcp-base-4.0.0 \ 97 isc-dhcp-server-4.0.0 98 99# Specify which root skeletons are required, and let the user include 100# their own. They are copied into ISODIR during the `customizeiso' 101# target; each overwrites the last. 102# 103REQ_ROOTSKELS= ${.CURDIR}/root 104ROOTSKELS?= ${REQ_ROOTSKELS} 105 106# LIST OF PACKAGES NOT INCLUDED DUE TO BUILD ISSUES: 107# chat/pidgin textproc/enchant dependency is broken 108# x11/rxvt-unicode broken configure 109# net/nmap tries to access openssl/md2.h which does not 110# exist. 111# sysutils/idesk dying on link __sync_fetch_and_add_4 112# 113.if make(gui) 114ISOFILE?= ${ISODIR}/dfly-gui.iso 115IMGFILE?= ${ISODIR}/dfly-gui.img 116 117# NOTE: order important, do not sort package list 118# 119# Apps we want in the gui build but which have problems building: 120# chat/xchat link error on x86-64, something about ___progname 121# 122# 123.if !make(nopkgs) 124PKGSRC_PACKAGES+= meta-pkgs/modular-xorg-libs \ 125 meta-pkgs/modular-xorg-fonts \ 126 meta-pkgs/modular-xorg-apps \ 127 meta-pkgs/modular-xorg-drivers \ 128 x11/libXinerama \ 129 wm/fluxbox \ 130 wm/fvwm \ 131 www/firefox \ 132 print/xpdf \ 133 shells/zsh \ 134 editors/emacs \ 135 editors/vim \ 136 chat/irssi \ 137 x11/modular-xorg-server \ 138 x11/eterm \ 139 lang/perl5 \ 140 editors/nano \ 141 shells/bash \ 142 devel/exctags \ 143 archivers/zip \ 144 security/sudo \ 145 www/links-gui \ 146 net/wget \ 147 fonts/terminus-font \ 148 net/rsync \ 149 time/asclock \ 150 misc/screen 151.endif 152 153ROOTSKELS+= ${.CURDIR}/gui 154.endif 155 156ISOFILE ?= ${ISODIR}/dfly.iso 157IMGFILE ?= ${ISODIR}/dfly.img 158 159IMGMNT ?= ${ISODIR}/mnt 160 161# USB umass now probes starting at da8, so the usb stick is 162# probably sitting on da8. 163# 164IMGUSBDEV ?= da8 165 166# note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add 167# the additional '/nrelease' manually, as a safety measure. 168# 169NRLOBJDIR?= /usr/obj 170 171######################################################################### 172# BASE ISO TARGETS # 173######################################################################### 174 175release: check clean buildworld1 buildkernel1 \ 176 buildiso srcs customizeiso mkiso mkimg 177 178quickrel: check clean buildworld2 buildkernel2 \ 179 buildiso srcs customizeiso mkiso mkimg 180 181realquickrel: check clean \ 182 buildiso srcs customizeiso mkiso mkimg 183 184restartpkgs: check customizeiso mkiso mkimg 185 186quick: quickrel 187 188realquick: realquickrel 189 190 191######################################################################### 192# CORE SUPPORT TARGETS # 193######################################################################### 194 195check: 196.if !exists(${PKGBIN_PKG_ADMIN}) 197 @echo "You never bootstrapped pkgsrc on your machine. You can install it with:" 198 @echo " make pkgsrc_bootstrap" 199.endif 200.if !exists (${PKGBIN_MKISOFS}) 201 @echo 202 @echo "Your machine does not have cdrtools installed. You can install it with:" 203 @echo " make pkgsrc_cdrecord" 204.endif 205.if !defined(PKGSRC_PATH) 206 @echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for" 207 @echo "package building. For example /usr/pkgsrc. See the Makefile" 208 @echo "in /usr if you are unfamiliar with pkgsrc." 209.endif 210.if !exists (${PKGBIN_MKISOFS}) 211 @exit 1 212.endif 213.if !defined(PKGSRC_PATH) 214 @exit 1 215.endif 216 217buildworld1 buildworld2: 218 cd ${.CURDIR}/..; \ 219 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \ 220 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//} 221 222buildkernel1 buildkernel2: 223 cd ${.CURDIR}/..; \ 224 for kernconf in ${KERNCONF}; do \ 225 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \ 226 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \ 227 KERNCONF=$${kernconf}; \ 228 done 229 230# note that we do not want to mess with any /usr/obj directories not related 231# to buildworld, buildkernel, or nrelease, so we must supply the proper 232# MAKEOBJDIRPREFIX for targets that are not run through the buildworld and 233# buildkernel mechanism. 234# 235# Unconditionally clean out /usr/release/root so a previous img build 236# does not blow up a future quick iso build 237# 238# We install with INSTALLSTRIPPEDMODULES to make things fit into the ISO. 239# We leave the kernel's debug variables intact. 240# 241buildiso: 242 -rm -rf ${ISOROOT} 243 -chflags -R noschg ${ISOROOT} 244 rm -rf ${ISOROOT} 245 mkdir -p ${ISOROOT} 246 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi 247 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld ) 248 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \ 249 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution ) 250 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd 251 cd ${.CURDIR}/..; \ 252 for kernconf in ${KERNCONF}; do \ 253 make DESTDIR=${ISOROOT} installkernel KERNCONF=$${kernconf}; \ 254 done 255 rm -rf ${ISOROOT}/boot/kernel.old 256 ln -s kernel ${ISOROOT}/boot/kernel/kernel.BOOTP 257 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/ 258 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var 259 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev 260 261# The GUI build includes the pkgsrc tree (~1G+) while the nominal release 262# build does not. 263# 264# The GUI build includes full sources while the nominal release build 265# only includes kernel sources (~27MB). 266# 267srcs: 268.if !defined(WITHOUT_SRCS) 269.if make(gui) 270 rm -f ${ISOROOT}/usr/src-sys.tgz 271 rm -f ${ISOROOT}/usr/src-sys.tar.bz2 272 cd ${ISOROOT}/usr && make pkgsrc-create-repo GITHOST=${GITHOST} 273 cd ${ISOROOT}/usr && make src-create-repo GITHOST=${GITHOST} 274.else 275 rm -f ${ISOROOT}/usr/src-sys.tgz 276 rm -f ${ISOROOT}/usr/src-sys.tar.bz2 277 cd ${.CURDIR}/.. && tar --exclude .git -s '/^\./src/' \ 278 -cf - ./Makefile ./Makefile.inc1 ./sys | \ 279 bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2 280.endif 281.endif 282 283# Customize the ISO by copying rootskels in reverse priority order, 284# building packages, and doing other post-install tasks. 285# 286customizeiso: 287 # Copy the rootskels. Allow sources to be owned by someone other 288 # than root (as is common when checked out via git). 289 # 290.for ROOTSKEL in ${ROOTSKELS} 291 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT} 292 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel" 293 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel)) 294.endfor 295 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd 296.for UPGRADE_ITEM in Makefile \ 297 etc.${MACHINE_ARCH} \ 298 rc.d/Makefile \ 299 periodic/Makefile \ 300 periodic/daily/Makefile \ 301 periodic/security/Makefile \ 302 periodic/weekly/Makefile \ 303 periodic/monthly/Makefile 304 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM} 305.endfor 306 # 307 # Setup some things & mount pkgsrc tree. Use defensive umounts and 308 # rm -rf's to allow restarts. Allow /usr/pkgsrc to be read-only. 309 # 310 # If we did not get past the bootstrap we clean out the entire 311 # /usr/pkg infrastructure. Otherwise we attempt to pick up where 312 # we left off. 313 # 314 cp -p /etc/resolv.conf ${ISOROOT}/etc 315 ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat" 316 -@umount ${ISOROOT}/usr/pkgsrc/distfiles 317 -@umount ${ISOROOT}/usr/pkgsrc 318 -@umount ${ISOROOT}/dev 319 mkdir -p ${ISODIR}/distfiles 320 rm -rf ${ISOROOT}/usr/pkgobj 321 # 322 # Mount /usr/pkgsrc, make sure /usr/pkgsrc/distfiles is writable. 323 # Make /usr/pkgsrc read-only for safety, else a failed umount and 324 # our rm -rf will do bad things. 325 # 326 mkdir -p ${ISOROOT}/usr/pkgobj 327 mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap 328 mkdir -p ${ISOROOT}/usr/pkgsrc 329 mount_null -o ro ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc 330 mount_null /dev ${ISOROOT}/dev 331 cp /etc/shells ${ISOROOT}/usr/pkgsrc/distfiles/.test > /dev/null 2>&1 \ 332 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/pkgsrc/distfiles 333 # 334 # Bootstrap, if not already installed, and add licenses needed 335 # for the gui release 336 # 337 test -e ${ISODIR}/.didbootstrap || \ 338 rm -rf ${ISOROOT}/usr/pkg ${ISOROOT}/var/db/pkg \ 339 ${ISOROOT}/var/db/pkg.refcount 340 test -e ${ISODIR}/.didbootstrap || \ 341 ${CHROOT_CMD} "cd /usr/pkgsrc/bootstrap; \ 342 export share_dir=/usr/pkgobj/bootstrap/work/share; \ 343 env USE_DESTDIR=no ./bootstrap --workdir /usr/pkgobj/bootstrap/work" 344 test -e ${ISODIR}/.didbootstrap || \ 345 echo ".ifdef BSD_PKG_MK # added by nrelease" \ 346 >> ${ISOROOT}/usr/pkg/etc/mk.conf 347 test -e ${ISODIR}/.didbootstrap || \ 348 echo "PKG_DEFAULT_OPTIONS=dri inet6" \ 349 >> ${ISOROOT}/usr/pkg/etc/mk.conf 350.if make(gui) 351 test -e ${ISODIR}/.didbootstrap || \ 352 echo "ACCEPTABLE_LICENSES+=openmotif-license" \ 353 >> ${ISOROOT}/usr/pkg/etc/mk.conf 354 test -e ${ISODIR}/.didbootstrap || \ 355 echo "ACCEPTABLE_LICENSES+=vim-license" \ 356 >> ${ISOROOT}/usr/pkg/etc/mk.conf 357.endif 358 test -e ${ISODIR}/.didbootstrap || \ 359 echo ".endif # added by nrelease" \ 360 >> ${ISOROOT}/usr/pkg/etc/mk.conf 361 test -e ${ISODIR}/.didbootstrap || sync 362 test -e ${ISODIR}/.didbootstrap || touch ${ISODIR}/.didbootstrap 363 # 364 # Build and install packages, skip packages already installed 365 # 366.for PKG in ${PKGSRC_PACKAGES} 367 ${CHROOT_CMD} "cd /usr/pkgsrc/${PKG} && \ 368 (bmake check > /dev/null 2>&1 || \ 369 env USE_DESTDIR=no bmake ${PKGSRC_OPTIONS} clean build install)" 370.endfor 371 # 372 # Remove packages which nothing depends on, add a whatis database 373 # for pkgsrc manual pages, create an initial locate database and 374 # clean up 375 # 376 ${CHROOT_CMD} "pkg_leaves | xargs pkg_delete -R" 377 ${CHROOT_CMD} "makewhatis /usr/pkg/man" 378 -umount ${ISOROOT}/usr/pkgsrc/distfiles 379 umount ${ISOROOT}/usr/pkgsrc 380 rm -rf ${ISOROOT}/usr/pkgobj 381 rm -f ${ISOROOT}/etc/resolv.conf 382 ${CHROOT_CMD} /etc/periodic/weekly/310.locate 383 umount ${ISOROOT}/dev 384 # 385 # Recopy files that pkgsrc may have updated in /etc into /etc.hdd 386 # 387 cpdup ${ISOROOT}/etc/shells ${ISOROOT}/etc.hdd/shells 388 cpdup ${ISOROOT}/etc/group ${ISOROOT}/etc.hdd/group 389 390mkiso: 391 ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \ 392 -R -J -o ${ISOFILE} \ 393 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . ) 394 395mkimg: 396 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi 397 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \ 398 vnconfig -u `cat ${ISODIR}/vn.which`; fi 399.ifdef IMGSIZE 400 @echo "STEP: use an image size of ${IMGSIZE} 512-byte sectors" 401 rm -f ${IMGFILE} 402 sz=`bc -e "((${IMGSIZE}) * 512)" -equit`; truncate -s $${sz} ${IMGFILE} 403.else 404 @echo "STEP: Determine required image size in 1GB steps" 405 @echo " Leave ~600MB of unused space" 406 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \ 407 sz=`bc -e "(($${sz}) * 1.15 + 999999 + 600000) / 1000000" -equit | \ 408 cut -f1 -d.`; \ 409 sz=`bc -e "(($${sz}) * 953)" -equit | cut -f1 -d.`; \ 410 rm -f ${IMGFILE}; \ 411 truncate -s $${sz}M ${IMGFILE}; 412.endif 413 fdisk -IB -p ${IMGFILE} 414 @echo "STEP: determine free vn device" 415 vnconfig -l | grep "not in use" | head -n 1 | \ 416 cut -f 1 -d: > ${ISODIR}/vn.which 417 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE} 418 @echo "STEP: write standard disklabel" 419 disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto 420 @echo "STEP: read disklabel back" 421 disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label 422 @echo "STEP: determine number of sectors of whole disk" 423 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \ 424 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label; 425 @echo "STEP: write modified disklabel back" 426 disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label 427 rm ${IMGFILE}.label 428 @echo "STEP: write bootsector" 429 disklabel -B `cat ${ISODIR}/vn.which`s1 430 boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which` 431 newfs /dev/`cat ${ISODIR}/vn.which`s1a 432 mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT} 433 cpdup ${ISOROOT} ${IMGMNT} 434 @echo "STEP: fixup ${IMGMNT}/etc/fstab" 435 echo "/dev/${IMGUSBDEV}s1a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab 436 echo "dummy /tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab 437 echo "dummy /var/tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab 438 echo "dummy /var/run tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab 439 echo "dummy /usr/obj tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab 440 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab 441 @echo "STEP: fixup ${IMGMNT}/boot/loader.conf" 442 -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new 443 echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s1a"' >> ${IMGMNT}/boot/loader.conf.new 444 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf 445 @echo "STEP: cleanup" 446 df ${IMGMNT} 447 umount ${IMGMNT} 448 vnconfig -u `cat ${ISODIR}/vn.which` 449 rm -f ${ISODIR}/vn.which 450 rmdir ${IMGMNT} 451 @echo "STEP: done" 452 453clean: 454 -umount ${ISOROOT}/usr/pkgsrc/distfiles > /dev/null 2>&1 455 -umount ${ISOROOT}/usr/pkgsrc > /dev/null 2>&1 456 -umount ${ISOROOT}/dev > /dev/null 2>&1 457 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \ 458 vnconfig -u `cat ${ISODIR}/vn.which`; fi 459 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi 460 rm -rf ${ISOROOT} 461 rm -rf ${NRLOBJDIR}/nrelease 462 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which 463 464realclean: clean 465 rm -rf ${OBJSYS}/${KERNCONF} 466 # 467 # do not use PKGSRC_PKG_PATH here, we do not want to destroy an 468 # override location. 469 # 470 rm -rf ${ISODIR}/packages 471 rm -rf ${ISODIR}/distfiles 472 473pkgsrc_bootstrap: 474 mkdir -p /usr/release/bootstrap 475 (cd ${PKGSRC_PATH}/bootstrap; \ 476 export share_dir=/usr/release/bootstrap/share; \ 477 ./bootstrap --workdir /usr/release/bootstrap) 478 479pkgsrc_cdrecord: 480.if !exists (${PKGBIN_MKISOFS}) 481 (cd ${PKGSRC_PATH}/sysutils/cdrtools; bmake clean build install) 482.endif 483 484help all: 485 @echo "make [gui] release - complete build from scratch" 486 @echo "make [gui] quick - attempt to do an incremental rebuild" 487 @echo "make [gui] realquick - attempt to restart after world & kernel" 488 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage" 489 @echo "" 490 @echo "PKGSRC_EXTRA_PACKAGES may be used to add additional pkgs" 491 @echo "GITHOST may be used to override git.dragonflybsd.org" 492 @echo "IMGSIZE may be used to override the .img (in 512-byte sectors)" 493 494.PHONY: release quickrel realquickrel 495.PHONY: installer 496.PHONY: quick realquick 497.PHONY: check buildworld1 buildworld2 498.PHONY: buildkernel1 buildkernel2 buildiso customizeiso mkiso mkimg 499.PHONY: clean realclean help all srcs 500 501.include <bsd.prog.mk> 502