Magellan Linux

Diff of /branches/mage-next/src/depwalker.in

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

revision 226 by niro, Fri Sep 9 16:35:46 2005 UTC revision 1559 by niro, Wed Dec 28 09:54:25 2011 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2    # $Id$
3  #depwalker  # dependeny walker
 # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/depwalker.sh,v 1.1 2005-09-09 16:35:27 niro Exp $  
4    
5  # default die function  # default die function
6  die()  die()
# Line 10  die() Line 9  die()
9   exit 1   exit 1
10  }  }
11    
12  # # include all needed files  # include all needed files
13  # [ -f ${MLIBDIR}/conf/mage.rc.global ] &&  \  [ -f /etc/mage.rc.global ] &&  \
14  # source ${MLIBDIR}/conf/mage.rc.global || \   source /etc/mage.rc.global || \
15  # die "${MLIBDIR}/conf/mage.rc.global missing"   die "/etc/mage.rc.global missing"
16  #  
17  # [ -f /etc/mage.rc ] && source /etc/mage.rc || \  [ -f ${MAGERC} ] && source ${MAGERC} || \
18  # die "Your /etc/mage.rc is missing. Aborting."   die "Your ${MAGERC} is missing. Aborting."
19  #  
20  # [ -f ${MLIBDIR}/mage.functions.sh ] && \  [ -f ${MLIBDIR}/mage4.functions.sh ] && \
21  # source ${MLIBDIR}/mage.functions.sh || \   source ${MLIBDIR}/mage4.functions.sh || \
22  # die "mage functions missing"   die "mage functions missing"
23    
24  # for tests only  # for tests only
25  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
26  source /etc/mage.rc  # source /etc/mage.rc
27  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
28    # MLIBDIR=/home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage
29    
30  # not serios if missing, only for colors  # not serious if missing, only needed for colors
31  [ -f /etc/init.d/functions ] && source /etc/init.d/functions  [ -f /etc/init.d/functions ] && source /etc/init.d/functions
32    
33  # disable colors if wanted  # disable colors if wanted
# Line 53  usage() Line 53  usage()
53   echo "  -v     --pver          version number of the package"   echo "  -v     --pver          version number of the package"
54   echo "  -b     --pbuild        build number of the package"   echo "  -b     --pbuild        build number of the package"
55   echo "  -m     --method        which calc method should be used:"   echo "  -m     --method        which calc method should be used:"
56   echo "                         install srcinstall depend srcdepend"   echo "                         install, srcinstall, depend, srcdepend"
57     echo "                         upgrade, srcupgrade"
58   echo   echo
59   echo "method,name, version and build must be given !"   echo "method, name, version and build must be given !"
60   echo   echo
61   exit 1   exit 1
62  }  }
# Line 90  done Line 91  done
91  ALLDEPS=""  ALLDEPS=""
92  MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage"  MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage"
93    
94    # much faster than fgrep
95    checklist_alldeps()
96    {
97     local i
98     local item="$1"
99    
100     for i in ${ALLDEPS}
101     do
102     [[ ${i} = ${item} ]] && return 1
103     done
104    
105     return 0
106    }
107    
108    checklist_processeddeps()
109    {
110     local i
111     local item="$1"
112    
113     for i in ${PROCESSEDDEPS}
114     do
115     [[ ${i} = ${item} ]] && return 1
116     done
117    
118     return 0
119    }
120    
121  #####################  #####################
122  ##  rumwandern /path/to/mage/file/.mage  ##  rumwandern /path/to/mage/file/.mage
123  rumwandern()  rumwandern()
# Line 108  rumwandern() Line 136  rumwandern()
136   local INSTALL_VIRTUAL   local INSTALL_VIRTUAL
137   local PNAME   local PNAME
138   local PCAT   local PCAT
139     local PVER
140     local PBUILD
141    
142   DFILE="$1"   DFILE="$1"
143    
144   source ${DFILE}   source ${DFILE}
145    
146     # forced nodeps
147     if [[ ${NODEPS} = true ]]
148     then
149     DEPEND=""
150     SDEPEND=""
151     fi
152    
153   MY_DEPEND="${DEPEND}"   MY_DEPEND="${DEPEND}"
154    
155   # for srcinstall & srcdepend only; SDEPEND also needed   # for srcinstall & srcdepend only; SDEPEND also needed
156   if [[ ${METHOD} = srcinstall ]] || [[ ${METHOD} = srcpretend ]]   if [[ ${METHOD} = srcinstall ]] || \
157     [[ ${METHOD} = srcpretend ]] || \
158     [[ ${METHOD} = srcupgrade ]] || \
159     [[ ${METHOD} = srcuppretend ]]
160   then   then
161   # only if SDEPEND is not zero   # only if SDEPEND is not zero
162   if [ -n "${SDEPEND}" ]   if [ -n "${SDEPEND}" ]
# Line 141  rumwandern() Line 182  rumwandern()
182    
183   while read SYM DEPNAME   while read SYM DEPNAME
184   do   do
185     # exclude empty depnames
186     [[ -z ${DEPNAME} ]] && continue
187    
188     # exclude all already processed deps -without version
189     if ! checklist_processeddeps "${DEPNAME%-*}"
190     then
191     continue
192     fi
193    
194     # mark depfile as processed to prevent double runs -without version
195     # but do not add any virtuals to PROCESSEDDEPS or their resolved
196     # pkgnames will be ignored and they are missing on the dependecy-list
197     if [[ ${DEPNAME/virtual\//} = ${DEPNAME} ]]
198     then
199     PROCESSEDDEPS="${PROCESSEDDEPS} ${DEPNAME%-*}"
200     fi
201    
202   HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}")   HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}")
203    
204   PCAT="$(magename2pcat ${HIGHEST_DEPFILE})"   PCAT="$(magename2pcat ${HIGHEST_DEPFILE})"
# Line 149  rumwandern() Line 207  rumwandern()
207   PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})"   PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})"
208    
209   ## check ob schon in ALLDEPS enthalten dann mach weiter   ## check ob schon in ALLDEPS enthalten dann mach weiter
210   if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ]  
211     # usage of fgrep is extremly slow and consumes a lot of cpu power
212     #if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ]
213     if checklist_alldeps "${HIGHEST_DEPFILE}"
214   then   then
215   ### check ob DFILE schon installiert ist ###   ### check ob DFILE schon installiert ist ###
216   if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]   if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]
# Line 169  EOF Line 230  EOF
230  # maybe later ?  # maybe later ?
231  #[ -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] && exit 3  #[ -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] && exit 3
232    
233  [[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]] && \  [[ ${METHOD} = pretend ]] || \
234     [[ ${METHOD} = srcpretend ]] || \
235     [[ ${METHOD} = uppretend ]] || \
236     [[ ${METHOD} = srcuppretend ]] && \
237   echo -n "Calculating dependencies ... "   echo -n "Calculating dependencies ... "
238    
 # get dependencies the package  
 rumwandern ${MAGEFILE}  
239    
240  [[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]] && echo "done"  if [[ ${METHOD} = upgrade ]] || \
241     [[ ${METHOD} = srcupgrade ]] || \
242     [[ ${METHOD} = uppretend ]] || \
243     [[ ${METHOD} = srcuppretend ]]
244    then
245     INSTDEPS="$(${MLIBDIR}/magequery.sh -i)"
246     for dep in ${INSTDEPS}
247     do
248     PCAT="$(magename2pcat ${dep} installdb)"
249     PNAME="$(magename2pname ${dep})"
250    
251     # get the highest mage file from mage-db
252     MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})"
253    
254     # if no install candidate was found, record this
255     # and process with the next one
256     if [[ -z ${MAGEFILE} ]]
257     then
258     NO_UPGRADE_CANDIDATE="${NO_UPGRADE_CANDIDATE} ${PCAT}/${PNAME}"
259     continue
260     fi
261    
262     # now get the pver&pbuild from the new file
263     PVER="$(magename2pver ${MAGEFILE})"
264     PBUILD="$(magename2pbuild ${MAGEFILE})"
265    
266     # do not wander files which are installed
267     if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]
268     then
269     # get dependencies the package
270     rumwandern ${MAGEFILE}
271    
272     # now add the package itself to the dependencies
273     # (if not exists already)
274     #if [ -z "$(echo ${ALLDEPS} | fgrep "${MAGEFILE}")" ]
275     if checklist_alldeps "${MAGEFILE}"
276     then
277     ALLDEPS="${ALLDEPS} ${MAGEFILE}"
278     fi
279     fi
280     done
281    else
282     # get dependencies the package
283     rumwandern ${MAGEFILE}
284    
285     # now add the package itself to the dependencies
286     ALLDEPS="${ALLDEPS} ${MAGEFILE}"
287    fi
288    
289    [[ ${METHOD} = pretend ]] || \
290     [[ ${METHOD} = srcpretend ]] || \
291     [[ ${METHOD} = uppretend ]] || \
292     [[ ${METHOD} = srcuppretend ]] && \
293     echo "done"
294    
 # now add the package itself to the dependencies  
 ALLDEPS="${ALLDEPS} ${MAGEFILE}"  
295    
296  ## show output of pretend  ## show output of pretend
297  if [[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]]  if [[ ${METHOD} = pretend ]] || \
298     [[ ${METHOD} = srcpretend ]] || \
299     [[ ${METHOD} = uppretend ]] || \
300     [[ ${METHOD} = srcuppretend ]]
301  then  then
302   # this is a little bit faster   # this is a little bit faster
303   declare -i x=0   declare -i x=0
# Line 209  then Line 324  then
324   echo "done"   echo "done"
325   echo -e "${list}"   echo -e "${list}"
326   echo   echo
327    
328     if [[ ! -z ${NO_UPGRADE_CANDIDATE} ]]
329     then
330     echo -e "${COLRED}Currently no candidates found for:${COLDEFAULT}"
331     for i in ${NO_UPGRADE_CANDIDATE}
332     do
333     echo -e "${COLRED}    ${i}${COLDEFAULT}"
334     done
335     echo
336     echo -e "${COLRED}Please consider to uninstall all of them first,${COLDEFAULT}"
337     echo -e "${COLRED}because these packages does not exist in this distribution${COLDEFAULT}"
338     echo -e "${COLRED}anymore and there will be no further support for them.${COLDEFAULT}"
339     echo
340     fi
341  fi  fi
342    
343  ## return output from src/install deps  ## return output from src/install deps
344  [[ ${METHOD} = install ]] || [[ ${METHOD} = srcinstall ]] && echo "${ALLDEPS}"  [[ ${METHOD} = install ]] || \
345     [[ ${METHOD} = srcinstall ]] || \
346     [[ ${METHOD} = upgrade ]] || \
347     [[ ${METHOD} = srcupgrade ]] && \
348     echo "${ALLDEPS}"
349    
350  # delete ${BUILDDIR}/virtuals if exists as not needed anymore  # delete ${BUILDDIR}/virtuals if exists as not needed anymore
351  #[ -d ${BUILDDIR}/virtuals ] && rm -rf ${BUILDDIR}/virtuals  #[ -d ${BUILDDIR}/virtuals ] && rm -rf ${BUILDDIR}/virtuals

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