--- trunk/mage/usr/lib/mage/smage2.sh 2005/02/16 01:00:39 63 +++ trunk/mage/usr/lib/mage/smage2.sh 2005/02/16 17:50:54 66 @@ -4,14 +4,14 @@ # needs pkgbuild_dir (mage) # SMAGE2 -# version: 0.3.6-r14 +# version: 0.3.6-r15 #01.10.2004 # added ccache support # added distcc support ## setup ## -SMAGEVERSION=0.3.6-r14 +SMAGEVERSION=0.3.6-r15 PKGSUFFIX="mpk" SMAGENAME="$1" SMAGESUFFIX="smage2" @@ -103,7 +103,10 @@ [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0 local EOA=${#SRC_URI[*]} - local MY_SRC_URI + local my_SRC_URI + local my_SRC_URI_DEST + local my_SRC_URI_MIRROR + local my_SOURCEDIR local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" local FETCHING local i mirror @@ -113,7 +116,7 @@ [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} # check if FETCHING is needed - ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} > /dev/null ) + ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null ) if [[ $? == 0 ]] then # md5's ok, not fetching needed @@ -124,27 +127,38 @@ for ((i=0; i < EOA; i++)) do - # get MD5 sum from database + # url to file + my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" + + # subdir in sources dir; the my_SRCI_URI file goes to there + my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" + + # if my_src_uri_dest is not equal my_src_uri; than an other dir is used + if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] + then + my_SOURCEDIR="${SOURCEDIR}/${PNAME}/${my_SRC_URI_DEST}" + else + my_SOURCEDIR="${SOURCEDIR}/${PNAME}" + fi - # if an mirrored file than replace first the mirror uri - if [ -n "$(echo ${SRC_URI[${i}]} | grep 'mirror://')" ] + if [ -n "$(echo ${my_SRC_URI} | grep 'mirror://')" ] then for mirror in ${MIRRORS} do - MY_SRC_URI="$(echo ${SRC_URI[${i}]} | sed "s|mirror:/|${mirror}/sources|g")" + my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")" #echo "DEBUG: ${MY_SRC_URI}" if [[ ${FETCHING} == true ]] then - echo "==> fetching ${MY_SRC_URI}" + echo "==> fetching ${my_SRC_URI_MIRROR}" wget \ --passive-ftp \ --tries 3 \ --continue \ --progress bar \ - --directory-prefix="${SOURCEDIR}/${PNAME}" \ - "${MY_SRC_URI}" + --directory-prefix="${my_SOURCEDIR}" \ + "${my_SRC_URI_MIRROR}" if [ "$?" == "0" ] then break @@ -157,14 +171,14 @@ #echo "DEBUG: ${SRC_URI[${i}]}" if [[ ${FETCHING} == true ]] then - echo "==> fetching ${SRC_URI[${i}]}" + echo "==> fetching ${my_SRC_URI}" wget \ --passive-ftp \ --tries 3 \ --continue \ --progress bar \ - --directory-prefix="${SOURCEDIR}/${PNAME}" \ - "${MY_SRC_URI}" + --directory-prefix="${my_SOURCEDIR}" \ + "${my_SRC_URI}" if [ "$?" == "0" ] then break @@ -173,7 +187,12 @@ fi fi fi - + + # unset them to be shure + unset my_SRC_URI + unset my_SRC_URI_DEST + unset my_SRC_URI_MIRROR + unset my_SOURCEDIR done # recheck md5 sums @@ -387,13 +406,13 @@ then if [ $# -ge 3 ] then - # overridable sourcedir - CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" - SMAGENAME="$2" MD5DIR="$3" source ${SMAGENAME} || die "download source failed" + # overridable sourcedir; must be declared after source of the smage2 + CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" + [ -z "${SRC_URI}" ] && die "Nothing declared to calculate." # end of array @@ -407,7 +426,20 @@ for ((i=0; i < EOA; i++)) do - MY_SRC_FILE="$(basename ${SRC_URI[${i}]})" + # url to file + my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" + + # subdir in sources dir; the my_SRCI_URI file goes to there + my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" + + # if my_src_uri_dest is not equal my_src_uri; than an other dir is used + if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] + then + MY_SRC_FILE="${my_SRC_URI_DEST}/$(basename ${SRC_URI[${i}]})" + else + MY_SRC_FILE="$(basename ${SRC_URI[${i}]})" + fi + if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ] then echo "calculating $(basename ${MY_SRC_FILE}) ..." @@ -415,6 +447,12 @@ else echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}." fi + + # unset them to be shure + unset my_SRC_URI + unset my_SRC_URI_DEST + unset my_SRC_URI_MIRROR + unset my_SOURCEDIR done echo