1 # $DragonFly: src/nrelease/Makefile,v 1.90 2008/09/01 21:20:30 swildner Exp $
4 #########################################################################
6 #########################################################################
8 # These targets are now obsolete and should not be used
10 installer_release: warning release
11 installer_quickrel: warning quickrel
12 installer_realquickrel: warning realquickrel
13 installer_fetch: warning fetch
15 # New method e.g. 'make gui release'. A series of enhancement
16 # targes may be specified which set make variables which enhance
17 # the build in various ways.
22 @echo "WARNING: The installer_* targets are now obsolete, please"
23 @echo "use 'make blah' instead of 'make installer_blah'"
25 @echo "will continue in 10 seconds"
28 #########################################################################
30 #########################################################################
32 ISODIR ?= /usr/release
33 ISOROOT ?= ${ISODIR}/root
34 OBJSYS= ${.OBJDIR}/../sys
37 KERNCONF ?= DFLYLIVE VKERNEL DFLYLIVE-SMP DFLYLIVE-SMP-NOAPIC
39 KERNCONF ?= GENERIC VKERNEL
42 PKGSRC_PREFIX?= /usr/pkg
43 PKGBIN_PKG_ADD?= ${PKGSRC_PREFIX}/sbin/pkg_add
44 PKGBIN_PKG_DELETE?= ${PKGSRC_PREFIX}/sbin/pkg_delete
45 PKGBIN_PKG_ADMIN?= ${PKGSRC_PREFIX}/sbin/pkg_admin
46 PKGBIN_MKISOFS?= ${PKGSRC_PREFIX}/bin/mkisofs
47 PKGSRC_PKG_PATH?= ${ISODIR}/packages
48 PKGSRC_DB?= /var/db/pkg
49 PKGSRC_BOOTSTRAP_URL?= http://pkgbox.dragonflybsd.org/DragonFly-pkgsrc-packages/i386/1.12.0-RELEASE-BUILD
50 CVSUP_BOOTSTRAP_KIT?= cvsup-bootstrap-20070716
52 # We use env -i in the chroot, so that environment variables won't
53 # disturb any (pkgsrc) build. This has happened for TARGET_ARCH,
54 # which is used by gmake in completely different context.
55 CHROOT_CMD?= env -i CCVER=${CCVER:Q} /usr/sbin/chroot ${ISOROOT} sh -c
57 # User may specify extra packages in addition to the defaults
59 PKGSRC_EXTRA_PACKAGES?=
61 # Pkgsrc packages to be built and installed on the release ISO
63 PKGSRC_PACKAGES?= pkgtools/pkg_leaves \
69 ${PKGSRC_EXTRA_PACKAGES}
71 # pkgsrc options to use when building packages
74 PKGSRC_OPTIONS?= PKG_OPTIONS.scmgit=-scmgit-gui
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 \
84 bootstrap-kit-20070205 \
85 dfuibe_installer-1.1.6 \
87 dfuibe_installer-1.1.7nb1 \
90 gettext-tools-0.14.6nb1 \
94 bootstrap-kit-20080211 \
95 cdrtools-ossdvd-2.01.1.36nb2 \
99 # Specify which root skeletons are required, and let the user include
100 # their own. They are copied into ISODIR during the `pkgcustomizeiso'
101 # target; each overwrites the last.
103 REQ_ROOTSKELS= ${.CURDIR}/root \
105 ROOTSKELS?= ${REQ_ROOTSKELS}
108 ISOFILE?= ${ISODIR}/dfly-gui.iso
109 IMGFILE?= ${ISODIR}/dfly-gui.img
110 PKGSRC_PACKAGES+= meta/modular-xorg-apps \
111 meta/modular-xorg-drivers \
112 meta/modular-xorg-fonts \
113 meta/modular-xorg-libs \
134 fonts/terminus-font \
138 ROOTSKELS+= ${.CURDIR}/gui
141 ISOFILE ?= ${ISODIR}/dfly.iso
142 IMGFILE ?= ${ISODIR}/dfly.img
144 IMGMNT ?= ${ISODIR}/mnt
145 IMGUSBDEV ?= /dev/da0
147 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
148 # the additional '/nrelease' manually, as a safety measure.
152 #########################################################################
154 #########################################################################
156 release: check clean buildworld1 buildkernel1 \
157 buildiso syssrcs customizeiso mklocatedb mkiso mkimg
159 quickrel: check clean buildworld2 buildkernel2 \
160 buildiso syssrcs customizeiso mklocatedb mkiso mkimg
162 realquickrel: check clean buildiso syssrcs customizeiso mklocatedb mkiso \
167 realquick: realquickrel
169 #########################################################################
170 # CORE SUPPORT TARGETS #
171 #########################################################################
174 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
175 @echo "The cvsup bootstrap kit is not installed. You can install it with:"
179 .if !defined(PKGSRC_PATH)
180 @echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for"
181 @echo "package building."
185 buildworld1 buildworld2:
186 cd ${.CURDIR}/..; ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} make -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
188 buildkernel1 buildkernel2:
191 for kernconf in ${KERNCONF}; do \
192 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
193 make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
194 KERNCONF=$${kernconf} KERNCONFDIR=${.CURDIR}/gui/root; \
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} \
203 $${first:+-DNO_MODULES}; \
208 # note that we do not want to mess with any /usr/obj directories not related
209 # to buildworld, buildkernel, or nrelease, so we must supply the proper
210 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
211 # buildkernel mechanism.
214 if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
215 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
216 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
217 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
218 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
219 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
221 if [ ! -d ${ISOROOT}/kernel.smp/boot ]; then mkdir -p ${ISOROOT}/kernel.smp/boot; fi
223 make installkernel DESTDIR=${ISOROOT} \
224 KERNCONF=DFLYLIVE DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
226 make installkernel DESTDIR=${ISOROOT} \
227 KERNCONF=VKERNEL DESTKERNNAME=kernel.VKERNEL -DNO_MODULES KERNCONFDIR=${.CURDIR}/gui/root; \
229 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
230 KERNCONF=DFLYLIVE-SMP DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
232 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
233 KERNCONF=DFLYLIVE-SMP-NOAPIC DESTKERNNAME=kernel.noapic \
234 KERNCONFDIR=${.CURDIR}/gui/root -DNO_MODULES;
238 for kernconf in ${KERNCONF}; do \
239 make DESTDIR=${ISOROOT} \
240 installkernel KERNCONF=$${kernconf} \
241 $${first:+DESTKERNNAME=kernel.$${kernconf}} \
242 $${first:+-DNO_MODULES}; \
246 ln -s kernel ${ISOROOT}/kernel.BOOTP
247 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
248 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
249 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
251 # Include kernel sources on the release CD (~14MB)
254 .if !defined(WITHOUT_SRCS)
255 ( cd ${.CURDIR}/../..; tar -cf - src/Makefile src/Makefile.inc1 src/sys | bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2 )
259 .for ROOTSKEL in ${ROOTSKELS}
260 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
262 (cd ${PKGSRC_PKG_PATH}; tar xzpf ${CVSUP_BOOTSTRAP_KIT}.tgz)
263 cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/bin/cvsup ${ISOROOT}/usr/local/bin/cvsup
264 cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/man/man1/cvsup.1 ${ISOROOT}/usr/local/man/man1/cvsup.1
265 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
266 .for UPGRADE_ITEM in Makefile \
267 etc.${MACHINE_ARCH} \
271 periodic/daily/Makefile \
272 periodic/security/Makefile \
273 periodic/weekly/Makefile \
274 periodic/monthly/Makefile
275 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
278 # Setup some things & mount pkgsrc tree. Use defensive umounts and
279 # rm -rf's to allow restarts. Allow /usr/pkgsrc to be read-only.
281 # If we did not get past the bootstrap we clean out the entire
282 # /usr/pkg infrastructure. Otherwise we attempt to pick up where
285 cp -p /etc/resolv.conf ${ISOROOT}/etc
286 ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
287 -@umount ${ISOROOT}/usr/pkgsrc/distfiles
288 -@umount ${ISOROOT}/usr/pkgsrc
289 mkdir -p ${ISODIR}/distfiles
290 rm -rf ${ISOROOT}/usr/pkgobj
291 test -e ${ISODIR}/.didbootstrap || \
292 rm -rf ${ISOROOT}/usr/pkg ${ISOROOT}/var/db/pkg \
293 ${ISOROOT}/var/db/pkg.refcount
295 # Mount /usr/pkgsrc, make sure /usr/pkgsrc/distfiles is writable
297 mkdir -p ${ISOROOT}/usr/pkgobj
298 mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap/work
299 mkdir -p ${ISOROOT}/usr/pkgsrc
300 mount_null ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc
301 cp /etc/shells ${ISOROOT}/usr/pkgsrc/distfiles/.test || \
302 mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/pkgsrc/distfiles
304 # Bootstrap, if not already installed
306 test -e ${ISODIR}/.didbootstrap || \
307 ${CHROOT_CMD} "cd /usr/pkgsrc/bootstrap; \
308 ./bootstrap --workdir /usr/pkgobj/bootstrap/work"
310 touch ${ISODIR}/.didbootstrap
312 # Build and install packages, skip packages already installed
314 .for PKG in ${PKGSRC_PACKAGES}
315 ${CHROOT_CMD} "cd /usr/pkgsrc/${PKG} && \
316 (bmake WRKOBJDIR=/usr/pkgobj check > /dev/null 2>&1 || \
317 bmake WRKOBJDIR=/usr/pkgobj ${PKGSRC_OPTIONS} clean build install)"
320 # Remove packages which nothing depends on and clean up
322 ${CHROOT_CMD} "pkg_leaves | xargs pkg_delete -R"
323 -umount ${ISOROOT}/usr/pkgsrc/distfiles
324 umount ${ISOROOT}/usr/pkgsrc
325 rmdir ${ISOROOT}/usr/pkgsrc
326 rm -rf ${ISOROOT}/usr/pkgobj
327 rm -f ${ISOROOT}/etc/resolv.conf
328 makewhatis ${ISOROOT}/usr/local/man
329 makewhatis ${ISOROOT}/usr/pkg/man
332 ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
333 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
334 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
335 /usr/libexec/locate.mklocatedb \
336 -presort >${ISOROOT}/var/db/locate.database )
339 ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
340 -R -J -o ${ISOFILE} \
341 -V DragonFly-`${.CURDIR}/../tools/gitrev.sh | cut -c -22` . )
346 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
348 echo "determine required image size" > /dev/null; \
349 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
350 echo "add 15% more space as required" > /dev/null; \
351 sz=`bc -e "(($${sz}) / 1024) * 1.15" -equit | cut -f1 -d.`; \
352 dd if=/dev/zero of=${IMGFILE} bs=1m count=$${sz}; \
353 fdisk -IB -p ${IMGFILE}; \
354 echo "determine free vn device" > /dev/null; \
355 vn=`vnconfig -l | grep "not in use" | head -n 1 | cut -f 1 -d:`; \
356 vnconfig -e -s labels $${vn} ${IMGFILE}; \
357 echo "write standard disklabel" > /dev/null; \
358 disklabel -w -r $${vn}s1 auto; \
359 echo "read disklabel back" > /dev/null; \
360 disklabel -r $${vn}s1 > ${IMGFILE}.label; \
361 echo "determine number of sectors of whole disk" > /dev/null; \
362 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
363 echo "and add a: partition" > /dev/null; \
364 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label; \
365 echo "write modified disklabel back" > /dev/null; \
366 disklabel -R -r $${vn}s1 ${IMGFILE}.label; \
367 rm ${IMGFILE}.label; \
368 echo "write bootsector" > /dev/null; \
369 disklabel -B $${vn}s1; \
370 newfs /dev/$${vn}s1a; \
371 mount /dev/$${vn}s1a ${IMGMNT}; \
372 cpdup -vvv ${ISOROOT} ${IMGMNT}; \
373 echo "fix /etc/fstab" > /dev/null; \
374 echo "${IMGUSBDEV}s1a / ufs rw 0 0" > ${IMGMNT}/etc/fstab; \
375 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab; \
378 vnconfig -u $${vn}; \
383 -umount ${ISOROOT}/usr/pkgsrc/distfiles
384 -umount ${ISOROOT}/usr/pkgsrc
385 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
386 if [ -d ${ISOROOT} ]; then rm -rf ${ISOROOT}/*; fi
387 if [ -d ${NRLOBJDIR}/nrelease ]; then rm -rf ${NRLOBJDIR}/nrelease; fi
388 rm -f ${ISODIR}/.didbootstrap
391 rm -rf ${OBJSYS}/${KERNCONF}
393 # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
396 if [ -d ${ISODIR}/packages ]; then rm -rf ${ISODIR}/packages; fi
399 @if [ ! -d ${PKGSRC_PKG_PATH} ]; then mkdir -p ${PKGSRC_PKG_PATH}; fi
400 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
401 (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${CVSUP_BOOTSTRAP_KIT}.tgz)
405 mkdir -p ${PKGSRC_PKG_PATH}
406 .if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
407 (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
409 (cd ${PKGSRC_PKG_PATH}; tar xzpf ${PKGSRC_BOOTSTRAP_KIT}.tgz)
410 (cd ${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}/bootstrap; ./bootstrap)
413 .if !exists (${PKGBIN_MKISOFS})
414 ${PKGBIN_PKG_ADD} ${PKGSRC_PKG_PATH}/cdrtools*
418 @echo "make release - complete build from scratch"
419 @echo "make quick - attempt to do an incremental rebuild"
420 @echo "make realquic - attempt to restart after world & kernel"
422 @echo "If the main build works but customizeiso fails you can restart"
423 @echo "at the customize iso step with:"
425 @echo "make customizeiso mklocatedb mkiso mkimg"
427 @echo "Extra packages may be specified with PKGSRC_EXTRA_PACKAGES"
429 .PHONY: all release installer_release quickrel installer_quickrel realquickrel
430 .PHONY: installer_fetch installer
431 .PHONY: quick realquick
432 .PHONY: installer_realquickrel check buildworld1 buildworld2
433 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso mkimg
434 .PHONY: clean realclean fetch help
436 .include <bsd.prog.mk>