nrelease - gui build adjustments
[dragonfly.git] / nrelease / Makefile
blob2fca0d82eb6de7e34f5e0867258e9746d87106a3
1 #########################################################################
2 # ENHANCEMENTS #
3 #########################################################################
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.
9 # img is now the default (produces both the .iso and .img)
11 gui installer img:
13 #########################################################################
14 # SETUP #
15 #########################################################################
17 ISODIR?= /usr/release
18 ISOROOT?= ${ISODIR}/root
19 OBJSYS= ${.OBJDIR}/../sys
20 GITHOST?= git.dragonflybsd.org
22 MAKE_JOBS?= $$(sysctl -n hw.ncpu)
24 # temporary until everybody has converted to x86_64
25 .if ${MACHINE_ARCH} == "amd64"
26 MACHINE_ARCH= x86_64
27 .makeenv MACHINE_ARCH
28 .endif
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"
33 KERNCONF ?= GENERIC GENERIC_SMP
34 .else
35 KERNCONF ?= X86_64_GENERIC X86_64_GENERIC_SMP
36 .endif
38 PKGSRC_PREFIX?= /usr/pkg
39 PKGBIN_PKG_ADD?= ${PKGSRC_PREFIX}/sbin/pkg_add
40 PKGBIN_PKG_DELETE?= ${PKGSRC_PREFIX}/sbin/pkg_delete
41 PKGBIN_PKG_ADMIN?= ${PKGSRC_PREFIX}/sbin/pkg_admin
42 PKGBIN_MKISOFS?= ${PKGSRC_PREFIX}/bin/mkisofs
43 PKGSRC_PKG_PATH?= ${ISODIR}/packages
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.
49 CHROOT_CMD?= env -i CCVER=${CCVER:Q} /usr/sbin/chroot ${ISOROOT} sh -c
51 # User may specify extra packages in addition to the defaults
53 PKGSRC_EXTRA_PACKAGES?=
55 # Pkgsrc packages to be built and installed on the release ISO
57 PKGSRC_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}
68 # pkgsrc options to use when building packages
70 PKGSRC_OPTIONS+= MAKE_JOBS=${MAKE_JOBS}
71 PKGSRC_OPTIONS+= WRKOBJDIR=/usr/pkgobj
72 PKGSRC_OPTIONS+= PKG_DEFAULT_OPTIONS='dri inet6'
73 .if !make(gui)
74 PKGSRC_OPTIONS+= PKG_OPTIONS.scmgit=-scmgit-gui
75 .endif
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.
82 OLD_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
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.
103 REQ_ROOTSKELS= ${.CURDIR}/root
104 ROOTSKELS?= ${REQ_ROOTSKELS}
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
113 .if make(gui)
114 ISOFILE?= ${ISODIR}/dfly-gui.iso
115 IMGFILE?= ${ISODIR}/dfly-gui.img
116 PKGSRC_PACKAGES+= meta-pkgs/modular-xorg-apps \
117 meta-pkgs/modular-xorg-drivers \
118 meta-pkgs/modular-xorg-fonts \
119 meta-pkgs/modular-xorg-libs \
120 wm/fluxbox \
121 wm/fvwm \
122 www/firefox \
123 print/xpdf \
124 shells/zsh \
125 editors/emacs \
126 editors/vim \
127 chat/irssi \
128 chat/xchat \
129 x11/modular-xorg-server \
130 x11/eterm \
131 lang/perl5 \
132 editors/nano \
133 shells/bash \
134 devel/exctags \
135 archivers/zip \
136 security/sudo \
137 www/links-gui \
138 net/wget \
139 fonts/terminus-font \
140 net/rsync \
141 time/asclock \
142 misc/screen
143 ROOTSKELS+= ${.CURDIR}/gui
144 .endif
146 ISOFILE ?= ${ISODIR}/dfly.iso
147 IMGFILE ?= ${ISODIR}/dfly.img
149 IMGMNT ?= ${ISODIR}/mnt
151 # USB umass now probes starting at da8, so the usb stick is
152 # probably sitting on da8.
154 IMGUSBDEV ?= da8
156 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
157 # the additional '/nrelease' manually, as a safety measure.
159 NRLOBJDIR?= /usr/obj
161 #########################################################################
162 # BASE ISO TARGETS #
163 #########################################################################
165 release: check clean buildworld1 buildkernel1 \
166 buildiso srcs customizeiso mkiso mkimg
168 quickrel: check clean buildworld2 buildkernel2 \
169 buildiso srcs customizeiso mkiso mkimg
171 realquickrel: check clean \
172 buildiso srcs customizeiso mkiso mkimg
174 restartpkgs: check customizeiso mkiso mkimg
176 quick: quickrel
178 realquick: realquickrel
181 #########################################################################
182 # CORE SUPPORT TARGETS #
183 #########################################################################
185 check:
186 .if !exists(${PKGBIN_PKG_ADMIN})
187 @echo "You never bootstrapped pkgsrc on your machine. You can install it with:"
188 @echo " make pkgsrc_bootstrap"
189 .endif
190 .if !exists (${PKGBIN_MKISOFS})
191 @echo
192 @echo "Your machine does not have cdrtools installed. You can install it with:"
193 @echo " make pkgsrc_cdrecord"
194 .endif
195 .if !defined(PKGSRC_PATH)
196 @echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for"
197 @echo "package building. For example /usr/pkgsrc. See the Makefile"
198 @echo "in /usr if you are unfamiliar with pkgsrc."
199 .endif
200 .if !exists (${PKGBIN_MKISOFS})
201 @exit 1
202 .endif
203 .if !defined(PKGSRC_PATH)
204 @exit 1
205 .endif
207 buildworld1 buildworld2:
208 cd ${.CURDIR}/..; \
209 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
210 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
212 buildkernel1 buildkernel2:
213 cd ${.CURDIR}/..; \
214 first=; \
215 for kernconf in ${KERNCONF}; do \
216 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
217 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
218 KERNCONF=$${kernconf} \
219 first=done; \
220 done
222 # note that we do not want to mess with any /usr/obj directories not related
223 # to buildworld, buildkernel, or nrelease, so we must supply the proper
224 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
225 # buildkernel mechanism.
227 # Unconditionally clean out /usr/release/root so a previous img build
228 # does not blow up a future quick iso build
230 # We install with INSTALLSTRIPPEDMODULES to make things fit into the ISO.
231 # We leave the kernel's debug variables intact.
233 buildiso:
234 -rm -rf ${ISOROOT}
235 -chflags -R noschg ${ISOROOT}
236 rm -rf ${ISOROOT}
237 mkdir -p ${ISOROOT}
238 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
239 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
240 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
241 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
242 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
243 cd ${.CURDIR}/..; \
244 first=; \
245 for kernconf in ${KERNCONF}; do \
246 make DESTDIR=${ISOROOT} installkernel \
247 KERNCONF=$${kernconf} \
248 DESTKERNDIR=/boot/kernel.$${kernconf} \
249 INSTALLSTRIPPEDMODULES=y; \
250 ln -s kernel ${ISOROOT}/boot/kernel.$${kernconf}/kernel.BOOTP; \
251 rm -rf ${ISOROOT}/boot/kernel.$${kernconf}.old; \
252 first=done; \
253 done
254 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
255 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
256 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
258 # The GUI build includes the pkgsrc tree (~1G+) while the nominal release
259 # build does not.
261 # The GUI build includes full sources while the nominal release build
262 # only includes kernel sources (~27MB).
264 srcs:
265 .if !defined(WITHOUT_SRCS)
266 .if make(gui)
267 cd ${ISOROOT}/usr && make pkgsrc-create GITHOST=${GITHOST}
268 cd ${ISOROOT}/usr && make src-create GITHOST=${GITHOST}
269 .else
270 rm -f ${ISOROOT}/usr/src-sys.tgz
271 rm -f ${ISOROOT}/usr/src-sys.tar.bz2
272 cd ${.CURDIR}/.. && tar --exclude .git -s '/^\./src/' \
273 -cf - ./Makefile ./Makefile.inc1 ./sys | \
274 bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2
275 .endif
276 .endif
278 # Customize the ISO by copying rootskels in reverse priority order,
279 # building packages, and doing other post-install tasks.
281 customizeiso:
282 # Copy the rootskels. Allow sources to be owned by someone other
283 # than root (as is common when checked out via git).
285 .for ROOTSKEL in ${ROOTSKELS}
286 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
287 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
288 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
289 .endfor
290 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
291 .for UPGRADE_ITEM in Makefile \
292 etc.${MACHINE_ARCH} \
293 isdn/Makefile \
294 rc.d/Makefile \
295 periodic/Makefile \
296 periodic/daily/Makefile \
297 periodic/security/Makefile \
298 periodic/weekly/Makefile \
299 periodic/monthly/Makefile
300 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
301 .endfor
303 # Setup some things & mount pkgsrc tree. Use defensive umounts and
304 # rm -rf's to allow restarts. Allow /usr/pkgsrc to be read-only.
306 # If we did not get past the bootstrap we clean out the entire
307 # /usr/pkg infrastructure. Otherwise we attempt to pick up where
308 # we left off.
310 cp -p /etc/resolv.conf ${ISOROOT}/etc
311 ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
312 -@umount ${ISOROOT}/usr/pkgsrc/distfiles
313 -@umount ${ISOROOT}/usr/pkgsrc
314 -@umount ${ISOROOT}/dev
315 mkdir -p ${ISODIR}/distfiles
316 rm -rf ${ISOROOT}/usr/pkgobj
318 # Mount /usr/pkgsrc, make sure /usr/pkgsrc/distfiles is writable.
319 # Make /usr/pkgsrc read-only for safety, else a failed umount and
320 # our rm -rf will do bad things.
322 mkdir -p ${ISOROOT}/usr/pkgobj
323 mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap
324 mkdir -p ${ISOROOT}/usr/pkgsrc
325 mount_null -o ro ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc
326 mount_null /dev ${ISOROOT}/dev
327 cp /etc/shells ${ISOROOT}/usr/pkgsrc/distfiles/.test > /dev/null 2>&1 \
328 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/pkgsrc/distfiles
330 # Bootstrap, if not already installed, and add licenses needed
331 # for the gui release
333 test -e ${ISODIR}/.didbootstrap || \
334 rm -rf ${ISOROOT}/usr/pkg ${ISOROOT}/var/db/pkg \
335 ${ISOROOT}/var/db/pkg.refcount
336 test -e ${ISODIR}/.didbootstrap || \
337 ${CHROOT_CMD} "cd /usr/pkgsrc/bootstrap; \
338 export share_dir=/usr/pkgobj/bootstrap/work/share; \
339 ./bootstrap --workdir /usr/pkgobj/bootstrap/work"
340 .if make(gui)
341 test -e ${ISODIR}/.didbootstrap || \
342 echo ".ifdef BSD_PKG_MK # added by nrelease" \
343 >> ${ISOROOT}/usr/pkg/etc/mk.conf
344 test -e ${ISODIR}/.didbootstrap || \
345 echo "ACCEPTABLE_LICENSES+=openmotif-license" \
346 >> ${ISOROOT}/usr/pkg/etc/mk.conf
347 test -e ${ISODIR}/.didbootstrap || \
348 echo "ACCEPTABLE_LICENSES+=vim-license" \
349 >> ${ISOROOT}/usr/pkg/etc/mk.conf
350 test -e ${ISODIR}/.didbootstrap || \
351 echo ".endif # added by nrelease" \
352 >> ${ISOROOT}/usr/pkg/etc/mk.conf
353 .endif
354 test -e ${ISODIR}/.didbootstrap || sync
355 test -e ${ISODIR}/.didbootstrap || touch ${ISODIR}/.didbootstrap
357 # Build and install packages, skip packages already installed
359 .for PKG in ${PKGSRC_PACKAGES}
360 ${CHROOT_CMD} "cd /usr/pkgsrc/${PKG} && \
361 (bmake check > /dev/null 2>&1 || \
362 bmake ${PKGSRC_OPTIONS} clean build install)"
363 .endfor
365 # Remove packages which nothing depends on, add a whatis database
366 # for pkgsrc manual pages, create an initial locate database and
367 # clean up
369 ${CHROOT_CMD} "pkg_leaves | xargs pkg_delete -R"
370 ${CHROOT_CMD} "makewhatis /usr/pkg/man"
371 -umount ${ISOROOT}/usr/pkgsrc/distfiles
372 umount ${ISOROOT}/usr/pkgsrc
373 rm -rf ${ISOROOT}/usr/pkgobj
374 rm -f ${ISOROOT}/etc/resolv.conf
375 ${CHROOT_CMD} /etc/periodic/weekly/310.locate
376 umount ${ISOROOT}/dev
378 # no iso is generated for gui builds, just img.
380 mkiso:
381 .if !make(gui)
382 ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
383 -R -J -o ${ISOFILE} \
384 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
385 .endif
387 mkimg:
388 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
389 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
390 vnconfig -u `cat ${ISODIR}/vn.which`; fi
391 .ifdef IMGSIZE
392 @echo "STEP: use an image size of ${IMGSIZE} 512-byte sectors"
393 rm -f ${IMGFILE}
394 sz=`bc -e "((${IMGSIZE}) * 512)" -equit`; truncate -s $${sz} ${IMGFILE}
395 .else
396 @echo "STEP: determine required image size in 1GB steps"
397 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
398 sz=`bc -e "(($${sz}) * 1.15 + 999999) / 1000000" -equit | \
399 cut -f1 -d.`; \
400 sz=`bc -e "(($${sz}) * 953)" -equit | cut -f1 -d.`; \
401 rm -f ${IMGFILE}; \
402 truncate -s $${sz}M ${IMGFILE};
403 .endif
404 fdisk -IB -p ${IMGFILE}
405 @echo "STEP: determine free vn device"
406 vnconfig -l | grep "not in use" | head -n 1 | \
407 cut -f 1 -d: > ${ISODIR}/vn.which
408 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
409 @echo "STEP: write standard disklabel"
410 disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto
411 @echo "STEP: read disklabel back"
412 disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label
413 @echo "STEP: determine number of sectors of whole disk"
414 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
415 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
416 @echo "STEP: write modified disklabel back"
417 disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label
418 rm ${IMGFILE}.label
419 @echo "STEP: write bootsector"
420 disklabel -B `cat ${ISODIR}/vn.which`s1
421 boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which`
422 newfs /dev/`cat ${ISODIR}/vn.which`s1a
423 mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT}
424 cpdup ${ISOROOT} ${IMGMNT}
425 @echo "STEP: fixup ${IMGMNT}/etc/fstab"
426 echo "/dev/${IMGUSBDEV}s1a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab
427 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab
428 @echo "STEP: fixup ${IMGMNT}/boot/loader.conf"
429 -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new
430 echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s1a"' >> ${IMGMNT}/boot/loader.conf.new
431 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
432 @echo "STEP: cleanup"
433 df ${IMGMNT}
434 umount ${IMGMNT}
435 vnconfig -u `cat ${ISODIR}/vn.which`
436 rm -f ${ISODIR}/vn.which
437 rmdir ${IMGMNT}
438 @echo "STEP: done"
440 clean:
441 -umount ${ISOROOT}/usr/pkgsrc/distfiles > /dev/null 2>&1
442 -umount ${ISOROOT}/usr/pkgsrc > /dev/null 2>&1
443 -umount ${ISOROOT}/dev > /dev/null 2>&1
444 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
445 vnconfig -u `cat ${ISODIR}/vn.which`; fi
446 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
447 rm -rf ${ISOROOT}
448 rm -rf ${NRLOBJDIR}/nrelease
449 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
451 realclean: clean
452 rm -rf ${OBJSYS}/${KERNCONF}
454 # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
455 # override location.
457 rm -rf ${ISODIR}/packages
458 rm -rf ${ISODIR}/distfiles
460 pkgsrc_bootstrap:
461 mkdir -p /usr/release/bootstrap
462 (cd ${PKGSRC_PATH}/bootstrap; \
463 export share_dir=/usr/release/bootstrap/share; \
464 ./bootstrap --workdir /usr/release/bootstrap)
466 pkgsrc_cdrecord:
467 .if !exists (${PKGBIN_MKISOFS})
468 (cd ${PKGSRC_PATH}/sysutils/cdrtools; bmake clean build install)
469 .endif
471 help all:
472 @echo "make [gui] release - complete build from scratch"
473 @echo "make [gui] quick - attempt to do an incremental rebuild"
474 @echo "make [gui] realquick - attempt to restart after world & kernel"
475 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
476 @echo ""
477 @echo "PKGSRC_EXTRA_PACKAGES may be used to add additional pkgs"
478 @echo "GITHOST may be used to override git.dragonflybsd.org"
479 @echo "IMGSIZE may be used to override the .img (in 512-byte sectors)"
481 .PHONY: release quickrel realquickrel
482 .PHONY: installer
483 .PHONY: quick realquick
484 .PHONY: check buildworld1 buildworld2
485 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mkiso mkimg
486 .PHONY: clean realclean help all srcs
488 .include <bsd.prog.mk>