Don't just assume that the directory offset supplied by the user is
[dragonfly.git] / nrelease / Makefile
CommitLineData
2157278d 1# $DragonFly: src/nrelease/Makefile,v 1.52 2006/03/09 22:16:40 corecode Exp $
6ca9a59c 2#
5b22b655 3
cc224c64
JS
4# compat target
5installer_release: release
f6c08bce 6installer_quickrel: quickrel
cc224c64 7installer_realquickrel: realquickrel
bce110a5 8installer_fetch: fetch
cc224c64 9
bce110a5 10.if make(installer_release) || make(installer_quickrel) || make(installer_realquickrel) || make(installer_fetch)
cc224c64
JS
11WITH_INSTALLER=
12.endif
13
6ca9a59c
MD
14ISODIR ?= /usr/release
15ISOFILE ?= ${ISODIR}/dfly.iso
16ISOROOT = ${ISODIR}/root
17OBJSYS= ${.OBJDIR}/../sys
18KERNCONF ?= GENERIC
19
cc224c64 20PKGSRC_PREFIX?= /usr/pkg
bce110a5
MD
21PKGBIN_PKG_ADD?= ${PKGSRC_PREFIX}/sbin/pkg_add
22PKGBIN_MKISOFS?= ${PKGSRC_PREFIX}/bin/mkisofs
23PKGSRC_PKG_PATH?= ${ISODIR}/packages
24PKGSRC_DB?= /var/db/pkg
25PKGSRC_BOOTSTRAP_URL?= http://pkgbox.dragonflybsd.org/DragonFly-pkgsrc-packages/i386/1.4.0-RELEASE-BUILD
cc224c64 26
2157278d 27ENVCMD?= env
cc224c64 28TAR?= tar
cc224c64 29
bce110a5
MD
30PKGSRC_CDRECORD?= cdrecord-2.00.3nb2.tgz
31PKGSRC_BOOTSTRAP_KIT?= bootstrap-kit-20051221
0a1628e7 32CVSUP_BOOTSTRAP_KIT?= cvsup-bootstrap-20051229
bce110a5
MD
33
34PKGSRC_PACKAGES?= cdrecord-2.00.3nb2.tgz
8188de86
MD
35
36# Specify which root skeletons are required, and let the user include
37# their own. They are copied into ISODIR during the `pkgcustomizeiso'
38# target; each overwrites the last.
39#
40REQ_ROOTSKELS= ${.CURDIR}/root
cc224c64
JS
41ROOTSKELS?= ${REQ_ROOTSKELS}
42
43.if defined(WITH_INSTALLER)
bce110a5
MD
44PKGSRC_PACKAGES+= dfuibe_installer-1.1.6.tgz dfuife_curses-1.5.tgz
45PKGSRC_PACKAGES+= gettext-lib-0.11.5nb6.tgz libaura-3.1.tgz \
46 libdfui-4.1.tgz libinstaller-5.1.tgz
cc224c64
JS
47ROOTSKELS+= installer
48.endif
8188de86 49
5b22b655
MD
50# note: we use the '${NRLOBJDIR}/nrelease' construct, that is we add
51# the additional '/nrelease' manually, as a safety measure.
52#
53NRLOBJDIR?= /usr/obj
54
acc392b5
JS
55WORLD_CCVER ?= ${CCVER}
56KERNEL_CCVER ?= ${CCVER}
57
8188de86
MD
58#########################################################################
59# BASE ISO TARGETS #
60#########################################################################
61
62release: check clean buildworld1 buildkernel1 \
cc224c64 63 buildiso customizeiso mklocatedb mkiso
8188de86
MD
64
65quickrel: check clean buildworld2 buildkernel2 \
cc224c64 66 buildiso customizeiso mklocatedb mkiso
2e3f8f38 67
cc224c64 68realquickrel: check clean buildiso customizeiso mklocatedb mkiso
6ca9a59c 69
d2582113 70check:
bce110a5
MD
71.if !exists(${PKGBIN_PKG_ADD})
72 @echo "Unable to find ${PKGBIN_PKG_ADD}. You can use the following"
73 @echo "command to bootstrap pkgsrc:"
74 @echo " make pkgsrc_bootstrap"
75 @exit 1
76.endif
77.if !exists(/etc/mk.conf)
78 @echo "You do not have an /etc/mk.conf. You can use the following"
79 @echo "command to install one. Otherwise pkgsrc defaults will not"
80 @echo "point to the right place:"
81 @echo " make pkgsrc_conf"
82 @exit 1
83.endif
84.for PKG in ${PKGSRC_PACKAGES}
2157278d 85 @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -n ${PKG} > /dev/null 2>&1 || \
bce110a5
MD
86 (echo "Unable to find ${PKG}, use the following command to fetch required packages:"; echo " make [installer_]fetch"; exit 1)
87.endfor
88.if !exists(${PKGBIN_MKISOFS})
89 @echo "mkisofs is not installed. It is part of the cdrecord package."
90 @echo "You can install it with:"
91 @echo " make pkgsrc_cdrecord"
92 @exit 1
93.endif
0a1628e7
MD
94.if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
95 @echo "The pkgsrc bootstrap kit is not installed. You can install it with:"
96 @echo " make [installer_]fetch"
97 @exit 1
98.endif
99.if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
100 @echo "The cvsup bootstrap kit is not installed. You can install it with:"
101 @echo " make [installer_]fetch"
102 @exit 1
103.endif
2e3f8f38 104
6ca9a59c 105buildworld1:
c3f3fe6d 106 ( cd ${.CURDIR}/..; CCVER=${WORLD_CCVER} make buildworld )
6ca9a59c
MD
107
108buildworld2:
82a1be39 109 ( cd ${.CURDIR}/..; CCVER=${WORLD_CCVER} make quickworld )
6ca9a59c
MD
110
111buildkernel1:
c3f3fe6d 112 ( cd ${.CURDIR}/..; CCVER=${KERNEL_CCVER} make buildkernel KERNCONF=${KERNCONF} )
6ca9a59c
MD
113
114buildkernel2:
82a1be39 115 ( cd ${.CURDIR}/..; CCVER=${KERNEL_CCVER} make quickkernel KERNCONF=${KERNCONF} )
6ca9a59c 116
5b22b655
MD
117# note that we do not want to mess with any /usr/obj directories not related
118# to buildworld, buildkernel, or nrelease, so we must supply the proper
119# MAKEOBJDIRPREFIX for targets that are not run through the buildworld and
120# buildkernel mechanism.
121#
6ca9a59c
MD
122buildiso:
123 if [ ! -d ${ISOROOT} ]; then mkdir -p ${ISOROOT}; fi
5b22b655 124 if [ ! -d ${NRLOBJDIR}/nrelease ]; then mkdir -p ${NRLOBJDIR}/nrelease; fi
6ca9a59c 125 ( cd ${.CURDIR}/..; make DESTDIR=${ISOROOT} installworld )
ab64cf06
SS
126 ( cd ${.CURDIR}/../etc; MAKEOBJDIRPREFIX=${NRLOBJDIR}/nrelease \
127 make -m ${.CURDIR}/../share/mk DESTDIR=${ISOROOT} distribution )
dddbd615 128 cp -p ${.CURDIR}/mk.conf.pkgsrc ${ISOROOT}/etc/mk.conf
21aa02d0 129 cpdup ${ISOROOT}/etc ${ISOROOT}/etc.hdd
6ca9a59c
MD
130 ( cd ${.CURDIR}/..; make DESTDIR=${ISOROOT} \
131 installkernel KERNCONF=${KERNCONF} )
c5c5e6fc 132 ln -s kernel ${ISOROOT}/kernel.BOOTP
6ca9a59c
MD
133 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.local.dist -p ${ISOROOT}/usr/local/
134 mtree -deU -f ${.CURDIR}/../etc/mtree/BSD.var.dist -p ${ISOROOT}/var
135 dev_mkdb -f ${ISOROOT}/var/run/dev.db ${ISOROOT}/dev
8188de86
MD
136
137customizeiso:
bce110a5 138 (cd ${PKGSRC_PKG_PATH}; tar xzpf ${PKGSRC_BOOTSTRAP_KIT}.tgz)
0a1628e7 139 (cd ${PKGSRC_PKG_PATH}; tar xzpf ${CVSUP_BOOTSTRAP_KIT}.tgz)
8188de86
MD
140.for ROOTSKEL in ${ROOTSKELS}
141 cpdup -X cpignore -o ${ROOTSKEL} ${ISOROOT}
142.endfor
f6c08bce
MD
143 rm -rf ${ISOROOT}/tmp/bootstrap ${ISOROOT}/usr/obj/pkgsrc
144 cpdup ${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT} ${ISOROOT}/tmp/bootstrap
0a1628e7 145 cp -p ${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}/usr/local/bin/cvsup ${ISOROOT}/usr/local/bin/cvsup
f6c08bce 146 chroot ${ISOROOT} csh -c "cd /tmp/bootstrap/bootstrap; ./bootstrap"
d08963d3 147 rm -rf ${ISOROOT}/tmp/bootstrap ${ISOROOT}/usr/obj/pkgsrc
8188de86 148 rm -rf `find ${ISOROOT} -type d -name CVS -print`
21aa02d0 149 rm -rf ${ISOROOT}/usr/local/share/pristine
7249926b 150 pwd_mkdb -p -d ${ISOROOT}/etc ${ISOROOT}/etc/master.passwd
4fba3387
CP
151.for UPGRADE_ITEM in Makefile \
152 etc.${MACHINE_ARCH} \
153 isdn/Makefile \
154 rc.d/Makefile \
155 periodic/Makefile \
156 periodic/daily/Makefile \
157 periodic/security/Makefile \
158 periodic/weekly/Makefile \
159 periodic/monthly/Makefile
160 cp -R ${.CURDIR}/../etc/${UPGRADE_ITEM} ${ISOROOT}/etc/${UPGRADE_ITEM}
161.endfor
bce110a5 162.for PKG in ${PKGSRC_PACKAGES}
2157278d 163 ${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -I -K ${ISOROOT}${PKGSRC_DB} -p ${ISOROOT}${PKGSRC_PREFIX} ${PKG}
8188de86 164.endfor
6ca9a59c 165
8398ca17
SW
166mklocatedb:
167 ( find -s ${ISOROOT} -path ${ISOROOT}/tmp -or \
168 -path ${ISOROOT}/usr/tmp -or -path ${ISOROOT}/var/tmp \
169 -prune -o -print | sed -e 's#^${ISOROOT}##g' | \
170 /usr/libexec/locate.mklocatedb \
171 -presort >${ISOROOT}/var/db/locate.database )
172
6ca9a59c 173mkiso:
bce110a5 174 ( cd ${ISOROOT}; ${PKGBIN_MKISOFS} -b boot/cdboot -no-emul-boot \
382f1ee3 175 -R -J -V DragonFly -o ${ISOFILE} . )
6ca9a59c
MD
176
177clean:
178 if [ -d ${ISOROOT} ]; then chflags -R noschg ${ISOROOT}; fi
8188de86 179 if [ -d ${ISOROOT} ]; then rm -rf ${ISOROOT}/*; fi
5b22b655 180 if [ -d ${NRLOBJDIR}/nrelease ]; then rm -rf ${NRLOBJDIR}/nrelease; fi
6ca9a59c
MD
181
182realclean: clean
3ebedc5e 183 rm -rf ${OBJSYS}/${KERNCONF}
bce110a5
MD
184 # do not use PKGSRC_PKG_PATH here, we do not want to destroy an
185 # override location.
186 if [ -d ${ISODIR}/packages ]; then rm -rf ${ISODIR}/packages; fi
6ca9a59c 187
cc224c64
JS
188fetch:
189 mkdir -p ${PKGSRC_PKG_PATH}
bce110a5 190.for PKG in ${PKGSRC_PACKAGES}
2157278d 191 @${ENVCMD} PKG_PATH=${PKGSRC_PKG_PATH} ${PKGBIN_PKG_ADD} -n ${PKG} > /dev/null 2>&1 || \
bce110a5
MD
192 (cd ${PKGSRC_PKG_PATH}; echo "Fetching ${PKGSRC_BOOTSTRAP_URL}/${PKG}"; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKG})
193.endfor
194.if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
195 (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
196.endif
0a1628e7
MD
197.if !exists(${PKGSRC_PKG_PATH}/${CVSUP_BOOTSTRAP_KIT}.tgz)
198 (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${CVSUP_BOOTSTRAP_KIT}.tgz)
199.endif
bce110a5
MD
200
201pkgsrc_bootstrap:
202 mkdir -p ${PKGSRC_PKG_PATH}
203.if !exists(${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
204 (cd ${PKGSRC_PKG_PATH}; fetch ${PKGSRC_BOOTSTRAP_URL}/${PKGSRC_BOOTSTRAP_KIT}.tgz)
205.endif
206 (cd ${PKGSRC_PKG_PATH}; tar xzpf ${PKGSRC_BOOTSTRAP_KIT}.tgz)
207 (cd ${PKGSRC_PKG_PATH}/${PKGSRC_BOOTSTRAP_KIT}/bootstrap; ./bootstrap)
208
209pkgsrc_conf:
210.if !exists(/etc/mk.conf)
211 cp ${.CURDIR}/mk.conf.pkgsrc /etc/mk.conf
212.else
213 fgrep -q BSD_PKG_MK /etc/mk.conf || cat ${.CURDIR}/mk.conf.pkgsrc >> /etc/mk.conf
214.endif
215
216pkgsrc_cdrecord:
217.if !exists (${PKGBIN_MKISOFS})
218 ${PKGBIN_PKG_ADD} ${PKGSRC_PKG_PATH}/cdrecord*
219.endif
cc224c64
JS
220
221.PHONY: all release installer_release quickrel installer_quickrel realquickrel
bce110a5 222.PHONY: installer_fetch
cc224c64
JS
223.PHONY: installer_realquickrel check buildworld1 buildworld2
224.PHONY: buildkernel1 buildkernel2 buildiso customizeiso mklocatedb mkiso
d5c58845 225.PHONY: clean realclean fetch
cc224c64 226
6ca9a59c 227.include <bsd.prog.mk>