Fix braino on my side.
[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
8# These targets are now obsolete and should not be used
9#
10installer_release: warning release
11installer_quickrel: warning quickrel
12installer_realquickrel: warning realquickrel
13installer_fetch: warning fetch
cc224c64 14
bce110a5 15.if make(installer_release) || make(installer_quickrel) || make(installer_realquickrel) || make(installer_fetch)
cc224c64
JS
16WITH_INSTALLER=
17.endif
18
9b29c40a
MD
19# New method e.g. 'make installer fetch'. A series of enhancement
20# targes may be specified which set make variables which enhance
21# the build in various ways.
22#
b9c3e754 23gui installer img:
9b29c40a
MD
24
25warning:
26 @echo "WARNING: The installer_* targets are now obsolete, please"
27 @echo "use 'make installer blah' instead of 'make installer_blah'"
28 @echo ""
29 @echo "will continue in 10 seconds"
30 @sleep 10
31
3f279b9e
SW
32.if make(gui)
33WITH_GUI=
34.endif
9b29c40a
MD
35.if make(installer)
36WITH_INSTALLER=
37.endif
b9c3e754
MN
38.if make(img)
39WITH_IMG=
40.endif
9b29c40a
MD
41
42#########################################################################
43# SETUP #
44#########################################################################
45
6ca9a59c 46ISODIR ?= /usr/release
5ec00f8a 47ISOROOT ?= ${ISODIR}/root
6ca9a59c 48OBJSYS= ${.OBJDIR}/../sys
bfe20b28
SW
49
50.if make(gui)
51KERNCONF ?= DFLYLIVE VKERNEL DFLYLIVE-SMP DFLYLIVE-SMP-NOAPIC
52.else
1d3eb8c5 53KERNCONF ?= GENERIC VKERNEL
bfe20b28 54.endif
6ca9a59c 55
cc224c64 56PKGSRC_PREFIX?= /usr/pkg
bce110a5 57PKGBIN_PKG_ADD?= ${PKGSRC_PREFIX}/sbin/pkg_add
95b64753 58PKGBIN_PKG_DELETE?= ${PKGSRC_PREFIX}/sbin/pkg_delete
c791834f 59PKGBIN_PKG_ADMIN?= ${PKGSRC_PREFIX}/sbin/pkg_admin
bce110a5
MD
60PKGBIN_MKISOFS?= ${PKGSRC_PREFIX}/bin/mkisofs
61PKGSRC_PKG_PATH?= ${ISODIR}/packages
62PKGSRC_DB?= /var/db/pkg
356095db 63PKGSRC_BOOTSTRAP_URL?= http://pkgbox.dragonflybsd.org/DragonFly-pkgsrc-packages/i386/1.12.0-RELEASE-BUILD
cc224c64 64
2157278d 65ENVCMD?= env
cc224c64 66TAR?= tar
cc224c64 67
356095db 68PKGSRC_BOOTSTRAP_KIT?= bootstrap-kit-20080211
4b08f3df 69CVSUP_BOOTSTRAP_KIT?= cvsup-bootstrap-20070716
bce110a5 70
95b64753
MD
71# Default packages to be installed on the release ISO.
72#
b67e8b8c 73PKGSRC_PACKAGES?= cdrtools-ossdvd-2.01.1.36nb2.tgz \
8edeaaff 74 isc-dhcp-base-4.0.0.tgz isc-dhcp-server-4.0.0.tgz
8188de86 75
95b64753
MD
76# Even though buildiso wipes the packages, our check target has to run
77# first and old packages (listed as they appear in pkg_info) must be
78# cleaned out in order for the pkg_add -n test we use in the check target
79# to operate properly.
80#
356095db
MD
81OLD_PKGSRC_PACKAGES?= cdrtools-2.01.01.27nb1 cdrecord-2.00.3nb2 \
82 bootstrap-kit-20070205
95b64753 83
8188de86
MD
84# Specify which root skeletons are required, and let the user include
85# their own. They are copied into ISODIR during the `pkgcustomizeiso'
86# target; each overwrites the last.
87#
88REQ_ROOTSKELS= ${.CURDIR}/root
cc224c64
JS
89ROOTSKELS?= ${REQ_ROOTSKELS}
90
bfe20b28
SW
91.if defined(WITH_INSTALLER)
92OLD_PKGSRC_PACKAGES+= dfuibe_installer-1.1.6 gettext-lib-0.14.5 \
93 dfuibe_installer-1.1.7nb1 dfuife_curses-1.5 \
94 gettext-lib-0.14.6 gettext-tools-0.14.6nb1 \
95 libaura-3.1 libdfui-4.2 libinstaller-5.1
96ROOTSKELS+= ${.CURDIR}/installer
97.endif
98
3f279b9e
SW
99.if defined(WITH_GUI)
100ISOFILE?= ${ISODIR}/dfly-gui.iso
b9c3e754 101IMGFILE?= ${ISODIR}/dfly-gui.img
3f279b9e
SW
102PKGSRC_PACKAGES+= modular-xorg-apps \
103 modular-xorg-drivers \
104 modular-xorg-fonts \
105 modular-xorg-libs \
bfe20b28
SW
106 fluxbox \
107 firefox3 \
108 xpdf \
109 zsh \
110 emacs \
111 vim \
112 pidgin \
113 irssi \
114 xchat \
115 rxvt-unicode \
116 eterm \
117 perl \
118 nano \
119 bash \
120 exctags \
121 zip \
122 sudo \
123 links-gui \
124 nmap \
125 wget \
126 terminus-font \
127 rsync \
128 idesk \
129 screen
3f279b9e
SW
130ROOTSKELS+= ${.CURDIR}/gui
131.endif
132
3f279b9e 133ISOFILE ?= ${ISODIR}/dfly.iso
b9c3e754
MN
134IMGFILE ?= ${ISODIR}/dfly.img
135
fb411313 136IMGMNT ?= ${ISODIR}/mnt
b9c3e754 137IMGUSBDEV ?= /dev/da0
3f279b9e 138
5b22b655
MD
139# note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
140# the additional '/nrelease' manually, as a safety measure.
141#
142NRLOBJDIR?= /usr/obj
143
8188de86
MD
144#########################################################################
145# BASE ISO TARGETS #
146#########################################################################
147
7ebbae99 148release: check clean buildworld1 buildkernel1 \
b9c3e754 149 buildiso syssrcs customizeiso mklocatedb mkiso mkimg
8188de86 150
7ebbae99 151quickrel: check clean buildworld2 buildkernel2 \
b9c3e754 152 buildiso syssrcs customizeiso mklocatedb mkiso mkimg
2e3f8f38 153
b9c3e754
MN
154realquickrel: check clean buildiso syssrcs customizeiso mklocatedb mkiso \
155 mkimg
6ca9a59c 156
9b29c40a
MD
157quick: quickrel
158
159realquick: realquickrel
160
161#########################################################################
162# CORE SUPPORT TARGETS #
163#########################################################################
164
d2582113 165check:
bce110a5
MD
166.if !exists(${PKGBIN_PKG_ADD})
167 @echo "Unable to find ${PKGBIN_PKG_ADD}. You can use the following"
168 @echo "command to bootstrap pkgsrc:"
169 @echo " make pkgsrc_bootstrap"
170 @exit 1
171.endif
95b64753 172.for PKG in ${OLD_PKGSRC_PACKAGES}
7c01f744 173 @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_DELETE} -K ${ISOROOT}${PKGSRC_DB} ${PKG} > /dev/null 2>&1 || exit 0
95b64753 174.endfor
bce110a5 175.for PKG in ${PKGSRC_PACKAGES}
7c01f744 176 @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -K ${ISOROOT}${PKGSRC_DB} -n ${PKG} > /dev/null 2>&1 || \
cbbd7681 177 (echo "Unable to find ${PKG}, use the following command to fetch required packages:"; echo " make [installer] fetch"; exit 1)
bce110a5
MD
178.endfor
179.if !exists(${PKGBIN_MKISOFS})
180 @echo "mkisofs is not installed. It is part of the cdrecord package."
181 @echo "You can install it with:"
182 @echo " make pkgsrc_cdrecord"
183 @exit 1
184.endif
0a1628e7
MD
185.if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
186 @echo "The pkgsrc bootstrap kit is not installed. You can install it with:"
cbbd7681 187 @echo " make [installer] fetch"
0a1628e7
MD
188 @exit 1
189.endif
190.if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
191 @echo "The cvsup bootstrap kit is not installed. You can install it with:"
cbbd7681 192 @echo " make [installer] fetch"
0a1628e7
MD
193 @exit 1
194.endif
2e3f8f38 195
588a679c 196buildworld1 buildworld2:
448b21e7 197 cd ${.CURDIR}/..; ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} make ${WITH_INSTALLER:C/^/-DWANT_INSTALLER/} ${.TARGET:C/build(.*)2/quick\1/:C/1//}
6ca9a59c 198
588a679c 199buildkernel1 buildkernel2:
bfe20b28
SW
200.if make(gui)
201 cd ${.CURDIR}/..; \
202 for kernconf in ${KERNCONF}; do \
448b21e7 203 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
82f56cac 204 make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
bfe20b28
SW
205 KERNCONF=$${kernconf} KERNCONFDIR=${.CURDIR}/gui/root; \
206 done
207.else
588a679c
SS
208 cd ${.CURDIR}/..; \
209 first=; \
210 for kernconf in ${KERNCONF}; do \
448b21e7 211 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
82f56cac 212 make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
588a679c
SS
213 KERNCONF=$${kernconf} \
214 $${first:+-DNO_MODULES}; \
215 first=done; \
216 done
bfe20b28 217.endif
6ca9a59c 218
5b22b655
MD
219# note that we do not want to mess with any /usr/obj directories not related
220# to buildworld, buildkernel, or nrelease, so we must supply the proper
221# MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
222# buildkernel mechanism.
223#
6ca9a59c
MD
224buildiso:
225 if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
5b22b655 226 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
7ebbae99 227 ( cd ${.CURDIR}/..; make ${WITH_INSTALLER:C/^/-DWANT_INSTALLER/} DESTDIR=${ISOROOT} installworld )
ab64cf06
SS
228 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
229 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
21aa02d0 230 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
bfe20b28
SW
231.if make(gui)
232 if [ ! -d ${ISOROOT}/kernel.smp ]; then mkdir -p ${ISOROOT}/kernel.smp; fi
233 cd ${.CURDIR}/..; \
234 make installkernel DESTDIR=${ISOROOT} \
235 KERNCONF=DFLYLIVE DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
236 cd ${.CURDIR}/..; \
237 make installkernel DESTDIR=${ISOROOT} \
238 KERNCONF=VKERNEL DESTKERNNAME=kernel.VKERNEL -DNO_MODULES KERNCONFDIR=${.CURDIR}/gui/root; \
239 cd ${.CURDIR}/..; \
240 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
241 KERNCONF=DFLYLIVE-SMP DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
242 cd ${.CURDIR}/..; \
243 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
244 KERNCONF=DFLYLIVE-SMP-NOAPIC DESTKERNNAME=kernel.noapic \
245 KERNCONFDIR=${.CURDIR}/gui/root -DNO_MODULES;
246.else
588a679c
SS
247 cd ${.CURDIR}/..; \
248 first=; \
249 for kernconf in ${KERNCONF}; do \
250 make DESTDIR=${ISOROOT} \
251 installkernel KERNCONF=$${kernconf} \
252 $${first:+DESTKERNNAME=kernel.$${kernconf}} \
253 $${first:+-DNO_MODULES}; \
254 first=done; \
255 done
bfe20b28 256.endif
c5c5e6fc 257 ln -s kernel ${ISOROOT}/kernel.BOOTP
6ca9a59c
MD
258 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
259 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
260 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
8188de86 261
19d86faa
MD
262# Include kernel sources on the release CD (~14MB)
263#
264syssrcs:
66b79064 265.if !defined(WITHOUT_SRCS)
ccbff5d3 266 ( cd ${.CURDIR}/../..; tar -cf - src/Makefile src/Makefile.inc1 src/sys | bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2 )
66b79064 267.endif
19d86faa 268
8188de86 269customizeiso:
0a1628e7 270 (cd ${PKGSRC_PKG_PATH}; tar xzpf ${CVSUP_BOOTSTRAP_KIT}.tgz)
8188de86
MD
271.for ROOTSKEL in ${ROOTSKELS}
272 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
273.endfor
f6c08bce 274 rm -rf ${ISOROOT}/tmp/bootstrap ${ISOROOT}/usr/obj/pkgsrc
20585f87 275 cd ${ISOROOT}; tar xvzpf ${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz
0a1628e7 276 cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/bin/cvsup ${ISOROOT}/usr/local/bin/cvsup
c751e497 277 cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/man/man1/cvsup.1 ${ISOROOT}/usr/local/man/man1/cvsup.1
d08963d3 278 rm -rf ${ISOROOT}/tmp/bootstrap ${ISOROOT}/usr/obj/pkgsrc
21aa02d0 279 rm -rf ${ISOROOT}/usr/local/share/pristine
7249926b 280 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
4fba3387
CP
281.for UPGRADE_ITEM in Makefile \
282 etc.${MACHINE_ARCH} \
283 isdn/Makefile \
284 rc.d/Makefile \
285 periodic/Makefile \
286 periodic/daily/Makefile \
287 periodic/security/Makefile \
288 periodic/weekly/Makefile \
289 periodic/monthly/Makefile
290 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
291.endfor
3ed3ccaa
SW
292 # There seems to be no reliable way to install a package to a target
293 # directory prefix so we mount_null our package directory into the
294 # ISO root and do the install chrooted.
295 #
296 mkdir ${ISOROOT}/tmp/packages
297 mount_null -o ro ${PKGSRC_PKG_PATH} ${ISOROOT}/tmp/packages
bce110a5 298.for PKG in ${PKGSRC_PACKAGES}
3ed3ccaa 299 ${ENVCMD} PKG_PATH=/tmp/packages chroot ${ISOROOT} ${PKGBIN_PKG_ADD} ${PKG}
8188de86 300.endfor
3ed3ccaa
SW
301 umount ${ISOROOT}/tmp/packages
302 rmdir ${ISOROOT}/tmp/packages
c791834f 303 find ${ISOROOT}${PKGSRC_DB} -name +CONTENTS -type f -exec sed -i '' -e 's,${ISOROOT},,' -- {} \;
3ed3ccaa 304 chroot ${ISOROOT} ${PKGBIN_PKG_ADMIN} rebuild
3652f053
SW
305 makewhatis ${ISOROOT}/usr/local/man
306 makewhatis ${ISOROOT}/usr/pkg/man
6ca9a59c 307
8398ca17
SW
308mklocatedb:
309 ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
310 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
311 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
312 /usr/libexec/locate.mklocatedb \
313 -presort >${ISOROOT}/var/db/locate.database )
314
6ca9a59c 315mkiso:
bce110a5 316 ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
382f1ee3 317 -R -J -V DragonFly -o ${ISOFILE} . )
6ca9a59c 318
b9c3e754
MN
319
320mkimg:
321.if defined(WITH_IMG)
60b68cbb
MN
322 if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
323
324 echo "determine required image size" > /dev/null; \
325 sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`; \
326 echo "add 10 MB more space as required" > /dev/null; \
327 sz=`bc -e "($${sz}) / 1024 + 10" -equit`; \
328 dd if=/dev/zero of=${IMGFILE} bs=1m count=$${sz}; \
329 fdisk -IB -p ${IMGFILE}; \
330 echo "determine free vn device" > /dev/null; \
331 vn=`vnconfig -l | grep "not in use" | head -n 1 | cut -f 1 -d:`; \
332 vnconfig -e -s labels $${vn} ${IMGFILE}; \
333 echo "write standard disklabel" > /dev/null; \
334 disklabel -w -r $${vn}s1 auto; \
335 echo "read disklabel back" > /dev/null; \
336 disklabel -r $${vn}s1 > ${IMGFILE}.label; \
337 echo "determine number of sectors of whole disk" > /dev/null; \
338 secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`; \
339 echo "and add a: partition" > /dev/null; \
340 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label; \
341 echo "write modified disklabel back" > /dev/null; \
342 disklabel -R -r $${vn}s1 ${IMGFILE}.label; \
343 rm ${IMGFILE}.label; \
344 echo "write bootsector" > /dev/null; \
345 disklabel -B $${vn}s1; \
346 newfs /dev/$${vn}s1a; \
347 mount /dev/$${vn}s1a ${IMGMNT}; \
348 cpdup -vvv ${ISOROOT} ${IMGMNT}; \
349 echo "fix /etc/fstab" > /dev/null; \
350 echo "${IMGUSBDEV}s1a / ufs rw 0 0" > ${IMGMNT}/etc/fstab; \
351 echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab; \
352 umount ${IMGMNT}; \
353 vnconfig -u $${vn}; \
354 rmdir ${IMGMNT}
b9c3e754
MN
355.endif
356
6ca9a59c 357clean:
3ed3ccaa 358 -umount ${ISOROOT}/tmp/packages
6ca9a59c 359 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
8188de86 360 if [ -d ${ISOROOT} ]; then rm -rf ${ISOROOT}/*; fi
5b22b655 361 if [ -d ${NRLOBJDIR}/nrelease ]; then rm -rf ${NRLOBJDIR}/nrelease; fi
6ca9a59c
MD
362
363realclean: clean
3ebedc5e 364 rm -rf ${OBJSYS}/${KERNCONF}
bce110a5
MD
365 # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
366 # override location.
367 if [ -d ${ISODIR}/packages ]; then rm -rf ${ISODIR}/packages; fi
6ca9a59c 368
cc224c64 369fetch:
9b29c40a 370 @if [ ! -d ${PKGSRC_PKG_PATH} ]; then mkdir -p ${PKGSRC_PKG_PATH}; fi
bce110a5 371.for PKG in ${PKGSRC_PACKAGES}
7c01f744 372 @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -K ${ISOROOT}${PKGSRC_DB} -n ${PKG} > /dev/null 2>&1 || \
bce110a5
MD
373 (cd ${PKGSRC_PKG_PATH}; echo "Fetching ${PKGSRC_BOOTSTRAP_URL}/${PKG}"; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKG})
374.endfor
375.if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
376 (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
377.endif
0a1628e7
MD
378.if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
379 (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${CVSUP_BOOTSTRAP_KIT}.tgz)
380.endif
bce110a5
MD
381
382pkgsrc_bootstrap:
383 mkdir -p ${PKGSRC_PKG_PATH}
384.if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
385 (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
386.endif
387 (cd ${PKGSRC_PKG_PATH}; tar xzpf ${PKGSRC_BOOTSTRAP_KIT}.tgz)
388 (cd ${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}/bootstrap; ./bootstrap)
389
bce110a5
MD
390pkgsrc_cdrecord:
391.if !exists (${PKGBIN_MKISOFS})
20585f87 392 ${PKGBIN_PKG_ADD} ${PKGSRC_PKG_PATH}/cdrtools*
bce110a5 393.endif
cc224c64 394
588a679c 395
cc224c64 396.PHONY: all release installer_release quickrel installer_quickrel realquickrel
9b29c40a
MD
397.PHONY: installer_fetch installer
398.PHONY: quick realquick
cc224c64 399.PHONY: installer_realquickrel check buildworld1 buildworld2
b9c3e754 400.PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso mkimg
d5c58845 401.PHONY: clean realclean fetch
cc224c64 402
6ca9a59c 403.include <bsd.prog.mk>