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