#!/bin/bash #DEPEND WANDERER MAGEFILE=$2 ALLDEPS="" source /etc/mage.rc source /etc/init.d/functions #check_stable_package /path/to/foo.mage # returns 0=stable 1=unstable check_stable_package(){ #be sure no previous $STATES exists unset STATE source $1 if [ "$?" == "1" ] then TODESVAR=1 fi if [ "${STATE}" != "stable" ] then return 1 fi #unset the sourced varibales; #we'll got bad problems later on if we don't do this unset PKGNAME unset STATE unset DESCRIPTION unset HOMEPAGE unset DEPEND unset preinstall unset postinstall return 0 } ##################### ## rumwandern /path/to/mage/file/.mage rumwandern(){ unset DEPEND unset MY_DEPEND local DFILE local SYM local DEPNAME local HIGHEST_DEPFILE local MY_DEPEND DFILE=$1 source ${DFILE} MY_DEPEND="${DEPEND}" unset DEPEND if [ -z "${MY_DEPEND}" ] then return 1 fi while read SYM DEPNAME do CAT=$(echo ${DEPNAME}|cut -d / -f1) PNAME=$(echo ${DEPNAME%-*}|cut -d / -f2) #echo "DEBUG CAT=${CAT}" #echo "DEBUG PNAME=${PNAME}" #echo "DEBUG DEPNAME=${DEPNAME}" for i in ${MAGEDIR}/${CAT}/${PNAME}/*.mage do #we exclude subdirs (for stuff like a md5sum dir) if [ ! -d ${i} ] then check_stable_package ${i} if [ "$?" == "0" ] then HIGHEST_DEPFILE=${i} fi #debug if [ "${TODESVAR}" == 1 ] then echo -e ${COLRED}"${DFILE}"${COLDEFAULT} unset TODESVAR fi fi done ##check ob schon in ALLDEPS enthalten dann mach weiter local x x=$(echo ${ALLDEPS}|fgrep "${HIGHEST_DEPFILE}") if [ -z "${x}" ] then ### check ob DFILE schon installiert ist ### if [ ! -d ${INSTALLDB}/$(basename ${HIGHEST_DEPFILE} .mage) ] then rumwandern ${HIGHEST_DEPFILE} ALLDEPS="${ALLDEPS} ${HIGHEST_DEPFILE}" fi fi done << EOF $MY_DEPEND EOF return 0 } ### check ob MAGEFILE schon installiert ist if [ -d ${INSTALLDB}/$(basename ${MAGEFILE} .mage) ] then exit 3 fi if [ $1 == pretend ] then echo -en "Calculating Dependencies ... " fi rumwandern ${MAGEFILE} if [ $1 == pretend ] then echo "done" fi ##anhängen des zu installierenden files selber ALLDEPS="${ALLDEPS} ${MAGEFILE}" ##ausgabe pretend if [ $1 == pretend ] then ####test ausgabe declare -i x=0 for i in ${ALLDEPS} do x=$x+1 echo -en "\t${COLBLUE}[" if [ ${x} -le 9 ] then echo -en "0" fi echo -e "${x}] ${COLGREEN}$(basename ${i} .mage)"${COLDEFAULT} done fi ##return ausgabe install if [ $1 == install ] then echo ${ALLDEPS} fi