--- trunk/mage/usr/lib/mage/depwalker.sh 2005/09/10 13:34:56 235 +++ trunk/mage/usr/lib/mage/depwalker.sh 2008/10/05 10:33:36 778 @@ -1,7 +1,7 @@ #!/bin/bash #depwalker -# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/depwalker.sh,v 1.3 2005-09-10 13:34:56 niro Exp $ +# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/depwalker.sh,v 1.11 2008-10-05 10:33:36 niro Exp $ # default die function die() @@ -15,8 +15,8 @@ source /etc/mage.rc.global || \ die "/etc/mage.rc.global missing" -[ -f /etc/mage.rc ] && source /etc/mage.rc || \ - die "Your /etc/mage.rc is missing. Aborting." +[ -f ${MAGERC} ] && source ${MAGERC} || \ + die "Your ${MAGERC} is missing. Aborting." [ -f ${MLIBDIR}/mage4.functions.sh ] && \ source ${MLIBDIR}/mage4.functions.sh || \ @@ -57,7 +57,7 @@ echo " install, srcinstall, depend, srcdepend" echo " upgrade, srcupgrade" echo - echo "method,name, version and build must be given !" + echo "method, name, version and build must be given !" echo exit 1 } @@ -92,6 +92,33 @@ ALLDEPS="" MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage" +# much faster than fgrep +checklist_alldeps() +{ + local i + local item="$1" + + for i in ${ALLDEPS} + do + [[ ${i} = ${item} ]] && return 1 + done + + return 0 +} + +checklist_processeddeps() +{ + local i + local item="$1" + + for i in ${PROCESSEDDEPS} + do + [[ ${i} = ${item} ]] && return 1 + done + + return 0 +} + ##################### ## rumwandern /path/to/mage/file/.mage rumwandern() @@ -110,10 +137,20 @@ local INSTALL_VIRTUAL local PNAME local PCAT + local PVER + local PBUILD DFILE="$1" source ${DFILE} + + # forced nodeps + if [[ ${NODEPS} = true ]] + then + DEPEND="" + SDEPEND="" + fi + MY_DEPEND="${DEPEND}" # for srcinstall & srcdepend only; SDEPEND also needed @@ -146,6 +183,23 @@ while read SYM DEPNAME do + # exclude empty depnames + [[ -z ${DEPNAME} ]] && continue + + # exclude all already processed deps -without version + if ! checklist_processeddeps "${DEPNAME%-*}" + then + continue + fi + + # mark depfile as processed to prevent double runs -without version + # but do not add any virtuals to PROCESSEDDEPS or their resolved + # pkgnames will be ignored and they are missing on the dependecy-list + if [[ ${DEPNAME/virtual\//} = ${DEPNAME} ]] + then + PROCESSEDDEPS="${PROCESSEDDEPS} ${DEPNAME%-*}" + fi + HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}") PCAT="$(magename2pcat ${HIGHEST_DEPFILE})" @@ -154,7 +208,10 @@ PBUILD="$(magename2pbuild ${HIGHEST_DEPFILE})" ## check ob schon in ALLDEPS enthalten dann mach weiter - if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ] + + # usage of fgrep is extremly slow and consumes a lot of cpu power + #if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ] + if checklist_alldeps "${HIGHEST_DEPFILE}" then ### check ob DFILE schon installiert ist ### if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] @@ -191,13 +248,36 @@ do PCAT="$(magename2pcat ${dep} installdb)" PNAME="$(magename2pname ${dep})" - PVER="$(magename2pver ${dep})" - PBUILD="$(magename2pbuild ${dep})" - # fake a mage file - MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage" + # get the highest mage file from mage-db + MAGEFILE="$(get_highest_magefile ${PCAT} ${PNAME})" + + # if no install candidate was found, record this + # and process with the next one + if [[ -z ${MAGEFILE} ]] + then + NO_UPGRADE_CANDIDATE="${NO_UPGRADE_CANDIDATE} ${PCAT}/${PNAME}" + continue + fi + + # now get the pver&pbuild from the new file + PVER="$(magename2pver ${MAGEFILE})" + PBUILD="$(magename2pbuild ${MAGEFILE})" - rumwandern ${MAGEFILE} + # do not wander files which are installed + if [ ! -d ${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] + then + # get dependencies the package + rumwandern ${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 + fi done else # get dependencies the package @@ -245,6 +325,20 @@ echo "done" echo -e "${list}" echo + + if [[ ! -z ${NO_UPGRADE_CANDIDATE} ]] + then + echo -e "${COLRED}Currently no candidates found for:${COLDEFAULT}" + for i in ${NO_UPGRADE_CANDIDATE} + do + echo -e "${COLRED} ${i}${COLDEFAULT}" + done + echo + echo -e "${COLRED}Please consider to uninstall all of them first,${COLDEFAULT}" + echo -e "${COLRED}because these packages does not exist in this distribution${COLDEFAULT}" + echo -e "${COLRED}and there will be no further updates or support for them.${COLDEFAULT}" + echo + fi fi ## return output from src/install deps