--- trunk/mage/usr/lib/mage/mage4.functions.sh 2013/10/25 07:28:23 2271 +++ trunk/mage/usr/lib/mage/mage4.functions.sh 2014/01/06 12:53:31 2364 @@ -1472,6 +1472,8 @@ local list="$@" local pkgname local pkgfile + local pcat + local pname local mirr local magefile local md5file @@ -1479,6 +1481,7 @@ local count_current local count_total local wget_opts + local fetching [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." @@ -1497,6 +1500,10 @@ pkgfile="${pkgname}.${PKGSUFFIX}" pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" + pcat=$(magename2pcat ${magefile}) + pname=$(magename2pname ${magefile}) + md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5" + (( count_current++ )) xtitle "[ (${count_current}/${count_total}) Fetching ${pkgfile} ]" @@ -1516,17 +1523,32 @@ continue fi - # abort if already exist - if [ -f ${PKGDIR}/${pkgfile} ] + # check if FETCHING is required + if [ ! -f "${md5file}" ] + then + fetching=true + else + if mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 &> /dev/null + then + # md5's ok, no fetching required + fetching=false + else + fetching=true + fi + fi + + if [[ ${fetching} = false ]] then echo -ne " ${COLBLUE}***${COLDEFAULT}" echo " fetch complete (${count_current}/${count_total}): ${pkgfile} ... " continue + else + echo -ne " ${COLBLUE}***${COLDEFAULT}" + echo -e " fetching (${count_current}/${count_total}): ${pkgfile} ... " + mdownload --uri "package://${pkgfile}" --dir "${PKGDIR}" || die "Could not download ${pkgfile}" fi - echo -ne " ${COLBLUE}***${COLDEFAULT}" - echo -e " fetching (${count_current}/${count_total}): ${pkgfile} ... " - mdownload --uri "package://${pkgfile}" --dir "${PKGDIR}" || die "Could not download ${pkgfile}" + # sanity check, not really needed but to be sure if [ ! -f ${PKGDIR}/${pkgfile} ] then die "Package '${pkgfile}' after download not found in '${PKGDIR}'" @@ -2234,10 +2256,10 @@ then for i in $* do - echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" + [[ ${SILENT} = 1 ]] || echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" source ${SMAGESCRIPTSDIR}/include/${i}.sminc done - echo + [[ ${SILENT} = 1 ]] || echo fi }