1 |
#!/bin/bash |
#!/bin/bash |
2 |
|
|
3 |
#depwalker |
#depwalker |
4 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/depwalker.sh,v 1.1 2005-09-09 16:35:27 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/depwalker.sh,v 1.2 2005-09-09 17:50:03 niro Exp $ |
5 |
|
|
6 |
# default die function |
# default die function |
7 |
die() |
die() |
10 |
exit 1 |
exit 1 |
11 |
} |
} |
12 |
|
|
13 |
# # include all needed files |
# include all needed files |
14 |
# [ -f ${MLIBDIR}/conf/mage.rc.global ] && \ |
[ -f ${MLIBDIR}/conf/mage.rc.global ] && \ |
15 |
# source ${MLIBDIR}/conf/mage.rc.global || \ |
source ${MLIBDIR}/conf/mage.rc.global || \ |
16 |
# die "${MLIBDIR}/conf/mage.rc.global missing" |
die "${MLIBDIR}/conf/mage.rc.global missing" |
17 |
# |
|
18 |
# [ -f /etc/mage.rc ] && source /etc/mage.rc || \ |
[ -f /etc/mage.rc ] && source /etc/mage.rc || \ |
19 |
# die "Your /etc/mage.rc is missing. Aborting." |
die "Your /etc/mage.rc is missing. Aborting." |
20 |
# |
|
21 |
# [ -f ${MLIBDIR}/mage.functions.sh ] && \ |
[ -f ${MLIBDIR}/mage.functions.sh ] && \ |
22 |
# source ${MLIBDIR}/mage.functions.sh || \ |
source ${MLIBDIR}/mage.functions.sh || \ |
23 |
# die "mage functions missing" |
die "mage functions missing" |
24 |
|
|
25 |
# for tests only |
# for tests only |
26 |
source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage.rc.global |
# source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage.rc.global |
27 |
source /etc/mage.rc |
# source /etc/mage.rc |
28 |
source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh |
# source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh |
29 |
|
# MLIBDIR=/home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage |
30 |
|
|
31 |
# not serios if missing, only for colors |
# not serious if missing, only needed for colors |
32 |
[ -f /etc/init.d/functions ] && source /etc/init.d/functions |
[ -f /etc/init.d/functions ] && source /etc/init.d/functions |
33 |
|
|
34 |
# disable colors if wanted |
# disable colors if wanted |
54 |
echo " -v --pver version number of the package" |
echo " -v --pver version number of the package" |
55 |
echo " -b --pbuild build number of the package" |
echo " -b --pbuild build number of the package" |
56 |
echo " -m --method which calc method should be used:" |
echo " -m --method which calc method should be used:" |
57 |
echo " install srcinstall depend srcdepend" |
echo " install, srcinstall, depend, srcdepend" |
58 |
|
echo " upgrade, srcupgrade" |
59 |
echo |
echo |
60 |
echo "method,name, version and build must be given !" |
echo "method,name, version and build must be given !" |
61 |
echo |
echo |
117 |
MY_DEPEND="${DEPEND}" |
MY_DEPEND="${DEPEND}" |
118 |
|
|
119 |
# for srcinstall & srcdepend only; SDEPEND also needed |
# for srcinstall & srcdepend only; SDEPEND also needed |
120 |
if [[ ${METHOD} = srcinstall ]] || [[ ${METHOD} = srcpretend ]] |
if [[ ${METHOD} = srcinstall ]] || \ |
121 |
|
[[ ${METHOD} = srcpretend ]] || \ |
122 |
|
[[ ${METHOD} = srcupgrade ]] || \ |
123 |
|
[[ ${METHOD} = srcuppretend ]] |
124 |
then |
then |
125 |
# only if SDEPEND is not zero |
# only if SDEPEND is not zero |
126 |
if [ -n "${SDEPEND}" ] |
if [ -n "${SDEPEND}" ] |
174 |
# maybe later ? |
# maybe later ? |
175 |
#[ -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] && exit 3 |
#[ -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] && exit 3 |
176 |
|
|
177 |
[[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]] && \ |
[[ ${METHOD} = pretend ]] || \ |
178 |
|
[[ ${METHOD} = srcpretend ]] || \ |
179 |
|
[[ ${METHOD} = uppretend ]] || \ |
180 |
|
[[ ${METHOD} = srcuppretend ]] && \ |
181 |
echo -n "Calculating dependencies ... " |
echo -n "Calculating dependencies ... " |
182 |
|
|
|
# get dependencies the package |
|
|
rumwandern ${MAGEFILE} |
|
183 |
|
|
184 |
[[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]] && echo "done" |
if [[ ${METHOD} = upgrade ]] || \ |
185 |
|
[[ ${METHOD} = srcupgrade ]] || \ |
186 |
|
[[ ${METHOD} = uppretend ]] || \ |
187 |
|
[[ ${METHOD} = srcuppretend ]] |
188 |
|
then |
189 |
|
INSTDEPS="$(${MLIBDIR}/magequery.sh -i)" |
190 |
|
for dep in ${INSTDEPS} |
191 |
|
do |
192 |
|
PCAT="$(magename2pcat ${dep} installdb)" |
193 |
|
PNAME="$(magename2pname ${dep})" |
194 |
|
PVER="$(magename2pver ${dep})" |
195 |
|
PBUILD="$(magename2pbuild ${dep})" |
196 |
|
|
197 |
|
# fake a mage file |
198 |
|
MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage" |
199 |
|
|
200 |
|
rumwandern ${MAGEFILE} |
201 |
|
done |
202 |
|
else |
203 |
|
# get dependencies the package |
204 |
|
rumwandern ${MAGEFILE} |
205 |
|
|
206 |
|
# now add the package itself to the dependencies |
207 |
|
ALLDEPS="${ALLDEPS} ${MAGEFILE}" |
208 |
|
fi |
209 |
|
|
210 |
|
[[ ${METHOD} = pretend ]] || \ |
211 |
|
[[ ${METHOD} = srcpretend ]] || \ |
212 |
|
[[ ${METHOD} = uppretend ]] || \ |
213 |
|
[[ ${METHOD} = srcuppretend ]] && \ |
214 |
|
echo "done" |
215 |
|
|
|
# now add the package itself to the dependencies |
|
|
ALLDEPS="${ALLDEPS} ${MAGEFILE}" |
|
216 |
|
|
217 |
## show output of pretend |
## show output of pretend |
218 |
if [[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]] |
if [[ ${METHOD} = pretend ]] || \ |
219 |
|
[[ ${METHOD} = srcpretend ]] || \ |
220 |
|
[[ ${METHOD} = uppretend ]] || \ |
221 |
|
[[ ${METHOD} = srcuppretend ]] |
222 |
then |
then |
223 |
# this is a little bit faster |
# this is a little bit faster |
224 |
declare -i x=0 |
declare -i x=0 |
248 |
fi |
fi |
249 |
|
|
250 |
## return output from src/install deps |
## return output from src/install deps |
251 |
[[ ${METHOD} = install ]] || [[ ${METHOD} = srcinstall ]] && echo "${ALLDEPS}" |
[[ ${METHOD} = install ]] || \ |
252 |
|
[[ ${METHOD} = srcinstall ]] || \ |
253 |
|
[[ ${METHOD} = upgrade ]] || \ |
254 |
|
[[ ${METHOD} = srcupgrade ]] && \ |
255 |
|
echo "${ALLDEPS}" |
256 |
|
|
257 |
# delete ${BUILDDIR}/virtuals if exists as not needed anymore |
# delete ${BUILDDIR}/virtuals if exists as not needed anymore |
258 |
#[ -d ${BUILDDIR}/virtuals ] && rm -rf ${BUILDDIR}/virtuals |
#[ -d ${BUILDDIR}/virtuals ] && rm -rf ${BUILDDIR}/virtuals |