vknetd.8: Document Matt's recent changes to vknetd(8).
[dragonfly.git] / nrelease / Makefile
blob86641e437ce08ea7925fc70fcfe8bf61ee8d9c8d
1 # $DragonFly: src/nrelease/Makefile,v 1.90 2008/09/01 21:20:30 swildner Exp $
4 #########################################################################
5 # ENHANCEMENTS #
6 #########################################################################
8 # New method e.g. 'make gui release'. A series of enhancement
9 # targes may be specified which set make variables which enhance
10 # the build in various ways.
12 gui installer img:
14 #########################################################################
15 # SETUP #
16 #########################################################################
18 ISODIR ?= /usr/release
19 ISOROOT ?= ${ISODIR}/root
20 OBJSYS= ${.OBJDIR}/../sys
22 .if make(gui)
23 KERNCONF ?= DFLYLIVE VKERNEL DFLYLIVE-SMP DFLYLIVE-SMP-NOAPIC
24 .else
25 KERNCONF ?= GENERIC VKERNEL
26 .endif
28 PKGSRC_PREFIX?= /usr/pkg
29 PKGBIN_PKG_ADD?= ${PKGSRC_PREFIX}/sbin/pkg_add
30 PKGBIN_PKG_DELETE?= ${PKGSRC_PREFIX}/sbin/pkg_delete
31 PKGBIN_PKG_ADMIN?= ${PKGSRC_PREFIX}/sbin/pkg_admin
32 PKGBIN_MKISOFS?= ${PKGSRC_PREFIX}/bin/mkisofs
33 PKGSRC_PKG_PATH?= ${ISODIR}/packages
34 PKGSRC_DB?= /var/db/pkg
35 PKGSRC_BOOTSTRAP_URL?= http://pkgbox.dragonflybsd.org/DragonFly-pkgsrc-packages/i386/1.12.0-RELEASE-BUILD
36 CVSUP_BOOTSTRAP_KIT?= cvsup-bootstrap-20070716
38 # We use env -i in the chroot, so that environment variables won't
39 # disturb any (pkgsrc) build. This has happened for TARGET_ARCH,
40 # which is used by gmake in completely different context.
42 CHROOT_CMD?= env -i CCVER=${CCVER:Q} /usr/sbin/chroot ${ISOROOT} sh -c
44 # User may specify extra packages in addition to the defaults
46 PKGSRC_EXTRA_PACKAGES?=
48 # Pkgsrc packages to be built and installed on the release ISO
50 PKGSRC_PACKAGES?= pkgtools/pkg_leaves \
51 pkgtools/pkg_tarup \
52 devel/scmgit \
53 net/isc-dhcp4 \
54 net/isc-dhcpd4 \
55 sysutils/cdrtools \
56 ${PKGSRC_EXTRA_PACKAGES}
58 # pkgsrc options to use when building packages
60 .if !make(gui)
61 PKGSRC_OPTIONS?= PKG_OPTIONS.scmgit=-scmgit-gui
62 .endif
64 # Even though buildiso wipes the packages, our check target has to run
65 # first and old packages (listed as they appear in pkg_info) must be
66 # cleaned out in order for the pkg_add -n test we use in the check target
67 # to operate properly.
69 OLD_PKGSRC_PACKAGES?= cdrtools-2.01.01.27nb1 \
70 cdrecord-2.00.3nb2 \
71 bootstrap-kit-20070205 \
72 dfuibe_installer-1.1.6 \
73 gettext-lib-0.14.5 \
74 dfuibe_installer-1.1.7nb1 \
75 dfuife_curses-1.5 \
76 gettext-lib-0.14.6 \
77 gettext-tools-0.14.6nb1 \
78 libaura-3.1 \
79 libdfui-4.2 \
80 libinstaller-5.1 \
81 bootstrap-kit-20080211 \
82 cdrtools-ossdvd-2.01.1.36nb2 \
83 isc-dhcp-base-4.0.0 \
84 isc-dhcp-server-4.0.0
86 # Specify which root skeletons are required, and let the user include
87 # their own. They are copied into ISODIR during the `customizeiso'
88 # target; each overwrites the last.
90 REQ_ROOTSKELS= ${.CURDIR}/root \
91 ${.CURDIR}/installer
92 ROOTSKELS?= ${REQ_ROOTSKELS}
94 .if make(gui)
95 ISOFILE?= ${ISODIR}/dfly-gui.iso
96 IMGFILE?= ${ISODIR}/dfly-gui.img
97 PKGSRC_PACKAGES+= meta-pkgs/modular-xorg-apps \
98 meta-pkgs/modular-xorg-drivers \
99 meta-pkgs/modular-xorg-fonts \
100 meta-pkgs/modular-xorg-libs \
101 wm/fluxbox \
102 wm/fvwm \
103 www/firefox3 \
104 print/xpdf \
105 shells/zsh \
106 editors/emacs \
107 editors/vim \
108 chat/pidgin \
109 chat/irssi \
110 chat/xchat \
111 x11/modular-xorg-server \
112 x11/rxvt-unicode \
113 x11/eterm \
114 lang/perl5 \
115 editors/nano \
116 shells/bash \
117 devel/exctags \
118 archivers/zip \
119 security/sudo \
120 www/links-gui \
121 net/nmap \
122 net/wget \
123 fonts/terminus-font \
124 net/rsync \
125 sysutils/idesk \
126 time/asclock \
127 misc/screen
128 ROOTSKELS+= ${.CURDIR}/gui
129 .endif
131 ISOFILE ?= ${ISODIR}/dfly.iso
132 IMGFILE ?= ${ISODIR}/dfly.img
134 IMGMNT ?= ${ISODIR}/mnt
135 IMGUSBDEV ?= /dev/da0
137 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
138 # the additional '/nrelease' manually, as a safety measure.
140 NRLOBJDIR?= /usr/obj
142 #########################################################################
143 # BASE ISO TARGETS #
144 #########################################################################
146 release: check clean buildworld1 buildkernel1 \
147 buildiso srcs customizeiso mklocatedb \
148 mkiso mkimg
150 quickrel: check clean buildworld2 buildkernel2 \
151 buildiso srcs customizeiso mklocatedb \
152 mkiso mkimg
154 realquickrel: check clean \
155 buildiso srcs customizeiso mklocatedb \
156 mkiso mkimg
158 restartpkgs: check customizeiso mklocatedb mkiso mkimg
160 quick: quickrel
162 realquick: realquickrel
165 #########################################################################
166 # CORE SUPPORT TARGETS #
167 #########################################################################
169 check:
170 .if !exists(${PKGBIN_PKG_ADMIN})
171 @echo "You never bootstrapped pkgsrc on your machine. You can install it with:"
172 @echo " make pkgsrc_bootstrap"
173 .endif
174 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
175 @echo "The cvsup bootstrap kit is not installed. You can install it with:"
176 @echo " make fetch"
177 .endif
178 .if !exists (${PKGBIN_MKISOFS})
179 @echo
180 @echo "Your machine does not have cdrtools installed. You can install it with:"
181 @echo " make pkgsrc_cdrecord"
182 .endif
183 .if !defined(PKGSRC_PATH)
184 @echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for"
185 @echo "package building. For example /usr/pkgsrc. See the Makefile"
186 @echo "in /usr if you are unfamiliar with pkgsrc."
187 .endif
188 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
189 @exit 1
190 .endif
191 .if !exists (${PKGBIN_MKISOFS})
192 @exit 1
193 .endif
194 .if !defined(PKGSRC_PATH)
195 @exit 1
196 .endif
198 buildworld1 buildworld2:
199 cd ${.CURDIR}/..; ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} make -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
201 buildkernel1 buildkernel2:
202 .if make(gui)
203 cd ${.CURDIR}/..; \
204 for kernconf in ${KERNCONF}; do \
205 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
206 make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
207 KERNCONF=$${kernconf} KERNCONFDIR=${.CURDIR}/gui/root; \
208 done
209 .else
210 cd ${.CURDIR}/..; \
211 first=; \
212 for kernconf in ${KERNCONF}; do \
213 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
214 make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
215 KERNCONF=$${kernconf} \
216 $${first:+-DNO_MODULES}; \
217 first=done; \
218 done
219 .endif
221 # note that we do not want to mess with any /usr/obj directories not related
222 # to buildworld, buildkernel, or nrelease, so we must supply the proper
223 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
224 # buildkernel mechanism.
226 buildiso:
227 if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
228 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
229 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
230 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
231 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
232 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
233 .if make(gui)
234 if [ ! -d ${ISOROOT}/kernel.smp/boot ]; then mkdir -p ${ISOROOT}/kernel.smp/boot; fi
235 cd ${.CURDIR}/..; \
236 make installkernel DESTDIR=${ISOROOT} \
237 KERNCONF=DFLYLIVE DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
238 cd ${.CURDIR}/..; \
239 make installkernel DESTDIR=${ISOROOT} \
240 KERNCONF=VKERNEL DESTKERNNAME=kernel.VKERNEL -DNO_MODULES KERNCONFDIR=${.CURDIR}/gui/root; \
241 cd ${.CURDIR}/..; \
242 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
243 KERNCONF=DFLYLIVE-SMP DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
244 cd ${.CURDIR}/..; \
245 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
246 KERNCONF=DFLYLIVE-SMP-NOAPIC DESTKERNNAME=kernel.noapic \
247 KERNCONFDIR=${.CURDIR}/gui/root -DNO_MODULES;
248 .else
249 cd ${.CURDIR}/..; \
250 first=; \
251 for kernconf in ${KERNCONF}; do \
252 make DESTDIR=${ISOROOT} \
253 installkernel KERNCONF=$${kernconf} \
254 $${first:+DESTKERNNAME=kernel.$${kernconf}} \
255 $${first:+-DNO_MODULES}; \
256 first=done; \
257 done
258 .endif
259 ln -s kernel ${ISOROOT}/boot/kernel.BOOTP
260 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
261 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
262 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
264 # Release CD: Kernel sources (~16M) and the full pkgsrc tree (~27M)
265 # Release DVD: Full sources (~90M) and the full pkgsrc tree (~27M)
267 srcs:
268 .if !defined(WITHOUT_SRCS)
269 rm -f ${ISOROOT}/usr/pkgsrc-all.tgz
270 cd ${PKGSRC_PATH} && tar --exclude distfiles --exclude packages --exclude work --exclude CVS --exclude .git \
271 -czf ${ISOROOT}/usr/pkgsrc-all.tgz .
272 .if make(gui)
273 rm -f ${ISOROOT}/usr/src-all.tgz
274 cd ${.CURDIR}/../.. && tar --exclude .git --exclude CVS \
275 -czf ${ISOROOT}/usr/src-all.tgz src
276 .else
277 rm -f ${ISOROOT}/usr/src-sys.tgz
278 cd ${.CURDIR}/../.. && tar --exclude .git --exclude CVS \
279 -czf ${ISOROOT}/usr/src-sys.tgz src/Makefile src/Makefile.inc1 src/sys
280 .endif
281 .endif
283 # Customize the ISO by copying rootskels in reverse priority order,
284 # building packages, and doing other post-install tasks.
286 customizeiso:
287 # Copy the rootskels. Allow sources to be owned by someone other
288 # then root (as is common when checked out via git).
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 (cd ${PKGSRC_PKG_PATH}; tar xzpf ${CVSUP_BOOTSTRAP_KIT}.tgz)
296 cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/bin/cvsup ${ISOROOT}/usr/local/bin/cvsup
297 cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/man/man1/cvsup.1 ${ISOROOT}/usr/local/man/man1/cvsup.1
298 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
299 .for UPGRADE_ITEM in Makefile \
300 etc.${MACHINE_ARCH} \
301 isdn/Makefile \
302 rc.d/Makefile \
303 periodic/Makefile \
304 periodic/daily/Makefile \
305 periodic/security/Makefile \
306 periodic/weekly/Makefile \
307 periodic/monthly/Makefile
308 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
309 .endfor
311 # Setup some things & mount pkgsrc tree. Use defensive umounts and
312 # rm -rf's to allow restarts. Allow /usr/pkgsrc to be read-only.
314 # If we did not get past the bootstrap we clean out the entire
315 # /usr/pkg infrastructure. Otherwise we attempt to pick up where
316 # we left off.
318 cp -p /etc/resolv.conf ${ISOROOT}/etc
319 ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
320 -@umount ${ISOROOT}/usr/pkgsrc/distfiles
321 -@umount ${ISOROOT}/usr/pkgsrc
322 mkdir -p ${ISODIR}/distfiles
323 rm -rf ${ISOROOT}/usr/pkgobj
325 # Mount /usr/pkgsrc, make sure /usr/pkgsrc/distfiles is writable
327 mkdir -p ${ISOROOT}/usr/pkgobj
328 mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap/work
329 mkdir -p ${ISOROOT}/usr/pkgsrc
330 mount_null ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc
331 cp /etc/shells ${ISOROOT}/usr/pkgsrc/distfiles/.test > /dev/null 2>&1 \
332 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/pkgsrc/distfiles
334 # Bootstrap, if not already installed, and add licenses needed
335 # for the gui release
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 ./bootstrap --workdir /usr/pkgobj/bootstrap/work"
343 test -e ${ISODIR}/.didbootstrap || \
344 echo ".ifdef BSD_PKG_MK # added by nrelease" \
345 >> ${ISOROOT}/usr/pkg/etc/mk.conf
346 test -e ${ISODIR}/.didbootstrap || \
347 echo "ACCEPTABLE_LICENSES+=openmotif-license" \
348 >> ${ISOROOT}/usr/pkg/etc/mk.conf
349 test -e ${ISODIR}/.didbootstrap || \
350 echo "ACCEPTABLE_LICENSES+=vim-license" \
351 >> ${ISOROOT}/usr/pkg/etc/mk.conf
352 test -e ${ISODIR}/.didbootstrap || \
353 echo ".endif # added by nrelease" \
354 >> ${ISOROOT}/usr/pkg/etc/mk.conf
355 test -e ${ISODIR}/.didbootstrap || sync
356 test -e ${ISODIR}/.didbootstrap || touch ${ISODIR}/.didbootstrap
358 # Build and install packages, skip packages already installed
360 .for PKG in ${PKGSRC_PACKAGES}
361 ${CHROOT_CMD} "cd /usr/pkgsrc/${PKG} && \
362 (bmake WRKOBJDIR=/usr/pkgobj check > /dev/null 2>&1 || \
363 bmake WRKOBJDIR=/usr/pkgobj ${PKGSRC_OPTIONS} clean build install)"
364 .endfor
366 # Remove packages which nothing depends on and clean up
368 ${CHROOT_CMD} "pkg_leaves | xargs pkg_delete -R"
369 -umount ${ISOROOT}/usr/pkgsrc/distfiles
370 umount ${ISOROOT}/usr/pkgsrc
371 rmdir ${ISOROOT}/usr/pkgsrc
372 rm -rf ${ISOROOT}/usr/pkgobj
373 rm -f ${ISOROOT}/etc/resolv.conf
374 makewhatis ${ISOROOT}/usr/local/man
375 makewhatis ${ISOROOT}/usr/pkg/man
377 # So locate works
379 mklocatedb:
380 ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
381 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
382 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
383 /usr/libexec/locate.mklocatedb \
384 -presort >${ISOROOT}/var/db/locate.database )
386 mkiso:
387 ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
388 -R -J -o ${ISOFILE} \
389 -V DragonFly-`${.CURDIR}/../tools/gitrev.sh | cut -c -22` . )
392 mkimg:
393 .if make(img)
394 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
396 echo "determine required image size" > /dev/null; \
397 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
398 echo "add 15% more space as required" > /dev/null; \
399 sz=`bc -e "(($${sz}) / 1024) * 1.15" -equit | cut -f1 -d.`; \
400 dd if=/dev/zero of=${IMGFILE} bs=1m count=$${sz}; \
401 fdisk -IB -p ${IMGFILE}; \
402 echo "determine free vn device" > /dev/null; \
403 vn=`vnconfig -l | grep "not in use" | head -n 1 | cut -f 1 -d:`; \
404 vnconfig -e -s labels $${vn} ${IMGFILE}; \
405 echo "write standard disklabel" > /dev/null; \
406 disklabel -w -r $${vn}s1 auto; \
407 echo "read disklabel back" > /dev/null; \
408 disklabel -r $${vn}s1 > ${IMGFILE}.label; \
409 echo "determine number of sectors of whole disk" > /dev/null; \
410 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
411 echo "and add a: partition" > /dev/null; \
412 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label; \
413 echo "write modified disklabel back" > /dev/null; \
414 disklabel -R -r $${vn}s1 ${IMGFILE}.label; \
415 rm ${IMGFILE}.label; \
416 echo "write bootsector" > /dev/null; \
417 disklabel -B $${vn}s1; \
418 newfs /dev/$${vn}s1a; \
419 mount /dev/$${vn}s1a ${IMGMNT}; \
420 cpdup -vvv ${ISOROOT} ${IMGMNT}; \
421 echo "fix /etc/fstab" > /dev/null; \
422 echo "${IMGUSBDEV}s1a / ufs rw 0 0" > ${IMGMNT}/etc/fstab; \
423 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab; \
424 df ${IMGMNT}; \
425 umount ${IMGMNT}; \
426 vnconfig -u $${vn}; \
427 rmdir ${IMGMNT}
428 .endif
430 clean:
431 -umount ${ISOROOT}/usr/pkgsrc/distfiles > /dev/null 2>&1
432 -umount ${ISOROOT}/usr/pkgsrc > /dev/null 2>&1
433 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
434 rm -rf ${ISOROOT}
435 rm -rf ${NRLOBJDIR}/nrelease
436 rm -f ${ISODIR}/.didbootstrap
438 realclean: clean
439 rm -rf ${OBJSYS}/${KERNCONF}
441 # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
442 # override location.
444 rm -rf ${ISODIR}/packages
445 rm -rf ${ISODIR}/distfiles
447 fetch:
448 @if [ ! -d ${PKGSRC_PKG_PATH} ]; then mkdir -p ${PKGSRC_PKG_PATH}; fi
449 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
450 (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${CVSUP_BOOTSTRAP_KIT}.tgz)
451 .endif
453 pkgsrc_bootstrap:
454 .if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
455 mkdir -p /usr/release/bootstrap
456 (cd ${PKGSRC_PATH}/bootstrap; ./bootstrap --workdir /usr/release/bootstrap)
457 .endif
459 pkgsrc_cdrecord:
460 .if !exists (${PKGBIN_MKISOFS})
461 (cd ${PKGSRC_PATH}/sysutils/cdrtools; bmake clean build install)
462 .endif
464 help all:
465 @echo "make [gui] release - complete build from scratch"
466 @echo "make [gui] quick - attempt to do an incremental rebuild"
467 @echo "make [gui] realquick - attempt to restart after world & kernel"
468 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
469 @echo ""
470 @echo "Extra packages may be specified with PKGSRC_EXTRA_PACKAGES"
472 .PHONY: release quickrel realquickrel
473 .PHONY: installer
474 .PHONY: quick realquick
475 .PHONY: check buildworld1 buildworld2
476 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso mkimg
477 .PHONY: clean realclean fetch help all srcs
479 .include <bsd.prog.mk>