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.2 2005-09-09 17:50:03 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/depwalker.sh,v 1.8 2008-01-13 21:42:16 niro Exp $ |
5 |
|
|
6 |
# default die function |
# default die function |
7 |
die() |
die() |
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 |
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 |
|
checklist_processeddeps() |
110 |
|
{ |
111 |
|
local i |
112 |
|
local item="$1" |
113 |
|
|
114 |
|
for i in ${PROCESSEDDEPS} |
115 |
|
do |
116 |
|
[[ ${i} = ${item} ]] && return 1 |
117 |
|
done |
118 |
|
|
119 |
|
return 0 |
120 |
|
} |
121 |
|
|
122 |
##################### |
##################### |
123 |
## rumwandern /path/to/mage/file/.mage |
## rumwandern /path/to/mage/file/.mage |
124 |
rumwandern() |
rumwandern() |
137 |
local INSTALL_VIRTUAL |
local INSTALL_VIRTUAL |
138 |
local PNAME |
local PNAME |
139 |
local PCAT |
local PCAT |
140 |
|
local PVER |
141 |
|
local PBUILD |
142 |
|
|
143 |
DFILE="$1" |
DFILE="$1" |
144 |
|
|
175 |
|
|
176 |
while read SYM DEPNAME |
while read SYM DEPNAME |
177 |
do |
do |
178 |
|
# exclude empty depnames |
179 |
|
[[ -z ${DEPNAME} ]] && continue |
180 |
|
|
181 |
|
# exclude all already processed deps -without version |
182 |
|
if ! checklist_processeddeps "${DEPNAME%-*}" |
183 |
|
then |
184 |
|
continue |
185 |
|
fi |
186 |
|
|
187 |
|
# mark depfile as processed to prevent double runs -without version |
188 |
|
PROCESSEDDEPS="${PROCESSEDDEPS} ${DEPNAME%-*}" |
189 |
|
|
190 |
HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}") |
HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}") |
191 |
|
|
192 |
PCAT="$(magename2pcat ${HIGHEST_DEPFILE})" |
PCAT="$(magename2pcat ${HIGHEST_DEPFILE})" |
195 |
PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})" |
PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})" |
196 |
|
|
197 |
## check ob schon in ALLDEPS enthalten dann mach weiter |
## check ob schon in ALLDEPS enthalten dann mach weiter |
198 |
if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ] |
|
199 |
|
# usage of fgrep is extremly slow and consumes a lot of cpu power |
200 |
|
#if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ] |
201 |
|
if checklist_alldeps "${HIGHEST_DEPFILE}" |
202 |
then |
then |
203 |
### check ob DFILE schon installiert ist ### |
### check ob DFILE schon installiert ist ### |
204 |
if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] |
if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] |
235 |
do |
do |
236 |
PCAT="$(magename2pcat ${dep} installdb)" |
PCAT="$(magename2pcat ${dep} installdb)" |
237 |
PNAME="$(magename2pname ${dep})" |
PNAME="$(magename2pname ${dep})" |
|
PVER="$(magename2pver ${dep})" |
|
|
PBUILD="$(magename2pbuild ${dep})" |
|
238 |
|
|
239 |
# fake a mage file |
# get the highest mage file from mage-db |
240 |
MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage" |
MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})" |
241 |
|
|
242 |
|
# now get the pver&pbuild from the new file |
243 |
|
PVER="$(magename2pver ${MAGEFILE})" |
244 |
|
PBUILD="$(magename2pbuild ${MAGEFILE})" |
245 |
|
|
246 |
|
# do not wander files which are installed |
247 |
|
if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] |
248 |
|
then |
249 |
|
# get dependencies the package |
250 |
|
rumwandern ${MAGEFILE} |
251 |
|
|
252 |
rumwandern ${MAGEFILE} |
# now add the package itself to the dependencies |
253 |
|
# (if not exists already) |
254 |
|
#if [ -z "$(echo ${ALLDEPS} | fgrep "${MAGEFILE}")" ] |
255 |
|
if checklist_alldeps "${MAGEFILE}" |
256 |
|
then |
257 |
|
ALLDEPS="${ALLDEPS} ${MAGEFILE}" |
258 |
|
fi |
259 |
|
fi |
260 |
done |
done |
261 |
else |
else |
262 |
# get dependencies the package |
# get dependencies the package |