1######################################################################### 2# ENHANCEMENTS # 3######################################################################### 4 5# Optional targets may be specified which set make variables which enhance 6# the build in various ways. 7# 8gui nopkgs binpkgs: 9 10######################################################################### 11# SETUP # 12######################################################################### 13 14SRCDIR= ${.CURDIR}/.. 15 16DPORTS_PATH?= /usr/dports 17ISODIR?= /usr/obj/release 18ISOROOT?= ${ISODIR}/root 19GITURL_SRC?= git://git.dragonflybsd.org/dragonfly.git 20GITURL_DPORTS?= git://mirror-master.dragonflybsd.org/dports.git 21NREL_MAKE_JOBS?= $$(sysctl -n hw.ncpu) 22.if !defined(NOFSCHG) 23MTREE_FSCHG= -i 24.endif 25WORLD_VERSION!= ${AWK} '/^\#define[[:blank:]]__DragonFly_version/ {print $$3}' < /usr/include/sys/param.h 26 27GITREV!= sh ${SRCDIR}/tools/gitrev.sh 28 29# The label/name of the disklabel64(5) slice in the ".img" file. This is 30# used to identify the USB device with DragonFly installation image, avoiding 31# hardcoding the USB device name (e.g., "da8"). 32# 33# This label is also used as the volume ID of the ".iso" file. 34# 35LABEL?= DragonFly_${GITREV} 36 37CHROOT_CMD?= /usr/sbin/chroot ${ISOROOT} sh -c 38 39ISOFILE?= ${ISODIR}/dfly.iso 40IMGFILE?= ${ISODIR}/dfly.img 41IMGMNT?= ${ISODIR}/mnt 42 43.if !make(nopkgs) 44# User may specify extra packages in addition to the defaults 45# 46DPORTS_EXTRA_PACKAGES?= 47 48# dports packages to be built and installed on the release ISO 49# 50DPORTS_PACKAGES?= security/ca_root_nss \ 51 devel/git-lite \ 52 dns/bind-tools \ 53 net/isc-dhcp44-server \ 54 sysutils/cdrtools \ 55 ${DPORTS_EXTRA_PACKAGES} 56 57# dports options to use when building packages 58# 59DPORTS_OPTIONS+= -DBATCH -DBUILDING_NRELEASE_DPORTS 60DPORTS_OPTIONS+= dns_bind-tools_UNSET=PYTHON 61.endif 62 63# Specify which root skeletons are required, and let the user include 64# their own. They are copied into ISODIR during the `customizeiso' 65# target; each overwrites the last. 66# 67REQ_ROOTSKELS= ${.CURDIR}/root 68ROOTSKELS?= ${REQ_ROOTSKELS} 69 70.if make(gui) 71ISOFILE?= ${ISODIR}/dfly-gui.iso 72IMGFILE?= ${ISODIR}/dfly-gui.img 73 74.if !make(nopkgs) 75# NOTE: order important, do not sort package list 76# 77DPORTS_PACKAGES+= x11/xorg \ 78 x11-wm/fluxbox \ 79 x11-wm/fvwm \ 80 www/firefox \ 81 graphics/xpdf \ 82 shells/zsh \ 83 editors/emacs \ 84 editors/vim \ 85 irc/irssi \ 86 lang/perl5 \ 87 editors/nano \ 88 shells/bash \ 89 devel/ctags \ 90 archivers/zip \ 91 security/sudo \ 92 www/links \ 93 ftp/wget \ 94 x11-fonts/terminus-font \ 95 net/rsync \ 96 x11-clocks/asclock \ 97 sysutils/screen 98.endif 99 100ROOTSKELS+= ${.CURDIR}/gui 101.endif # make(gui) 102 103# one port may have multiple binary packages (e.g., Python flavors) or have a 104# different name that may not be found by pkg(8), therefore, allow to specify 105# the exact binary package name for a port by setting 'PKG_<port>=<pkg-name>'. 106# 107.for PORT in ${DPORTS_PACKAGES} 108.if defined(PKG_${PORT}) 109PACKAGES+= ${PKG_${PORT}} 110.else 111PACKAGES+= ${PORT} 112.endif 113.endfor 114 115######################################################################### 116# BASE ISO TARGETS # 117######################################################################### 118 119release: check clean buildworld1 buildkernel1 \ 120 buildiso customizeiso pkgs srcs mkiso mkimg 121 122quickrel: check clean buildworld2 buildkernel2 \ 123 buildiso customizeiso pkgs srcs mkiso mkimg 124 125realquickrel: check clean \ 126 buildiso customizeiso pkgs srcs mkiso mkimg 127 128restartpkgs: check pkgs srcs mkiso mkimg 129 130quick: quickrel 131 132realquick: realquickrel 133 134######################################################################### 135# CORE SUPPORT TARGETS # 136######################################################################### 137 138check: 139.if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs) 140 @echo 141 @echo "Your machine does not have cdrtools installed. You can install it with:" 142 @echo " pkg install cdrtools" 143.endif 144 145.if make(nopkgs) 146 @echo Not building packages. 147.elif make(binpkgs) 148 @echo Using binary packages from a mirror. 149.else 150 @if [ ! -d ${DPORTS_PATH} ]; then \ 151 echo "${DPORTS_PATH} does not exist."; \ 152 echo ""; \ 153 echo "Please set DPORTS_PATH to the dports tree that shall be used for"; \ 154 echo "package building. The default is /usr/dports. See the Makefile in"; \ 155 echo "/usr if you are unfamiliar with dports."; \ 156 /usr/bin/false; \ 157 else \ 158 echo "Using ${DPORTS_PATH} as the dports tree."; \ 159 fi 160.endif 161 162.if !exists(/usr/local/bin/mkisofs) && !exists(/usr/pkg/bin/mkisofs) 163 @/usr/bin/false 164.endif 165 166buildworld1 buildworld2: 167 ( cd ${SRCDIR}; \ 168 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \ 169 make -j ${NREL_MAKE_JOBS} -DWANT_INSTALLER \ 170 ${.TARGET:C/build(.*)2/quick\1/:C/1//} ) 171 172buildkernel1 buildkernel2: 173 ( cd ${SRCDIR}; \ 174 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \ 175 make -j ${NREL_MAKE_JOBS} \ 176 ${.TARGET:C/build(.*)2/quick\1/:C/1//} ) 177 178# Unconditionally clean out ${ISOROOT} so a previous img build 179# does not blow up a future quick iso build 180# 181buildiso: 182 -chflags -R noschg ${ISOROOT} 183 rm -rf ${ISOROOT} 184 mkdir -p ${ISOROOT} 185 ( cd ${SRCDIR}; \ 186 make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld ) 187 # Do not mess with any /usr/obj directories not related to 188 # buildworld, buildkernel, or nrelease. 189 ( cd ${SRCDIR}/etc && \ 190 tmpdir=`mktemp -d -t nrelease` && \ 191 MAKEOBJDIRPREFIX=$${tmpdir} \ 192 make -m ${SRCDIR}/share/mk \ 193 DESTDIR=${ISOROOT} distribution && \ 194 rm -rf $${tmpdir} ) 195 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd 196 ( cd ${SRCDIR}; make DESTDIR=${ISOROOT} reinstallkernel ) 197 rm -rf ${ISOROOT}/boot/kernel.old 198 ln -sf kernel ${ISOROOT}/boot/kernel/kernel.BOOTP 199 mtree ${MTREE_FSCHG} -deU -f ${SRCDIR}/etc/mtree/BSD.var.dist \ 200 -p ${ISOROOT}/var 201 ${CHROOT_CMD} "rcrestart ldconfig" 202 203# The GUI build includes the full system source (~500 MB) and the full 204# dports tree (~250 MB). The nominal release build only includes the 205# kernel source (~30 MB). 206# 207srcs: 208 rm -rf ${ISOROOT}/usr/dports 209 rm -f ${ISOROOT}/usr/src-sys.tar.bz2 210.if !defined(WITHOUT_SRCS) 211.if make(gui) 212 ( cd ${ISOROOT}/usr && \ 213 make dports-create-shallow GITURL_DPORTS=${GITURL_DPORTS} ) 214 ( cd ${ISOROOT}/usr && \ 215 make src-create-shallow GITURL_SRC=${GITURL_SRC} ) 216.else 217 ( cd ${SRCDIR} && \ 218 tar --exclude .git -s '/^\./src/' -cf - \ 219 ./Makefile ./Makefile.inc1 ./sys \ 220 ./share/syscons/fonts | \ 221 bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2 ) 222.endif 223.endif 224 225# Customize the ISO by copying rootskels in reverse priority order. 226# 227customizeiso: 228 # Copy the rootskels. Allow sources to be owned by someone other 229 # than root (as is common when checked out via git). 230 # 231.for ROOTSKEL in ${ROOTSKELS} 232 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT} 233 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel" 234 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel)) 235.endfor 236 237 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd 238 pw -V ${ISOROOT}/etc useradd installer -o -u 0 -g 0 \ 239 -c "DragonFly Installer" -d /root -s /usr/sbin/installer 240 ${CHROOT_CMD} "chpass -p '' root" 241 ${CHROOT_CMD} "chpass -p '' installer" 242 243.for UPGRADE_ITEM in Makefile \ 244 etc.${MACHINE_ARCH} \ 245 rc.d/Makefile \ 246 periodic/Makefile \ 247 periodic/daily/Makefile \ 248 periodic/security/Makefile \ 249 periodic/weekly/Makefile \ 250 periodic/monthly/Makefile 251 cp -R ${SRCDIR}/etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM} 252.endfor 253 254# Install packages by using pkg(8) or building from dports. 255# 256pkgs: 257.if !empty(DPORTS_PACKAGES) 258 cp /etc/resolv.conf ${ISOROOT}/etc 259 cp /etc/ssl/cert.pem ${ISOROOT}/etc/ssl 260 -@umount ${ISOROOT}/dev 261 mount_null /dev ${ISOROOT}/dev 262 263.if make(binpkgs) 264 ${CHROOT_CMD} "cd /usr && make pkg-bootstrap-force" 265 ${CHROOT_CMD} "pkg update" 266.for PKG in ${PACKAGES} 267 @${CHROOT_CMD} "pkg search --exact --search name ${PKG}" || \ 268 ${CHROOT_CMD} "pkg search --exact --search origin ${PKG}" || \ 269 { \ 270 echo "ERROR: Cannot find the package for port '${PKG}'!"; \ 271 echo "-----> Use 'PKG_${PKG}=<pkg-name>' to specify the package name."; \ 272 false; \ 273 } 274.endfor 275 ${CHROOT_CMD} "pkg install --yes ${PACKAGES}" 276 277.else # !make(binpkgs) 278 -@umount ${ISOROOT}/usr/distfiles 279 -@umount ${ISOROOT}/usr/dports 280 rm -rf ${ISOROOT}/usr/obj/dports 281 282 mkdir -p ${ISOROOT}/usr/dports 283 mkdir -p ${ISOROOT}/usr/distfiles 284 285 # Mount /usr/dports read-only for safety, else a failed umount 286 # and our rm -rf will do bad things. 287 mount_null -o ro ${DPORTS_PATH} ${ISOROOT}/usr/dports 288 289 # Make sure /usr/distfiles is writable 290 cp /etc/shells ${ISOROOT}/usr/distfiles/.test > /dev/null 2>&1 \ 291 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/distfiles 292 293.for PKG in ${DPORTS_PACKAGES} 294.if make(restartpkgs) 295 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} deinstall" 296.endif 297 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} install" 298.endfor 299.for PKG in ${DPORTS_PACKAGES} 300 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} clean" 301.endfor 302 303 ${CHROOT_CMD} "pkg autoremove --yes" 304 305 -umount ${ISOROOT}/usr/distfiles 306 umount ${ISOROOT}/usr/dports 307 308 rm -rf ${ISOROOT}/usr/dports 309 rm -rf ${ISOROOT}/usr/distfiles 310 rm -rf ${ISOROOT}/usr/obj/dports 311.endif # make(binpkgs) 312 313 # Update the locate(8) and whatis(1) databases, allow ISODIR 314 # to be on tmpfs (fails to create locate database then) 315 # 316 -${CHROOT_CMD} /etc/periodic/weekly/310.locate 317 -${CHROOT_CMD} /etc/periodic/weekly/320.whatis 318 319 umount ${ISOROOT}/dev 320 rm -f ${ISOROOT}/etc/resolv.conf 321 322.if exists(${ISOROOT}/usr/local/etc) 323 echo "dummy /usr/local/etc tmpfs rw,-C 0 0" >> ${ISOROOT}/etc/fstab 324.endif 325 326 # Recopy files that dports may have updated in /etc into /etc.hdd 327 # 328 cpdup ${ISOROOT}/etc/shells ${ISOROOT}/etc.hdd/shells 329 cpdup ${ISOROOT}/etc/group ${ISOROOT}/etc.hdd/group 330 cpdup ${ISOROOT}/etc/passwd ${ISOROOT}/etc.hdd/passwd 331 cpdup ${ISOROOT}/etc/master.passwd ${ISOROOT}/etc.hdd/master.passwd 332.endif # !empty(DPORTS_PACKAGES) 333 334mkiso: 335.if ${WORLD_VERSION} < 600106 336 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi 337 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \ 338 vnconfig -u `cat ${ISODIR}/vn.which`; fi 339 newfs_msdos -C 400k -F 12 -L EFI -m 0xf8 ${ISOROOT}/boot/efiboot.img 340 vnconfig -l | grep "not in use" | head -n 1 | \ 341 cut -f 1 -d: > ${ISODIR}/vn.which 342 vnconfig -e `cat ${ISODIR}/vn.which` ${ISOROOT}/boot/efiboot.img 343 mount_msdos /dev/`cat ${ISODIR}/vn.which` ${IMGMNT} 344 mkdir -p ${IMGMNT}/EFI/BOOT 345 cp ${ISOROOT}/boot/loader.efi ${IMGMNT}/EFI/BOOT/BOOTX64.EFI 346 umount ${IMGMNT} 347.else 348 ( tmpdir=`mktemp -d -t nrelease` && mkdir -p "$${tmpdir}/EFI/BOOT" && \ 349 cp ${ISOROOT}/boot/loader.efi $${tmpdir}/EFI/BOOT/BOOTX64.EFI && \ 350 makefs -t msdos -o fat_type=12 -o sectors_per_cluster=1 \ 351 -o volume_label=EFI -o media_descriptor=248 -s 400k \ 352 ${ISOROOT}/boot/efiboot.img $${tmpdir} && \ 353 rm -rf $${tmpdir} ) 354.endif 355 ( cd ${ISOROOT}; mkisofs -R -J -o ${ISOFILE} \ 356 -b boot/cdboot -no-emul-boot \ 357 -eltorito-alt-boot -eltorito-platform efi \ 358 -eltorito-boot boot/efiboot.img -no-emul-boot \ 359 -V ${LABEL:C/(^.{32}).*/\1/} . ) # cut label to <= 32 characters 360 rm -f ${ISOROOT}/boot/efiboot.img 361 362mkimg: 363 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi 364 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \ 365 vnconfig -u `cat ${ISODIR}/vn.which`; fi 366.ifdef IMGSIZE 367 @echo "STEP: use an image size of ${IMGSIZE} 512-byte sectors" 368 rm -f ${IMGFILE} 369 sz=`bc -e "((${IMGSIZE}) * 512)" -equit`; truncate -s $${sz} ${IMGFILE} 370.else 371 @echo "STEP: Determine required image size in 1GB steps" 372 @echo " Leave ~600MB of unused space" 373 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \ 374 sz=`bc -e "(($${sz}) * 1.15 + 999999 + 600000) / 1000000" -equit | \ 375 cut -f1 -d.`; \ 376 sz=`bc -e "(($${sz}) * 953)" -equit | cut -f1 -d.`; \ 377 rm -f ${IMGFILE}; \ 378 truncate -s $${sz}M ${IMGFILE}; 379.endif 380 @echo "STEP: determine free vn device" 381 vnconfig -l | grep "not in use" | head -n 1 | \ 382 cut -f 1 -d: > ${ISODIR}/vn.which 383 vnconfig -e `cat ${ISODIR}/vn.which` ${IMGFILE} 384 @echo "STEP: set up legacy MBR" 385 fdisk -b ${ISOROOT}/boot/mbr -IB `cat ${ISODIR}/vn.which` 386 fdisk -s `cat ${ISODIR}/vn.which` >${ISODIR}/fdisk.dat 387 awk '(NR==1){printf("g c%s h%s s%s\n", $$2, $$4, $$6);}' \ 388 ${ISODIR}/fdisk.dat >${ISODIR}/fdisk.conf 389 echo "p 1 239 63 257985" >>${ISODIR}/fdisk.conf 390 awk '($$1=="1:"){printf("p 2 108 258048 %lu\n", $$3 - 258528);}' \ 391 ${ISODIR}/fdisk.dat >>${ISODIR}/fdisk.conf 392 echo "a 2" >>${ISODIR}/fdisk.conf 393 fdisk -iv -f ${ISODIR}/fdisk.conf `cat ${ISODIR}/vn.which` 394 rm ${ISODIR}/fdisk.conf ${ISODIR}/fdisk.dat 395 newfs_msdos -F 32 -c 2 -L EFI -m 0xf8 `cat ${ISODIR}/vn.which`s1 396 mount_msdos /dev/`cat ${ISODIR}/vn.which`s1 ${IMGMNT} 397 mkdir -p ${IMGMNT}/EFI/BOOT 398 cp ${ISOROOT}/boot/boot1.efi ${IMGMNT}/EFI/BOOT/BOOTX64.EFI 399 umount ${IMGMNT} 400 @echo "STEP: write standard disklabel" 401 disklabel -w -r `cat ${ISODIR}/vn.which`s2 auto 402 @echo "STEP: read disklabel back" 403 disklabel -r `cat ${ISODIR}/vn.which`s2 > ${IMGFILE}.label 404 @echo "STEP: set disklabel name" 405 echo "label: ${LABEL}" >> ${IMGFILE}.label 406 @echo "STEP: add slice partition" 407 echo "a: * * 4.2BSD" >> ${IMGFILE}.label; 408 @echo "STEP: write modified disklabel back" 409 disklabel -R -r `cat ${ISODIR}/vn.which`s2 ${IMGFILE}.label 410 rm ${IMGFILE}.label 411 disklabel -B -b ${ISOROOT}/boot/boot1_64 -s ${ISOROOT}/boot/boot2_64 \ 412 `cat ${ISODIR}/vn.which`s2 413 newfs /dev/`cat ${ISODIR}/vn.which`s2a 414 mount /dev/`cat ${ISODIR}/vn.which`s2a ${IMGMNT} 415 cpdup ${ISOROOT} ${IMGMNT} 416 @echo "STEP: fixup ${IMGMNT}/etc/fstab" 417 echo "/dev/part-by-label/${LABEL}.a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab 418 echo "dummy /tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab 419 echo "dummy /var/tmp tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab 420 echo "dummy /var/run tmpfs rw,-C 0 0" >> ${IMGMNT}/etc/fstab 421 echo "dummy /usr/obj tmpfs rw 0 0" >> ${IMGMNT}/etc/fstab 422 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab 423 @echo "STEP: fixup ${IMGMNT}/boot/loader.conf" 424 -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new 425 echo 'vfs.root.mountfrom="ufs:part-by-label/${LABEL}.a"' >> ${IMGMNT}/boot/loader.conf.new 426 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf 427 @echo "STEP: create /firstboot" 428 touch ${IMGMNT}/firstboot 429 @echo "STEP: cleanup" 430 df ${IMGMNT} 431 sync 432 sleep 1 433 umount ${IMGMNT} 434 vnconfig -u `cat ${ISODIR}/vn.which` 435 rm -f ${ISODIR}/vn.which 436 rmdir ${IMGMNT} 437 @echo "STEP: done, image files are in ${ISODIR}" 438 439clean: 440 sync 441 sleep 1 442 -umount ${ISOROOT}/usr/distfiles > /dev/null 2>&1 443 -umount ${ISOROOT}/usr/dports > /dev/null 2>&1 444 -umount ${ISOROOT}/dev > /dev/null 2>&1 445 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \ 446 vnconfig -u `cat ${ISODIR}/vn.which`; fi 447 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi 448 rm -rf ${ISOROOT} 449 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which 450 451realclean: clean 452 rm -rf ${ISODIR}/packages 453 rm -rf ${ISODIR}/distfiles 454 455.MAIN: help 456help: 457 @echo "Targets:" 458 @echo " release - full build from scratch" 459 @echo " quick - attempt to do an incremental rebuild" 460 @echo " realquick - attempt to restart after world & kernel" 461 @echo " restartpkgs - attempt to restart at the pkg building stage" 462 @echo "" 463 @echo "Optional targets:" 464 @echo " nopkgs - do not install any packages" 465 @echo " binpkgs - use binary packages with pkg(8)" 466 @echo " gui - do a GUI release" 467 @echo "" 468 @echo "Variables:" 469 @echo " DPORTS_EXTRA_PACKAGES: add additional packages" 470 @echo " GITURL_SRC: override the Git URL to source repository" 471 @echo " GITURL_DPORTS: override the Git URL to dports repository" 472 @echo " IMGSIZE: override the size of .img (in 512-byte sectors)" 473 @echo " NREL_MAKE_JOBS: override the default value (sysctl hw.ncpu)" 474 @echo " PKG_<port>: specify the package name for port <port>" 475 @echo " WITHOUT_SRCS: do not package source code if set" 476 @echo "" 477 478.PHONY: release quickrel realquickrel 479.PHONY: quick realquick 480.PHONY: check buildworld1 buildworld2 481.PHONY: buildkernel1 buildkernel2 buildiso customizeiso mkiso mkimg 482.PHONY: clean realclean help all srcs pkgs 483