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