Integrate USB stick image generation into nrelease.
[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
136IMGMNT ?= /mnt
137IMGSIZE ?= 450
138IMGVN ?= vn0
139IMGUSBDEV ?= /dev/da0
3f279b9e 140
5b22b655
MD
141# note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
142# the additional '/nrelease' manually, as a safety measure.
143#
144NRLOBJDIR?= /usr/obj
145
8188de86
MD
146#########################################################################
147# BASE ISO TARGETS #
148#########################################################################
149
7ebbae99 150release: check clean buildworld1 buildkernel1 \
b9c3e754 151 buildiso syssrcs customizeiso mklocatedb mkiso mkimg
8188de86 152
7ebbae99 153quickrel: check clean buildworld2 buildkernel2 \
b9c3e754 154 buildiso syssrcs customizeiso mklocatedb mkiso mkimg
2e3f8f38 155
b9c3e754
MN
156realquickrel: check clean buildiso syssrcs customizeiso mklocatedb mkiso \
157 mkimg
6ca9a59c 158
9b29c40a
MD
159quick: quickrel
160
161realquick: realquickrel
162
163#########################################################################
164# CORE SUPPORT TARGETS #
165#########################################################################
166
d2582113 167check:
bce110a5
MD
168.if !exists(${PKGBIN_PKG_ADD})
169 @echo "Unable to find ${PKGBIN_PKG_ADD}. You can use the following"
170 @echo "command to bootstrap pkgsrc:"
171 @echo " make pkgsrc_bootstrap"
172 @exit 1
173.endif
95b64753 174.for PKG in ${OLD_PKGSRC_PACKAGES}
7c01f744 175 @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_DELETE} -K ${ISOROOT}${PKGSRC_DB} ${PKG} > /dev/null 2>&1 || exit 0
95b64753 176.endfor
bce110a5 177.for PKG in ${PKGSRC_PACKAGES}
7c01f744 178 @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -K ${ISOROOT}${PKGSRC_DB} -n ${PKG} > /dev/null 2>&1 || \
cbbd7681 179 (echo "Unable to find ${PKG}, use the following command to fetch required packages:"; echo " make [installer] fetch"; exit 1)
bce110a5
MD
180.endfor
181.if !exists(${PKGBIN_MKISOFS})
182 @echo "mkisofs is not installed. It is part of the cdrecord package."
183 @echo "You can install it with:"
184 @echo " make pkgsrc_cdrecord"
185 @exit 1
186.endif
0a1628e7
MD
187.if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
188 @echo "The pkgsrc bootstrap kit is not installed. You can install it with:"
cbbd7681 189 @echo " make [installer] fetch"
0a1628e7
MD
190 @exit 1
191.endif
192.if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
193 @echo "The cvsup bootstrap kit is not installed. You can install it with:"
cbbd7681 194 @echo " make [installer] fetch"
0a1628e7
MD
195 @exit 1
196.endif
2e3f8f38 197
588a679c 198buildworld1 buildworld2:
448b21e7 199 cd ${.CURDIR}/..; ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} make ${WITH_INSTALLER:C/^/-DWANT_INSTALLER/} ${.TARGET:C/build(.*)2/quick\1/:C/1//}
6ca9a59c 200
588a679c 201buildkernel1 buildkernel2:
bfe20b28
SW
202.if make(gui)
203 cd ${.CURDIR}/..; \
204 for kernconf in ${KERNCONF}; do \
448b21e7 205 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
82f56cac 206 make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
bfe20b28
SW
207 KERNCONF=$${kernconf} KERNCONFDIR=${.CURDIR}/gui/root; \
208 done
209.else
588a679c
SS
210 cd ${.CURDIR}/..; \
211 first=; \
212 for kernconf in ${KERNCONF}; do \
448b21e7 213 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
82f56cac 214 make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
588a679c
SS
215 KERNCONF=$${kernconf} \
216 $${first:+-DNO_MODULES}; \
217 first=done; \
218 done
bfe20b28 219.endif
6ca9a59c 220
5b22b655
MD
221# note that we do not want to mess with any /usr/obj directories not related
222# to buildworld, buildkernel, or nrelease, so we must supply the proper
223# MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
224# buildkernel mechanism.
225#
6ca9a59c
MD
226buildiso:
227 if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
5b22b655 228 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
7ebbae99 229 ( cd ${.CURDIR}/..; make ${WITH_INSTALLER:C/^/-DWANT_INSTALLER/} DESTDIR=${ISOROOT} installworld )
ab64cf06
SS
230 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
231 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
21aa02d0 232 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
bfe20b28
SW
233.if make(gui)
234 if [ ! -d ${ISOROOT}/kernel.smp ]; then mkdir -p ${ISOROOT}/kernel.smp; fi
235 cd ${.CURDIR}/..; \
236 make installkernel DESTDIR=${ISOROOT} \
237 KERNCONF=DFLYLIVE DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
238 cd ${.CURDIR}/..; \
239 make installkernel DESTDIR=${ISOROOT} \
240 KERNCONF=VKERNEL DESTKERNNAME=kernel.VKERNEL -DNO_MODULES KERNCONFDIR=${.CURDIR}/gui/root; \
241 cd ${.CURDIR}/..; \
242 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
243 KERNCONF=DFLYLIVE-SMP DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
244 cd ${.CURDIR}/..; \
245 make installkernel DESTDIR=${ISOROOT}/kernel.smp \
246 KERNCONF=DFLYLIVE-SMP-NOAPIC DESTKERNNAME=kernel.noapic \
247 KERNCONFDIR=${.CURDIR}/gui/root -DNO_MODULES;
248.else
588a679c
SS
249 cd ${.CURDIR}/..; \
250 first=; \
251 for kernconf in ${KERNCONF}; do \
252 make DESTDIR=${ISOROOT} \
253 installkernel KERNCONF=$${kernconf} \
254 $${first:+DESTKERNNAME=kernel.$${kernconf}} \
255 $${first:+-DNO_MODULES}; \
256 first=done; \
257 done
bfe20b28 258.endif
c5c5e6fc 259 ln -s kernel ${ISOROOT}/kernel.BOOTP
6ca9a59c
MD
260 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
261 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
262 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
8188de86 263
19d86faa
MD
264# Include kernel sources on the release CD (~14MB)
265#
266syssrcs:
66b79064 267.if !defined(WITHOUT_SRCS)
ccbff5d3 268 ( cd ${.CURDIR}/../..; tar -cf - src/Makefile src/Makefile.inc1 src/sys | bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2 )
66b79064 269.endif
19d86faa 270
8188de86 271customizeiso:
0a1628e7 272 (cd ${PKGSRC_PKG_PATH}; tar xzpf ${CVSUP_BOOTSTRAP_KIT}.tgz)
8188de86
MD
273.for ROOTSKEL in ${ROOTSKELS}
274 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
275.endfor
f6c08bce 276 rm -rf ${ISOROOT}/tmp/bootstrap ${ISOROOT}/usr/obj/pkgsrc
20585f87 277 cd ${ISOROOT}; tar xvzpf ${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz
0a1628e7 278 cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/bin/cvsup ${ISOROOT}/usr/local/bin/cvsup
c751e497 279 cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/man/man1/cvsup.1 ${ISOROOT}/usr/local/man/man1/cvsup.1
d08963d3 280 rm -rf ${ISOROOT}/tmp/bootstrap ${ISOROOT}/usr/obj/pkgsrc
21aa02d0 281 rm -rf ${ISOROOT}/usr/local/share/pristine
7249926b 282 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
4fba3387
CP
283.for UPGRADE_ITEM in Makefile \
284 etc.${MACHINE_ARCH} \
285 isdn/Makefile \
286 rc.d/Makefile \
287 periodic/Makefile \
288 periodic/daily/Makefile \
289 periodic/security/Makefile \
290 periodic/weekly/Makefile \
291 periodic/monthly/Makefile
292 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
293.endfor
bce110a5 294.for PKG in ${PKGSRC_PACKAGES}
799393ad 295 ${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -I -K ${ISOROOT}${PKGSRC_DB} -p ${ISOROOT}${PKGSRC_PREFIX} ${PKG}
8188de86 296.endfor
c791834f 297 find ${ISOROOT}${PKGSRC_DB} -name +CONTENTS -type f -exec sed -i '' -e 's,${ISOROOT},,' -- {} \;
7c01f744 298 ${PKGBIN_PKG_ADMIN} -K ${ISOROOT}${PKGSRC_DB} rebuild
3f279b9e
SW
299.if defined(WITH_GUI)
300.for FONT in 75dpi 100dpi misc Type1 TTF
301 chroot ${ISOROOT} /usr/pkg/bin/mkfontdir /usr/pkg/lib/X11/fonts/${FONT}
302.endfor
303.endif
3652f053
SW
304 makewhatis ${ISOROOT}/usr/local/man
305 makewhatis ${ISOROOT}/usr/pkg/man
6ca9a59c 306
8398ca17
SW
307mklocatedb:
308 ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
309 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
310 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
311 /usr/libexec/locate.mklocatedb \
312 -presort >${ISOROOT}/var/db/locate.database )
313
6ca9a59c 314mkiso:
bce110a5 315 ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
382f1ee3 316 -R -J -V DragonFly -o ${ISOFILE} . )
6ca9a59c 317
b9c3e754
MN
318
319mkimg:
320.if defined(WITH_IMG)
321 #dd if=/dev/zero of=${IMGFILE} bs=1m count=${IMGSIZE}
322 fdisk -IB -p ${IMGFILE}
323 vnconfig -e -s labels ${IMGVN} ${IMGFILE}
324 # write standard disklabel
325 disklabel -w -r ${IMGVN}s1 auto
326 # read back disklabel
327 disklabel -r ${IMGVN}s1 > ${IMGFILE}.label
328 # determine number of sectors of whole disk
329 # and add a: partition
330 ( secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w` && \
331 echo " a: $${secs} 0 4.2BSD" >> ${IMGFILE}.label )
332 # write modified disklabel back
333 disklabel -R -r ${IMGVN}s1 ${IMGFILE}.label
334 # write bootsector
335 disklabel -B ${IMGVN}s1
336 newfs /dev/${IMGVN}s1a
337 mount /dev/${IMGVN}s1a ${IMGMNT}
338
339 cpdup -vvv ${ISOROOT} ${IMGMNT}
340
341 #
342 # fix /etc/fstab
343 #
344 mv ${IMGMNT}/etc/fstab ${IMGMNT}/etc/fstab.old
345 cat ${IMGMNT}/etc/fstab.old | grep -v "cd9660" > ${IMGMNT}/etc/fstab
346 echo "${IMGUSBDEV}s1a / ufs rw 0 0" >> ${IMGMNT}/etc/fstab
347 rm ${IMGMNT}/etc/fstab.old
348
349 umount ${IMGMNT}
350 vnconfig -u ${IMGVN}
351.endif
352
6ca9a59c
MD
353clean:
354 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
8188de86 355 if [ -d ${ISOROOT} ]; then rm -rf ${ISOROOT}/*; fi
5b22b655 356 if [ -d ${NRLOBJDIR}/nrelease ]; then rm -rf ${NRLOBJDIR}/nrelease; fi
6ca9a59c
MD
357
358realclean: clean
3ebedc5e 359 rm -rf ${OBJSYS}/${KERNCONF}
bce110a5
MD
360 # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
361 # override location.
362 if [ -d ${ISODIR}/packages ]; then rm -rf ${ISODIR}/packages; fi
6ca9a59c 363
cc224c64 364fetch:
9b29c40a 365 @if [ ! -d ${PKGSRC_PKG_PATH} ]; then mkdir -p ${PKGSRC_PKG_PATH}; fi
bce110a5 366.for PKG in ${PKGSRC_PACKAGES}
7c01f744 367 @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -K ${ISOROOT}${PKGSRC_DB} -n ${PKG} > /dev/null 2>&1 || \
bce110a5
MD
368 (cd ${PKGSRC_PKG_PATH}; echo "Fetching ${PKGSRC_BOOTSTRAP_URL}/${PKG}"; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKG})
369.endfor
370.if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
371 (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
372.endif
0a1628e7
MD
373.if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
374 (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${CVSUP_BOOTSTRAP_KIT}.tgz)
375.endif
bce110a5
MD
376
377pkgsrc_bootstrap:
378 mkdir -p ${PKGSRC_PKG_PATH}
379.if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
380 (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
381.endif
382 (cd ${PKGSRC_PKG_PATH}; tar xzpf ${PKGSRC_BOOTSTRAP_KIT}.tgz)
383 (cd ${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}/bootstrap; ./bootstrap)
384
bce110a5
MD
385pkgsrc_cdrecord:
386.if !exists (${PKGBIN_MKISOFS})
20585f87 387 ${PKGBIN_PKG_ADD} ${PKGSRC_PKG_PATH}/cdrtools*
bce110a5 388.endif
cc224c64 389
588a679c 390
cc224c64 391.PHONY: all release installer_release quickrel installer_quickrel realquickrel
9b29c40a
MD
392.PHONY: installer_fetch installer
393.PHONY: quick realquick
cc224c64 394.PHONY: installer_realquickrel check buildworld1 buildworld2
b9c3e754 395.PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso mkimg
d5c58845 396.PHONY: clean realclean fetch
cc224c64 397
6ca9a59c 398.include <bsd.prog.mk>