Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly into...
[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 .if make(installer_release) || make(installer_quickrel) || make(installer_realquickrel) || make(installer_fetch)
16 WITH_INSTALLER=
17 .endif
18
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 #
23 gui installer img:
24
25 warning:
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
32 .if make(gui)
33 WITH_GUI=
34 .endif
35 .if make(installer)
36 WITH_INSTALLER=
37 .endif
38 .if make(img)
39 WITH_IMG=
40 .endif
41
42 #########################################################################
43 #                                SETUP                                  #
44 #########################################################################
45
46 ISODIR ?= /usr/release
47 ISOROOT ?= ${ISODIR}/root
48 OBJSYS= ${.OBJDIR}/../sys
49
50 .if make(gui)
51 KERNCONF ?= DFLYLIVE VKERNEL DFLYLIVE-SMP DFLYLIVE-SMP-NOAPIC
52 .else
53 KERNCONF ?= GENERIC VKERNEL
54 .endif
55
56 PKGSRC_PREFIX?=         /usr/pkg
57 PKGBIN_PKG_ADD?=        ${PKGSRC_PREFIX}/sbin/pkg_add
58 PKGBIN_PKG_DELETE?=     ${PKGSRC_PREFIX}/sbin/pkg_delete
59 PKGBIN_PKG_ADMIN?=      ${PKGSRC_PREFIX}/sbin/pkg_admin
60 PKGBIN_MKISOFS?=        ${PKGSRC_PREFIX}/bin/mkisofs
61 PKGSRC_PKG_PATH?=       ${ISODIR}/packages
62 PKGSRC_DB?=             /var/db/pkg
63 PKGSRC_BOOTSTRAP_URL?=  http://pkgbox.dragonflybsd.org/DragonFly-pkgsrc-packages/i386/1.12.0-RELEASE-BUILD
64
65 ENVCMD?=        env
66 TAR?=   tar
67
68 PKGSRC_BOOTSTRAP_KIT?=  bootstrap-kit-20080211
69 CVSUP_BOOTSTRAP_KIT?=   cvsup-bootstrap-20070716
70
71 # Default packages to be installed on the release ISO.
72 #
73 PKGSRC_PACKAGES?=       cdrtools-ossdvd-2.01.1.36nb2.tgz \
74                         isc-dhcp-base-4.0.0.tgz isc-dhcp-server-4.0.0.tgz
75
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 #
81 OLD_PKGSRC_PACKAGES?= cdrtools-2.01.01.27nb1 cdrecord-2.00.3nb2 \
82                       bootstrap-kit-20070205
83
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 #
88 REQ_ROOTSKELS= ${.CURDIR}/root
89 ROOTSKELS?=     ${REQ_ROOTSKELS}
90
91 .if defined(WITH_INSTALLER)
92 OLD_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
96 ROOTSKELS+=             ${.CURDIR}/installer
97 .endif
98
99 .if defined(WITH_GUI)
100 ISOFILE?=               ${ISODIR}/dfly-gui.iso
101 IMGFILE?=               ${ISODIR}/dfly-gui.img
102 PKGSRC_PACKAGES+=       modular-xorg-apps \
103                         modular-xorg-drivers \
104                         modular-xorg-fonts \
105                         modular-xorg-libs \
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
130 ROOTSKELS+=             ${.CURDIR}/gui
131 .endif
132
133 ISOFILE ?= ${ISODIR}/dfly.iso
134 IMGFILE ?= ${ISODIR}/dfly.img
135
136 IMGMNT ?= ${ISOROOT}/mnt
137 IMGUSBDEV ?= /dev/da0
138
139 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
140 # the additional '/nrelease' manually, as a safety measure.
141 #
142 NRLOBJDIR?= /usr/obj
143
144 #########################################################################
145 #                               BASE ISO TARGETS                        #
146 #########################################################################
147
148 release:        check clean buildworld1 buildkernel1 \
149                 buildiso syssrcs customizeiso mklocatedb mkiso mkimg
150
151 quickrel:       check clean buildworld2 buildkernel2 \
152                 buildiso syssrcs customizeiso mklocatedb mkiso mkimg
153
154 realquickrel:   check clean buildiso syssrcs customizeiso mklocatedb mkiso \
155                 mkimg
156
157 quick:          quickrel
158
159 realquick:      realquickrel
160
161 #########################################################################
162 #                          CORE SUPPORT TARGETS                         #
163 #########################################################################
164
165 check:
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
172 .for PKG in ${OLD_PKGSRC_PACKAGES}
173         @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_DELETE} -K ${ISOROOT}${PKGSRC_DB} ${PKG} > /dev/null 2>&1 || exit 0
174 .endfor
175 .for PKG in ${PKGSRC_PACKAGES}
176         @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -K ${ISOROOT}${PKGSRC_DB} -n ${PKG} > /dev/null 2>&1 || \
177                 (echo "Unable to find ${PKG}, use the following command to fetch required packages:"; echo "    make [installer] fetch"; exit 1)
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
185 .if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
186         @echo "The pkgsrc bootstrap kit is not installed.  You can install it with:"
187         @echo "    make [installer] fetch"
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:"
192         @echo "    make [installer] fetch"
193         @exit 1
194 .endif
195
196 buildworld1 buildworld2:
197         cd ${.CURDIR}/..; ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} make ${WITH_INSTALLER:C/^/-DWANT_INSTALLER/} ${.TARGET:C/build(.*)2/quick\1/:C/1//}
198
199 buildkernel1 buildkernel2:
200 .if make(gui)
201         cd ${.CURDIR}/..; \
202         for kernconf in ${KERNCONF}; do \
203                 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
204                 make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
205                         KERNCONF=$${kernconf} KERNCONFDIR=${.CURDIR}/gui/root; \
206         done
207 .else
208         cd ${.CURDIR}/..; \
209         first=; \
210         for kernconf in ${KERNCONF}; do \
211                 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
212                 make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
213                         KERNCONF=$${kernconf} \
214                         $${first:+-DNO_MODULES}; \
215                 first=done; \
216         done
217 .endif
218
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 #
224 buildiso:
225         if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
226         if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
227         ( cd ${.CURDIR}/..; make ${WITH_INSTALLER:C/^/-DWANT_INSTALLER/} DESTDIR=${ISOROOT} installworld )
228         ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
229                 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
230         cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
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
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
256 .endif
257         ln -s kernel ${ISOROOT}/kernel.BOOTP
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
261
262 # Include kernel sources on the release CD (~14MB)
263 #
264 syssrcs:
265 .if !defined(WITHOUT_SRCS)
266         ( cd ${.CURDIR}/../..; tar -cf - src/Makefile src/Makefile.inc1 src/sys | bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2 )
267 .endif
268
269 customizeiso:
270         (cd ${PKGSRC_PKG_PATH}; tar xzpf ${CVSUP_BOOTSTRAP_KIT}.tgz)
271 .for ROOTSKEL in ${ROOTSKELS}
272         cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
273 .endfor
274         rm -rf ${ISOROOT}/tmp/bootstrap ${ISOROOT}/usr/obj/pkgsrc
275         cd ${ISOROOT}; tar xvzpf ${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz
276         cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/bin/cvsup ${ISOROOT}/usr/local/bin/cvsup
277         cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/man/man1/cvsup.1 ${ISOROOT}/usr/local/man/man1/cvsup.1
278         rm -rf ${ISOROOT}/tmp/bootstrap ${ISOROOT}/usr/obj/pkgsrc
279         rm -rf ${ISOROOT}/usr/local/share/pristine
280         pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
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
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
298 .for PKG in ${PKGSRC_PACKAGES}
299         ${ENVCMD} PKG_PATH=/tmp/packages chroot ${ISOROOT} ${PKGBIN_PKG_ADD} ${PKG}
300 .endfor
301         umount ${ISOROOT}/tmp/packages
302         rmdir ${ISOROOT}/tmp/packages
303         find ${ISOROOT}${PKGSRC_DB} -name +CONTENTS -type f -exec sed -i '' -e 's,${ISOROOT},,' -- {} \;
304         chroot ${ISOROOT} ${PKGBIN_PKG_ADMIN} rebuild
305         makewhatis ${ISOROOT}/usr/local/man
306         makewhatis ${ISOROOT}/usr/pkg/man
307
308 mklocatedb:
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
315 mkiso:
316         ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
317                 -R -J -V DragonFly -o ${ISOFILE} . )
318
319
320 mkimg:
321 .if defined(WITH_IMG)
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}
355 .endif
356
357 clean:
358         -umount ${ISOROOT}/tmp/packages
359         if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
360         if [ -d ${ISOROOT} ]; then rm -rf ${ISOROOT}/*; fi
361         if [ -d ${NRLOBJDIR}/nrelease ]; then rm -rf ${NRLOBJDIR}/nrelease; fi
362
363 realclean:      clean
364         rm -rf ${OBJSYS}/${KERNCONF}
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
368
369 fetch:
370         @if [ ! -d ${PKGSRC_PKG_PATH} ]; then mkdir -p ${PKGSRC_PKG_PATH}; fi
371 .for PKG in ${PKGSRC_PACKAGES}
372         @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -K ${ISOROOT}${PKGSRC_DB} -n ${PKG} > /dev/null 2>&1 || \
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
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
381
382 pkgsrc_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
390 pkgsrc_cdrecord:
391 .if !exists (${PKGBIN_MKISOFS})
392         ${PKGBIN_PKG_ADD} ${PKGSRC_PKG_PATH}/cdrtools*
393 .endif
394
395
396 .PHONY: all release installer_release quickrel installer_quickrel realquickrel
397 .PHONY: installer_fetch installer
398 .PHONY: quick realquick
399 .PHONY: installer_realquickrel check buildworld1 buildworld2
400 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso mkimg
401 .PHONY: clean realclean fetch
402
403 .include <bsd.prog.mk>