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.6 2007-11-05 16:49:33 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 /etc/mage.rc.global ] && \ |
15 |
# source ${MLIBDIR}/conf/mage.rc.global || \ |
source /etc/mage.rc.global || \ |
16 |
# die "${MLIBDIR}/conf/mage.rc.global missing" |
die "/etc/mage.rc.global missing" |
17 |
# |
|
18 |
# [ -f /etc/mage.rc ] && source /etc/mage.rc || \ |
[ -f ${MAGERC} ] && source ${MAGERC} || \ |
19 |
# die "Your /etc/mage.rc is missing. Aborting." |
die "Your ${MAGERC} is missing. Aborting." |
20 |
# |
|
21 |
# [ -f ${MLIBDIR}/mage.functions.sh ] && \ |
[ -f ${MLIBDIR}/mage4.functions.sh ] && \ |
22 |
# source ${MLIBDIR}/mage.functions.sh || \ |
source ${MLIBDIR}/mage4.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 |
92 |
ALLDEPS="" |
ALLDEPS="" |
93 |
MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage" |
MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage" |
94 |
|
|
95 |
|
# much faster than fgrep |
96 |
|
checklist_alldeps() |
97 |
|
{ |
98 |
|
local i |
99 |
|
local item="$1" |
100 |
|
|
101 |
|
for i in ${ALLDEPS} |
102 |
|
do |
103 |
|
[[ ${i} = ${item} ]] && return 1 |
104 |
|
done |
105 |
|
|
106 |
|
return 0 |
107 |
|
} |
108 |
|
|
109 |
##################### |
##################### |
110 |
## rumwandern /path/to/mage/file/.mage |
## rumwandern /path/to/mage/file/.mage |
111 |
rumwandern() |
rumwandern() |
124 |
local INSTALL_VIRTUAL |
local INSTALL_VIRTUAL |
125 |
local PNAME |
local PNAME |
126 |
local PCAT |
local PCAT |
127 |
|
local PVER |
128 |
|
local PBUILD |
129 |
|
|
130 |
DFILE="$1" |
DFILE="$1" |
131 |
|
|
133 |
MY_DEPEND="${DEPEND}" |
MY_DEPEND="${DEPEND}" |
134 |
|
|
135 |
# for srcinstall & srcdepend only; SDEPEND also needed |
# for srcinstall & srcdepend only; SDEPEND also needed |
136 |
if [[ ${METHOD} = srcinstall ]] || [[ ${METHOD} = srcpretend ]] |
if [[ ${METHOD} = srcinstall ]] || \ |
137 |
|
[[ ${METHOD} = srcpretend ]] || \ |
138 |
|
[[ ${METHOD} = srcupgrade ]] || \ |
139 |
|
[[ ${METHOD} = srcuppretend ]] |
140 |
then |
then |
141 |
# only if SDEPEND is not zero |
# only if SDEPEND is not zero |
142 |
if [ -n "${SDEPEND}" ] |
if [ -n "${SDEPEND}" ] |
170 |
PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})" |
PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})" |
171 |
|
|
172 |
## check ob schon in ALLDEPS enthalten dann mach weiter |
## check ob schon in ALLDEPS enthalten dann mach weiter |
173 |
if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ] |
|
174 |
|
# usage of fgrep is extremly slow and consumes a lot of cpu power |
175 |
|
#if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ] |
176 |
|
if checklist_alldeps "${HIGHEST_DEPFILE}" |
177 |
then |
then |
178 |
### check ob DFILE schon installiert ist ### |
### check ob DFILE schon installiert ist ### |
179 |
if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] |
if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] |
193 |
# maybe later ? |
# maybe later ? |
194 |
#[ -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] && exit 3 |
#[ -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] && exit 3 |
195 |
|
|
196 |
[[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]] && \ |
[[ ${METHOD} = pretend ]] || \ |
197 |
|
[[ ${METHOD} = srcpretend ]] || \ |
198 |
|
[[ ${METHOD} = uppretend ]] || \ |
199 |
|
[[ ${METHOD} = srcuppretend ]] && \ |
200 |
echo -n "Calculating dependencies ... " |
echo -n "Calculating dependencies ... " |
201 |
|
|
|
# get dependencies the package |
|
|
rumwandern ${MAGEFILE} |
|
202 |
|
|
203 |
[[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]] && echo "done" |
if [[ ${METHOD} = upgrade ]] || \ |
204 |
|
[[ ${METHOD} = srcupgrade ]] || \ |
205 |
|
[[ ${METHOD} = uppretend ]] || \ |
206 |
|
[[ ${METHOD} = srcuppretend ]] |
207 |
|
then |
208 |
|
INSTDEPS="$(${MLIBDIR}/magequery.sh -i)" |
209 |
|
for dep in ${INSTDEPS} |
210 |
|
do |
211 |
|
PCAT="$(magename2pcat ${dep} installdb)" |
212 |
|
PNAME="$(magename2pname ${dep})" |
213 |
|
|
214 |
|
# get the highest mage file from mage-db |
215 |
|
MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})" |
216 |
|
|
217 |
|
# now get the pver&pbuild from the new file |
218 |
|
PVER="$(magename2pver ${MAGEFILE})" |
219 |
|
PBUILD="$(magename2pbuild ${MAGEFILE})" |
220 |
|
|
221 |
|
# do not wander files which are installed |
222 |
|
if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] |
223 |
|
then |
224 |
|
# get dependencies the package |
225 |
|
rumwandern ${MAGEFILE} |
226 |
|
|
227 |
|
# now add the package itself to the dependencies |
228 |
|
# (if not exists already) |
229 |
|
#if [ -z "$(echo ${ALLDEPS} | fgrep "${MAGEFILE}")" ] |
230 |
|
if checklist_alldeps "${MAGEFILE}" |
231 |
|
then |
232 |
|
ALLDEPS="${ALLDEPS} ${MAGEFILE}" |
233 |
|
fi |
234 |
|
fi |
235 |
|
done |
236 |
|
else |
237 |
|
# get dependencies the package |
238 |
|
rumwandern ${MAGEFILE} |
239 |
|
|
240 |
|
# now add the package itself to the dependencies |
241 |
|
ALLDEPS="${ALLDEPS} ${MAGEFILE}" |
242 |
|
fi |
243 |
|
|
244 |
|
[[ ${METHOD} = pretend ]] || \ |
245 |
|
[[ ${METHOD} = srcpretend ]] || \ |
246 |
|
[[ ${METHOD} = uppretend ]] || \ |
247 |
|
[[ ${METHOD} = srcuppretend ]] && \ |
248 |
|
echo "done" |
249 |
|
|
|
# now add the package itself to the dependencies |
|
|
ALLDEPS="${ALLDEPS} ${MAGEFILE}" |
|
250 |
|
|
251 |
## show output of pretend |
## show output of pretend |
252 |
if [[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]] |
if [[ ${METHOD} = pretend ]] || \ |
253 |
|
[[ ${METHOD} = srcpretend ]] || \ |
254 |
|
[[ ${METHOD} = uppretend ]] || \ |
255 |
|
[[ ${METHOD} = srcuppretend ]] |
256 |
then |
then |
257 |
# this is a little bit faster |
# this is a little bit faster |
258 |
declare -i x=0 |
declare -i x=0 |
282 |
fi |
fi |
283 |
|
|
284 |
## return output from src/install deps |
## return output from src/install deps |
285 |
[[ ${METHOD} = install ]] || [[ ${METHOD} = srcinstall ]] && echo "${ALLDEPS}" |
[[ ${METHOD} = install ]] || \ |
286 |
|
[[ ${METHOD} = srcinstall ]] || \ |
287 |
|
[[ ${METHOD} = upgrade ]] || \ |
288 |
|
[[ ${METHOD} = srcupgrade ]] && \ |
289 |
|
echo "${ALLDEPS}" |
290 |
|
|
291 |
# delete ${BUILDDIR}/virtuals if exists as not needed anymore |
# delete ${BUILDDIR}/virtuals if exists as not needed anymore |
292 |
#[ -d ${BUILDDIR}/virtuals ] && rm -rf ${BUILDDIR}/virtuals |
#[ -d ${BUILDDIR}/virtuals ] && rm -rf ${BUILDDIR}/virtuals |