Fix messages: s/installer_fetch/installer fetch/
[dragonfly.git] / nrelease / Makefile
1 # $DragonFly: src/nrelease/Makefile,v 1.74 2008/02/02 19:23:24 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 installer:
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(installer)
33 WITH_INSTALLER=
34 .endif
35
36 #########################################################################
37 #                                SETUP                                  #
38 #########################################################################
39
40 ISODIR ?= /usr/release
41 ISOFILE ?= ${ISODIR}/dfly.iso
42 ISOROOT = ${ISODIR}/root
43 OBJSYS= ${.OBJDIR}/../sys
44 KERNCONF ?= GENERIC VKERNEL
45
46 PKGSRC_PREFIX?=         /usr/pkg
47 PKGBIN_PKG_ADD?=        ${PKGSRC_PREFIX}/sbin/pkg_add
48 PKGBIN_PKG_DELETE?=     ${PKGSRC_PREFIX}/sbin/pkg_delete
49 PKGBIN_PKG_ADMIN?=      ${PKGSRC_PREFIX}/sbin/pkg_admin
50 PKGBIN_MKISOFS?=        ${PKGSRC_PREFIX}/bin/mkisofs
51 PKGSRC_PKG_PATH?=       ${ISODIR}/packages
52 PKGSRC_DB?=             /var/db/pkg
53 PKGSRC_BOOTSTRAP_URL?=  http://pkgbox.dragonflybsd.org/DragonFly-pkgsrc-packages/i386/1.10.0-RELEASE-BUILD
54
55 ENVCMD?=        env
56 TAR?=   tar
57
58 PKGSRC_CDRECORD?=       cdrtools-2.01.01.27nb1.tgz
59 PKGSRC_BOOTSTRAP_KIT?=  bootstrap-kit-20070801
60 CVSUP_BOOTSTRAP_KIT?=   cvsup-bootstrap-20070716
61
62 # Default packages to be installed on the release ISO.
63 #
64 PKGSRC_PACKAGES?=       cdrtools-2.01.01.27nb1.tgz
65
66 # Even though buildiso wipes the packages, our check target has to run
67 # first and old packages (listed as they appear in pkg_info) must be
68 # cleaned out in order for the pkg_add -n test we use in the check target
69 # to operate properly.
70 #
71 OLD_PKGSRC_PACKAGES?= cdrecord-2.00.3nb2 bootstrap-kit-20070205
72
73 # Specify which root skeletons are required, and let the user include
74 # their own.  They are copied into ISODIR during the `pkgcustomizeiso'
75 # target; each overwrites the last.
76 #
77 REQ_ROOTSKELS= ${.CURDIR}/root
78 ROOTSKELS?=     ${REQ_ROOTSKELS}
79
80 .if defined(WITH_INSTALLER)
81 OLD_PKGSRC_PACKAGES+=   dfuibe_installer-1.1.6
82 PKGSRC_PACKAGES+=       dfuibe_installer-1.1.7nb1.tgz dfuife_curses-1.5.tgz
83 PKGSRC_PACKAGES+=       gettext-lib-0.14.5.tgz libaura-3.1.tgz \
84                         libdfui-4.2.tgz libinstaller-5.1.tgz
85 ROOTSKELS+=             ${.CURDIR}/installer
86 .endif
87
88 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
89 # the additional '/nrelease' manually, as a safety measure.
90 #
91 NRLOBJDIR?= /usr/obj
92
93 WORLD_CCVER ?= ${CCVER}
94 KERNEL_CCVER ?= ${CCVER}
95
96 #########################################################################
97 #                               BASE ISO TARGETS                        #
98 #########################################################################
99
100 release:        check clean buildworld1 buildkernel1 \
101                 buildiso syssrcs customizeiso mklocatedb mkiso
102
103 quickrel:       check clean buildworld2 buildkernel2 \
104                 buildiso syssrcs customizeiso mklocatedb mkiso
105
106 realquickrel:   check clean buildiso syssrcs customizeiso mklocatedb mkiso
107
108 quick:          quickrel
109
110 realquick:      realquickrel
111
112 #########################################################################
113 #                          CORE SUPPORT TARGETS                         #
114 #########################################################################
115
116 check:
117 .if !exists(${PKGBIN_PKG_ADD})
118         @echo "Unable to find ${PKGBIN_PKG_ADD}.  You can use the following"
119         @echo "command to bootstrap pkgsrc:"
120         @echo "    make pkgsrc_bootstrap"
121         @exit 1
122 .endif
123 .for PKG in ${OLD_PKGSRC_PACKAGES}
124         @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_DELETE} -K ${ISOROOT}/var/db/pkg ${PKG} > /dev/null 2>&1 || exit 0
125 .endfor
126 .for PKG in ${PKGSRC_PACKAGES}
127         @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -K ${ISOROOT}/var/db/pkg -n ${PKG} > /dev/null 2>&1 || \
128                 (echo "Unable to find ${PKG}, use the following command to fetch required packages:"; echo "    make [installer] fetch"; exit 1)
129 .endfor
130 .if !exists(${PKGBIN_MKISOFS})
131         @echo "mkisofs is not installed.  It is part of the cdrecord package."
132         @echo "You can install it with:"
133         @echo "    make pkgsrc_cdrecord"
134         @exit 1
135 .endif
136 .if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
137         @echo "The pkgsrc bootstrap kit is not installed.  You can install it with:"
138         @echo "    make [installer] fetch"
139         @exit 1
140 .endif
141 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
142         @echo "The cvsup bootstrap kit is not installed.  You can install it with:"
143         @echo "    make [installer] fetch"
144         @exit 1
145 .endif
146
147 buildworld1 buildworld2:
148         cd ${.CURDIR}/..; CCVER=${WORLD_CCVER} make ${.TARGET:C/build(.*)2/quick\1/:C/1//}
149
150 buildkernel1 buildkernel2:
151         cd ${.CURDIR}/..; \
152         first=; \
153         for kernconf in ${KERNCONF}; do \
154                 CCVER=${KERNEL_CCVER} make ${.TARGET:C/build(.*)2/quick\1/:C/1//} \
155                         KERNCONF=$${kernconf} \
156                         $${first:+-DNO_MODULES}; \
157                 first=done; \
158         done
159
160 # note that we do not want to mess with any /usr/obj directories not related
161 # to buildworld, buildkernel, or nrelease, so we must supply the proper
162 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and 
163 # buildkernel mechanism.
164 #
165 buildiso:
166         if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
167         if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
168         ( cd ${.CURDIR}/..; make DESTDIR=${ISOROOT} installworld )
169         ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
170                 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
171         chroot ${ISOROOT} /usr/bin/newaliases
172         cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
173         cd ${.CURDIR}/..; \
174         first=; \
175         for kernconf in ${KERNCONF}; do \
176                 make DESTDIR=${ISOROOT} \
177                         installkernel KERNCONF=$${kernconf} \
178                         $${first:+DESTKERNNAME=kernel.$${kernconf}} \
179                         $${first:+-DNO_MODULES}; \
180                 first=done; \
181         done
182         ln -s kernel ${ISOROOT}/kernel.BOOTP
183         mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
184         mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
185         dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
186
187 # Include kernel sources on the release CD (~14MB)
188 #
189 syssrcs:
190 .if !defined(WITHOUT_SRCS)
191         ( cd ${.CURDIR}/../..; tar --exclude CVS -cf - src/Makefile src/Makefile.inc1 src/sys | bzip2 -9 > ${ISOROOT}/usr/src-sys.tar.bz2 )
192 .endif
193
194 customizeiso:
195         (cd ${PKGSRC_PKG_PATH}; tar xzpf ${CVSUP_BOOTSTRAP_KIT}.tgz)
196 .for ROOTSKEL in ${ROOTSKELS}
197         cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
198 .endfor
199         rm -rf ${ISOROOT}/tmp/bootstrap ${ISOROOT}/usr/obj/pkgsrc
200         cd ${ISOROOT}; tar xvzpf ${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz
201         cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/bin/cvsup ${ISOROOT}/usr/local/bin/cvsup
202         cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/man/man1/cvsup.1 ${ISOROOT}/usr/local/man/man1/cvsup.1
203         rm -rf ${ISOROOT}/tmp/bootstrap ${ISOROOT}/usr/obj/pkgsrc
204         rm -rf `find ${ISOROOT} -type d -name CVS -print`
205         rm -rf ${ISOROOT}/usr/local/share/pristine
206         pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
207 .for UPGRADE_ITEM in Makefile                   \
208                      etc.${MACHINE_ARCH}        \
209                      isdn/Makefile              \
210                      rc.d/Makefile              \
211                      periodic/Makefile          \
212                      periodic/daily/Makefile    \
213                      periodic/security/Makefile \
214                      periodic/weekly/Makefile   \
215                      periodic/monthly/Makefile
216         cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
217 .endfor
218         # This is a really bad hack.  There seems to be no reliable way
219         # to install a package to a target directory prefix so we have to
220         # copy everything into the ISO root and do the install chrooted.
221         #
222         rm -rf ${ISOROOT}/tmp/packages
223         mkdir ${ISOROOT}/tmp/packages
224 .for PKG in ${PKGSRC_PACKAGES}
225         cp ${PKGSRC_PKG_PATH}/${PKG} ${ISOROOT}/tmp/packages
226 .endfor
227 .for PKG in ${PKGSRC_PACKAGES}
228         ${ENVCMD} PKG_PATH=/tmp/packages chroot ${ISOROOT} ${PKGBIN_PKG_ADD} -I ${PKG}
229 .endfor
230         rm -rf ${ISOROOT}/tmp/packages
231         find ${ISOROOT}${PKGSRC_DB} -name +CONTENTS -type f -exec sed -i '' -e 's,${ISOROOT},,' -- {} \;
232         chroot ${ISOROOT} ${PKGBIN_PKG_ADMIN} rebuild
233
234 mklocatedb:
235         ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
236                 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
237                 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
238                 /usr/libexec/locate.mklocatedb \
239                 -presort >${ISOROOT}/var/db/locate.database )
240
241 mkiso:
242         ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
243                 -R -J -V DragonFly -o ${ISOFILE} . )
244
245 clean:
246         if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
247         if [ -d ${ISOROOT} ]; then rm -rf ${ISOROOT}/*; fi
248         if [ -d ${NRLOBJDIR}/nrelease ]; then rm -rf ${NRLOBJDIR}/nrelease; fi
249
250 realclean:      clean
251         rm -rf ${OBJSYS}/${KERNCONF}
252         # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
253         # override location.
254         if [ -d ${ISODIR}/packages ]; then rm -rf ${ISODIR}/packages; fi
255
256 fetch:
257         @if [ ! -d ${PKGSRC_PKG_PATH} ]; then mkdir -p ${PKGSRC_PKG_PATH}; fi
258 .for PKG in ${PKGSRC_PACKAGES}
259         @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -K ${ISOROOT}/var/db/pkg -n ${PKG} > /dev/null 2>&1 || \
260         (cd ${PKGSRC_PKG_PATH}; echo "Fetching ${PKGSRC_BOOTSTRAP_URL}/${PKG}"; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKG})
261 .endfor
262 .if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
263         (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
264 .endif
265 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
266         (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${CVSUP_BOOTSTRAP_KIT}.tgz)
267 .endif
268
269 pkgsrc_bootstrap:
270         mkdir -p ${PKGSRC_PKG_PATH}
271 .if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
272         (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
273 .endif
274         (cd ${PKGSRC_PKG_PATH}; tar xzpf ${PKGSRC_BOOTSTRAP_KIT}.tgz)
275         (cd ${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}/bootstrap; ./bootstrap)
276
277 pkgsrc_cdrecord:
278 .if !exists (${PKGBIN_MKISOFS})
279         ${PKGBIN_PKG_ADD} ${PKGSRC_PKG_PATH}/cdrtools*
280 .endif
281
282
283 .PHONY: all release installer_release quickrel installer_quickrel realquickrel
284 .PHONY: installer_fetch installer
285 .PHONY: quick realquick
286 .PHONY: installer_realquickrel check buildworld1 buildworld2
287 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso
288 .PHONY: clean realclean fetch
289
290 .include <bsd.prog.mk>