Merge branch 'vendor/GDTOA'
[dragonfly.git] / nrelease / Makefile
1 # $DragonFly: src/nrelease/Makefile,v 1.90 2008/09/01 21:20:30 swildner Exp $
2 #
3
4 #########################################################################
5 #                               ENHANCEMENTS                            #
6 #########################################################################
7
8 # These targets are now obsolete and should not be used 
9 #
10 installer_release: warning release
11 installer_quickrel: warning quickrel
12 installer_realquickrel: warning realquickrel
13 installer_fetch: warning fetch
14
15 # New method e.g. 'make gui release'.  A series of enhancement
16 # targes may be specified which set make variables which enhance
17 # the build in various ways.
18 #
19 gui installer img:
20
21 warning:
22         @echo "WARNING: The installer_* targets are now obsolete, please"
23         @echo "use 'make blah' instead of 'make installer_blah'"
24         @echo ""
25         @echo "will continue in 10 seconds"
26         @sleep 10
27
28 .if make(gui)
29 WITH_GUI=
30 .endif
31 .if make(img)
32 WITH_IMG=
33 .endif
34
35 #########################################################################
36 #                                SETUP                                  #
37 #########################################################################
38
39 ISODIR ?= /usr/release
40 ISOROOT ?= ${ISODIR}/root
41 OBJSYS= ${.OBJDIR}/../sys
42
43 .if make(gui)
44 KERNCONF ?= DFLYLIVE VKERNEL DFLYLIVE-SMP DFLYLIVE-SMP-NOAPIC
45 .else
46 KERNCONF ?= GENERIC VKERNEL
47 .endif
48
49 PKGSRC_PREFIX?=         /usr/pkg
50 PKGBIN_PKG_ADD?=        ${PKGSRC_PREFIX}/sbin/pkg_add
51 PKGBIN_PKG_DELETE?=     ${PKGSRC_PREFIX}/sbin/pkg_delete
52 PKGBIN_PKG_ADMIN?=      ${PKGSRC_PREFIX}/sbin/pkg_admin
53 PKGBIN_MKISOFS?=        ${PKGSRC_PREFIX}/bin/mkisofs
54 PKGSRC_PKG_PATH?=       ${ISODIR}/packages
55 PKGSRC_DB?=             /var/db/pkg
56 PKGSRC_BOOTSTRAP_URL?=  http://pkgbox.dragonflybsd.org/DragonFly-pkgsrc-packages/i386/1.12.0-RELEASE-BUILD
57
58 ENVCMD?=        env
59 TAR?=   tar
60
61 PKGSRC_BOOTSTRAP_KIT?=  bootstrap-kit-20080211
62 CVSUP_BOOTSTRAP_KIT?=   cvsup-bootstrap-20070716
63
64 # Default packages to be installed on the release ISO.
65 #
66 PKGSRC_PACKAGES?=       cdrtools-ossdvd-2.01.1.36nb2.tgz \
67                         isc-dhcp-base-4.0.0.tgz isc-dhcp-server-4.0.0.tgz
68
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 #
74 OLD_PKGSRC_PACKAGES?= cdrtools-2.01.01.27nb1 cdrecord-2.00.3nb2 \
75                       bootstrap-kit-20070205
76
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 #
81 REQ_ROOTSKELS= ${.CURDIR}/root
82 ROOTSKELS?=     ${REQ_ROOTSKELS}
83
84 OLD_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
88 ROOTSKELS+=             ${.CURDIR}/installer
89
90 .if defined(WITH_GUI)
91 ISOFILE?=               ${ISODIR}/dfly-gui.iso
92 IMGFILE?=               ${ISODIR}/dfly-gui.img
93 PKGSRC_PACKAGES+=       modular-xorg-apps \
94                         modular-xorg-drivers \
95                         modular-xorg-fonts \
96                         modular-xorg-libs \
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
121 ROOTSKELS+=             ${.CURDIR}/gui
122 .endif
123
124 ISOFILE ?= ${ISODIR}/dfly.iso
125 IMGFILE ?= ${ISODIR}/dfly.img
126
127 IMGMNT ?= ${ISODIR}/mnt
128 IMGUSBDEV ?= /dev/da0
129
130 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
131 # the additional '/nrelease' manually, as a safety measure.
132 #
133 NRLOBJDIR?= /usr/obj
134
135 #########################################################################
136 #                               BASE ISO TARGETS                        #
137 #########################################################################
138
139 release:        check clean buildworld1 buildkernel1 \
140                 buildiso syssrcs customizeiso mklocatedb mkiso mkimg
141
142 quickrel:       check clean buildworld2 buildkernel2 \
143                 buildiso syssrcs customizeiso mklocatedb mkiso mkimg
144
145 realquickrel:   check clean buildiso syssrcs customizeiso mklocatedb mkiso \
146                 mkimg
147
148 quick:          quickrel
149
150 realquick:      realquickrel
151
152 #########################################################################
153 #                          CORE SUPPORT TARGETS                         #
154 #########################################################################
155
156 check:
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
163 .for PKG in ${OLD_PKGSRC_PACKAGES}
164         @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_DELETE} -K ${ISOROOT}${PKGSRC_DB} ${PKG} > /dev/null 2>&1 || exit 0
165 .endfor
166 .for PKG in ${PKGSRC_PACKAGES}
167         @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -K ${ISOROOT}${PKGSRC_DB} -n ${PKG} > /dev/null 2>&1 || \
168                 (echo "Unable to find ${PKG}, use the following command to fetch required packages:"; echo "    make fetch"; exit 1)
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
176 .if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
177         @echo "The pkgsrc bootstrap kit is not installed.  You can install it with:"
178         @echo "    make fetch"
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:"
183         @echo "    make fetch"
184         @exit 1
185 .endif
186
187 buildworld1 buildworld2:
188         cd ${.CURDIR}/..; ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} make -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
189
190 buildkernel1 buildkernel2:
191 .if make(gui)
192         cd ${.CURDIR}/..; \
193         for kernconf in ${KERNCONF}; do \
194                 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
195                 make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
196                         KERNCONF=$${kernconf} KERNCONFDIR=${.CURDIR}/gui/root; \
197         done
198 .else
199         cd ${.CURDIR}/..; \
200         first=; \
201         for kernconf in ${KERNCONF}; do \
202                 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
203                 make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
204                         KERNCONF=$${kernconf} \
205                         $${first:+-DNO_MODULES}; \
206                 first=done; \
207         done
208 .endif
209
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 #
215 buildiso:
216         if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
217         if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
218         ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
219         ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
220                 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
221         cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
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
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
247 .endif
248         ln -s kernel ${ISOROOT}/kernel.BOOTP
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
252
253 # Include kernel sources on the release CD (~14MB)
254 #
255 syssrcs:
256 .if !defined(WITHOUT_SRCS)
257         ( cd ${.CURDIR}/../..; tar -cf - src/Makefile src/Makefile.inc1 src/sys | bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2 )
258 .endif
259
260 customizeiso:
261         (cd ${PKGSRC_PKG_PATH}; tar xzpf ${CVSUP_BOOTSTRAP_KIT}.tgz)
262 .for ROOTSKEL in ${ROOTSKELS}
263         cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
264 .endfor
265         rm -rf ${ISOROOT}/tmp/bootstrap ${ISOROOT}/usr/obj/pkgsrc
266         cd ${ISOROOT}; tar xvzpf ${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz
267         cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/bin/cvsup ${ISOROOT}/usr/local/bin/cvsup
268         cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/man/man1/cvsup.1 ${ISOROOT}/usr/local/man/man1/cvsup.1
269         rm -rf ${ISOROOT}/tmp/bootstrap ${ISOROOT}/usr/obj/pkgsrc
270         rm -rf ${ISOROOT}/usr/local/share/pristine
271         pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
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}
282 .endfor
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
289 .for PKG in ${PKGSRC_PACKAGES}
290         ${ENVCMD} PKG_PATH=/tmp/packages chroot ${ISOROOT} ${PKGBIN_PKG_ADD} ${PKG}
291 .endfor
292         umount ${ISOROOT}/tmp/packages
293         rmdir ${ISOROOT}/tmp/packages
294         find ${ISOROOT}${PKGSRC_DB} -name +CONTENTS -type f -exec sed -i '' -e 's,${ISOROOT},,' -- {} \;
295         chroot ${ISOROOT} ${PKGBIN_PKG_ADMIN} rebuild
296         makewhatis ${ISOROOT}/usr/local/man
297         makewhatis ${ISOROOT}/usr/pkg/man
298
299 mklocatedb:
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
306 mkiso:
307         ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
308                 -R -J -V DragonFly -o ${ISOFILE} . )
309
310
311 mkimg:
312 .if defined(WITH_IMG)
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`;                  \
317         echo "add 15% more space as required" > /dev/null;              \
318         sz=`bc -e "(($${sz}) / 1024) * 1.15" -equit | cut -f1 -d.`;     \
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;                              \
341         echo "${IMGUSBDEV}s1a / ufs rw 0 0" > ${IMGMNT}/etc/fstab;      \
342         echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab;         \
343         df ${IMGMNT};                                                   \
344         umount ${IMGMNT};                                               \
345         vnconfig -u $${vn};                                             \
346         rmdir ${IMGMNT}
347 .endif
348
349 clean:
350         -umount ${ISOROOT}/tmp/packages
351         if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
352         if [ -d ${ISOROOT} ]; then rm -rf ${ISOROOT}/*; fi
353         if [ -d ${NRLOBJDIR}/nrelease ]; then rm -rf ${NRLOBJDIR}/nrelease; fi
354
355 realclean:      clean
356         rm -rf ${OBJSYS}/${KERNCONF}
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
360
361 fetch:
362         @if [ ! -d ${PKGSRC_PKG_PATH} ]; then mkdir -p ${PKGSRC_PKG_PATH}; fi
363 .for PKG in ${PKGSRC_PACKAGES}
364         @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -K ${ISOROOT}${PKGSRC_DB} -n ${PKG} > /dev/null 2>&1 || \
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
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
373
374 pkgsrc_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
382 pkgsrc_cdrecord:
383 .if !exists (${PKGBIN_MKISOFS})
384         ${PKGBIN_PKG_ADD} ${PKGSRC_PKG_PATH}/cdrtools*
385 .endif
386
387
388 .PHONY: all release installer_release quickrel installer_quickrel realquickrel
389 .PHONY: installer_fetch installer
390 .PHONY: quick realquick
391 .PHONY: installer_realquickrel check buildworld1 buildworld2
392 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso mkimg
393 .PHONY: clean realclean fetch
394
395 .include <bsd.prog.mk>