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