Fix a bug in the pkg_add -n tests where pkg_add was incorrectly reporting
[dragonfly.git] / nrelease / Makefile
1 # $DragonFly: src/nrelease/Makefile,v 1.54 2006/04/14 20:56:53 dillon 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
19
20 PKGSRC_PREFIX?=         /usr/pkg
21 PKGBIN_PKG_ADD?=        ${PKGSRC_PREFIX}/sbin/pkg_add
22 PKGBIN_PKG_ADMIN?=      ${PKGSRC_PREFIX}/sbin/pkg_admin
23 PKGBIN_MKISOFS?=        ${PKGSRC_PREFIX}/bin/mkisofs
24 PKGSRC_PKG_PATH?=       ${ISODIR}/packages
25 PKGSRC_DB?=             /var/db/pkg
26 PKGSRC_BOOTSTRAP_URL?=  http://pkgbox.dragonflybsd.org/DragonFly-pkgsrc-packages/i386/1.4.4-RELEASE-BUILD
27
28 ENVCMD?=        env
29 TAR?=   tar
30
31 PKGSRC_CDRECORD?=       cdrecord-2.00.3nb2.tgz
32 PKGSRC_BOOTSTRAP_KIT?=  bootstrap-kit-20051221
33 CVSUP_BOOTSTRAP_KIT?=   cvsup-bootstrap-20051229
34
35 PKGSRC_PACKAGES?=       cdrecord-2.00.3nb2.tgz
36
37 # Specify which root skeletons are required, and let the user include
38 # their own.  They are copied into ISODIR during the `pkgcustomizeiso'
39 # target; each overwrites the last.
40 #
41 REQ_ROOTSKELS= ${.CURDIR}/root
42 ROOTSKELS?=     ${REQ_ROOTSKELS}
43
44 .if defined(WITH_INSTALLER)
45 PKGSRC_PACKAGES+=       dfuibe_installer-1.1.6a.tgz dfuife_curses-1.5.tgz
46 PKGSRC_PACKAGES+=       gettext-lib-0.14.5.tgz libaura-3.1.tgz \
47                         libdfui-4.2.tgz libinstaller-5.1.tgz
48 ROOTSKELS+=             installer
49 .endif
50
51 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
52 # the additional '/nrelease' manually, as a safety measure.
53 #
54 NRLOBJDIR?= /usr/obj
55
56 WORLD_CCVER ?= ${CCVER}
57 KERNEL_CCVER ?= ${CCVER}
58
59 #########################################################################
60 #                               BASE ISO TARGETS                        #
61 #########################################################################
62
63 release:        check clean buildworld1 buildkernel1 \
64                 buildiso customizeiso mklocatedb mkiso
65
66 quickrel:       check clean buildworld2 buildkernel2 \
67                 buildiso customizeiso mklocatedb mkiso
68
69 realquickrel:   check clean buildiso customizeiso mklocatedb mkiso
70
71 check:
72 .if !exists(${PKGBIN_PKG_ADD})
73         @echo "Unable to find ${PKGBIN_PKG_ADD}.  You can use the following"
74         @echo "command to bootstrap pkgsrc:"
75         @echo "    make pkgsrc_bootstrap"
76         @exit 1
77 .endif
78 .if !exists(/etc/mk.conf)
79         @echo "You do not have an /etc/mk.conf.  You can use the following"
80         @echo "command to install one.  Otherwise pkgsrc defaults will not"
81         @echo "point to the  right place:"
82         @echo "    make pkgsrc_conf"
83         @exit 1
84 .endif
85 .for PKG in ${PKGSRC_PACKAGES}
86         @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -K ${ISOROOT}/var/db/pkg -n ${PKG} > /dev/null 2>&1 || \
87                 (echo "Unable to find ${PKG}, use the following command to fetch required packages:"; echo "    make [installer_]fetch"; exit 1)
88 .endfor
89 .if !exists(${PKGBIN_MKISOFS})
90         @echo "mkisofs is not installed.  It is part of the cdrecord package."
91         @echo "You can install it with:"
92         @echo "    make pkgsrc_cdrecord"
93         @exit 1
94 .endif
95 .if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
96         @echo "The pkgsrc bootstrap kit is not installed.  You can install it with:"
97         @echo "    make [installer_]fetch"
98         @exit 1
99 .endif
100 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
101         @echo "The cvsup bootstrap kit is not installed.  You can install it with:"
102         @echo "    make [installer_]fetch"
103         @exit 1
104 .endif
105
106 buildworld1:
107         ( cd ${.CURDIR}/..; CCVER=${WORLD_CCVER} make buildworld )
108
109 buildworld2:
110         ( cd ${.CURDIR}/..; CCVER=${WORLD_CCVER} make quickworld )
111
112 buildkernel1:
113         ( cd ${.CURDIR}/..; CCVER=${KERNEL_CCVER} make buildkernel KERNCONF=${KERNCONF} )
114
115 buildkernel2:
116         ( cd ${.CURDIR}/..; CCVER=${KERNEL_CCVER} make quickkernel KERNCONF=${KERNCONF} )
117
118 # note that we do not want to mess with any /usr/obj directories not related
119 # to buildworld, buildkernel, or nrelease, so we must supply the proper
120 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and 
121 # buildkernel mechanism.
122 #
123 buildiso:
124         if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
125         if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
126         ( cd ${.CURDIR}/..; make DESTDIR=${ISOROOT} installworld )
127         ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
128                 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
129         cp -p ${.CURDIR}/mk.conf.pkgsrc ${ISOROOT}/etc/mk.conf
130         chroot ${ISOROOT} /usr/bin/newaliases
131         cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
132         ( cd ${.CURDIR}/..; make DESTDIR=${ISOROOT} \
133                 installkernel KERNCONF=${KERNCONF} )
134         ln -s kernel ${ISOROOT}/kernel.BOOTP
135         mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
136         mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
137         dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
138
139 customizeiso:
140         (cd ${PKGSRC_PKG_PATH}; tar xzpf ${PKGSRC_BOOTSTRAP_KIT}.tgz)
141         (cd ${PKGSRC_PKG_PATH}; tar xzpf ${CVSUP_BOOTSTRAP_KIT}.tgz)
142 .for ROOTSKEL in ${ROOTSKELS}
143         cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
144 .endfor
145         rm -rf ${ISOROOT}/tmp/bootstrap ${ISOROOT}/usr/obj/pkgsrc
146         cpdup ${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT} ${ISOROOT}/tmp/bootstrap
147         cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/bin/cvsup ${ISOROOT}/usr/local/bin/cvsup
148         chroot ${ISOROOT} csh -c "cd /tmp/bootstrap/bootstrap; ./bootstrap"
149         rm -rf ${ISOROOT}/tmp/bootstrap ${ISOROOT}/usr/obj/pkgsrc
150         rm -rf `find ${ISOROOT} -type d -name CVS -print`
151         rm -rf ${ISOROOT}/usr/local/share/pristine
152         pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
153 .for UPGRADE_ITEM in Makefile                   \
154                      etc.${MACHINE_ARCH}        \
155                      isdn/Makefile              \
156                      rc.d/Makefile              \
157                      periodic/Makefile          \
158                      periodic/daily/Makefile    \
159                      periodic/security/Makefile \
160                      periodic/weekly/Makefile   \
161                      periodic/monthly/Makefile
162         cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
163 .endfor
164 .for PKG in ${PKGSRC_PACKAGES}
165         ${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -I -K ${ISOROOT}${PKGSRC_DB} -p ${ISOROOT}${PKGSRC_PREFIX} ${PKG}
166 .endfor
167         find ${ISOROOT}${PKGSRC_DB} -name +CONTENTS -type f -exec sed -i '' -e 's,${ISOROOT},,' -- {} \;
168         ${PKGBIN_PKG_ADMIN} -K ${ISOROOT}${PKGSRC_DB} rebuild
169
170 mklocatedb:
171         ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
172                 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
173                 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
174                 /usr/libexec/locate.mklocatedb \
175                 -presort >${ISOROOT}/var/db/locate.database )
176
177 mkiso:
178         ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
179                 -R -J -V DragonFly -o ${ISOFILE} . )
180
181 clean:
182         if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
183         if [ -d ${ISOROOT} ]; then rm -rf ${ISOROOT}/*; fi
184         if [ -d ${NRLOBJDIR}/nrelease ]; then rm -rf ${NRLOBJDIR}/nrelease; fi
185
186 realclean:      clean
187         rm -rf ${OBJSYS}/${KERNCONF}
188         # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
189         # override location.
190         if [ -d ${ISODIR}/packages ]; then rm -rf ${ISODIR}/packages; fi
191
192 fetch:
193         mkdir -p ${PKGSRC_PKG_PATH}
194 .for PKG in ${PKGSRC_PACKAGES}
195         @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -K ${ISOROOT}/var/db/pkg -n ${PKG} > /dev/null 2>&1 || \
196         (cd ${PKGSRC_PKG_PATH}; echo "Fetching ${PKGSRC_BOOTSTRAP_URL}/${PKG}"; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKG})
197 .endfor
198 .if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
199         (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
200 .endif
201 .if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
202         (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${CVSUP_BOOTSTRAP_KIT}.tgz)
203 .endif
204
205 pkgsrc_bootstrap:
206         mkdir -p ${PKGSRC_PKG_PATH}
207 .if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
208         (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
209 .endif
210         (cd ${PKGSRC_PKG_PATH}; tar xzpf ${PKGSRC_BOOTSTRAP_KIT}.tgz)
211         (cd ${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}/bootstrap; ./bootstrap)
212
213 pkgsrc_conf:
214 .if !exists(/etc/mk.conf) 
215         cp ${.CURDIR}/mk.conf.pkgsrc /etc/mk.conf
216 .else
217         fgrep -q BSD_PKG_MK /etc/mk.conf || cat ${.CURDIR}/mk.conf.pkgsrc >> /etc/mk.conf
218 .endif
219
220 pkgsrc_cdrecord:
221 .if !exists (${PKGBIN_MKISOFS})
222         ${PKGBIN_PKG_ADD} ${PKGSRC_PKG_PATH}/cdrecord*
223 .endif
224
225 .PHONY: all release installer_release quickrel installer_quickrel realquickrel
226 .PHONY: installer_fetch
227 .PHONY: installer_realquickrel check buildworld1 buildworld2
228 .PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso
229 .PHONY: clean realclean fetch
230
231 .include <bsd.prog.mk>