Magellan Linux

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

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

trunk/mage/usr/lib/mage/depwalker.sh revision 2286 by niro, Mon Dec 2 10:12:35 2013 UTC branches/mage-next/src/depwalker.in revision 2839 by niro, Wed Oct 22 12:27:17 2014 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  # $Id$  # $Id$
3  # dependeny walker  # dependency walker
4    
5  # default die function  # set default variables
6  die()  : ${MAGERC="@@SYSCONFDIR@@/mage.rc"}
7  {  : ${MLIBDIR="@@MAGELIBDIR@@"}
8   echo ${COLRED}"$@"${COLDEFAULT}  
9   exit 1  # first of all include common functions
10  }  source ${MLIBDIR}/common.functions.sh || exit 1
11    source @@SYSCONFDIR@@/mage.rc.global || die "@@SYSCONFDIR@@/mage.rc.global missing"
12    source ${MAGERC} || die "Your ${MAGERC} is missing. Aborting."
13    source ${MLIBDIR}/mage4.functions.sh || die "mage functions missing"
14    source ${MLIBDIR}/smage2.functions.sh || die "smage functions missing"
15    
16  decho()  decho()
17  {  {
# Line 17  decho() Line 21  decho()
21   fi   fi
22  }  }
23    
 # include all needed files  
 [ -f /etc/mage.rc.global ] &&  \  
  source /etc/mage.rc.global || \  
  die "/etc/mage.rc.global missing"  
   
 [ -f ${MAGERC} ] && source ${MAGERC} || \  
  die "Your ${MAGERC} is missing. Aborting."  
   
 [ -f ${MLIBDIR}/mage4.functions.sh ] && \  
  source ${MLIBDIR}/mage4.functions.sh || \  
  die "mage functions missing"  
   
24  usage()  usage()
25  {  {
26   echo   echo
# Line 40  usage() Line 32  usage()
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, pretend, srcpretend"
36   echo "                         upgrade, srcupgrade,"   echo "                         upgrade, srcupgrade,"
37   echo "                         install-build-prerequisites,"   echo "                         install-build-prerequisites,"
38   echo "                         pretend-build-prerequisites"   echo "                         pretend-build-prerequisites"
39   echo "  -d     --debug         enable debug mode"   echo "  -d     --debug         enable debug mode"
40     echo "  -s     --smage         use a smage to calculate dependencies"
41   echo   echo
42   echo "method, category, name, version and build must be given !"   echo "method, category, name, version and build must be given !"
43   echo   echo
44   exit 1   exit 1
45  }  }
46    
47  # always default debug=0  # set some sane defaults
48  DEBUG=0  DEBUG=0
49    SMAGE_DEPEND=0
50    
51  # very basic getops  # very basic getops
52  for i in $*  for i in $*
# Line 64  do Line 58  do
58   --pbuild|-b) shift; PBUILD="$1" ;;   --pbuild|-b) shift; PBUILD="$1" ;;
59   --method|-m) shift; METHOD="$1" ;;   --method|-m) shift; METHOD="$1" ;;
60   --debug|-d) shift; DEBUG=1 ;;   --debug|-d) shift; DEBUG=1 ;;
61     --smage|-s) shift; SMAGEFILE="$1"; SMAGE_DEPEND=1; SILENT=1; FVERBOSE=off ;;
62   --help|-h) usage ;;   --help|-h) usage ;;
63   esac   esac
64   shift   shift
65  done  done
66    
67  # sanity checks; abort if not given  # sanity checks; abort if not given
68  [ -z "${PCAT}" ] && usage  if [[ -z ${SMAGEFILE} ]]
69  [ -z "${PNAME}" ] && usage  then
70  [ -z "${PVER}" ] && usage   [ -z "${PCAT}" ] && usage
71  [ -z "${PBUILD}" ] && usage   [ -z "${PNAME}" ] && usage
72     [ -z "${PVER}" ] && usage
73     [ -z "${PBUILD}" ] && usage
74    fi
75  [ -z "${METHOD}" ] && usage  [ -z "${METHOD}" ] && usage
76    
77  # check needed global vars  # check needed global vars
# Line 81  done Line 79  done
79  [ -z "${INSTALLDB}" ] && die "\$INSTALLDB not set."  [ -z "${INSTALLDB}" ] && die "\$INSTALLDB not set."
80  [ -z "${BUILDDIR}" ] && die "\$BUILDDIR not set."  [ -z "${BUILDDIR}" ] && die "\$BUILDDIR not set."
81    
82    # load mage-features to support them with smagesource()
83    load_mage_features
84    
85  # other needed vars  # other needed vars
86  ALLDEPS=""  ALLDEPS=""
87    if [[ -n ${SMAGEFILE} ]]
88    then
89     if [[ -e ${SMAGEFILE} ]]
90     then
91     smagesource "${SMAGEFILE}"
92     else
93     die "Smage file '${SMAGEFILE}' does not exist!"
94     fi
95    fi
96  MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage"  MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage"
97    
98  # much faster than fgrep  # much faster than fgrep
# Line 197  depwalking() Line 207  depwalking()
207    
208   # mark depfile as processed to prevent double runs -without version   # mark depfile as processed to prevent double runs -without version
209   # but do not add any virtuals to PROCESSEDDEPS or their resolved   # but do not add any virtuals to PROCESSEDDEPS or their resolved
210   # pkgnames will be ignored and they are missing on the dependecy-list   # pkgnames will be ignored and they are missing on the dependency-list
211   if [[ ${DEPNAME/virtual\//} = ${DEPNAME} ]]   if [[ ${DEPNAME/virtual\//} = ${DEPNAME} ]]
212   then   then
213   PROCESSEDDEPS="${PROCESSEDDEPS} ${DEPNAME%-*}"   PROCESSEDDEPS="${PROCESSEDDEPS} ${DEPNAME%-*}"
# Line 224  depwalking() Line 234  depwalking()
234   ### check if the dependency is already installed ###   ### check if the dependency is already installed ###
235   if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]   if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]
236   then   then
237     # but first get all deps of highest_depfile to catch all dependencies of it
238   depwalking ${HIGHEST_DEPFILE}   depwalking ${HIGHEST_DEPFILE}
239   ALLDEPS="${ALLDEPS} ${HIGHEST_DEPFILE}"   ALLDEPS="${ALLDEPS} ${HIGHEST_DEPFILE}"
240   decho "added '${HIGHEST_DEPFILE}' to ALLDEPS"   decho "added '${HIGHEST_DEPFILE}' to ALLDEPS"
# Line 294  then Line 305  then
305   ALLDEPS="${ALLDEPS} ${MAGEFILE}"   ALLDEPS="${ALLDEPS} ${MAGEFILE}"
306   fi   fi
307   else   else
308   # debug info   # debug info
309   decho "ignored package"   decho "ignored package"
310   decho   decho
  fi  
311   fi   fi
312   done   done
313  else  else
  LOOP_COUNTER=0  
314   # get all dependencies of the package   # get all dependencies of the package
315   depwalking ${MAGEFILE}   if [[ -n ${SMAGEFILE} ]]
316     then
317     depwalking "${SMAGEFILE}"
318     else
319     depwalking "${MAGEFILE}"
320     fi
321  fi  fi
322    
323  if [[ ${METHOD} != install-build-prerequisites ]] &&  if [[ ${METHOD} != install-build-prerequisites ]] &&

Legend:
Removed from v.2286  
changed lines
  Added in v.2839