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