Magellan Linux

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

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

revision 677 by niro, Tue Feb 26 19:51:40 2008 UTC revision 2276 by niro, Fri Oct 25 07:53:19 2013 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.9 2008-02-26 19:51:40 niro Exp $  
4    
5  # default die function  # default die function
6  die()  die()
# Line 22  die() Line 21  die()
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
27   echo "Usage: $(basename $0) [command] [arg] ..."   echo "Usage: $(basename $0) [command] [arg] ..."
28   echo   echo
29   echo "  -h     --help          shows this help"   echo "  -h     --help          shows this help"
30   echo "  -c     --pcat          categorie of the package"   echo "  -c     --pcat          category of the package"
31   echo "  -n     --pname         name of the package"   echo "  -n     --pname         name of the package"
32   echo "  -v     --pver          version number of the package"   echo "  -v     --pver          version number of the package"
33   echo "  -b     --pbuild        build number of the package"   echo "  -b     --pbuild        build number of the package"
34   echo "  -m     --method        which calc method should be used:"   echo "  -m     --method        which calc method should be used:"
35   echo "                         install, srcinstall, depend, srcdepend"   echo "                         install, srcinstall, depend, srcdepend"
36   echo "                         upgrade, srcupgrade"   echo "                         upgrade, srcupgrade,"
37     echo "                         install-build-prerequisites,"
38     echo "                         pretend-build-prerequisites"
39     echo "  -d     --debug         enable debug mode"
40   echo   echo
41   echo "method,name, version and build must be given !"   echo "method, category, name, version and build must be given !"
42   echo   echo
43   exit 1   exit 1
44  }  }
45    
46    # always default debug=0
47    DEBUG=0
48    
49  # very basic getops  # very basic getops
50  for i in $*  for i in $*
51  do  do
# Line 71  do Line 55  do
55   --pver|-v) shift; PVER="$1" ;;   --pver|-v) shift; PVER="$1" ;;
56   --pbuild|-b) shift; PBUILD="$1" ;;   --pbuild|-b) shift; PBUILD="$1" ;;
57   --method|-m) shift; METHOD="$1" ;;   --method|-m) shift; METHOD="$1" ;;
58     --debug|-d) shift; DEBUG=1 ;;
59   --help|-h) usage ;;   --help|-h) usage ;;
60   esac   esac
61   shift   shift
# Line 120  checklist_processeddeps() Line 105  checklist_processeddeps()
105  }  }
106    
107  #####################  #####################
108  ##  rumwandern /path/to/mage/file/.mage  ##  depwalking /path/to/mage/file/.mage
109  rumwandern()  depwalking()
110  {  {
111   unset DEPEND   unset DEPEND
112   unset SDEPEND   unset SDEPEND
# Line 143  rumwandern() Line 128  rumwandern()
128   DFILE="$1"   DFILE="$1"
129    
130   source ${DFILE}   source ${DFILE}
131    
132     # forced nodeps
133     if [[ ${NODEPS} = true ]]
134     then
135     DEPEND=""
136     SDEPEND=""
137     fi
138    
139   MY_DEPEND="${DEPEND}"   MY_DEPEND="${DEPEND}"
140    
141   # for srcinstall & srcdepend only; SDEPEND also needed   # for srcinstall & srcdepend only; SDEPEND also needed
# Line 165  rumwandern() Line 158  rumwandern()
158   fi   fi
159   fi   fi
160    
161     if [[ ${METHOD} = install-build-prerequisites ]] || \
162     [[ ${METHOD} = pretend-build-prerequisites ]]
163     then
164     # only one time
165     if [[ ${LOOP_COUNTER} -lt 1 ]]
166     then
167     # only if SDEPEND is not zero
168     if [ -n "${SDEPEND}" ]
169     then
170     # crlf is substantly needed !!
171     if [ -n "${MY_DEPEND}" ]
172     then
173     MY_DEPEND="${MY_DEPEND}
174     ${SDEPEND}"
175     else
176     MY_DEPEND="${SDEPEND}"
177     fi
178     fi
179     fi
180     LOOP_COUNTER=${LOOP_COUNTER}+1
181     fi
182    
183   unset DEPEND   unset DEPEND
184   unset SDEPEND   unset SDEPEND
185    
# Line 175  rumwandern() Line 190  rumwandern()
190    
191   while read SYM DEPNAME   while read SYM DEPNAME
192   do   do
193     if [[ ${DEBUG} = 1 ]]
194     then
195     echo "DEBUG: DEPNAME='${DEPNAME}'" >&2
196     fi
197    
198   # exclude empty depnames   # exclude empty depnames
199   [[ -z ${DEPNAME} ]] && continue   [[ -z ${DEPNAME} ]] && continue
200    
# Line 193  rumwandern() Line 213  rumwandern()
213   fi   fi
214    
215   HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}")   HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}")
216     if [[ -z ${HIGHEST_DEPFILE} ]]
217     then
218     INVALID_DEPS+=" ${DEPNAME}:${DFILE}"
219     continue
220     fi
221    
222   PCAT="$(magename2pcat ${HIGHEST_DEPFILE})"   PCAT="$(magename2pcat ${HIGHEST_DEPFILE})"
223   PNAME="$(magename2pname ${HIGHEST_DEPFILE})"   PNAME="$(magename2pname ${HIGHEST_DEPFILE})"
224   PVER="$(magename2pver ${HIGHEST_DEPFILE})"   PVER="$(magename2pver ${HIGHEST_DEPFILE})"
225   PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})"   PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})"
226    
227   ## check ob schon in ALLDEPS enthalten dann mach weiter   ## dep already in ALLDEPS? then going on
228    
229   # usage of fgrep is extremly slow and consumes a lot of cpu power   # usage of fgrep is extremly slow and consumes a lot of cpu power
230   #if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ]   #if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ]
231   if checklist_alldeps "${HIGHEST_DEPFILE}"   if checklist_alldeps "${HIGHEST_DEPFILE}"
232   then   then
233   ### check ob DFILE schon installiert ist ###   ### check if the dependency is already installed ###
234   if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]   if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]
235   then   then
236   rumwandern ${HIGHEST_DEPFILE}   depwalking ${HIGHEST_DEPFILE}
237   ALLDEPS="${ALLDEPS} ${HIGHEST_DEPFILE}"   ALLDEPS="${ALLDEPS} ${HIGHEST_DEPFILE}"
238   fi   fi
239   fi   fi
# Line 218  EOF Line 243  EOF
243   return 0   return 0
244  }  }
245    
   
 ### abort if this package is already installed (retval 3)  
 # maybe later ?  
 #[ -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] && exit 3  
   
246  [[ ${METHOD} = pretend ]] || \  [[ ${METHOD} = pretend ]] || \
247   [[ ${METHOD} = srcpretend ]] || \   [[ ${METHOD} = srcpretend ]] || \
248   [[ ${METHOD} = uppretend ]] || \   [[ ${METHOD} = uppretend ]] || \
249   [[ ${METHOD} = srcuppretend ]] && \   [[ ${METHOD} = srcuppretend ]] || \
250     [[ ${METHOD} = pretend-build-prerequisites ]] && \
251   echo -n "Calculating dependencies ... "   echo -n "Calculating dependencies ... "
252    
253    
# Line 244  then Line 265  then
265   # get the highest mage file from mage-db   # get the highest mage file from mage-db
266   MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})"   MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})"
267    
268     # if no install candidate was found, record this
269     # and process with the next one
270     if [[ -z ${MAGEFILE} ]]
271     then
272     NO_UPGRADE_CANDIDATE="${NO_UPGRADE_CANDIDATE} ${PCAT}/${PNAME}"
273     continue
274     fi
275    
276   # now get the pver&pbuild from the new file   # now get the pver&pbuild from the new file
277   PVER="$(magename2pver ${MAGEFILE})"   PVER="$(magename2pver ${MAGEFILE})"
278   PBUILD="$(magename2pbuild ${MAGEFILE})"   PBUILD="$(magename2pbuild ${MAGEFILE})"
279    
280   # do not wander files which are installed   # do not walk files which are installed
281   if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]   if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]
282   then   then
283   # get dependencies the package   # get dependencies the package
284   rumwandern ${MAGEFILE}   depwalking ${MAGEFILE}
   
  # now add the package itself to the dependencies  
  # (if not exists already)  
  #if [ -z "$(echo ${ALLDEPS} | fgrep "${MAGEFILE}")" ]  
  if checklist_alldeps "${MAGEFILE}"  
  then  
  ALLDEPS="${ALLDEPS} ${MAGEFILE}"  
  fi  
285   fi   fi
286   done   done
287  else  else
288   # get dependencies the package   LOOP_COUNTER=0
289   rumwandern ${MAGEFILE}   # get all dependencies of the package
290     depwalking ${MAGEFILE}
291    fi
292    
293    if [[ ${METHOD} != install-build-prerequisites ]] &&
294     [[ ${METHOD} != pretend-build-prerequisites ]]
295    then
296   # now add the package itself to the dependencies   # now add the package itself to the dependencies
297   ALLDEPS="${ALLDEPS} ${MAGEFILE}"   # (if not exists already)
298     if checklist_alldeps "${MAGEFILE}"
299     then
300     ALLDEPS="${ALLDEPS} ${MAGEFILE}"
301     fi
302  fi  fi
303    
304  [[ ${METHOD} = pretend ]] || \  [[ ${METHOD} = pretend ]] || \
305   [[ ${METHOD} = srcpretend ]] || \   [[ ${METHOD} = srcpretend ]] || \
306   [[ ${METHOD} = uppretend ]] || \   [[ ${METHOD} = uppretend ]] || \
307   [[ ${METHOD} = srcuppretend ]] && \   [[ ${METHOD} = srcuppretend ]] || \
308     [[ ${METHOD} = pretend-build-prerequisites ]] && \
309   echo "done"   echo "done"
310    
311    
# Line 282  fi Line 313  fi
313  if [[ ${METHOD} = pretend ]] || \  if [[ ${METHOD} = pretend ]] || \
314   [[ ${METHOD} = srcpretend ]] || \   [[ ${METHOD} = srcpretend ]] || \
315   [[ ${METHOD} = uppretend ]] || \   [[ ${METHOD} = uppretend ]] || \
316   [[ ${METHOD} = srcuppretend ]]   [[ ${METHOD} = srcuppretend ]] || \
317     [[ ${METHOD} = pretend-build-prerequisites ]]
318  then  then
319   # this is a little bit faster   # this is a little bit faster
320   declare -i x=0   declare -i x=0
# Line 299  then Line 331  then
331   PBUILD="$(magename2pbuild ${i})"   PBUILD="$(magename2pbuild ${i})"
332   if [ -z "${list}" ]   if [ -z "${list}" ]
333   then   then
334   list="\t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"   list="\t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
335   else   else
336   list="${list}   list="${list}
337  \t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"  \t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
# Line 309  then Line 341  then
341   echo "done"   echo "done"
342   echo -e "${list}"   echo -e "${list}"
343   echo   echo
344    
345     if [[ ! -z ${INVALID_DEPS} ]]
346     then
347     echo -e "${COLRED}Invalid dependencies found:${COLDEFAULT}"
348     for i in ${INVALID_DEPS}
349     do
350     _dep="${i%%:*}"
351     _mage="${i##*:}"
352     echo -e "${COLRED} '${_dep}' -> '${_mage}'${COLDEFAULT}"
353     done
354     echo
355     fi
356    
357     if [[ ! -z ${NO_UPGRADE_CANDIDATE} ]]
358     then
359     echo -e "${COLRED}Currently no candidates found for:${COLDEFAULT}"
360     for i in ${NO_UPGRADE_CANDIDATE}
361     do
362     echo -e "${COLRED}    ${i}${COLDEFAULT}"
363     done
364     echo
365     echo -e "${COLRED}Please consider to uninstall all of them first,${COLDEFAULT}"
366     echo -e "${COLRED}because these packages does not exist in this distribution${COLDEFAULT}"
367     echo -e "${COLRED}anymore and there will be no further support for them.${COLDEFAULT}"
368     echo
369     fi
370  fi  fi
371    
372  ## return output from src/install deps  ## return output from src/install deps
373  [[ ${METHOD} = install ]] || \  [[ ${METHOD} = install ]] || \
374   [[ ${METHOD} = srcinstall ]] || \   [[ ${METHOD} = srcinstall ]] || \
375   [[ ${METHOD} = upgrade ]] || \   [[ ${METHOD} = upgrade ]] || \
376   [[ ${METHOD} = srcupgrade ]] && \   [[ ${METHOD} = srcupgrade ]] || \
377     [[ ${METHOD} = install-build-prerequisites ]] && \
378   echo "${ALLDEPS}"   echo "${ALLDEPS}"
   
 # delete ${BUILDDIR}/virtuals if exists as not needed anymore  
 #[ -d ${BUILDDIR}/virtuals ] && rm -rf ${BUILDDIR}/virtuals  

Legend:
Removed from v.677  
changed lines
  Added in v.2276