Magellan Linux

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

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

revision 235 by niro, Sat Sep 10 13:34:56 2005 UTC revision 1560 by niro, Wed Dec 28 09:55:37 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.3 2005-09-10 13:34:56 niro Exp $  
4    
5  # default die function  # default die function
6  die()  die()
# Line 15  die() Line 14  die()
14   source /etc/mage.rc.global || \   source /etc/mage.rc.global || \
15   die "/etc/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}/mage4.functions.sh ] && \  [ -f ${MLIBDIR}/mage4.functions.sh ] && \
21   source ${MLIBDIR}/mage4.functions.sh || \   source ${MLIBDIR}/mage4.functions.sh || \
22   die "mage functions missing"   die "mage functions missing"
23    
 # for tests only  
 # source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage.rc.global  
 # source /etc/mage.rc  
 # source /home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh  
 # MLIBDIR=/home/tjoke/alx-cvs/magellan-src/mage/usr/lib/mage  
   
 # not serious if missing, only needed for colors  
 [ -f /etc/init.d/functions ] && source /etc/init.d/functions  
   
 # disable colors if wanted  
 if [[ ${NOCOLORS} = true ]]  
 then  
  COLRED=""  
  COLGREEN=""  
  COLYELLOW=""  
  COLBLUE=""  
  COLMAGENTA=""  
  COLWHITE=""  
  COLDEFAULT=""  
 fi  
   
24  usage()  usage()
25  {  {
26   echo   echo
# Line 57  usage() Line 35  usage()
35   echo "                         install, srcinstall, depend, srcdepend"   echo "                         install, srcinstall, depend, srcdepend"
36   echo "                         upgrade, srcupgrade"   echo "                         upgrade, srcupgrade"
37   echo   echo
38   echo "method,name, version and build must be given !"   echo "method, name, version and build must be given !"
39   echo   echo
40   exit 1   exit 1
41  }  }
# Line 92  done Line 70  done
70  ALLDEPS=""  ALLDEPS=""
71  MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage"  MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage"
72    
73    # much faster than fgrep
74    checklist_alldeps()
75    {
76     local i
77     local item="$1"
78    
79     for i in ${ALLDEPS}
80     do
81     [[ ${i} = ${item} ]] && return 1
82     done
83    
84     return 0
85    }
86    
87    checklist_processeddeps()
88    {
89     local i
90     local item="$1"
91    
92     for i in ${PROCESSEDDEPS}
93     do
94     [[ ${i} = ${item} ]] && return 1
95     done
96    
97     return 0
98    }
99    
100  #####################  #####################
101  ##  rumwandern /path/to/mage/file/.mage  ##  rumwandern /path/to/mage/file/.mage
102  rumwandern()  rumwandern()
# Line 110  rumwandern() Line 115  rumwandern()
115   local INSTALL_VIRTUAL   local INSTALL_VIRTUAL
116   local PNAME   local PNAME
117   local PCAT   local PCAT
118     local PVER
119     local PBUILD
120    
121   DFILE="$1"   DFILE="$1"
122    
123   source ${DFILE}   source ${DFILE}
124    
125     # forced nodeps
126     if [[ ${NODEPS} = true ]]
127     then
128     DEPEND=""
129     SDEPEND=""
130     fi
131    
132   MY_DEPEND="${DEPEND}"   MY_DEPEND="${DEPEND}"
133    
134   # for srcinstall & srcdepend only; SDEPEND also needed   # for srcinstall & srcdepend only; SDEPEND also needed
# Line 146  rumwandern() Line 161  rumwandern()
161    
162   while read SYM DEPNAME   while read SYM DEPNAME
163   do   do
164     # exclude empty depnames
165     [[ -z ${DEPNAME} ]] && continue
166    
167     # exclude all already processed deps -without version
168     if ! checklist_processeddeps "${DEPNAME%-*}"
169     then
170     continue
171     fi
172    
173     # mark depfile as processed to prevent double runs -without version
174     # but do not add any virtuals to PROCESSEDDEPS or their resolved
175     # pkgnames will be ignored and they are missing on the dependecy-list
176     if [[ ${DEPNAME/virtual\//} = ${DEPNAME} ]]
177     then
178     PROCESSEDDEPS="${PROCESSEDDEPS} ${DEPNAME%-*}"
179     fi
180    
181   HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}")   HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}")
182    
183   PCAT="$(magename2pcat ${HIGHEST_DEPFILE})"   PCAT="$(magename2pcat ${HIGHEST_DEPFILE})"
# Line 154  rumwandern() Line 186  rumwandern()
186   PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})"   PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})"
187    
188   ## check ob schon in ALLDEPS enthalten dann mach weiter   ## check ob schon in ALLDEPS enthalten dann mach weiter
189   if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ]  
190     # usage of fgrep is extremly slow and consumes a lot of cpu power
191     #if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ]
192     if checklist_alldeps "${HIGHEST_DEPFILE}"
193   then   then
194   ### check ob DFILE schon installiert ist ###   ### check ob DFILE schon installiert ist ###
195   if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]   if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]
# Line 191  then Line 226  then
226   do   do
227   PCAT="$(magename2pcat ${dep} installdb)"   PCAT="$(magename2pcat ${dep} installdb)"
228   PNAME="$(magename2pname ${dep})"   PNAME="$(magename2pname ${dep})"
  PVER="$(magename2pver ${dep})"  
  PBUILD="$(magename2pbuild ${dep})"  
229    
230   # fake a mage file   # get the highest mage file from mage-db
231   MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage"   MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})"
232    
233   rumwandern ${MAGEFILE}   # if no install candidate was found, record this
234     # and process with the next one
235     if [[ -z ${MAGEFILE} ]]
236     then
237     NO_UPGRADE_CANDIDATE="${NO_UPGRADE_CANDIDATE} ${PCAT}/${PNAME}"
238     continue
239     fi
240    
241     # now get the pver&pbuild from the new file
242     PVER="$(magename2pver ${MAGEFILE})"
243     PBUILD="$(magename2pbuild ${MAGEFILE})"
244    
245     # do not wander files which are installed
246     if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]
247     then
248     # get dependencies the package
249     rumwandern ${MAGEFILE}
250    
251     # now add the package itself to the dependencies
252     # (if not exists already)
253     #if [ -z "$(echo ${ALLDEPS} | fgrep "${MAGEFILE}")" ]
254     if checklist_alldeps "${MAGEFILE}"
255     then
256     ALLDEPS="${ALLDEPS} ${MAGEFILE}"
257     fi
258     fi
259   done   done
260  else  else
261   # get dependencies the package   # get dependencies the package
# Line 245  then Line 303  then
303   echo "done"   echo "done"
304   echo -e "${list}"   echo -e "${list}"
305   echo   echo
306    
307     if [[ ! -z ${NO_UPGRADE_CANDIDATE} ]]
308     then
309     echo -e "${COLRED}Currently no candidates found for:${COLDEFAULT}"
310     for i in ${NO_UPGRADE_CANDIDATE}
311     do
312     echo -e "${COLRED}    ${i}${COLDEFAULT}"
313     done
314     echo
315     echo -e "${COLRED}Please consider to uninstall all of them first,${COLDEFAULT}"
316     echo -e "${COLRED}because these packages does not exist in this distribution${COLDEFAULT}"
317     echo -e "${COLRED}anymore and there will be no further support for them.${COLDEFAULT}"
318     echo
319     fi
320  fi  fi
321    
322  ## return output from src/install deps  ## return output from src/install deps

Legend:
Removed from v.235  
changed lines
  Added in v.1560