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