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 701 by niro, Wed Mar 26 15:58:25 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.10 2008-03-26 15:58:25 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
62   exit 1   exit 1
63  }  }
# 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 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     # but do not add any virtuals to PROCESSEDDEPS or their resolved
189     # pkgnames will be ignored and they are missing on the dependecy-list
190     if [[ ${DEPNAME/virtual\//} = ${DEPNAME} ]]
191     then
192     PROCESSEDDEPS="${PROCESSEDDEPS} ${DEPNAME%-*}"
193     fi
194    
195   HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}")   HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}")
196    
197   PCAT="$(magename2pcat ${HIGHEST_DEPFILE})"   PCAT="$(magename2pcat ${HIGHEST_DEPFILE})"
# Line 149  rumwandern() Line 200  rumwandern()
200   PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})"   PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})"
201    
202   ## check ob schon in ALLDEPS enthalten dann mach weiter   ## check ob schon in ALLDEPS enthalten dann mach weiter
203   if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ]  
204     # usage of fgrep is extremly slow and consumes a lot of cpu power
205     #if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ]
206     if checklist_alldeps "${HIGHEST_DEPFILE}"
207   then   then
208   ### check ob DFILE schon installiert ist ###   ### check ob DFILE schon installiert ist ###
209   if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]   if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]
# Line 169  EOF Line 223  EOF
223  # maybe later ?  # maybe later ?
224  #[ -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] && exit 3  #[ -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] && exit 3
225    
226  [[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]] && \  [[ ${METHOD} = pretend ]] || \
227     [[ ${METHOD} = srcpretend ]] || \
228     [[ ${METHOD} = uppretend ]] || \
229     [[ ${METHOD} = srcuppretend ]] && \
230   echo -n "Calculating dependencies ... "   echo -n "Calculating dependencies ... "
231    
 # get dependencies the package  
 rumwandern ${MAGEFILE}  
232    
233  [[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]] && echo "done"  if [[ ${METHOD} = upgrade ]] || \
234     [[ ${METHOD} = srcupgrade ]] || \
235     [[ ${METHOD} = uppretend ]] || \
236     [[ ${METHOD} = srcuppretend ]]
237    then
238     INSTDEPS="$(${MLIBDIR}/magequery.sh -i)"
239     for dep in ${INSTDEPS}
240     do
241     PCAT="$(magename2pcat ${dep} installdb)"
242     PNAME="$(magename2pname ${dep})"
243    
244     # get the highest mage file from mage-db
245     MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})"
246    
247     # if no install candidate was found, record this
248     # and process with the next one
249     if [[ -z ${MAGEFILE} ]]
250     then
251     NO_UPGRADE_CANDIDATE="${NO_UPGRADE_CANDIDATE} ${PCAT}/${PNAME}"
252     continue
253     fi
254    
255     # now get the pver&pbuild from the new file
256     PVER="$(magename2pver ${MAGEFILE})"
257     PBUILD="$(magename2pbuild ${MAGEFILE})"
258    
259     # do not wander files which are installed
260     if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]
261     then
262     # get dependencies the package
263     rumwandern ${MAGEFILE}
264    
265     # now add the package itself to the dependencies
266     # (if not exists already)
267     #if [ -z "$(echo ${ALLDEPS} | fgrep "${MAGEFILE}")" ]
268     if checklist_alldeps "${MAGEFILE}"
269     then
270     ALLDEPS="${ALLDEPS} ${MAGEFILE}"
271     fi
272     fi
273     done
274    else
275     # get dependencies the package
276     rumwandern ${MAGEFILE}
277    
278     # now add the package itself to the dependencies
279     ALLDEPS="${ALLDEPS} ${MAGEFILE}"
280    fi
281    
282    [[ ${METHOD} = pretend ]] || \
283     [[ ${METHOD} = srcpretend ]] || \
284     [[ ${METHOD} = uppretend ]] || \
285     [[ ${METHOD} = srcuppretend ]] && \
286     echo "done"
287    
 # now add the package itself to the dependencies  
 ALLDEPS="${ALLDEPS} ${MAGEFILE}"  
288    
289  ## show output of pretend  ## show output of pretend
290  if [[ ${METHOD} = pretend ]] || [[ ${METHOD} = srcpretend ]]  if [[ ${METHOD} = pretend ]] || \
291     [[ ${METHOD} = srcpretend ]] || \
292     [[ ${METHOD} = uppretend ]] || \
293     [[ ${METHOD} = srcuppretend ]]
294  then  then
295   # this is a little bit faster   # this is a little bit faster
296   declare -i x=0   declare -i x=0
# Line 209  then Line 317  then
317   echo "done"   echo "done"
318   echo -e "${list}"   echo -e "${list}"
319   echo   echo
320    
321     if [[ ! -z ${NO_UPGRADE_CANDIDATE} ]]
322     then
323     echo -e "${COLRED}Currently no candidates found for:${COLDEFAULT}"
324     for i in ${NO_UPGRADE_CANDIDATE}
325     do
326     echo -e "${COLRED}    ${i}${COLDEFAULT}"
327     done
328     echo
329     echo -e "${COLRED}Please consider to uninstall all of them first,${COLDEFAULT}"
330     echo -e "${COLRED}because these packages does not exist in this distribution${COLDEFAULT}"
331     echo -e "${COLRED}and there will be no further updates or support for them.${COLDEFAULT}"
332     echo
333     fi
334  fi  fi
335    
336  ## return output from src/install deps  ## return output from src/install deps
337  [[ ${METHOD} = install ]] || [[ ${METHOD} = srcinstall ]] && echo "${ALLDEPS}"  [[ ${METHOD} = install ]] || \
338     [[ ${METHOD} = srcinstall ]] || \
339     [[ ${METHOD} = upgrade ]] || \
340     [[ ${METHOD} = srcupgrade ]] && \
341     echo "${ALLDEPS}"
342    
343  # delete ${BUILDDIR}/virtuals if exists as not needed anymore  # delete ${BUILDDIR}/virtuals if exists as not needed anymore
344  #[ -d ${BUILDDIR}/virtuals ] && rm -rf ${BUILDDIR}/virtuals  #[ -d ${BUILDDIR}/virtuals ] && rm -rf ${BUILDDIR}/virtuals

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