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