--- trunk/mage/usr/lib/mage/depwalker.sh 2011/12/28 10:02:01 1563 +++ trunk/mage/usr/lib/mage/depwalker.sh 2013/10/16 07:40:02 2221 @@ -32,14 +32,19 @@ echo " -v --pver version number of the package" echo " -b --pbuild build number of the package" echo " -m --method which calc method should be used:" + echo " -d --debug enable debug mode" echo " install, srcinstall, depend, srcdepend" - echo " upgrade, srcupgrade" + echo " upgrade, srcupgrade," + echo " install-build-prerequisites, pretend-build-prerequisites" echo echo "method, name, version and build must be given !" echo exit 1 } +# always default debug=0 +DEBUG=0 + # very basic getops for i in $* do @@ -49,6 +54,7 @@ --pver|-v) shift; PVER="$1" ;; --pbuild|-b) shift; PBUILD="$1" ;; --method|-m) shift; METHOD="$1" ;; + --debug|-d) shift; DEBUG=1 ;; --help|-h) usage ;; esac shift @@ -151,6 +157,28 @@ fi fi + 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 + unset DEPEND unset SDEPEND @@ -161,6 +189,11 @@ while read SYM DEPNAME do + if [[ ${DEBUG} = 1 ]] + then + echo "DEBUG: DEPNAME='${DEPNAME}'" >&2 + fi + # exclude empty depnames [[ -z ${DEPNAME} ]] && continue @@ -179,6 +212,11 @@ fi HIGHEST_DEPFILE=$(dep2highest_magefile "${DEPNAME}") + if [[ -z ${HIGHEST_DEPFILE} ]] + then + INVALID_DEPS+=" ${DEPNAME}:${DFILE}" + continue + fi PCAT="$(magename2pcat ${HIGHEST_DEPFILE})" PNAME="$(magename2pname ${HIGHEST_DEPFILE})" @@ -191,7 +229,7 @@ #if [ -z "$(echo ${ALLDEPS} | fgrep "${HIGHEST_DEPFILE}")" ] if checklist_alldeps "${HIGHEST_DEPFILE}" then - ### check ob DFILE schon installiert ist ### + ### check if the dependency is already installed ### if [ ! -d ${MROOT}${INSTALLDB}/${PCAT}/${PNAME}-${PVER}-${PBUILD} ] then depwalking ${HIGHEST_DEPFILE} @@ -207,7 +245,8 @@ [[ ${METHOD} = pretend ]] || \ [[ ${METHOD} = srcpretend ]] || \ [[ ${METHOD} = uppretend ]] || \ - [[ ${METHOD} = srcuppretend ]] && \ + [[ ${METHOD} = srcuppretend ]] || \ + [[ ${METHOD} = pretend-build-prerequisites ]] && \ echo -n "Calculating dependencies ... " @@ -242,28 +281,30 @@ then # get dependencies the package 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 fi done else + LOOP_COUNTER=0 # get all dependencies of the package depwalking ${MAGEFILE} +fi +if [[ ${METHOD} != install-build-prerequisites ]] && + [[ ${METHOD} != pretend-build-prerequisites ]] +then # now add the package itself to the dependencies - ALLDEPS="${ALLDEPS} ${MAGEFILE}" + # (if not exists already) + if checklist_alldeps "${MAGEFILE}" + then + ALLDEPS="${ALLDEPS} ${MAGEFILE}" + fi fi [[ ${METHOD} = pretend ]] || \ [[ ${METHOD} = srcpretend ]] || \ [[ ${METHOD} = uppretend ]] || \ - [[ ${METHOD} = srcuppretend ]] && \ + [[ ${METHOD} = srcuppretend ]] || \ + [[ ${METHOD} = pretend-build-prerequisites ]] && \ echo "done" @@ -271,7 +312,8 @@ if [[ ${METHOD} = pretend ]] || \ [[ ${METHOD} = srcpretend ]] || \ [[ ${METHOD} = uppretend ]] || \ - [[ ${METHOD} = srcuppretend ]] + [[ ${METHOD} = srcuppretend ]] || \ + [[ ${METHOD} = pretend-build-prerequisites ]] then # this is a little bit faster declare -i x=0 @@ -288,7 +330,7 @@ PBUILD="$(magename2pbuild ${i})" if [ -z "${list}" ] then - list="\t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" + list="\t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" else list="${list} \t${COLBLUE}[${k}] ${COLGREEN}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}" @@ -299,6 +341,18 @@ echo -e "${list}" echo + if [[ ! -z ${INVALID_DEPS} ]] + then + echo -e "${COLRED}Invalid dependencies found:${COLDEFAULT}" + for i in ${INVALID_DEPS} + do + _dep="${i%%:*}" + _mage="${i##*:}" + echo -e "${COLRED} '${_dep}' -> '${_mage}'${COLDEFAULT}" + done + echo + fi + if [[ ! -z ${NO_UPGRADE_CANDIDATE} ]] then echo -e "${COLRED}Currently no candidates found for:${COLDEFAULT}" @@ -318,5 +372,6 @@ [[ ${METHOD} = install ]] || \ [[ ${METHOD} = srcinstall ]] || \ [[ ${METHOD} = upgrade ]] || \ - [[ ${METHOD} = srcupgrade ]] && \ + [[ ${METHOD} = srcupgrade ]] || \ + [[ ${METHOD} = install-build-prerequisites ]] && \ echo "${ALLDEPS}"