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