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 2221 by niro, Wed Oct 16 07:40:02 2013 UTC branches/mage-next/src/depwalker.in revision 2626 by niro, Wed Mar 5 08:16:25 2014 UTC
# Line 2  Line 2 
2  # $Id$  # $Id$
3  # dependeny walker  # dependeny walker
4    
5  # default die function  decho()
 die()  
6  {  {
7   echo ${COLRED}"$@"${COLDEFAULT}   if [[ ${DEBUG} = 1 ]]
8   exit 1   then
9     echo "DEBUG: $@" >&2
10     fi
11  }  }
12    
13  # include all needed files  # first of all include common functions
14  [ -f /etc/mage.rc.global ] &&  \  source ${MLIBDIR}/common.functions.sh || exit 1
15   source /etc/mage.rc.global || \  source @@SYSCONFDIR@@/mage.rc.global || die "@@SYSCONFDIR@@/mage.rc.global missing"
16   die "/etc/mage.rc.global missing"  source ${MAGERC} || die "Your ${MAGERC} is missing. Aborting."
17    source ${MLIBDIR}/mage4.functions.sh || die "mage functions missing"
18  [ -f ${MAGERC} ] && source ${MAGERC} || \  source ${MLIBDIR}/smage2.functions.sh || die "smage functions missing"
  die "Your ${MAGERC} is missing. Aborting."  
   
 [ -f ${MLIBDIR}/mage4.functions.sh ] && \  
  source ${MLIBDIR}/mage4.functions.sh || \  
  die "mage functions missing"  
19    
20  usage()  usage()
21  {  {
# Line 27  usage() Line 23  usage()
23   echo "Usage: $(basename $0) [command] [arg] ..."   echo "Usage: $(basename $0) [command] [arg] ..."
24   echo   echo
25   echo "  -h     --help          shows this help"   echo "  -h     --help          shows this help"
26   echo "  -c     --pcat          categorie of the package"   echo "  -c     --pcat          category of the package"
27   echo "  -n     --pname         name of the package"   echo "  -n     --pname         name of the package"
28   echo "  -v     --pver          version number of the package"   echo "  -v     --pver          version number of the package"
29   echo "  -b     --pbuild        build number of the package"   echo "  -b     --pbuild        build number of the package"
30   echo "  -m     --method        which calc method should be used:"   echo "  -m     --method        which calc method should be used:"
31   echo "  -d     --debug         enable debug mode"   echo "                         install, srcinstall, pretend, srcpretend"
  echo "                         install, srcinstall, depend, srcdepend"  
32   echo "                         upgrade, srcupgrade,"   echo "                         upgrade, srcupgrade,"
33   echo "                         install-build-prerequisites, pretend-build-prerequisites"   echo "                         install-build-prerequisites,"
34     echo "                         pretend-build-prerequisites"
35     echo "  -d     --debug         enable debug mode"
36     echo "  -s     --smage         use a smage to calculate dependencies"
37   echo   echo
38   echo "method, name, version and build must be given !"   echo "method, category, name, version and build must be given !"
39   echo   echo
40   exit 1   exit 1
41  }  }
# Line 55  do Line 53  do
53   --pbuild|-b) shift; PBUILD="$1" ;;   --pbuild|-b) shift; PBUILD="$1" ;;
54   --method|-m) shift; METHOD="$1" ;;   --method|-m) shift; METHOD="$1" ;;
55   --debug|-d) shift; DEBUG=1 ;;   --debug|-d) shift; DEBUG=1 ;;
56     --smage|-s) shift; SMAGEFILE="$1"; SILENT=1; FVERBOSE=off ;;
57   --help|-h) usage ;;   --help|-h) usage ;;
58   esac   esac
59   shift   shift
60  done  done
61    
62  # sanity checks; abort if not given  # sanity checks; abort if not given
63  [ -z "${PCAT}" ] && usage  if [[ -z ${SMAGEFILE} ]]
64  [ -z "${PNAME}" ] && usage  then
65  [ -z "${PVER}" ] && usage   [ -z "${PCAT}" ] && usage
66  [ -z "${PBUILD}" ] && usage   [ -z "${PNAME}" ] && usage
67     [ -z "${PVER}" ] && usage
68     [ -z "${PBUILD}" ] && usage
69    fi
70  [ -z "${METHOD}" ] && usage  [ -z "${METHOD}" ] && usage
71    
72  # check needed global vars  # check needed global vars
# Line 74  done Line 76  done
76    
77  # other needed vars  # other needed vars
78  ALLDEPS=""  ALLDEPS=""
79    if [[ -n ${SMAGEFILE} ]]
80    then
81     if [[ -e ${SMAGEFILE} ]]
82     then
83     smagesource "${SMAGEFILE}"
84     else
85     die "Smage file '${SMAGEFILE}' does not exist!"
86     fi
87    fi
88  MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage"  MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage"
89    
90  # much faster than fgrep  # much faster than fgrep
# Line 126  depwalking() Line 137  depwalking()
137    
138   DFILE="$1"   DFILE="$1"
139    
140     # debug info
141     decho "depwalking magefile '${DFILE}'"
142     decho
143    
144   source ${DFILE}   source ${DFILE}
145    
146   # forced nodeps   # forced nodeps
# Line 138  depwalking() Line 153  depwalking()
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 ]] || \   if [[ ${METHOD} = srcinstall ]] ||
157   [[ ${METHOD} = srcpretend ]] || \   [[ ${METHOD} = srcpretend ]] ||
158   [[ ${METHOD} = srcupgrade ]] || \   [[ ${METHOD} = srcupgrade ]] ||
159   [[ ${METHOD} = srcuppretend ]]   [[ ${METHOD} = srcuppretend ]] ||
160     [[ ${METHOD} = install-build-prerequisites ]] ||
161     [[ ${METHOD} = pretend-build-prerequisites ]]
162   then   then
163   # only if SDEPEND is not zero   # only if SDEPEND is not zero
164   if [ -n "${SDEPEND}" ]   if [ -n "${SDEPEND}" ]
# Line 157  depwalking() Line 174  depwalking()
174   fi   fi
175   fi   fi
176    
  if [[ ${METHOD} = install-build-prerequisites ]] || \  
  [[ ${METHOD} = pretend-build-prerequisites ]]  
  then  
  # only one time  
  if [[ ${LOOP_COUNTER} -lt 1 ]]  
  then  
  # only if SDEPEND is not zero  
  if [ -n "${SDEPEND}" ]  
  then  
  # crlf is substantly needed !!  
  if [ -n "${MY_DEPEND}" ]  
  then  
  MY_DEPEND="${MY_DEPEND}  
  ${SDEPEND}"  
  else  
  MY_DEPEND="${SDEPEND}"  
  fi  
  fi  
  fi  
  LOOP_COUNTER=${LOOP_COUNTER}+1  
  fi  
   
177   unset DEPEND   unset DEPEND
178   unset SDEPEND   unset SDEPEND
179    
180   if [ -z "${MY_DEPEND}" ]   if [ -z "${MY_DEPEND}" ]
181   then   then
182     decho "MY_DEPEND is empty; deps of '${DFILE}' ignored"
183   return 1   return 1
184   fi   fi
185    
186   while read SYM DEPNAME   while read SYM DEPNAME
187   do   do
188   if [[ ${DEBUG} = 1 ]]   # debug info
189   then   decho "DEPNAME='${DEPNAME}'"
  echo "DEBUG: DEPNAME='${DEPNAME}'" >&2  
  fi  
190    
191   # exclude empty depnames   # exclude empty depnames
192   [[ -z ${DEPNAME} ]] && continue   [[ -z ${DEPNAME} ]] && continue
# Line 234  depwalking() Line 228  depwalking()
228   then   then
229   depwalking ${HIGHEST_DEPFILE}   depwalking ${HIGHEST_DEPFILE}
230   ALLDEPS="${ALLDEPS} ${HIGHEST_DEPFILE}"   ALLDEPS="${ALLDEPS} ${HIGHEST_DEPFILE}"
231     decho "added '${HIGHEST_DEPFILE}' to ALLDEPS"
232   fi   fi
233   fi   fi
234   done << EOF   done << EOF
# Line 264  then Line 259  then
259   # get the highest mage file from mage-db   # get the highest mage file from mage-db
260   MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})"   MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})"
261    
262     # debug info
263     decho "dep='${dep}'"
264     decho "PCAT='${PCAT}'"
265     decho "PNAME='${PNAME}'"
266     decho "MAGEFILE='${MAGEFILE}'"
267    
268   # if no install candidate was found, record this   # if no install candidate was found, record this
269   # and process with the next one   # and process with the next one
270   if [[ -z ${MAGEFILE} ]]   if [[ -z ${MAGEFILE} ]]
271   then   then
272   NO_UPGRADE_CANDIDATE="${NO_UPGRADE_CANDIDATE} ${PCAT}/${PNAME}"   NO_UPGRADE_CANDIDATE="${NO_UPGRADE_CANDIDATE} ${PCAT}/${PNAME}"
273     decho "added to NO_UPGRADE_CANDIDATE"
274   continue   continue
275   fi   fi
276    
# Line 276  then Line 278  then
278   PVER="$(magename2pver ${MAGEFILE})"   PVER="$(magename2pver ${MAGEFILE})"
279   PBUILD="$(magename2pbuild ${MAGEFILE})"   PBUILD="$(magename2pbuild ${MAGEFILE})"
280    
281     # debug info
282     decho "PVER='${PVER}'"
283     decho "PBUILD='${PBUILD}'"
284    
285   # do not walk files which are installed   # do not walk files which are installed
286   if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]   if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ]
287   then   then
288   # get dependencies the package   # get dependencies the package
289   depwalking ${MAGEFILE}   depwalking ${MAGEFILE}
290    
291     # now add the package itself to the dependencies
292     # (if not exists already)
293     if checklist_alldeps "${MAGEFILE}"
294     then
295     decho "added '${MAGEFILE}' to ALLDEPS"
296     ALLDEPS="${ALLDEPS} ${MAGEFILE}"
297     fi
298     else
299     # debug info
300     decho "ignored package"
301     decho
302   fi   fi
303   done   done
304  else  else
  LOOP_COUNTER=0  
305   # get all dependencies of the package   # get all dependencies of the package
306   depwalking ${MAGEFILE}   if [[ -n ${SMAGEFILE} ]]
307     then
308     depwalking "${SMAGEFILE}"
309     else
310     depwalking "${MAGEFILE}"
311     fi
312  fi  fi
313    
314  if [[ ${METHOD} != install-build-prerequisites ]] &&  if [[ ${METHOD} != install-build-prerequisites ]] &&
315   [[ ${METHOD} != pretend-build-prerequisites ]]   [[ ${METHOD} != pretend-build-prerequisites ]] &&
316     [[ ${METHOD} != upgrade ]] &&
317     [[ ${METHOD} != uppretend ]] &&
318     [[ ${METHOD} != srcupgrade ]] &&
319     [[ ${METHOD} != srcuppretend ]]
320  then  then
321   # now add the package itself to the dependencies   # now add the package itself to the dependencies
322   # (if not exists already)   # (if not exists already)
323   if checklist_alldeps "${MAGEFILE}"   if checklist_alldeps "${MAGEFILE}"
324   then   then
325     decho "added '${MAGEFILE}' to ALLDEPS"
326   ALLDEPS="${ALLDEPS} ${MAGEFILE}"   ALLDEPS="${ALLDEPS} ${MAGEFILE}"
327   fi   fi
328  fi  fi

Legend:
Removed from v.2221  
changed lines
  Added in v.2626