evtr: modularize debug output
[dragonfly.git] / nrelease / Makefile
CommitLineData
bfe20b28 1# $DragonFly: src/nrelease/Makefile,v 1.90 2008/09/01 21:20:30 swildner Exp $
6ca9a59c 2#
5b22b655 3
9b29c40a
MD
4#########################################################################
5# ENHANCEMENTS #
6#########################################################################
7
f4ec1279 8# New method e.g. 'make gui release'. A series of enhancement
9b29c40a
MD
9# targes may be specified which set make variables which enhance
10# the build in various ways.
11#
b9c3e754 12gui installer img:
9b29c40a 13
9b29c40a
MD
14#########################################################################
15# SETUP #
16#########################################################################
17
3fff415b
SW
18ISODIR?= /usr/release
19ISOROOT?= ${ISODIR}/root
20OBJSYS= ${.OBJDIR}/../sys
21
5cb6cda9 22MAKE_JOBS?= $$(sysctl -n hw.ncpu)
bfe20b28 23
b2b3ffcd
SS
24# temporary until everybody has converted to x86_64
25.if ${MACHINE_ARCH} == "amd64"
26MACHINE_ARCH= x86_64
27.makeenv MACHINE_ARCH
28.endif
29
bfe20b28
SW
30.if make(gui)
31KERNCONF ?= DFLYLIVE VKERNEL DFLYLIVE-SMP DFLYLIVE-SMP-NOAPIC
32.else
702a95cc
SS
33# XXX makeshift fix to build the right kernel for the (target) architecture
34# We should configure this in the platform files somehow
35.if ${MACHINE_ARCH} == "i386"
1d3eb8c5 36KERNCONF ?= GENERIC VKERNEL
702a95cc 37.else
b2b3ffcd 38KERNCONF ?= X86_64_GENERIC
702a95cc 39.endif
bfe20b28 40.endif
6ca9a59c 41
cc224c64 42PKGSRC_PREFIX?= /usr/pkg
bce110a5 43PKGBIN_PKG_ADD?= ${PKGSRC_PREFIX}/sbin/pkg_add
95b64753 44PKGBIN_PKG_DELETE?= ${PKGSRC_PREFIX}/sbin/pkg_delete
c791834f 45PKGBIN_PKG_ADMIN?= ${PKGSRC_PREFIX}/sbin/pkg_admin
bce110a5
MD
46PKGBIN_MKISOFS?= ${PKGSRC_PREFIX}/bin/mkisofs
47PKGSRC_PKG_PATH?= ${ISODIR}/packages
af88d908 48PKGSRC_BOOTSTRAP_URL?= http://avalon.dragonflybsd.org/DragonFly-pkgsrc-packages/i386/1.12.0-RELEASE-BUILD
4b08f3df 49CVSUP_BOOTSTRAP_KIT?= cvsup-bootstrap-20070716
bce110a5 50
cc55a235
SS
51# We use env -i in the chroot, so that environment variables won't
52# disturb any (pkgsrc) build. This has happened for TARGET_ARCH,
53# which is used by gmake in completely different context.
e2dbfa0b 54#
cc55a235
SS
55CHROOT_CMD?= env -i CCVER=${CCVER:Q} /usr/sbin/chroot ${ISOROOT} sh -c
56
8abe78a1 57# User may specify extra packages in addition to the defaults
95b64753 58#
8abe78a1
MD
59PKGSRC_EXTRA_PACKAGES?=
60
61# Pkgsrc packages to be built and installed on the release ISO
62#
63PKGSRC_PACKAGES?= pkgtools/pkg_leaves \
64 pkgtools/pkg_tarup \
b2c6ab6c 65 pkgtools/pkgin \
8abe78a1 66 devel/scmgit \
fbc26094
SW
67 net/isc-dhcp4 \
68 net/isc-dhcpd4 \
8abe78a1
MD
69 sysutils/cdrtools \
70 ${PKGSRC_EXTRA_PACKAGES}
fbc26094
SW
71
72# pkgsrc options to use when building packages
73#
3fff415b
SW
74PKGSRC_OPTIONS+= MAKE_JOBS=${MAKE_JOBS}
75PKGSRC_OPTIONS+= WRKOBJDIR=/usr/pkgobj
9ecb41e5 76PKGSRC_OPTIONS+= PKG_DEFAULT_OPTIONS='dri inet6'
fbc26094 77.if !make(gui)
9ecb41e5 78PKGSRC_OPTIONS+= PKG_OPTIONS.scmgit=-scmgit-gui
fbc26094 79.endif
8188de86 80
95b64753
MD
81# Even though buildiso wipes the packages, our check target has to run
82# first and old packages (listed as they appear in pkg_info) must be
83# cleaned out in order for the pkg_add -n test we use in the check target
84# to operate properly.
85#
fbc26094
SW
86OLD_PKGSRC_PACKAGES?= cdrtools-2.01.01.27nb1 \
87 cdrecord-2.00.3nb2 \
88 bootstrap-kit-20070205 \
89 dfuibe_installer-1.1.6 \
90 gettext-lib-0.14.5 \
91 dfuibe_installer-1.1.7nb1 \
92 dfuife_curses-1.5 \
93 gettext-lib-0.14.6 \
94 gettext-tools-0.14.6nb1 \
95 libaura-3.1 \
96 libdfui-4.2 \
97 libinstaller-5.1 \
98 bootstrap-kit-20080211 \
99 cdrtools-ossdvd-2.01.1.36nb2 \
100 isc-dhcp-base-4.0.0 \
101 isc-dhcp-server-4.0.0
95b64753 102
8188de86 103# Specify which root skeletons are required, and let the user include
e2dbfa0b 104# their own. They are copied into ISODIR during the `customizeiso'
8188de86
MD
105# target; each overwrites the last.
106#
8f51ac0b 107REQ_ROOTSKELS= ${.CURDIR}/root
cc224c64
JS
108ROOTSKELS?= ${REQ_ROOTSKELS}
109
fbc26094 110.if make(gui)
3f279b9e 111ISOFILE?= ${ISODIR}/dfly-gui.iso
b9c3e754 112IMGFILE?= ${ISODIR}/dfly-gui.img
0936984e
MD
113PKGSRC_PACKAGES+= meta-pkgs/modular-xorg-apps \
114 meta-pkgs/modular-xorg-drivers \
115 meta-pkgs/modular-xorg-fonts \
116 meta-pkgs/modular-xorg-libs \
fbc26094 117 wm/fluxbox \
0936984e 118 wm/fvwm \
30e27f66 119 www/firefox \
fbc26094
SW
120 print/xpdf \
121 shells/zsh \
122 editors/emacs \
123 editors/vim \
124 chat/pidgin \
125 chat/irssi \
126 chat/xchat \
0936984e 127 x11/modular-xorg-server \
fbc26094
SW
128 x11/rxvt-unicode \
129 x11/eterm \
130 lang/perl5 \
131 editors/nano \
132 shells/bash \
133 devel/exctags \
134 archivers/zip \
135 security/sudo \
136 www/links-gui \
137 net/nmap \
138 net/wget \
139 fonts/terminus-font \
140 net/rsync \
141 sysutils/idesk \
0936984e 142 time/asclock \
fbc26094 143 misc/screen
3f279b9e
SW
144ROOTSKELS+= ${.CURDIR}/gui
145.endif
146
3f279b9e 147ISOFILE ?= ${ISODIR}/dfly.iso
b9c3e754
MN
148IMGFILE ?= ${ISODIR}/dfly.img
149
60b68cbb 150IMGMNT ?= ${ISODIR}/mnt
a2f841ed
MD
151
152# USB umass now probes starting at da8, so the usb stick is
153# probably sitting on da8.
154#
9a122c9a 155IMGUSBDEV ?= da8
3f279b9e 156
5b22b655
MD
157# note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
158# the additional '/nrelease' manually, as a safety measure.
159#
160NRLOBJDIR?= /usr/obj
161
8188de86
MD
162#########################################################################
163# BASE ISO TARGETS #
164#########################################################################
165
7ebbae99 166release: check clean buildworld1 buildkernel1 \
03e2a3c5 167 buildiso srcs customizeiso mklocatedb \
0936984e 168 mkiso mkimg
8188de86 169
7ebbae99 170quickrel: check clean buildworld2 buildkernel2 \
03e2a3c5 171 buildiso srcs customizeiso mklocatedb \
0936984e 172 mkiso mkimg
2e3f8f38 173
03e2a3c5
SW
174realquickrel: check clean \
175 buildiso srcs customizeiso mklocatedb \
0936984e 176 mkiso mkimg
6ca9a59c 177
03e2a3c5 178restartpkgs: check customizeiso mklocatedb mkiso mkimg
5af45f85 179
9b29c40a
MD
180quick: quickrel
181
182realquick: realquickrel
183
5af45f85 184
9b29c40a
MD
185#########################################################################
186# CORE SUPPORT TARGETS #
187#########################################################################
188
d2582113 189check:
0936984e
MD
190.if !exists(${PKGBIN_PKG_ADMIN})
191 @echo "You never bootstrapped pkgsrc on your machine. You can install it with:"
192 @echo " make pkgsrc_bootstrap"
193.endif
f6be72c9 194.if ${MACHINE_ARCH} == "i386" && !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
0a1628e7 195 @echo "The cvsup bootstrap kit is not installed. You can install it with:"
f4ec1279 196 @echo " make fetch"
0936984e
MD
197.endif
198.if !exists (${PKGBIN_MKISOFS})
199 @echo
200 @echo "Your machine does not have cdrtools installed. You can install it with:"
201 @echo " make pkgsrc_cdrecord"
0a1628e7 202.endif
fbc26094
SW
203.if !defined(PKGSRC_PATH)
204 @echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for"
5af45f85
MD
205 @echo "package building. For example /usr/pkgsrc. See the Makefile"
206 @echo "in /usr if you are unfamiliar with pkgsrc."
0936984e 207.endif
f6be72c9 208.if ${MACHINE_ARCH} == "i386" && !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
0936984e
MD
209 @exit 1
210.endif
211.if !exists (${PKGBIN_MKISOFS})
212 @exit 1
213.endif
214.if !defined(PKGSRC_PATH)
fbc26094
SW
215 @exit 1
216.endif
2e3f8f38 217
588a679c 218buildworld1 buildworld2:
3fff415b
SW
219 cd ${.CURDIR}/..; \
220 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
221 make -j ${MAKE_JOBS} -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
6ca9a59c 222
588a679c 223buildkernel1 buildkernel2:
bfe20b28
SW
224.if make(gui)
225 cd ${.CURDIR}/..; \
226 for kernconf in ${KERNCONF}; do \
448b21e7 227 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
3fff415b 228 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
bfe20b28
SW
229 KERNCONF=$${kernconf} KERNCONFDIR=${.CURDIR}/gui/root; \
230 done
231.else
588a679c
SS
232 cd ${.CURDIR}/..; \
233 first=; \
234 for kernconf in ${KERNCONF}; do \
448b21e7 235 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
3fff415b 236 make -j ${MAKE_JOBS} ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
588a679c
SS
237 KERNCONF=$${kernconf} \
238 $${first:+-DNO_MODULES}; \
239 first=done; \
240 done
bfe20b28 241.endif
6ca9a59c 242
5b22b655
MD
243# note that we do not want to mess with any /usr/obj directories not related
244# to buildworld, buildkernel, or nrelease, so we must supply the proper
245# MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
246# buildkernel mechanism.
247#
6ca9a59c
MD
248buildiso:
249 if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
5b22b655 250 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
f4ec1279 251 ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
ab64cf06
SS
252 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
253 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
21aa02d0 254 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
bfe20b28 255.if make(gui)
fbc26094 256 if [ ! -d ${ISOROOT}/kernel.smp/boot ]; then mkdir -p ${ISOROOT}/kernel.smp/boot; fi
bfe20b28
SW
257 cd ${.CURDIR}/..; \
258 make installkernel DESTDIR=${ISOROOT} \
259 KERNCONF=DFLYLIVE DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
260 cd ${.CURDIR}/..; \
261 make installkernel DESTDIR=${ISOROOT} \
262 KERNCONF=VKERNEL DESTKERNNAME=kernel.VKERNEL -DNO_MODULES KERNCONFDIR=${.CURDIR}/gui/root; \
263 cd ${.CURDIR}/..; \
264 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
265 KERNCONF=DFLYLIVE-SMP DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
266 cd ${.CURDIR}/..; \
267 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
268 KERNCONF=DFLYLIVE-SMP-NOAPIC DESTKERNNAME=kernel.noapic \
269 KERNCONFDIR=${.CURDIR}/gui/root -DNO_MODULES;
270.else
588a679c
SS
271 cd ${.CURDIR}/..; \
272 first=; \
273 for kernconf in ${KERNCONF}; do \
274 make DESTDIR=${ISOROOT} \
275 installkernel KERNCONF=$${kernconf} \
276 $${first:+DESTKERNNAME=kernel.$${kernconf}} \
277 $${first:+-DNO_MODULES}; \
278 first=done; \
279 done
bfe20b28 280.endif
3f6dbfa9 281 ln -s kernel ${ISOROOT}/boot/kernel.BOOTP
6ca9a59c
MD
282 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
283 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
284 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
8188de86 285
e2dbfa0b
TN
286# Release CD: Kernel sources (~16M) and the full pkgsrc tree (~27M)
287# Release DVD: Full sources (~90M) and the full pkgsrc tree (~27M)
19d86faa 288#
e2dbfa0b
TN
289srcs:
290.if !defined(WITHOUT_SRCS)
1eeae16f
MD
291 rm -f ${ISOROOT}/usr/pkgsrc-git.tgz
292 rm -f ${ISOROOT}/usr/pkgsrc
293 mkdir -p ${ISOROOT}/usr/pkgsrc
294 cd ${ISOROOT}/usr/pkgsrc && git init
295 cd ${ISOROOT}/usr/pkgsrc && \
296 git remote add origin git://git.dragonflybsd.org/pkgsrc.git
297 cd ${ISOROOT}/usr/pkgsrc && git fetch origin
298 cd ${ISOROOT}/usr/pkgsrc && git branch vendor origin/vendor
299 cd ${ISOROOT}/usr/pkgsrc && git gc
c19c746b 300.if make(gui)
1eeae16f
MD
301 rm -f ${ISOROOT}/usr/src-git.tgz
302 rm -rf ${ISOROOT}/usr/src
303 mkdir -p ${ISOROOT}/usr/src
304 cd ${ISOROOT}/usr/src && git init
305 cd ${ISOROOT}/usr/src && \
306 git remote add origin git://git.dragonflybsd.org/dragonfly.git
307 cd ${ISOROOT}/usr/src && git fetch origin
308 cd ${ISOROOT}/usr/src && git branch master origin/master
309 cd ${ISOROOT}/usr/src && git gc
c19c746b 310.else
e2dbfa0b 311 rm -f ${ISOROOT}/usr/src-sys.tgz
3617b2c9
SW
312 cd ${.CURDIR}/.. && tar --exclude .git --exclude CVS -s '/^\./src/' \
313 -czf ${ISOROOT}/usr/src-sys.tgz ./Makefile ./Makefile.inc1 ./sys
c19c746b 314.endif
66b79064 315.endif
19d86faa 316
5af45f85
MD
317# Customize the ISO by copying rootskels in reverse priority order,
318# building packages, and doing other post-install tasks.
319#
8188de86 320customizeiso:
5af45f85
MD
321 # Copy the rootskels. Allow sources to be owned by someone other
322 # then root (as is common when checked out via git).
323 #
8188de86
MD
324.for ROOTSKEL in ${ROOTSKELS}
325 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
5af45f85
MD
326 @test -O ${.CURDIR} || echo "chowning copied files to root:wheel"
327 @test -O ${.CURDIR} || ((cd ${ROOTSKEL} && find .) | fgrep -v cpignore | (cd ${ISOROOT} && xargs chown root:wheel))
8188de86 328.endfor
f6be72c9 329.if ${MACHINE_ARCH} == "i386"
fbc26094 330 (cd ${PKGSRC_PKG_PATH}; tar xzpf ${CVSUP_BOOTSTRAP_KIT}.tgz)
0a1628e7 331 cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/bin/cvsup ${ISOROOT}/usr/local/bin/cvsup
c751e497 332 cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/man/man1/cvsup.1 ${ISOROOT}/usr/local/man/man1/cvsup.1
f6be72c9 333.endif
7249926b 334 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
4fba3387
CP
335.for UPGRADE_ITEM in Makefile \
336 etc.${MACHINE_ARCH} \
337 isdn/Makefile \
338 rc.d/Makefile \
339 periodic/Makefile \
340 periodic/daily/Makefile \
341 periodic/security/Makefile \
342 periodic/weekly/Makefile \
343 periodic/monthly/Makefile
344 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
20585f87 345.endfor
8abe78a1
MD
346 #
347 # Setup some things & mount pkgsrc tree. Use defensive umounts and
348 # rm -rf's to allow restarts. Allow /usr/pkgsrc to be read-only.
349 #
350 # If we did not get past the bootstrap we clean out the entire
351 # /usr/pkg infrastructure. Otherwise we attempt to pick up where
352 # we left off.
353 #
fbc26094 354 cp -p /etc/resolv.conf ${ISOROOT}/etc
cc55a235 355 ${CHROOT_CMD} "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
8abe78a1
MD
356 -@umount ${ISOROOT}/usr/pkgsrc/distfiles
357 -@umount ${ISOROOT}/usr/pkgsrc
45e80934 358 -@umount ${ISOROOT}/dev
8abe78a1
MD
359 mkdir -p ${ISODIR}/distfiles
360 rm -rf ${ISOROOT}/usr/pkgobj
8abe78a1 361 #
1eeae16f
MD
362 # Mount /usr/pkgsrc, make sure /usr/pkgsrc/distfiles is writable.
363 # Make /usr/pkgsrc read-only for safety, else a failed umount and
364 # our rm -rf will do bad things.
8abe78a1
MD
365 #
366 mkdir -p ${ISOROOT}/usr/pkgobj
3aa2328e 367 mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap
8abe78a1 368 mkdir -p ${ISOROOT}/usr/pkgsrc
1eeae16f 369 mount_null -o ro ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc
0c5de895 370 mount_null /dev ${ISOROOT}/dev
5af45f85
MD
371 cp /etc/shells ${ISOROOT}/usr/pkgsrc/distfiles/.test > /dev/null 2>&1 \
372 || mount_null ${ISODIR}/distfiles ${ISOROOT}/usr/pkgsrc/distfiles
8abe78a1 373 #
5af45f85 374 # Bootstrap, if not already installed, and add licenses needed
ee3561ee 375 # for the gui release
8abe78a1 376 #
c19c746b
MD
377 test -e ${ISODIR}/.didbootstrap || \
378 rm -rf ${ISOROOT}/usr/pkg ${ISOROOT}/var/db/pkg \
379 ${ISOROOT}/var/db/pkg.refcount
380 test -e ${ISODIR}/.didbootstrap || \
381 ${CHROOT_CMD} "cd /usr/pkgsrc/bootstrap; \
8abe78a1 382 ./bootstrap --workdir /usr/pkgobj/bootstrap/work"
3fff415b 383.if make(gui)
c19c746b
MD
384 test -e ${ISODIR}/.didbootstrap || \
385 echo ".ifdef BSD_PKG_MK # added by nrelease" \
ee3561ee 386 >> ${ISOROOT}/usr/pkg/etc/mk.conf
c19c746b
MD
387 test -e ${ISODIR}/.didbootstrap || \
388 echo "ACCEPTABLE_LICENSES+=openmotif-license" \
ee3561ee 389 >> ${ISOROOT}/usr/pkg/etc/mk.conf
c19c746b
MD
390 test -e ${ISODIR}/.didbootstrap || \
391 echo "ACCEPTABLE_LICENSES+=vim-license" \
ee3561ee 392 >> ${ISOROOT}/usr/pkg/etc/mk.conf
c19c746b
MD
393 test -e ${ISODIR}/.didbootstrap || \
394 echo ".endif # added by nrelease" \
ee3561ee 395 >> ${ISOROOT}/usr/pkg/etc/mk.conf
3fff415b 396.endif
c19c746b
MD
397 test -e ${ISODIR}/.didbootstrap || sync
398 test -e ${ISODIR}/.didbootstrap || touch ${ISODIR}/.didbootstrap
8abe78a1
MD
399 #
400 # Build and install packages, skip packages already installed
401 #
bce110a5 402.for PKG in ${PKGSRC_PACKAGES}
8abe78a1 403 ${CHROOT_CMD} "cd /usr/pkgsrc/${PKG} && \
3fff415b
SW
404 (bmake check > /dev/null 2>&1 || \
405 bmake ${PKGSRC_OPTIONS} clean build install)"
8188de86 406.endfor
8abe78a1
MD
407 #
408 # Remove packages which nothing depends on and clean up
409 #
cc55a235 410 ${CHROOT_CMD} "pkg_leaves | xargs pkg_delete -R"
8abe78a1 411 -umount ${ISOROOT}/usr/pkgsrc/distfiles
45e80934 412 umount ${ISOROOT}/dev
fbc26094 413 umount ${ISOROOT}/usr/pkgsrc
589a5738 414 rm -rf ${ISOROOT}/usr/pkgobj
fbc26094 415 rm -f ${ISOROOT}/etc/resolv.conf
3652f053
SW
416 makewhatis ${ISOROOT}/usr/local/man
417 makewhatis ${ISOROOT}/usr/pkg/man
6ca9a59c 418
0936984e
MD
419# So locate works
420#
8398ca17
SW
421mklocatedb:
422 ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
423 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
424 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
425 /usr/libexec/locate.mklocatedb \
426 -presort >${ISOROOT}/var/db/locate.database )
427
6ca9a59c 428mkiso:
bce110a5 429 ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
74ec6a9d 430 -R -J -o ${ISOFILE} \
64bba8c7 431 -V "DragonFly `${.CURDIR}/../tools/gitrev.sh | cut -c -22`" . )
6ca9a59c 432
b9c3e754
MN
433
434mkimg:
fbc26094 435.if make(img)
60b68cbb 436 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
9a122c9a
MD
437 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
438 vnconfig -u `cat ${ISODIR}/vn.which`; fi
439 @echo "STEP: determine required image size"
60b68cbb 440 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
9a122c9a
MD
441 sz=`bc -e "(($${sz}) / 1024) * 1.15" -equit | cut -f1 -d.`; \
442 dd if=/dev/zero of=${IMGFILE} bs=1m count=$${sz};
443 fdisk -IB -p ${IMGFILE}
444 @echo "STEP: determine free vn device"
445 vnconfig -l | grep "not in use" | head -n 1 | \
446 cut -f 1 -d: > ${ISODIR}/vn.which
447 vnconfig -e -s labels `cat ${ISODIR}/vn.which` ${IMGFILE}
448 @echo "STEP: write standard disklabel"
449 disklabel -w -r `cat ${ISODIR}/vn.which`s1 auto
450 @echo "STEP: read disklabel back"
451 disklabel -r `cat ${ISODIR}/vn.which`s1 > ${IMGFILE}.label
452 @echo "STEP: determine number of sectors of whole disk"
60b68cbb 453 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
9a122c9a
MD
454 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label;
455 @echo "STEP: write modified disklabel back"
456 disklabel -R -r `cat ${ISODIR}/vn.which`s1 ${IMGFILE}.label
457 rm ${IMGFILE}.label
458 @echo "STEP: write bootsector"
459 disklabel -B `cat ${ISODIR}/vn.which`s1
460 boot0cfg -B -o noupdate `cat ${ISODIR}/vn.which`
461 newfs /dev/`cat ${ISODIR}/vn.which`s1a
462 mount /dev/`cat ${ISODIR}/vn.which`s1a ${IMGMNT}
463 cpdup ${ISOROOT} ${IMGMNT}
464 @echo "STEP: fixup ${IMGMNT}/etc/fstab"
e36bedaf 465 echo "/dev/${IMGUSBDEV}s1a / ufs rw,noatime 0 1" > ${IMGMNT}/etc/fstab
9a122c9a
MD
466 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab
467 @echo "STEP: fixup ${IMGMNT}/boot/loader.conf"
468 -fgrep -v kernel_options ${IMGMNT}/boot/loader.conf > ${IMGMNT}/boot/loader.conf.new
469 echo 'vfs.root.mountfrom="ufs:${IMGUSBDEV}s1a"' >> ${IMGMNT}/boot/loader.conf.new
470 mv ${IMGMNT}/boot/loader.conf.new ${IMGMNT}/boot/loader.conf
471 @echo "STEP: cleanup"
472 df ${IMGMNT}
473 umount ${IMGMNT}
474 vnconfig -u `cat ${ISODIR}/vn.which`
475 rm -f ${ISODIR}/vn.which
60b68cbb 476 rmdir ${IMGMNT}
9a122c9a 477 @echo "STEP: done"
b9c3e754
MN
478.endif
479
6ca9a59c 480clean:
c19c746b
MD
481 -umount ${ISOROOT}/usr/pkgsrc/distfiles > /dev/null 2>&1
482 -umount ${ISOROOT}/usr/pkgsrc > /dev/null 2>&1
9a122c9a
MD
483 -umount ${ISOROOT}/dev > /dev/null 2>&1
484 -if [ -f ${ISODIR}/vn.which ]; then umount ${IMGMNT}; \
485 vnconfig -u `cat ${ISODIR}/vn.which`; fi
6ca9a59c 486 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
c19c746b
MD
487 rm -rf ${ISOROOT}
488 rm -rf ${NRLOBJDIR}/nrelease
9a122c9a 489 rm -f ${ISODIR}/.didbootstrap ${ISODIR}/vn.which
6ca9a59c
MD
490
491realclean: clean
3ebedc5e 492 rm -rf ${OBJSYS}/${KERNCONF}
8abe78a1 493 #
bce110a5
MD
494 # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
495 # override location.
8abe78a1 496 #
c19c746b
MD
497 rm -rf ${ISODIR}/packages
498 rm -rf ${ISODIR}/distfiles
6ca9a59c 499
f6be72c9 500.if ${MACHINE_ARCH} == "i386"
cc224c64 501fetch:
9b29c40a 502 @if [ ! -d ${PKGSRC_PKG_PATH} ]; then mkdir -p ${PKGSRC_PKG_PATH}; fi
0a1628e7
MD
503.if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
504 (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${CVSUP_BOOTSTRAP_KIT}.tgz)
505.endif
f6be72c9 506.endif
bce110a5
MD
507
508pkgsrc_bootstrap:
bce110a5 509.if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
0936984e
MD
510 mkdir -p /usr/release/bootstrap
511 (cd ${PKGSRC_PATH}/bootstrap; ./bootstrap --workdir /usr/release/bootstrap)
bce110a5 512.endif
bce110a5 513
bce110a5
MD
514pkgsrc_cdrecord:
515.if !exists (${PKGBIN_MKISOFS})
0936984e 516 (cd ${PKGSRC_PATH}/sysutils/cdrtools; bmake clean build install)
bce110a5 517.endif
cc224c64 518
e2dbfa0b 519help all:
5af45f85
MD
520 @echo "make [gui] release - complete build from scratch"
521 @echo "make [gui] quick - attempt to do an incremental rebuild"
522 @echo "make [gui] realquick - attempt to restart after world & kernel"
523 @echo "make [gui] restartpkgs - attempt to restart at the pkg building stage"
8abe78a1
MD
524 @echo ""
525 @echo "Extra packages may be specified with PKGSRC_EXTRA_PACKAGES"
588a679c 526
e2dbfa0b
TN
527.PHONY: release quickrel realquickrel
528.PHONY: installer
9b29c40a 529.PHONY: quick realquick
e2dbfa0b 530.PHONY: check buildworld1 buildworld2
b9c3e754 531.PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso mkimg
03e2a3c5 532.PHONY: clean realclean fetch help all srcs
cc224c64 533
6ca9a59c 534.include <bsd.prog.mk>