--- trunk/mage/usr/lib/mage/depwalker.sh 2014/01/06 12:35:42 2359 +++ branches/mage-next/src/depwalker.in 2014/03/05 08:16:25 2626 @@ -2,13 +2,6 @@ # $Id$ # dependeny walker -# default die function -die() -{ - echo ${COLRED}"$@"${COLDEFAULT} - exit 1 -} - decho() { if [[ ${DEBUG} = 1 ]] @@ -17,17 +10,12 @@ fi } -# 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" +# first of all include common functions +source ${MLIBDIR}/common.functions.sh || exit 1 +source @@SYSCONFDIR@@/mage.rc.global || die "@@SYSCONFDIR@@/mage.rc.global missing" +source ${MAGERC} || die "Your ${MAGERC} is missing. Aborting." +source ${MLIBDIR}/mage4.functions.sh || die "mage functions missing" +source ${MLIBDIR}/smage2.functions.sh || die "smage functions missing" usage() { @@ -45,6 +33,7 @@ echo " install-build-prerequisites," echo " pretend-build-prerequisites" echo " -d --debug enable debug mode" + echo " -s --smage use a smage to calculate dependencies" echo echo "method, category, name, version and build must be given !" echo @@ -64,16 +53,20 @@ --pbuild|-b) shift; PBUILD="$1" ;; --method|-m) shift; METHOD="$1" ;; --debug|-d) shift; DEBUG=1 ;; + --smage|-s) shift; SMAGEFILE="$1"; SILENT=1; FVERBOSE=off ;; --help|-h) usage ;; esac shift done # sanity checks; abort if not given -[ -z "${PCAT}" ] && usage -[ -z "${PNAME}" ] && usage -[ -z "${PVER}" ] && usage -[ -z "${PBUILD}" ] && usage +if [[ -z ${SMAGEFILE} ]] +then + [ -z "${PCAT}" ] && usage + [ -z "${PNAME}" ] && usage + [ -z "${PVER}" ] && usage + [ -z "${PBUILD}" ] && usage +fi [ -z "${METHOD}" ] && usage # check needed global vars @@ -83,6 +76,15 @@ # other needed vars ALLDEPS="" +if [[ -n ${SMAGEFILE} ]] +then + if [[ -e ${SMAGEFILE} ]] + then + smagesource "${SMAGEFILE}" + else + die "Smage file '${SMAGEFILE}' does not exist!" + fi +fi MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.mage" # much faster than fgrep @@ -294,16 +296,19 @@ ALLDEPS="${ALLDEPS} ${MAGEFILE}" fi else - # debug info - decho "ignored package" - decho - fi + # debug info + decho "ignored package" + decho fi done else - LOOP_COUNTER=0 # get all dependencies of the package - depwalking ${MAGEFILE} + if [[ -n ${SMAGEFILE} ]] + then + depwalking "${SMAGEFILE}" + else + depwalking "${MAGEFILE}" + fi fi if [[ ${METHOD} != install-build-prerequisites ]] &&