Magellan Linux

Diff of /trunk/mage/usr/lib/mage/depwalker.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 226 by niro, Fri Sep 9 16:35:46 2005 UTC revision 654 by niro, Sun Jan 13 21:32:38 2008 UTC
# Line 1  Line 1 
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.7 2008-01-13 21:32:38 niro Exp $
5    
6  # default die function  # default die function
7  die()  die()
# Line 10  die() Line 10  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
# Line 53  usage() Line 54  usage()
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
# Line 90  done Line 92  done
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()
# Line 108  rumwandern() Line 137  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    
# Line 115  rumwandern() Line 146  rumwandern()
146   MY_DEPEND="${DEPEND}"   MY_DEPEND="${DEPEND}"
147    
148   # for srcinstall & srcdepend only; SDEPEND also needed   # for srcinstall & srcdepend only; SDEPEND also needed
149   if [[ ${METHOD} = srcinstall ]] || [[ ${METHOD} = srcpretend ]]   if [[ ${METHOD} = srcinstall ]] || \
150     [[ ${METHOD} = srcpretend ]] || \
151     [[ ${METHOD} = srcupgrade ]] || \
152     [[ ${METHOD} = srcuppretend ]]
153   then   then
154   # only if SDEPEND is not zero   # only if SDEPEND is not zero
155   if [ -n "${SDEPEND}" ]   if [ -n "${SDEPEND}" ]
# Line 141  rumwandern() Line 175  rumwandern()
175    
176   while read SYM DEPNAME   while read SYM DEPNAME
177   do   do
178     # exclude all already processed deps -without version
179     if ! checklist_processeddeps "${DEPNAME%-*}"
180     then
181     continue
182     fi
183    
184     # mark depfile as processed to prevent double runs -without version
185     PROCESSEDDEPS="${PROCESSEDDEPS} ${DEPNAME%-*}"
186    
187   HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}")   HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}")
188    
189   PCAT="$(magename2pcat ${HIGHEST_DEPFILE})"   PCAT="$(magename2pcat ${HIGHEST_DEPFILE})"
# Line 149  rumwandern() Line 192  rumwandern()
192   PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})"   PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})"
193    
194   ## check ob schon in ALLDEPS enthalten dann mach weiter   ## check ob schon in ALLDEPS enthalten dann mach weiter
195   if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ]  
196     # usage of fgrep is extremly slow and consumes a lot of cpu power
197     #if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ]
198     if checklist_alldeps "${HIGHEST_DEPFILE}"
199   then   then
200   ### check ob DFILE schon installiert ist ###   ### check ob DFILE schon installiert ist ###
201   if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]   if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]
# Line 169  EOF Line 215  EOF
215  # maybe later ?  # maybe later ?
216  #[ -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] && exit 3  #[ -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] && exit 3
217    
218  [[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]] && \  [[ ${METHOD} = pretend ]] || \
219     [[ ${METHOD} = srcpretend ]] || \
220     [[ ${METHOD} = uppretend ]] || \
221     [[ ${METHOD} = srcuppretend ]] && \
222   echo -n "Calculating dependencies ... "   echo -n "Calculating dependencies ... "
223    
 # get dependencies the package  
 rumwandern ${MAGEFILE}  
224    
225  [[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]] && echo "done"  if [[ ${METHOD} = upgrade ]] || \
226     [[ ${METHOD} = srcupgrade ]] || \
227     [[ ${METHOD} = uppretend ]] || \
228     [[ ${METHOD} = srcuppretend ]]
229    then
230     INSTDEPS="$(${MLIBDIR}/magequery.sh -i)"
231     for dep in ${INSTDEPS}
232     do
233     PCAT="$(magename2pcat ${dep} installdb)"
234     PNAME="$(magename2pname ${dep})"
235    
236     # get the highest mage file from mage-db
237     MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})"
238    
239     # now get the pver&pbuild from the new file
240     PVER="$(magename2pver ${MAGEFILE})"
241     PBUILD="$(magename2pbuild ${MAGEFILE})"
242    
243     # do not wander files which are installed
244     if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]
245     then
246     # get dependencies the package
247     rumwandern ${MAGEFILE}
248    
249     # now add the package itself to the dependencies
250     # (if not exists already)
251     #if [ -z "$(echo ${ALLDEPS} | fgrep "${MAGEFILE}")" ]
252     if checklist_alldeps "${MAGEFILE}"
253     then
254     ALLDEPS="${ALLDEPS} ${MAGEFILE}"
255     fi
256     fi
257     done
258    else
259     # get dependencies the package
260     rumwandern ${MAGEFILE}
261    
262     # now add the package itself to the dependencies
263     ALLDEPS="${ALLDEPS} ${MAGEFILE}"
264    fi
265    
266    [[ ${METHOD} = pretend ]] || \
267     [[ ${METHOD} = srcpretend ]] || \
268     [[ ${METHOD} = uppretend ]] || \
269     [[ ${METHOD} = srcuppretend ]] && \
270     echo "done"
271    
 # now add the package itself to the dependencies  
 ALLDEPS="${ALLDEPS} ${MAGEFILE}"  
272    
273  ## show output of pretend  ## show output of pretend
274  if [[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]]  if [[ ${METHOD} = pretend ]] || \
275     [[ ${METHOD} = srcpretend ]] || \
276     [[ ${METHOD} = uppretend ]] || \
277     [[ ${METHOD} = srcuppretend ]]
278  then  then
279   # this is a little bit faster   # this is a little bit faster
280   declare -i x=0   declare -i x=0
# Line 212  then Line 304  then
304  fi  fi
305    
306  ## return output from src/install deps  ## return output from src/install deps
307  [[ ${METHOD} = install ]] || [[ ${METHOD} = srcinstall ]] && echo "${ALLDEPS}"  [[ ${METHOD} = install ]] || \
308     [[ ${METHOD} = srcinstall ]] || \
309     [[ ${METHOD} = upgrade ]] || \
310     [[ ${METHOD} = srcupgrade ]] && \
311     echo "${ALLDEPS}"
312    
313  # delete ${BUILDDIR}/virtuals if exists as not needed anymore  # delete ${BUILDDIR}/virtuals if exists as not needed anymore
314  #[ -d ${BUILDDIR}/virtuals ] && rm -rf ${BUILDDIR}/virtuals  #[ -d ${BUILDDIR}/virtuals ] && rm -rf ${BUILDDIR}/virtuals

Legend:
Removed from v.226  
changed lines
  Added in v.654