Ansify function definitions.
[dragonfly.git] / nrelease / Makefile
CommitLineData
c7a637ad 1# $DragonFly: src/nrelease/Makefile,v 1.44 2005/12/04 21:24:13 dillon Exp $
6ca9a59c 2#
5b22b655 3
6ca9a59c
MD
4ISODIR ?= /usr/release
5ISOFILE ?= ${ISODIR}/dfly.iso
6ISOROOT = ${ISODIR}/root
7OBJSYS= ${.OBJDIR}/../sys
8KERNCONF ?= GENERIC
5e7672df 9PKG_PATH= /usr/freebsd_pkg/sbin
6ca9a59c 10
8188de86
MD
11# Specify which packages are required on the ISO, and let the user
12# specify additional packages to include. During the `pkgaddiso'
13# target, the packages are obtained from PACKAGES_LOC.
14#
3b4d7f2d 15REQ_PACKAGES= cdrtools-2.01 cvsup-without-gui-16.1h
bf9b513b
JS
16REL_PACKAGES?= ${REQ_PACKAGES} ${EXTRA_PACKAGES}
17.if defined(PACKAGES)
18PACKAGES_LOC?= ${PACKAGES}/All
19.else
8188de86 20PACKAGES_LOC?= /usr/ports/packages/All
bf9b513b 21.endif
95ab05eb
CP
22PACKAGE_SITES?=http://www.bsdinstaller.org/packages/ \
23 http://cvs.bsdinstaller.org/packages/
8188de86
MD
24
25# Specify which root skeletons are required, and let the user include
26# their own. They are copied into ISODIR during the `pkgcustomizeiso'
27# target; each overwrites the last.
28#
29REQ_ROOTSKELS= ${.CURDIR}/root
30ROOTSKELS?= ${REQ_ROOTSKELS} ${EXTRA_ROOTSKELS}
31
5b22b655
MD
32# note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
33# the additional '/nrelease' manually, as a safety measure.
34#
35NRLOBJDIR?= /usr/obj
36
acc392b5
JS
37WORLD_CCVER ?= ${CCVER}
38KERNEL_CCVER ?= ${CCVER}
39
8188de86
MD
40#########################################################################
41# BASE ISO TARGETS #
42#########################################################################
43
44release: check clean buildworld1 buildkernel1 \
8398ca17 45 buildiso customizeiso pkgaddiso mklocatedb mkiso
8188de86
MD
46
47quickrel: check clean buildworld2 buildkernel2 \
8398ca17 48 buildiso customizeiso pkgaddiso mklocatedb mkiso
8188de86
MD
49
50realquickrel: check clean \
8398ca17 51 buildiso customizeiso pkgaddiso mklocatedb mkiso
6ca9a59c 52
8188de86
MD
53#########################################################################
54# ISO TARGETS WITH INSTALLER #
55#########################################################################
6ca9a59c 56
e94931c5
MD
57INSTALLER_PKGS= libaura-3.1 libdfui-4.1 libinstaller-5.1 \
58 dfuibe_installer-1.1.6 dfuife_curses-1.5 \
59 thttpd-notimeout-2.24 dfuife_cgi-1.4
8188de86
MD
60INSTALLER_SKELS= installer
61
10dd2a9b
CP
62INSTALLER_ENV= EXTRA_PACKAGES="${INSTALLER_PKGS} ${EXTRA_PACKAGES}" \
63 EXTRA_ROOTSKELS="${INSTALLER_SKELS} ${EXTRA_ROOTSKELS}"
8188de86
MD
64
65installer_check:
66 @${INSTALLER_ENV} ${MAKE} check
67
2e3f8f38
MD
68installer_fetchpkgs:
69 @${INSTALLER_ENV} ${MAKE} fetchpkgs
70
8188de86
MD
71installer_release:
72 ${INSTALLER_ENV} ${MAKE} release
73
74installer_quickrel:
75 ${INSTALLER_ENV} ${MAKE} quickrel
76
77installer_realquickrel:
78 ${INSTALLER_ENV} ${MAKE} realquickrel
79
80#########################################################################
81# HELPER TARGETS #
82#########################################################################
6ca9a59c 83
d2582113 84check:
8188de86 85 @if [ ! -f /usr/local/bin/mkisofs ]; then \
755f2cbd
MD
86 echo "You need to install the sysutils/cdrtools port for"; \
87 echo "this target"; \
8188de86
MD
88 exit 1; \
89 fi
bf9b513b 90.for PKG in ${REL_PACKAGES}
8188de86 91 @if [ ! -f ${PACKAGES_LOC}/${PKG}.tgz ]; then \
16d62894
CP
92 echo "Unable to find ${PACKAGES_LOC}/${PKG}.tgz."; \
93 echo "(Perhaps you need to download or build it first?)"; \
8188de86
MD
94 echo ""; \
95 echo "If you are trying to build the installer, the"; \
96 echo "required packages can be obtained from:"; \
16d62894
CP
97 echo ""; \
98 echo " http://www.bsdinstaller.org/packages/"; \
99 echo ""; \
c7a637ad
MD
100 echo "They can be automatically downloaded by issuing:"; \
101 echo " make installer_fetchpkgs"; \
16d62894 102 echo ""; \
8188de86
MD
103 exit 1; \
104 fi
105.endfor
c7a637ad
MD
106 @if [ ! -f /usr/pkg/sbin/pkg_add ]; then \
107 echo "NetBSD pkgsrc has not been bootstrapped. You can"; \
108 echo "automatically download the pkgsrc and install the"; \
109 echo "the bootstrap with:"; \
110 echo " make pkgsrc_fetch"; \
111 echo " make pkgsrc_bootstrap"; \
112 exit 1; \
113 fi
114 @if [ ! -f /etc/mk.conf ]; then \
115 echo "NetBSD pkgsrc: /etc/mk.conf must exist. You can"; \
116 echo "automatically create this file with:"; \
117 echo " make pkgsrc_conf"; \
118 exit 1; \
119 fi
8188de86 120 @echo "check: all preqs found"
6ca9a59c 121
c7a637ad
MD
122pkgsrc_fetch:
123 cd /usr
124 cvs -d anoncvs@anoncvs.us.netbsd.org:/cvsroot checkout pkgsrc
125
126pkgsrc_bootstrap:
127 rm -rf /tmp/bootstrap-workdir
128 cd /usr/pkgsrc/bootstrap && ./bootstrap --workdir=/tmp/bootstrap-workdir
129 rm -rf /tmp/bootstrap-workdir
130 fgrep -q LOCALBASE /etc/mk.conf || (echo "you may also have to run make pkgsrc_conf to initialize /etc/mk.conf")
131
132pkgsrc_conf:
133.if !exists(/etc/mk.conf)
134 cp ${.CURDIR}/mk.conf.pkgsrc /etc/mk.conf
135.else
136 fgrep -q BSD_PKG_MK /etc/mk.conf || cat ${.CURDIR}/mk.conf.pkgsrc >> /etc/mk.conf
137.endif
138
2e3f8f38 139fetchpkgs:
bf9b513b 140.for PKG in ${REL_PACKAGES}
2e3f8f38
MD
141 @if [ ! -f ${PACKAGES_LOC}/${PKG}.tgz ]; then \
142 cd ${PACKAGES_LOC} && \
143 echo "fetching ${PKG}..." && \
95ab05eb
CP
144 for SITE in ${PACKAGE_SITES}; do \
145 if [ ! -f ${PKG}.tgz ]; then \
146 fetch $${SITE}${PKG}.tgz || \
147 echo "Not available from $${SITE}"; \
148 fi; \
149 done; \
150 if [ ! -f ${PKG}.tgz ]; then \
151 echo "Couldn't retrieve ${PKG}.tgz!"; \
152 exit 1; \
153 fi; \
2e3f8f38
MD
154 fi
155.endfor
156
6ca9a59c 157buildworld1:
c3f3fe6d 158 ( cd ${.CURDIR}/..; CCVER=${WORLD_CCVER} make buildworld )
6ca9a59c
MD
159
160buildworld2:
82a1be39 161 ( cd ${.CURDIR}/..; CCVER=${WORLD_CCVER} make quickworld )
6ca9a59c
MD
162
163buildkernel1:
c3f3fe6d 164 ( cd ${.CURDIR}/..; CCVER=${KERNEL_CCVER} make buildkernel KERNCONF=${KERNCONF} )
6ca9a59c
MD
165
166buildkernel2:
82a1be39 167 ( cd ${.CURDIR}/..; CCVER=${KERNEL_CCVER} make quickkernel KERNCONF=${KERNCONF} )
6ca9a59c 168
5b22b655
MD
169# note that we do not want to mess with any /usr/obj directories not related
170# to buildworld, buildkernel, or nrelease, so we must supply the proper
171# MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
172# buildkernel mechanism.
173#
6ca9a59c
MD
174buildiso:
175 if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
5b22b655 176 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
6ca9a59c 177 ( cd ${.CURDIR}/..; make DESTDIR=${ISOROOT} installworld )
ab64cf06
SS
178 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
179 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
21aa02d0 180 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
6ca9a59c
MD
181 ( cd ${.CURDIR}/..; make DESTDIR=${ISOROOT} \
182 installkernel KERNCONF=${KERNCONF} )
c5c5e6fc 183 ln -s kernel ${ISOROOT}/kernel.BOOTP
6ca9a59c
MD
184 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
185 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
186 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
8188de86
MD
187
188customizeiso:
c7a637ad
MD
189 cd /usr/pkgsrc/bootstrap && ./bootstrap --workdir=${NRLOBJDIR}/nrelease/bootstrap-workdir --prefix=${ISOROOT}/usr/pkg
190 cp ${.CURDIR}/mk.conf.pkgsrc ${ISOROOT}/etc/mk.conf
8188de86
MD
191.for ROOTSKEL in ${ROOTSKELS}
192 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
193.endfor
194 rm -rf `find ${ISOROOT} -type d -name CVS -print`
21aa02d0 195 rm -rf ${ISOROOT}/usr/local/share/pristine
7249926b 196 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
4fba3387
CP
197.for UPGRADE_ITEM in Makefile \
198 etc.${MACHINE_ARCH} \
199 isdn/Makefile \
200 rc.d/Makefile \
201 periodic/Makefile \
202 periodic/daily/Makefile \
203 periodic/security/Makefile \
204 periodic/weekly/Makefile \
205 periodic/monthly/Makefile
206 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
207.endfor
8188de86
MD
208
209pkgcleaniso:
210 rm -f ${ISOROOT}/tmp/chrootscript
211 echo "#!/bin/sh" > ${ISOROOT}/tmp/chrootscript
bf9b513b 212.for PKG in ${REL_PACKAGES}
5e7672df 213 echo "${PKG_PATH}/pkg_delete -f ${PKG}" >> ${ISOROOT}/tmp/chrootscript
8188de86
MD
214.endfor
215 chmod a+x ${ISOROOT}/tmp/chrootscript
216 chroot ${ISOROOT}/ /tmp/chrootscript || exit 0
217 rm ${ISOROOT}/tmp/chrootscript
218
219pkgaddiso:
220 rm -f ${ISOROOT}/tmp/chrootscript
221 echo "#!/bin/sh" > ${ISOROOT}/tmp/chrootscript
bf9b513b 222.for PKG in ${REL_PACKAGES}
0272b808
CP
223 if [ ! -d ${ISOROOT}/var/db/pkg/${PKG} ]; then \
224 cp ${PACKAGES_LOC}/${PKG}.tgz ${ISOROOT}/tmp/${PKG}.tgz; \
225 echo "echo 'Installing package ${PKG}...' && \\" >> \
226 ${ISOROOT}/tmp/chrootscript; \
5e7672df 227 echo "${PKG_PATH}/pkg_add /tmp/${PKG}.tgz && \\" >> \
0272b808
CP
228 ${ISOROOT}/tmp/chrootscript; \
229 fi
8188de86 230.endfor
0272b808
CP
231 echo "echo 'All packages added successfully!'" >> \
232 ${ISOROOT}/tmp/chrootscript
8188de86
MD
233 chmod a+x ${ISOROOT}/tmp/chrootscript
234 chroot ${ISOROOT}/ /tmp/chrootscript
235 rm ${ISOROOT}/tmp/chrootscript
bf9b513b 236.for PKG in ${REL_PACKAGES}
8188de86
MD
237 rm -f ${ISOROOT}/tmp/${PKG}.tgz
238.endfor
6ca9a59c 239
8398ca17
SW
240mklocatedb:
241 ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
242 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
243 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
244 /usr/libexec/locate.mklocatedb \
245 -presort >${ISOROOT}/var/db/locate.database )
246
6ca9a59c
MD
247mkiso:
248 ( cd ${ISOROOT}; mkisofs -b boot/cdboot -no-emul-boot \
382f1ee3 249 -R -J -V DragonFly -o ${ISOFILE} . )
6ca9a59c
MD
250
251clean:
c7a637ad 252 rm -rf /tmp/bootstrap-workdir
6ca9a59c 253 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
8188de86 254 if [ -d ${ISOROOT} ]; then rm -rf ${ISOROOT}/*; fi
5b22b655 255 if [ -d ${NRLOBJDIR}/nrelease ]; then rm -rf ${NRLOBJDIR}/nrelease; fi
6ca9a59c
MD
256
257realclean: clean
3ebedc5e 258 rm -rf ${OBJSYS}/${KERNCONF}
6ca9a59c
MD
259
260.include <bsd.prog.mk>