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