Adjust the ${ISODIR}/.didbootstrap logic a little, add needed licenses.
[dragonfly.git] / nrelease / Makefile
blobb35caf83456acc7e0d6b402d10e7f521446b31c1
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.
41 CHROOT_CMD?= env -i CCVER=${CCVER:Q} /usr/sbin/chroot ${ISOROOT} sh -c
43 # User may specify extra packages in addition to the defaults
45 PKGSRC_EXTRA_PACKAGES?=
47 # Pkgsrc packages to be built and installed on the release ISO
49 PKGSRC_PACKAGES?= pkgtools/pkg_leaves \
50 pkgtools/pkg_tarup \
51 devel/scmgit \
52 net/isc-dhcp4 \
53 net/isc-dhcpd4 \
54 sysutils/cdrtools \
55 ${PKGSRC_EXTRA_PACKAGES}
57 # pkgsrc options to use when building packages
59 .if !make(gui)
60 PKGSRC_OPTIONS?= PKG_OPTIONS.scmgit=-scmgit-gui
61 .endif
63 # Even though buildiso wipes the packages, our check target has to run
64 # first and old packages (listed as they appear in pkg_info) must be
65 # cleaned out in order for the pkg_add -n test we use in the check target
66 # to operate properly.
68 OLD_PKGSRC_PACKAGES?= cdrtools-2.01.01.27nb1 \
69 cdrecord-2.00.3nb2 \
70 bootstrap-kit-20070205 \
71 dfuibe_installer-1.1.6 \
72 gettext-lib-0.14.5 \
73 dfuibe_installer-1.1.7nb1 \
74 dfuife_curses-1.5 \
75 gettext-lib-0.14.6 \
76 gettext-tools-0.14.6nb1 \
77 libaura-3.1 \
78 libdfui-4.2 \
79 libinstaller-5.1 \
80 bootstrap-kit-20080211 \
81 cdrtools-ossdvd-2.01.1.36nb2 \
82 isc-dhcp-base-4.0.0 \
83 isc-dhcp-server-4.0.0
85 # Specify which root skeletons are required, and let the user include
86 # their own. They are copied into ISODIR during the `pkgcustomizeiso'
87 # target; each overwrites the last.
89 REQ_ROOTSKELS= ${.CURDIR}/root \
90 ${.CURDIR}/installer
91 ROOTSKELS?= ${REQ_ROOTSKELS}
93 .if make(gui)
94 ISOFILE?= ${ISODIR}/dfly-gui.iso
95 IMGFILE?= ${ISODIR}/dfly-gui.img
96 PKGSRC_PACKAGES+= meta-pkgs/modular-xorg-apps \
97 meta-pkgs/modular-xorg-drivers \
98 meta-pkgs/modular-xorg-fonts \
99 meta-pkgs/modular-xorg-libs \
100 wm/fluxbox \
101 wm/fvwm \
102 www/firefox3 \
103 print/xpdf \
104 shells/zsh \
105 editors/emacs \
106 editors/vim \
107 chat/pidgin \
108 chat/irssi \
109 chat/xchat \
110 x11/modular-xorg-server \
111 x11/rxvt-unicode \
112 x11/eterm \
113 lang/perl5 \
114 editors/nano \
115 shells/bash \
116 devel/exctags \
117 archivers/zip \
118 security/sudo \
119 www/links-gui \
120 net/nmap \
121 net/wget \
122 fonts/terminus-font \
123 net/rsync \
124 sysutils/idesk \
125 time/asclock \
126 misc/screen
127 ROOTSKELS+= ${.CURDIR}/gui
128 .endif
130 ISOFILE ?= ${ISODIR}/dfly.iso
131 IMGFILE ?= ${ISODIR}/dfly.img
133 IMGMNT ?= ${ISODIR}/mnt
134 IMGUSBDEV ?= /dev/da0
136 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
137 # the additional '/nrelease' manually, as a safety measure.
139 NRLOBJDIR?= /usr/obj
141 #########################################################################
142 # BASE ISO TARGETS #
143 #########################################################################
145 release: check clean buildworld1 buildkernel1 \
146 buildiso syssrcs customizeiso mkaliases mklocatedb \
147 mkiso mkimg
149 quickrel: check clean buildworld2 buildkernel2 \
150 buildiso syssrcs customizeiso mkaliases mklocatedb \
151 mkiso mkimg
153 realquickrel: check clean buildiso syssrcs customizeiso \
154 mkaliases mklocatedb \
155 mkiso mkimg
157 quick: quickrel
159 realquick: realquickrel
161 #########################################################################
162 # CORE SUPPORT TARGETS #
163 #########################################################################
165 check:
166 .if !exists(${PKGBIN_PKG_ADMIN})
167 @echo "You never bootstrapped pkgsrc on your machine. You can install it with:"
168 @echo " make pkgsrc_bootstrap"
169 .endif
170 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
171 @echo "The cvsup bootstrap kit is not installed. You can install it with:"
172 @echo " make fetch"
173 .endif
174 .if !exists (${PKGBIN_MKISOFS})
175 @echo
176 @echo "Your machine does not have cdrtools installed. You can install it with:"
177 @echo " make pkgsrc_cdrecord"
178 .endif
179 .if !defined(PKGSRC_PATH)
180 @echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for"
181 @echo "package building."
182 .endif
183 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
184 @exit 1
185 .endif
186 .if !exists (${PKGBIN_MKISOFS})
187 @exit 1
188 .endif
189 .if !defined(PKGSRC_PATH)
190 @exit 1
191 .endif
193 buildworld1 buildworld2:
194 cd ${.CURDIR}/..; ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} make -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
196 buildkernel1 buildkernel2:
197 .if make(gui)
198 cd ${.CURDIR}/..; \
199 for kernconf in ${KERNCONF}; do \
200 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
201 make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
202 KERNCONF=$${kernconf} KERNCONFDIR=${.CURDIR}/gui/root; \
203 done
204 .else
205 cd ${.CURDIR}/..; \
206 first=; \
207 for kernconf in ${KERNCONF}; do \
208 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
209 make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
210 KERNCONF=$${kernconf} \
211 $${first:+-DNO_MODULES}; \
212 first=done; \
213 done
214 .endif
216 # note that we do not want to mess with any /usr/obj directories not related
217 # to buildworld, buildkernel, or nrelease, so we must supply the proper
218 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
219 # buildkernel mechanism.
221 buildiso:
222 if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
223 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
224 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
225 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
226 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
227 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
228 .if make(gui)
229 if [ ! -d ${ISOROOT}/kernel.smp/boot ]; then mkdir -p ${ISOROOT}/kernel.smp/boot; fi
230 cd ${.CURDIR}/..; \
231 make installkernel DESTDIR=${ISOROOT} \
232 KERNCONF=DFLYLIVE DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
233 cd ${.CURDIR}/..; \
234 make installkernel DESTDIR=${ISOROOT} \
235 KERNCONF=VKERNEL DESTKERNNAME=kernel.VKERNEL -DNO_MODULES KERNCONFDIR=${.CURDIR}/gui/root; \
236 cd ${.CURDIR}/..; \
237 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
238 KERNCONF=DFLYLIVE-SMP DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
239 cd ${.CURDIR}/..; \
240 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
241 KERNCONF=DFLYLIVE-SMP-NOAPIC DESTKERNNAME=kernel.noapic \
242 KERNCONFDIR=${.CURDIR}/gui/root -DNO_MODULES;
243 .else
244 cd ${.CURDIR}/..; \
245 first=; \
246 for kernconf in ${KERNCONF}; do \
247 make DESTDIR=${ISOROOT} \
248 installkernel KERNCONF=$${kernconf} \
249 $${first:+DESTKERNNAME=kernel.$${kernconf}} \
250 $${first:+-DNO_MODULES}; \
251 first=done; \
252 done
253 .endif
254 ln -s kernel ${ISOROOT}/kernel.BOOTP
255 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
256 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
257 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
259 # Include kernel sources on the release CD (~14MB)
261 syssrcs:
262 .if !defined(WITHOUT_SRCS)
263 ( cd ${.CURDIR}/../..; tar -cf - src/Makefile src/Makefile.inc1 src/sys | bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2 )
264 .endif
266 customizeiso:
267 .for ROOTSKEL in ${ROOTSKELS}
268 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
269 .endfor
270 (cd ${PKGSRC_PKG_PATH}; tar xzpf ${CVSUP_BOOTSTRAP_KIT}.tgz)
271 cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/bin/cvsup ${ISOROOT}/usr/local/bin/cvsup
272 cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/man/man1/cvsup.1 ${ISOROOT}/usr/local/man/man1/cvsup.1
273 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
274 .for UPGRADE_ITEM in Makefile \
275 etc.${MACHINE_ARCH} \
276 isdn/Makefile \
277 rc.d/Makefile \
278 periodic/Makefile \
279 periodic/daily/Makefile \
280 periodic/security/Makefile \
281 periodic/weekly/Makefile \
282 periodic/monthly/Makefile
283 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
284 .endfor
286 # Setup some things & mount pkgsrc tree. Use defensive umounts and
287 # rm -rf's to allow restarts. Allow /usr/pkgsrc to be read-only.
289 # If we did not get past the bootstrap we clean out the entire
290 # /usr/pkg infrastructure. Otherwise we attempt to pick up where
291 # we left off.
293 cp -p /etc/resolv.conf ${ISOROOT}/etc
294 ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
295 -@umount ${ISOROOT}/usr/pkgsrc/distfiles
296 -@umount ${ISOROOT}/usr/pkgsrc
297 mkdir -p ${ISODIR}/distfiles
298 rm -rf ${ISOROOT}/usr/pkgobj
299 test -e ${ISODIR}/.didbootstrap || \
300 rm -rf ${ISOROOT}/usr/pkg ${ISOROOT}/var/db/pkg \
301 ${ISOROOT}/var/db/pkg.refcount
303 # Mount /usr/pkgsrc, make sure /usr/pkgsrc/distfiles is writable
305 mkdir -p ${ISOROOT}/usr/pkgobj
306 mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap/work
307 mkdir -p ${ISOROOT}/usr/pkgsrc
308 mount_null ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc
309 cp /etc/shells ${ISOROOT}/usr/pkgsrc/distfiles/.test || \
310 mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/pkgsrc/distfiles
312 # Bootstrap, if not already installed, and added licenses needed
313 # for the gui release
315 .if !exists (${ISODIR}/.didbootstrap)
316 ${CHROOT_CMD} "cd /usr/pkgsrc/bootstrap; \
317 ./bootstrap --workdir /usr/pkgobj/bootstrap/work"
318 echo ".ifdef BSD_PKG_MK # added by nrelease" \
319 >> ${ISOROOT}/usr/pkg/etc/mk.conf
320 echo "ACCEPTABLE_LICENSES+=openmotif-license" \
321 >> ${ISOROOT}/usr/pkg/etc/mk.conf
322 echo "ACCEPTABLE_LICENSES+=vim-license" \
323 >> ${ISOROOT}/usr/pkg/etc/mk.conf
324 echo ".endif # added by nrelease" \
325 >> ${ISOROOT}/usr/pkg/etc/mk.conf
326 sync
327 touch ${ISODIR}/.didbootstrap
328 .endif
330 # Build and install packages, skip packages already installed
332 .for PKG in ${PKGSRC_PACKAGES}
333 ${CHROOT_CMD} "cd /usr/pkgsrc/${PKG} && \
334 (bmake WRKOBJDIR=/usr/pkgobj check > /dev/null 2>&1 || \
335 bmake WRKOBJDIR=/usr/pkgobj ${PKGSRC_OPTIONS} clean build install)"
336 .endfor
338 # Remove packages which nothing depends on and clean up
340 ${CHROOT_CMD} "pkg_leaves | xargs pkg_delete -R"
341 -umount ${ISOROOT}/usr/pkgsrc/distfiles
342 umount ${ISOROOT}/usr/pkgsrc
343 rmdir ${ISOROOT}/usr/pkgsrc
344 rm -rf ${ISOROOT}/usr/pkgobj
345 rm -f ${ISOROOT}/etc/resolv.conf
346 makewhatis ${ISOROOT}/usr/local/man
347 makewhatis ${ISOROOT}/usr/pkg/man
349 # So a CD boot does not complain about a missing aliases database
351 mkaliases:
352 ${CHROOT_CMD} "newaliases"
354 # So locate works
356 mklocatedb:
357 ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
358 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
359 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
360 /usr/libexec/locate.mklocatedb \
361 -presort >${ISOROOT}/var/db/locate.database )
363 mkiso:
364 ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
365 -R -J -o ${ISOFILE} \
366 -V DragonFly-`${.CURDIR}/../tools/gitrev.sh | cut -c -22` . )
369 mkimg:
370 .if make(img)
371 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
373 echo "determine required image size" > /dev/null; \
374 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
375 echo "add 15% more space as required" > /dev/null; \
376 sz=`bc -e "(($${sz}) / 1024) * 1.15" -equit | cut -f1 -d.`; \
377 dd if=/dev/zero of=${IMGFILE} bs=1m count=$${sz}; \
378 fdisk -IB -p ${IMGFILE}; \
379 echo "determine free vn device" > /dev/null; \
380 vn=`vnconfig -l | grep "not in use" | head -n 1 | cut -f 1 -d:`; \
381 vnconfig -e -s labels $${vn} ${IMGFILE}; \
382 echo "write standard disklabel" > /dev/null; \
383 disklabel -w -r $${vn}s1 auto; \
384 echo "read disklabel back" > /dev/null; \
385 disklabel -r $${vn}s1 > ${IMGFILE}.label; \
386 echo "determine number of sectors of whole disk" > /dev/null; \
387 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
388 echo "and add a: partition" > /dev/null; \
389 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label; \
390 echo "write modified disklabel back" > /dev/null; \
391 disklabel -R -r $${vn}s1 ${IMGFILE}.label; \
392 rm ${IMGFILE}.label; \
393 echo "write bootsector" > /dev/null; \
394 disklabel -B $${vn}s1; \
395 newfs /dev/$${vn}s1a; \
396 mount /dev/$${vn}s1a ${IMGMNT}; \
397 cpdup -vvv ${ISOROOT} ${IMGMNT}; \
398 echo "fix /etc/fstab" > /dev/null; \
399 echo "${IMGUSBDEV}s1a / ufs rw 0 0" > ${IMGMNT}/etc/fstab; \
400 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab; \
401 df ${IMGMNT}; \
402 umount ${IMGMNT}; \
403 vnconfig -u $${vn}; \
404 rmdir ${IMGMNT}
405 .endif
407 clean:
408 -umount ${ISOROOT}/usr/pkgsrc/distfiles
409 -umount ${ISOROOT}/usr/pkgsrc
410 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
411 if [ -d ${ISOROOT} ]; then rm -rf ${ISOROOT}/*; fi
412 if [ -d ${NRLOBJDIR}/nrelease ]; then rm -rf ${NRLOBJDIR}/nrelease; fi
413 rm -f ${ISODIR}/.didbootstrap
415 realclean: clean
416 rm -rf ${OBJSYS}/${KERNCONF}
418 # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
419 # override location.
421 if [ -d ${ISODIR}/packages ]; then rm -rf ${ISODIR}/packages; fi
423 fetch:
424 @if [ ! -d ${PKGSRC_PKG_PATH} ]; then mkdir -p ${PKGSRC_PKG_PATH}; fi
425 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
426 (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${CVSUP_BOOTSTRAP_KIT}.tgz)
427 .endif
429 pkgsrc_bootstrap:
430 .if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
431 mkdir -p /usr/release/bootstrap
432 (cd ${PKGSRC_PATH}/bootstrap; ./bootstrap --workdir /usr/release/bootstrap)
433 .endif
435 pkgsrc_cdrecord:
436 .if !exists (${PKGBIN_MKISOFS})
437 (cd ${PKGSRC_PATH}/sysutils/cdrtools; bmake clean build install)
438 .endif
440 help:
441 @echo "make release - complete build from scratch"
442 @echo "make quick - attempt to do an incremental rebuild"
443 @echo "make realquick - attempt to restart after world & kernel"
444 @echo ""
445 @echo "If the main build works but customizeiso fails you can restart"
446 @echo "at the customize iso step with:"
447 @echo ""
448 @echo "make customizeiso mkaliases mklocatedb mkiso mkimg"
449 @echo ""
450 @echo "Extra packages may be specified with PKGSRC_EXTRA_PACKAGES"
452 .PHONY: all release installer_release quickrel installer_quickrel realquickrel
453 .PHONY: installer_fetch installer
454 .PHONY: quick realquick
455 .PHONY: installer_realquickrel check buildworld1 buildworld2
456 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso mkimg
457 .PHONY: clean realclean fetch help mkaliases
459 .include <bsd.prog.mk>