1 #########################################################################
3 #########################################################################
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.
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
22 GITHOST_DPORTS?
=mirror-master.dragonflybsd.org
24 MAKE_JOBS?
= $$(sysctl
-n hw.ncpu
)
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"
31 KERNCONF ?
= X86_64_GENERIC
34 CHROOT_CMD?
= /usr
/sbin
/chroot
${ISOROOT} sh
-c
37 # User may specify extra packages in addition to the defaults
39 DPORTS_EXTRA_PACKAGES?
=
41 # dports packages to be built and installed on the release ISO
45 DPORTS_PACKAGES?
= devel
/git \
47 net
/isc-dhcp42-server \
49 ${DPORTS_EXTRA_PACKAGES}
51 # dports options to use when building packages
53 DPORTS_OPTIONS
+= -DBATCH
55 DPORTS_OPTIONS.devel_git
+= -DWITH_GUI
57 DPORTS_OPTIONS.devel_git
+= -DWITHOUT_CONTRIB
-DWITHOUT_PERL
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.
65 REQ_ROOTSKELS
= ${.CURDIR
}/root
66 ROOTSKELS?
= ${REQ_ROOTSKELS}
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
74 # sysutils/idesk dying on link __sync_fetch_and_add_4
76 ISOFILE?
= ${ISODIR}/dfly-gui.iso
77 IMGFILE?
= ${ISODIR}/dfly-gui.img
79 # NOTE: order important, do not sort package list
81 # Apps we want in the gui build but which have problems building:
82 # chat/xchat link error on x86-64, something about ___progname
86 DPORTS_PACKAGES
+= x11
/xorg \
103 x11-fonts
/terminus-font \
109 ROOTSKELS
+= ${.CURDIR
}/gui
112 ISOFILE ?
= ${ISODIR}/dfly.iso
113 IMGFILE ?
= ${ISODIR}/dfly.img
115 IMGMNT ?
= ${ISODIR}/mnt
117 # USB umass now probes starting at da8, so the usb stick is
118 # probably sitting on da8.
122 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
123 # the additional '/nrelease' manually, as a safety measure.
127 #########################################################################
129 #########################################################################
131 release
: check clean buildworld1 buildkernel1 \
132 buildiso srcs customizeiso mkiso mkimg
134 quickrel
: check clean buildworld2 buildkernel2 \
135 buildiso srcs customizeiso mkiso mkimg
137 realquickrel
: check clean \
138 buildiso srcs customizeiso mkiso mkimg
140 restartpkgs
: check customizeiso mkiso mkimg
144 realquick
: realquickrel
147 #########################################################################
148 # CORE SUPPORT TARGETS #
149 #########################################################################
152 .if
!exists
(/usr
/local
/bin
/mkisofs
) && !exists
(/usr
/pkg
/bin
/mkisofs
)
154 @echo
"Your machine does not have cdrtools installed. You can install it with:"
155 @echo
" pkg install cdrtools"
157 @if
[ ! -d
${DPORTS_PATH} ]; then \
158 echo
"${DPORTS_PATH} does not exist."; \
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."; \
165 .if
!exists
(/usr
/local
/bin
/mkisofs
) && !exists
(/usr
/pkg
/bin
/mkisofs
)
168 @echo
"Using ${DPORTS_PATH} as the dports tree."
170 buildworld1 buildworld2
:
172 ${WORLD_CCVER
:C
/^..
*$/WORLD_CCVER
=/}${WORLD_CCVER} \
173 make
-j
${MAKE_JOBS} -DWANT_INSTALLER
${.TARGET
:C
/build
(.
*)2/quick\
1/:C
/1//}
175 buildkernel1 buildkernel2
:
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}; \
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.
188 # Unconditionally clean out ${ISOROOT} so a previous img build
189 # does not blow up a future quick iso build
191 # We install with INSTALLSTRIPPEDMODULES to make things fit into the ISO.
192 # We leave the kernel's debug variables intact.
196 -chflags
-R noschg
${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
205 for kernconf in
${KERNCONF}; do \
206 make DESTDIR
=${ISOROOT} reinstallkernel KERNCONF
=$${kernconf}; \
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.
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
220 # The GUI build includes the ports tree (~1G+) while the nominal release
223 # The GUI build includes full sources while the nominal release build
224 # only includes kernel sources (~27MB).
227 .if
!defined
(WITHOUT_SRCS
)
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.
236 cd
${ISOROOT}/usr
/dports
&& git gc
--aggressive
238 cd
${ISOROOT}/usr
&& make src-create-repo GITHOST
=${GITHOST}
239 # XXX: git gc --aggressive
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
249 # Customize the ISO by copying rootskels in reverse priority order,
250 # building packages, and doing other post-install tasks.
253 # Copy the rootskels. Allow sources to be owned by someone other
254 # than root (as is common when checked out via git).
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
))
261 pwd_mkdb
-p
-d
${ISOROOT}/etc
${ISOROOT}/etc
/master.passwd
262 .for UPGRADE_ITEM in Makefile \
263 etc.
${MACHINE_ARCH} \
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}
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.
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
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.
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
295 # Build and install packages, skip packages already installed
297 .for PKG in
${DPORTS_PACKAGES}
298 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} ${DPORTS_OPTIONS.${PKG:S/\//_/g}} install"
300 .for PKG in
${DPORTS_PACKAGES}
301 ${CHROOT_CMD} "cd /usr/dports/${PKG} && make ${DPORTS_OPTIONS} clean"
304 # Remove packages which nothing depends on, add a whatis database
305 # for dports manual pages, create an initial locate database and
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
318 # Finally, update the locate(8) database
320 ${CHROOT_CMD} /etc
/periodic
/weekly
/310.locate
321 umount
${ISOROOT}/dev
323 # Recopy files that dports may have updated in /etc into /etc.hdd
325 cpdup
${ISOROOT}/etc
/shells
${ISOROOT}/etc.hdd
/shells
326 cpdup
${ISOROOT}/etc
/group
${ISOROOT}/etc.hdd
/group
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`" .
)
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
338 @echo
"STEP: use an image size of ${IMGSIZE} 512-byte sectors"
340 sz
=`bc -e "((${IMGSIZE}) * 512)" -equit`; truncate
-s
$${sz} ${IMGFILE}
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 | \
347 sz
=`bc -e "(($${sz}) * 953)" -equit | cut -f1 -d.`; \
349 truncate
-s
$${sz}M
${IMGFILE};
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
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"
388 vnconfig
-u
`cat ${ISODIR}/vn.which`
389 rm -f
${ISODIR}/vn.which
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
403 rm -rf
${NRLOBJDIR}/nrelease
404 rm -f
${ISODIR}/.didbootstrap
${ISODIR}/vn.which
407 rm -rf
${OBJSYS}/${KERNCONF}
408 rm -rf
${ISODIR}/packages
409 rm -rf
${ISODIR}/distfiles
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"
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)"
422 .PHONY
: release quickrel realquickrel
424 .PHONY
: quick realquick
425 .PHONY
: check buildworld1 buildworld2
426 .PHONY
: buildkernel1 buildkernel2 buildiso customizeiso mkiso mkimg
427 .PHONY
: clean realclean help
all srcs
429 .
include <bsd.prog.mk
>