--- trunk/mage/usr/lib/mage/mage4.functions.sh 2013/10/16 07:46:58 2224 +++ trunk/mage/usr/lib/mage/mage4.functions.sh 2014/01/06 12:53:31 2364 @@ -1,6 +1,6 @@ #!/bin/bash # Magellan Linux Installer Functions (mage.functions.sh) -# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/mage4.functions.sh,v 1.38 2008-10-05 10:32:24 niro Exp $ +# $Id$ COLRED="\033[1;6m\033[31m" COLGREEN="\033[1;6m\033[32m" @@ -46,6 +46,8 @@ local method local cmd local retval + local sum + local dest # very basic getops for i in $* @@ -72,9 +74,24 @@ if [[ -d ${rundir} ]] then pushd ${rundir} &> /dev/null - # be verbose here - ${cmd} -c ${file} #&> /dev/null - retval="$?" + + # all file must be non-zero + retval=0 + while read sum dest + do + if [ ! -s ${dest} ] + then + echo "${dest}: file is empty ;(" + retval=127 + fi + done < ${file} + if [[ ${retval} != 127 ]] + then + # be verbose here + ${cmd} -c ${file} #&> /dev/null + retval="$?" + fi + popd &> /dev/null else retval=1 @@ -105,11 +122,13 @@ unpack_package() { local magefile="$1" - local pkg + local pkgname + local pkgfile local pkgtype local tar_opts - pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" + pkgname="$(get_value_from_magefile PKGNAME ${magefile})" + pkgfile="${pkgname}.${PKGSUFFIX}" pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" xtitle "[ Unpacking ${pkg} ]" @@ -118,7 +137,7 @@ if [[ ${pkgtype} = virtual ]] then echo -ne " ${COLBLUE}---${COLDEFAULT}" - echo " !unpack virtual ${pkg/.${PKGSUFFIX}/} ... " + echo " !unpack virtual ${pkgname} ... " continue fi @@ -126,7 +145,7 @@ if [[ ${pkgtype} = sources ]] then echo -ne " ${COLBLUE}---${COLDEFAULT}" - echo " !unpack sources ${pkg/.${PKGSUFFIX}/} ... " + echo " !unpack sources ${pkgname} ... " continue fi @@ -138,8 +157,8 @@ tar_opts="xjmf" fi - echo -e " ${COLBLUE}***${COLDEFAULT} unpacking ${pkg} ... " - tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" + echo -e " ${COLBLUE}***${COLDEFAULT} unpacking ${pkgfile} ... " + tar ${tar_opts} ${PKGDIR}/${pkgfile} -C ${BUILDDIR} || die "Unpacking package ${pkgfile}" } unpack_packages() @@ -1384,7 +1403,7 @@ output+="${mirror}${addon}/${uri/${scheme}/}" done else - output="${uri}" + output="${uri}" fi echo "${output}" @@ -1451,7 +1470,10 @@ { local i local list="$@" - local pkg + local pkgname + local pkgfile + local pcat + local pname local mirr local magefile local md5file @@ -1459,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}." @@ -1473,17 +1496,22 @@ for magefile in ${list} do - pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" + pkgname="$(get_value_from_magefile PKGNAME ${magefile})" + 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 ${pkg} ]" + xtitle "[ (${count_current}/${count_total}) Fetching ${pkgfile} ]" # abort on virtual pkg if [[ ${pkgtype} = virtual ]] then echo -ne " ${COLBLUE}---${COLDEFAULT}" - echo " !fetch virtual (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... " + echo " !fetch virtual (${count_current}/${count_total}): ${pkgname} ... " continue fi @@ -1491,24 +1519,39 @@ if [[ ${pkgtype} = sources ]] then echo -ne " ${COLBLUE}---${COLDEFAULT}" - echo " !fetch sources (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... " + echo " !fetch sources (${count_current}/${count_total}): ${pkgname} ... " continue fi - # abort if already exist - if [ -f ${PKGDIR}/${pkg} ] + # 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}): ${pkg} ... " + 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}): ${pkg} ... " - mdownload --uri "package://${pkg}" --dir "${PKGDIR}" || die "Could not download ${pkg}" - if [ ! -f ${PKGDIR}/${pkg} ] + # sanity check, not really needed but to be sure + if [ ! -f ${PKGDIR}/${pkgfile} ] then - die "Package '${pkg}' after download not found in '${PKGDIR}'" + die "Package '${pkgfile}' after download not found in '${PKGDIR}'" fi done @@ -2213,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 } @@ -2786,7 +2829,7 @@ pname=$(magename2pname ${magefile}) pkgname="$(get_value_from_magefile PKGNAME ${magefile})" md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5" - pkgfile="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}" + pkgfile="${pkgname}.${PKGSUFFIX}" pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})" (( count_current++ )) @@ -2796,7 +2839,7 @@ if [[ ${pkgtype} = virtual ]] then echo -ne " ${COLBLUE}---${COLDEFAULT}" - echo " !md5sum virtual (${count_current}/${count_total}): ${pkgfile/.${PKGSUFFIX}/} ... " + echo " !md5sum virtual (${count_current}/${count_total}): ${pkgname} ... " continue fi @@ -2804,7 +2847,7 @@ if [[ ${pkgtype} = sources ]] then echo -ne " ${COLBLUE}---${COLDEFAULT}" - echo " !md5sum sources (${count_current}/${count_total}): ${pkgfile/.${PKGSUFFIX}/} ... " + echo " !md5sum sources (${count_current}/${count_total}): ${pkgname} ... " continue fi @@ -2852,7 +2895,7 @@ pbuild=$(magename2pbuild ${pkg}) can_pcat="${pcat}" can_pname="${pname}" - + if [ -z "${can_ver_list}" ] then can_ver_list=" ${pver}-${pbuild}"