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