Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
[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 #########################################################################
29 #                                SETUP                                  #
30 #########################################################################
31
32 ISODIR ?= /usr/release
33 ISOROOT ?= ${ISODIR}/root
34 OBJSYS= ${.OBJDIR}/../sys
35
36 .if make(gui)
37 KERNCONF ?= DFLYLIVE VKERNEL DFLYLIVE-SMP DFLYLIVE-SMP-NOAPIC
38 .else
39 KERNCONF ?= GENERIC VKERNEL
40 .endif
41
42 PKGSRC_PREFIX?=         /usr/pkg
43 PKGBIN_PKG_ADD?=        ${PKGSRC_PREFIX}/sbin/pkg_add
44 PKGBIN_PKG_DELETE?=     ${PKGSRC_PREFIX}/sbin/pkg_delete
45 PKGBIN_PKG_ADMIN?=      ${PKGSRC_PREFIX}/sbin/pkg_admin
46 PKGBIN_MKISOFS?=        ${PKGSRC_PREFIX}/bin/mkisofs
47 PKGSRC_PKG_PATH?=       ${ISODIR}/packages
48 PKGSRC_DB?=             /var/db/pkg
49 CVSUP_BOOTSTRAP_KIT?=   cvsup-bootstrap-20070716
50
51 # pkgsrc packages to be built and installed on the release ISO
52 #
53 PKGSRC_PACKAGES?=       devel/scmgit \
54                         net/isc-dhcp4 \
55                         net/isc-dhcpd4 \
56                         pkgtools/pkg_leaves \
57                         sysutils/cdrtools
58
59 # pkgsrc options to use when building packages
60 #
61 .if !make(gui)
62 PKGSRC_OPTIONS?=        PKG_OPTIONS.scmgit=-scmgit-gui
63 .endif
64
65 # Even though buildiso wipes the packages, our check target has to run
66 # first and old packages (listed as they appear in pkg_info) must be
67 # cleaned out in order for the pkg_add -n test we use in the check target
68 # to operate properly.
69 #
70 OLD_PKGSRC_PACKAGES?=   cdrtools-2.01.01.27nb1 \
71                         cdrecord-2.00.3nb2 \
72                         bootstrap-kit-20070205 \
73                         dfuibe_installer-1.1.6 \
74                         gettext-lib-0.14.5 \
75                         dfuibe_installer-1.1.7nb1 \
76                         dfuife_curses-1.5 \
77                         gettext-lib-0.14.6 \
78                         gettext-tools-0.14.6nb1 \
79                         libaura-3.1 \
80                         libdfui-4.2 \
81                         libinstaller-5.1 \
82                         bootstrap-kit-20080211 \
83                         cdrtools-ossdvd-2.01.1.36nb2 \
84                         isc-dhcp-base-4.0.0 \
85                         isc-dhcp-server-4.0.0
86
87 # Specify which root skeletons are required, and let the user include
88 # their own.  They are copied into ISODIR during the `pkgcustomizeiso'
89 # target; each overwrites the last.
90 #
91 REQ_ROOTSKELS=  ${.CURDIR}/root \
92                 ${.CURDIR}/installer
93 ROOTSKELS?=     ${REQ_ROOTSKELS}
94
95 .if make(gui)
96 ISOFILE?=               ${ISODIR}/dfly-gui.iso
97 IMGFILE?=               ${ISODIR}/dfly-gui.img
98 PKGSRC_PACKAGES+=       meta/modular-xorg-apps \
99                         meta/modular-xorg-drivers \
100                         meta/modular-xorg-fonts \
101                         meta/modular-xorg-libs \
102                         wm/fluxbox \
103                         www/firefox3 \
104                         print/xpdf \
105                         shells/zsh \
106                         editors/emacs \
107                         editors/vim \
108                         chat/pidgin \
109                         chat/irssi \
110                         chat/xchat \
111                         x11/rxvt-unicode \
112                         x11/eterm \
113                         lang/perl5 \
114                         editors/nano \
115                         shells/bash \
116                         devel/exctags \
117                         archivers/zip \
118                         security/sudo \
119                         www/links-gui \
120                         net/nmap \
121                         net/wget \
122                         fonts/terminus-font \
123                         net/rsync \
124                         sysutils/idesk \
125                         misc/screen
126 ROOTSKELS+=             ${.CURDIR}/gui
127 .endif
128
129 ISOFILE ?= ${ISODIR}/dfly.iso
130 IMGFILE ?= ${ISODIR}/dfly.img
131
132 IMGMNT ?= ${ISODIR}/mnt
133 IMGUSBDEV ?= /dev/da0
134
135 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
136 # the additional '/nrelease' manually, as a safety measure.
137 #
138 NRLOBJDIR?= /usr/obj
139
140 #########################################################################
141 #                               BASE ISO TARGETS                        #
142 #########################################################################
143
144 release:        check clean buildworld1 buildkernel1 \
145                 buildiso syssrcs customizeiso mklocatedb mkiso mkimg
146
147 quickrel:       check clean buildworld2 buildkernel2 \
148                 buildiso syssrcs customizeiso mklocatedb mkiso mkimg
149
150 realquickrel:   check clean buildiso syssrcs customizeiso mklocatedb mkiso \
151                 mkimg
152
153 quick:          quickrel
154
155 realquick:      realquickrel
156
157 #########################################################################
158 #                          CORE SUPPORT TARGETS                         #
159 #########################################################################
160
161 check:
162 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
163         @echo "The cvsup bootstrap kit is not installed.  You can install it with:"
164         @echo "    make fetch"
165         @exit 1
166 .endif
167 .if !defined(PKGSRC_PATH)
168         @echo "Please set PKGSRC_PATH to the pkgsrc tree that shall be used for"
169         @echo "package building."
170         @exit 1
171 .endif
172
173 buildworld1 buildworld2:
174         cd ${.CURDIR}/..; ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} make -DWANT_INSTALLER ${.TARGET:C/build(.*)2/quick\1/:C/1//}
175
176 buildkernel1 buildkernel2:
177 .if make(gui)
178         cd ${.CURDIR}/..; \
179         for kernconf in ${KERNCONF}; do \
180                 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
181                 make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
182                         KERNCONF=$${kernconf} KERNCONFDIR=${.CURDIR}/gui/root; \
183         done
184 .else
185         cd ${.CURDIR}/..; \
186         first=; \
187         for kernconf in ${KERNCONF}; do \
188                 ${WORLD_CCVER:C/^..*$/WORLD_CCVER=/}${WORLD_CCVER} \
189                 make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
190                         KERNCONF=$${kernconf} \
191                         $${first:+-DNO_MODULES}; \
192                 first=done; \
193         done
194 .endif
195
196 # note that we do not want to mess with any /usr/obj directories not related
197 # to buildworld, buildkernel, or nrelease, so we must supply the proper
198 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and 
199 # buildkernel mechanism.
200 #
201 buildiso:
202         if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
203         if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
204         ( cd ${.CURDIR}/..; make -DWANT_INSTALLER DESTDIR=${ISOROOT} installworld )
205         ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
206                 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
207         cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
208 .if make(gui)
209         if [ ! -d ${ISOROOT}/kernel.smp/boot ]; then mkdir -p ${ISOROOT}/kernel.smp/boot; fi
210         cd ${.CURDIR}/..; \
211         make installkernel DESTDIR=${ISOROOT} \
212         KERNCONF=DFLYLIVE DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
213         cd ${.CURDIR}/..; \
214         make installkernel DESTDIR=${ISOROOT} \
215         KERNCONF=VKERNEL DESTKERNNAME=kernel.VKERNEL -DNO_MODULES KERNCONFDIR=${.CURDIR}/gui/root; \
216         cd ${.CURDIR}/..; \
217         make installkernel DESTDIR=${ISOROOT}/kernel.smp \
218         KERNCONF=DFLYLIVE-SMP DESTKERNNAME=kernel KERNCONFDIR=${.CURDIR}/gui/root; \
219         cd ${.CURDIR}/..; \
220         make installkernel DESTDIR=${ISOROOT}/kernel.smp \
221         KERNCONF=DFLYLIVE-SMP-NOAPIC DESTKERNNAME=kernel.noapic \
222                 KERNCONFDIR=${.CURDIR}/gui/root -DNO_MODULES;
223 .else
224         cd ${.CURDIR}/..; \
225         first=; \
226         for kernconf in ${KERNCONF}; do \
227                 make DESTDIR=${ISOROOT} \
228                         installkernel KERNCONF=$${kernconf} \
229                         $${first:+DESTKERNNAME=kernel.$${kernconf}} \
230                         $${first:+-DNO_MODULES}; \
231                 first=done; \
232         done
233 .endif
234         ln -s kernel ${ISOROOT}/kernel.BOOTP
235         mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
236         mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
237         dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
238
239 # Include kernel sources on the release CD (~14MB)
240 #
241 syssrcs:
242 .if !defined(WITHOUT_SRCS)
243         ( cd ${.CURDIR}/../..; tar -cf - src/Makefile src/Makefile.inc1 src/sys | bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2 )
244 .endif
245
246 customizeiso:
247 .for ROOTSKEL in ${ROOTSKELS}
248         cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
249 .endfor
250         (cd ${PKGSRC_PKG_PATH}; tar xzpf ${CVSUP_BOOTSTRAP_KIT}.tgz)
251         cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/bin/cvsup ${ISOROOT}/usr/local/bin/cvsup
252         cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/man/man1/cvsup.1 ${ISOROOT}/usr/local/man/man1/cvsup.1
253         pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
254 .for UPGRADE_ITEM in Makefile                   \
255                      etc.${MACHINE_ARCH}        \
256                      isdn/Makefile              \
257                      rc.d/Makefile              \
258                      periodic/Makefile          \
259                      periodic/daily/Makefile    \
260                      periodic/security/Makefile \
261                      periodic/weekly/Makefile   \
262                      periodic/monthly/Makefile
263         cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
264 .endfor
265         # setup some things & mount pkgsrc tree
266         cp -p /etc/resolv.conf ${ISOROOT}/etc
267         chroot ${ISOROOT} sh -c "ldconfig -elf /usr/lib /usr/lib/gcc* /usr/lib/compat"
268         mkdir -p ${ISOROOT}/usr/pkgobj/bootstrap/work
269         mkdir ${ISOROOT}/usr/pkgsrc
270         mount_null ${PKGSRC_PATH} ${ISOROOT}/usr/pkgsrc
271         # bootstrap
272         chroot ${ISOROOT} sh -c "cd /usr/pkgsrc/bootstrap; ./bootstrap --workdir /usr/pkgobj/bootstrap/work"
273         # build and install packages
274 .for PKG in ${PKGSRC_PACKAGES}
275         chroot ${ISOROOT} sh -c "cd /usr/pkgsrc; cd ${PKG}; bmake WRKOBJDIR=/usr/pkgobj ${PKGSRC_OPTIONS} build install"
276 .endfor
277         # remove packages which nothing depends on
278         chroot ${ISOROOT} sh -c "pkg_leaves | xargs pkg_delete -R"
279         umount ${ISOROOT}/usr/pkgsrc
280         rmdir ${ISOROOT}/usr/pkgsrc
281         rm -rf ${ISOROOT}/usr/pkgobj
282         rm -f ${ISOROOT}/etc/resolv.conf
283         makewhatis ${ISOROOT}/usr/local/man
284         makewhatis ${ISOROOT}/usr/pkg/man
285
286 mklocatedb:
287         ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
288                 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
289                 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
290                 /usr/libexec/locate.mklocatedb \
291                 -presort >${ISOROOT}/var/db/locate.database )
292
293 mkiso:
294         ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
295                 -R -J -V DragonFly-`${.CURDIR}/../tools/gitrev.sh` -o ${ISOFILE} . )
296
297
298 mkimg:
299 .if make(img)
300         if [ ! -d ${IMGMNT} ]; then mkdir -p ${IMGMNT}; fi
301
302         echo "determine required image size" > /dev/null;               \
303         sz=`du -ck ${ISOROOT} | tail -n 1 | cut -f 1`;                  \
304         echo "add 15% more space as required" > /dev/null;              \
305         sz=`bc -e "(($${sz}) / 1024) * 1.15" -equit | cut -f1 -d.`;     \
306         dd if=/dev/zero of=${IMGFILE} bs=1m count=$${sz};               \
307         fdisk -IB -p ${IMGFILE};                                        \
308         echo "determine free vn device" > /dev/null;                    \
309         vn=`vnconfig -l | grep "not in use" | head -n 1 | cut -f 1 -d:`; \
310         vnconfig -e -s labels $${vn} ${IMGFILE};                        \
311         echo "write standard disklabel" > /dev/null;                    \
312         disklabel -w -r $${vn}s1 auto;                                  \
313         echo "read disklabel back" > /dev/null;                         \
314         disklabel -r $${vn}s1 > ${IMGFILE}.label;                       \
315         echo "determine number of sectors of whole disk" > /dev/null;   \
316         secs=`tail -n 1 ${IMGFILE}.label | cut -f 3 -w`;                \
317         echo "and add a: partition" > /dev/null;                        \
318         echo "  a:  $${secs} 0 4.2BSD" >> ${IMGFILE}.label;             \
319         echo "write modified disklabel back" > /dev/null;               \
320         disklabel -R -r $${vn}s1 ${IMGFILE}.label;                      \
321         rm ${IMGFILE}.label;                                            \
322         echo "write bootsector" >  /dev/null;                           \
323         disklabel -B $${vn}s1;                                          \
324         newfs /dev/$${vn}s1a;                                           \
325         mount /dev/$${vn}s1a ${IMGMNT};                                 \
326         cpdup -vvv ${ISOROOT} ${IMGMNT};                                \
327         echo "fix /etc/fstab" > /dev/null;                              \
328         echo "${IMGUSBDEV}s1a / ufs rw 0 0" > ${IMGMNT}/etc/fstab;      \
329         echo "proc /proc procfs rw 0 0" >> ${IMGMNT}/etc/fstab;         \
330         df ${IMGMNT};                                                   \
331         umount ${IMGMNT};                                               \
332         vnconfig -u $${vn};                                             \
333         rmdir ${IMGMNT}
334 .endif
335
336 clean:
337         -umount ${ISOROOT}/usr/pkgsrc
338         if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
339         if [ -d ${ISOROOT} ]; then rm -rf ${ISOROOT}/*; fi
340         if [ -d ${NRLOBJDIR}/nrelease ]; then rm -rf ${NRLOBJDIR}/nrelease; fi
341
342 realclean:      clean
343         rm -rf ${OBJSYS}/${KERNCONF}
344         # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
345         # override location.
346         if [ -d ${ISODIR}/packages ]; then rm -rf ${ISODIR}/packages; fi
347
348 fetch:
349         @if [ ! -d ${PKGSRC_PKG_PATH} ]; then mkdir -p ${PKGSRC_PKG_PATH}; fi
350 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
351         (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${CVSUP_BOOTSTRAP_KIT}.tgz)
352 .endif
353
354 pkgsrc_bootstrap:
355         mkdir -p ${PKGSRC_PKG_PATH}
356 .if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
357         (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
358 .endif
359         (cd ${PKGSRC_PKG_PATH}; tar xzpf ${PKGSRC_BOOTSTRAP_KIT}.tgz)
360         (cd ${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}/bootstrap; ./bootstrap)
361
362 pkgsrc_cdrecord:
363 .if !exists (${PKGBIN_MKISOFS})
364         ${PKGBIN_PKG_ADD} ${PKGSRC_PKG_PATH}/cdrtools*
365 .endif
366
367
368 .PHONY: all release installer_release quickrel installer_quickrel realquickrel
369 .PHONY: installer_fetch installer
370 .PHONY: quick realquick
371 .PHONY: installer_realquickrel check buildworld1 buildworld2
372 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso mkimg
373 .PHONY: clean realclean fetch
374
375 .include <bsd.prog.mk>