Move the freebsd package system from /usr/sbin to /usr/freebsd_pkg/sbin
[dragonfly.git] / nrelease / Makefile
1 # $DragonFly: src/nrelease/Makefile,v 1.42 2005/11/01 20:50:28 dillon Exp $
2 #
3
4 ISODIR ?= /usr/release
5 ISOFILE ?= ${ISODIR}/dfly.iso
6 ISOROOT = ${ISODIR}/root
7 OBJSYS= ${.OBJDIR}/../sys
8 KERNCONF ?= GENERIC
9 PKG_PATH= /usr/freebsd_pkg/sbin
10
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 #
15 REQ_PACKAGES= cdrtools-2.01 cvsup-without-gui-16.1h
16 REL_PACKAGES?= ${REQ_PACKAGES} ${EXTRA_PACKAGES}
17 .if defined(PACKAGES)
18 PACKAGES_LOC?= ${PACKAGES}/All
19 .else
20 PACKAGES_LOC?= /usr/ports/packages/All
21 .endif
22 PACKAGE_SITES?=http://www.bsdinstaller.org/packages/ \
23                http://cvs.bsdinstaller.org/packages/
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 #
29 REQ_ROOTSKELS= ${.CURDIR}/root
30 ROOTSKELS?= ${REQ_ROOTSKELS} ${EXTRA_ROOTSKELS}
31
32 # note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
33 # the additional '/nrelease' manually, as a safety measure.
34 #
35 NRLOBJDIR?= /usr/obj
36
37 WORLD_CCVER ?= ${CCVER}
38 KERNEL_CCVER ?= ${CCVER}
39
40 #########################################################################
41 #                               BASE ISO TARGETS                        #
42 #########################################################################
43
44 release:        check clean buildworld1 buildkernel1 \
45                 buildiso customizeiso pkgaddiso mklocatedb mkiso
46
47 quickrel:       check clean buildworld2 buildkernel2 \
48                 buildiso customizeiso pkgaddiso mklocatedb mkiso
49
50 realquickrel:   check clean \
51                 buildiso customizeiso pkgaddiso mklocatedb mkiso
52
53 #########################################################################
54 #                       ISO TARGETS WITH INSTALLER                      #
55 #########################################################################
56
57 INSTALLER_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
60 INSTALLER_SKELS= installer
61
62 INSTALLER_ENV= EXTRA_PACKAGES="${INSTALLER_PKGS} ${EXTRA_PACKAGES}" \
63                 EXTRA_ROOTSKELS="${INSTALLER_SKELS} ${EXTRA_ROOTSKELS}"
64
65 installer_check:
66                 @${INSTALLER_ENV} ${MAKE} check
67
68 installer_fetchpkgs:
69                 @${INSTALLER_ENV} ${MAKE} fetchpkgs
70
71 installer_release:
72                 ${INSTALLER_ENV} ${MAKE} release
73
74 installer_quickrel:
75                 ${INSTALLER_ENV} ${MAKE} quickrel
76
77 installer_realquickrel:
78                 ${INSTALLER_ENV} ${MAKE} realquickrel
79
80 #########################################################################
81 #                               HELPER TARGETS                          #
82 #########################################################################
83
84 check:
85         @if [ ! -f /usr/local/bin/mkisofs ]; then \
86                 echo "You need to install the sysutils/cdrtools port for"; \
87                 echo "this target"; \
88                 exit 1; \
89         fi
90 .for PKG in ${REL_PACKAGES}
91         @if [ ! -f ${PACKAGES_LOC}/${PKG}.tgz ]; then \
92                 echo "Unable to find ${PACKAGES_LOC}/${PKG}.tgz."; \
93                 echo "(Perhaps you need to download or build it first?)"; \
94                 echo ""; \
95                 echo "If you are trying to build the installer, the"; \
96                 echo "required packages can be obtained from:"; \
97                 echo ""; \
98                 echo "    http://www.bsdinstaller.org/packages/"; \
99                 echo ""; \
100                 echo "They can be automatically downloaded by issuing"; \
101                 echo "'make installer_fetchpkgs' from this directory."; \
102                 echo ""; \
103                 exit 1; \
104         fi
105 .endfor
106         @echo "check: all preqs found"
107
108 fetchpkgs:
109 .for PKG in ${REL_PACKAGES}
110         @if [ ! -f ${PACKAGES_LOC}/${PKG}.tgz ]; then \
111                 cd ${PACKAGES_LOC} && \
112                 echo "fetching ${PKG}..." && \
113                 for SITE in ${PACKAGE_SITES}; do \
114                         if [ ! -f ${PKG}.tgz ]; then \
115                                 fetch $${SITE}${PKG}.tgz || \
116                                     echo "Not available from $${SITE}"; \
117                         fi; \
118                 done; \
119                 if [ ! -f ${PKG}.tgz ]; then \
120                         echo "Couldn't retrieve ${PKG}.tgz!"; \
121                         exit 1; \
122                 fi; \
123         fi
124 .endfor
125
126 buildworld1:
127         ( cd ${.CURDIR}/..; CCVER=${WORLD_CCVER} make buildworld )
128
129 buildworld2:
130         ( cd ${.CURDIR}/..; CCVER=${WORLD_CCVER} make quickworld )
131
132 buildkernel1:
133         ( cd ${.CURDIR}/..; CCVER=${KERNEL_CCVER} make buildkernel KERNCONF=${KERNCONF} )
134
135 buildkernel2:
136         ( cd ${.CURDIR}/..; CCVER=${KERNEL_CCVER} make quickkernel KERNCONF=${KERNCONF} )
137
138 # note that we do not want to mess with any /usr/obj directories not related
139 # to buildworld, buildkernel, or nrelease, so we must supply the proper
140 # MAKEOBJDIRPREFIX for targets that are not run through the buildworld and 
141 # buildkernel mechanism.
142 #
143 buildiso:
144         if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
145         if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
146         ( cd ${.CURDIR}/..; make DESTDIR=${ISOROOT} installworld )
147         ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
148                 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
149         cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
150         ( cd ${.CURDIR}/..; make DESTDIR=${ISOROOT} \
151                 installkernel KERNCONF=${KERNCONF} )
152         ln -s kernel ${ISOROOT}/kernel.BOOTP
153         mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
154         mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
155         dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
156
157 customizeiso:
158 .for ROOTSKEL in ${ROOTSKELS}
159         cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
160 .endfor
161         rm -rf `find ${ISOROOT} -type d -name CVS -print`
162         rm -rf ${ISOROOT}/usr/local/share/pristine
163         pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
164 .for UPGRADE_ITEM in Makefile                   \
165                      etc.${MACHINE_ARCH}        \
166                      isdn/Makefile              \
167                      rc.d/Makefile              \
168                      periodic/Makefile          \
169                      periodic/daily/Makefile    \
170                      periodic/security/Makefile \
171                      periodic/weekly/Makefile   \
172                      periodic/monthly/Makefile
173         cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
174 .endfor
175
176 PKG_VERSTR!=    ${PKG_PATH}/pkg_info -vP
177 .if !empty(PKG_VERSTR:M*fakeroot*)
178
179 pkgcleaniso:
180 .for PKG in ${REL_PACKAGES}
181         -PKG_FAKEROOT=${ISOROOT:Q} ${PKG_PATH}/pkg_delete -f ${PKG}
182 .endfor
183
184 pkgaddiso:
185 .for PKG in ${REL_PACKAGES}
186         -PKG_FAKEROOT=${ISOROOT:Q} ${PKG_PATH}/pkg_add ${PACKAGES_LOC}/${PKG}.tgz
187 .endfor
188
189 .else   # pkgtools don't know fakeroot
190
191 pkgcleaniso:
192         rm -f ${ISOROOT}/tmp/chrootscript
193         echo "#!/bin/sh" > ${ISOROOT}/tmp/chrootscript
194 .for PKG in ${REL_PACKAGES}
195         echo "${PKG_PATH}/pkg_delete -f ${PKG}" >> ${ISOROOT}/tmp/chrootscript
196 .endfor
197         chmod a+x ${ISOROOT}/tmp/chrootscript
198         chroot ${ISOROOT}/ /tmp/chrootscript || exit 0
199         rm ${ISOROOT}/tmp/chrootscript
200
201 pkgaddiso:
202         rm -f ${ISOROOT}/tmp/chrootscript
203         echo "#!/bin/sh" > ${ISOROOT}/tmp/chrootscript
204 .for PKG in ${REL_PACKAGES}
205         if [ ! -d ${ISOROOT}/var/db/pkg/${PKG} ]; then \
206                 cp ${PACKAGES_LOC}/${PKG}.tgz ${ISOROOT}/tmp/${PKG}.tgz; \
207                 echo "echo 'Installing package ${PKG}...' && \\" >> \
208                     ${ISOROOT}/tmp/chrootscript; \
209                 echo "${PKG_PATH}/pkg_add /tmp/${PKG}.tgz && \\" >> \
210                     ${ISOROOT}/tmp/chrootscript; \
211         fi
212 .endfor
213         echo "echo 'All packages added successfully!'" >> \
214             ${ISOROOT}/tmp/chrootscript
215         chmod a+x ${ISOROOT}/tmp/chrootscript
216         chroot ${ISOROOT}/ /tmp/chrootscript
217         rm ${ISOROOT}/tmp/chrootscript
218 .for PKG in ${REL_PACKAGES}
219         rm -f ${ISOROOT}/tmp/${PKG}.tgz
220 .endfor
221
222 .endif  # pkgtools fakeroot
223
224 mklocatedb:
225         ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
226                 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
227                 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
228                 /usr/libexec/locate.mklocatedb \
229                 -presort >${ISOROOT}/var/db/locate.database )
230
231 mkiso:
232         ( cd ${ISOROOT}; mkisofs -b boot/cdboot -no-emul-boot \
233                 -R -J -V DragonFly -o ${ISOFILE} . )
234
235 clean:
236         if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
237         if [ -d ${ISOROOT} ]; then rm -rf ${ISOROOT}/*; fi
238         if [ -d ${NRLOBJDIR}/nrelease ]; then rm -rf ${NRLOBJDIR}/nrelease; fi
239
240 realclean:      clean
241         rm -rf ${OBJSYS}/${KERNCONF}
242
243 .include <bsd.prog.mk>