Magellan Linux

Diff of /trunk/mage/usr/lib/mage/mage4.functions.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2271 by niro, Fri Oct 25 07:28:23 2013 UTC revision 3040 by niro, Fri Jun 30 12:34:44 2017 UTC
# Line 71  mchecksum() Line 71  mchecksum()
71   *) die "mchecksum(): unknown method '${method}'" ;;   *) die "mchecksum(): unknown method '${method}'" ;;
72   esac   esac
73    
74   if [[ -d ${rundir} ]]   if [[ -f ${file} ]]
75   then   then
76   pushd ${rundir} &> /dev/null   if [[ -d ${rundir} ]]
77     then
78     pushd ${rundir} &> /dev/null
79    
80   # all file must be non-zero   # all file must be non-zero
81   retval=0   retval=0
82   while read sum dest   while read sum dest
83   do   do
84   if [ ! -s ${dest} ]   if [ ! -s ${dest} ]
85     then
86     echo "${dest}: file is empty ;("
87     retval=127
88     fi
89     done < ${file}
90     if [[ ${retval} != 127 ]]
91   then   then
92   echo "${dest}: file is empty ;("   # be verbose here
93   retval=127   ${cmd} -c ${file} #&> /dev/null
94     retval="$?"
95   fi   fi
  done < ${file}  
  if [[ ${retval} != 127 ]]  
  then  
  # be verbose here  
  ${cmd} -c ${file} #&> /dev/null  
  retval="$?"  
  fi  
96    
97   popd &> /dev/null   popd &> /dev/null
98     else
99     retval=1
100     fi
101   else   else
102     echo "missing checksum file '${file}' ;("
103   retval=1   retval=1
104   fi   fi
105    
# Line 761  remove_database_entry() Line 767  remove_database_entry()
767   [ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist."   [ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist."
768    
769   # remove virtuals only if no other exist   # remove virtuals only if no other exist
770   if [[ $(count_installed_pkgs --pcat ${pcat} --pname ${pname}) -le 1 ]]   if [[ $(count_installed_pkgs --pcat=${pcat} --pname=${pname}) -le 1 ]]
771   then   then
772   # first unregister virtuals   # first unregister virtuals
773   provide="$(get_value_from_magefile PROVIDE ${magefile})"   provide="$(get_value_from_magefile PROVIDE ${magefile})"
# Line 790  count_installed_pkgs() Line 796  count_installed_pkgs()
796   local i   local i
797    
798   # very basic getops   # very basic getops
799   for i in $*   for i in $@
800   do   do
801   case $1 in   case ${i} in
802   --pcat|-c) shift; pcat="$1" ;;   --pcat*) pcat="${i#*=}" ;;
803   --pname|-n) shift; pname="$1" ;;   --pname*) pname="${i#*=}" ;;
804   esac   esac
  shift  
805   done   done
806    
807   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 1384  convertmirrors() Line 1389  convertmirrors()
1389    
1390   # check known uri schemes   # check known uri schemes
1391   case ${uri} in   case ${uri} in
1392   http://*|https://*|ftp://*|ftps://*) mirrors="" ;;   http://*|https://*|ftp://*|ftps://*|file://*) mirrors="" ;;
1393   mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;;   mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;;
1394   package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;;   package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;;
1395   gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;;   gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;;
# Line 1451  mdownload() Line 1456  mdownload()
1456   # get the name of the output file   # get the name of the output file
1457   outputfile="${mirror##*/}"   outputfile="${mirror##*/}"
1458    
1459   wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}"   case ${mirror} in
1460   retval="$?"   file://*)
1461     cp -v "${mirror//file:\/\/}" "${outputdir}/${outputfile}"
1462     retval="$?"
1463     ;;
1464     *)
1465     wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}"
1466     retval="$?"
1467     ;;
1468     esac
1469    
1470   if [[ ${retval} = 0 ]]   if [[ ${retval} = 0 ]]
1471   then   then
1472   break   break
# Line 1472  fetch_packages() Line 1486  fetch_packages()
1486   local list="$@"   local list="$@"
1487   local pkgname   local pkgname
1488   local pkgfile   local pkgfile
1489     local pcat
1490     local pname
1491   local mirr   local mirr
1492   local magefile   local magefile
1493   local md5file   local md5file
# Line 1479  fetch_packages() Line 1495  fetch_packages()
1495   local count_current   local count_current
1496   local count_total   local count_total
1497   local wget_opts   local wget_opts
1498     local fetching
1499    
1500   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."
1501    
# Line 1497  fetch_packages() Line 1514  fetch_packages()
1514   pkgfile="${pkgname}.${PKGSUFFIX}"   pkgfile="${pkgname}.${PKGSUFFIX}"
1515   pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"   pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"
1516    
1517     pcat=$(magename2pcat ${magefile})
1518     pname=$(magename2pname ${magefile})
1519     md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5"
1520    
1521   (( count_current++ ))   (( count_current++ ))
1522   xtitle "[ (${count_current}/${count_total}) Fetching ${pkgfile} ]"   xtitle "[ (${count_current}/${count_total}) Fetching ${pkgfile} ]"
1523    
# Line 1516  fetch_packages() Line 1537  fetch_packages()
1537   continue   continue
1538   fi   fi
1539    
1540   # abort if already exist   # check if FETCHING is required
1541   if [ -f ${PKGDIR}/${pkgfile} ]   if [ ! -f "${md5file}" ]
1542     then
1543     fetching=true
1544     else
1545     if mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 &> /dev/null
1546     then
1547     # md5's ok, no fetching required
1548     fetching=false
1549     else
1550     fetching=true
1551     fi
1552     fi
1553    
1554     if [[ ${fetching} = false ]]
1555   then   then
1556   echo -ne " ${COLBLUE}***${COLDEFAULT}"   echo -ne " ${COLBLUE}***${COLDEFAULT}"
1557   echo " fetch complete (${count_current}/${count_total}): ${pkgfile} ... "   echo " fetch complete (${count_current}/${count_total}): ${pkgfile} ... "
1558   continue   continue
1559     else
1560     echo -ne " ${COLBLUE}***${COLDEFAULT}"
1561     echo -e " fetching (${count_current}/${count_total}): ${pkgfile} ... "
1562     mdownload --uri "package://${pkgfile}" --dir "${PKGDIR}" || die "Could not download ${pkgfile}"
1563   fi   fi
1564    
1565   echo -ne " ${COLBLUE}***${COLDEFAULT}"   # sanity check, not really needed but to be sure
  echo -e " fetching (${count_current}/${count_total}): ${pkgfile} ... "  
  mdownload --uri "package://${pkgfile}" --dir "${PKGDIR}" || die "Could not download ${pkgfile}"  
1566   if [ ! -f ${PKGDIR}/${pkgfile} ]   if [ ! -f ${PKGDIR}/${pkgfile} ]
1567   then   then
1568   die "Package '${pkgfile}' after download not found in '${PKGDIR}'"   die "Package '${pkgfile}' after download not found in '${PKGDIR}'"
# Line 2234  sminclude() Line 2270  sminclude()
2270   then   then
2271   for i in $*   for i in $*
2272   do   do
2273   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"   [[ ${SILENT} = 1 ]] || echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
2274   source ${SMAGESCRIPTSDIR}/include/${i}.sminc   source ${SMAGESCRIPTSDIR}/include/${i}.sminc
2275   done   done
2276   echo   [[ ${SILENT} = 1 ]] || echo
2277   fi   fi
2278  }  }
2279    
# Line 2541  get_value_from_magefile() Line 2577  get_value_from_magefile()
2577   local SDEPEND   local SDEPEND
2578   local PROVIDE   local PROVIDE
2579   local PKGTYPE   local PKGTYPE
  local MAGE_TARGETS  
2580   local SPLIT_PACKAGE_BASE   local SPLIT_PACKAGE_BASE
2581   local preinstall   local preinstall
2582   local postinstall   local postinstall
# Line 2663  mage_install() Line 2698  mage_install()
2698   echo B:${pbuild}   echo B:${pbuild}
2699   fi   fi
2700    
2701   if [[ -n ${MAGE_TARGETS} ]]   if [[ -n ${SPLIT_PACKAGE_BASE} ]]
  then  
  # basic svn compat  
  if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]  
  then  
  for i in ${SMAGESCRIPTSDIR}/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2  
  do  
  smage2file="${i}"  
  done  
  else  
  smage2file=${SMAGESCRIPTSDIR}/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2  
  fi  
   
  elif [[ -n ${SPLIT_PACKAGE_BASE} ]]  
2702   then   then
2703   # basic svn compat   # basic svn compat
2704   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
# Line 3046  mage_uninstall() Line 3068  mage_uninstall()
3068   unset -f postremove   unset -f postremove
3069  }  }
3070    
3071    # rerun_pkgfunctions [method] pkg1 pkg2 pkg3
3072    rerun_pkgfunctions()
3073    {
3074     local method
3075     local list
3076     local pcat
3077     local pname
3078     local pver
3079     local pbuild
3080     local magefile
3081     local i
3082    
3083     # very basic getops
3084     case $1 in
3085     --method) shift; method="$1" ;;
3086     esac
3087     shift
3088     local list="$@"
3089    
3090     # sanity check
3091     case ${method} in
3092     preinstall|postinstall) ;;
3093     preremove|postremove) ;;
3094     *) die "rerun_pkgfunctions(): Unknown method '${method}'." ;;
3095     esac
3096    
3097     if [[ -n ${MROOT} ]]
3098     then
3099     echo -ne ${COLRED}
3100     echo "!! running in MROOT=${MROOT}"
3101     echo -ne ${COLDEFAULT}
3102     echo
3103     fi
3104    
3105     for pkg in ${list}
3106     do
3107     pcat=$(dep2pcat ${pkg})
3108     pname=$(magename2pname ${pkg})
3109     pver=$(magename2pver ${pkg})
3110     pbuild=$(magename2pbuild ${pkg})
3111     magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
3112    
3113     if [ -e ${magefile} ]
3114     then
3115     source ${magefile}
3116     if [ -n "$(typeset -f ${method})" ]
3117     then
3118     echo -e " ${COLBLUE}***${COLDEFAULT} running ${method} for ${pkg} ... "
3119     ${method}
3120     else
3121     echo "No ${method}() for pkg '${pkg}' defined. Doing nothing."
3122     fi
3123     unset -f preinstall postinstall preremove postremove
3124     else
3125     die "Magefile '${magefile}' does not exist."
3126     fi
3127     done
3128    }
3129    
3130  show_etc_update_mesg()  show_etc_update_mesg()
3131  {  {
3132   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0
# Line 3457  msetfeature() Line 3538  msetfeature()
3538   MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )   MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )
3539   fi   fi
3540    
3541   export MAGE_FEATURE_CURRENT   export MAGE_FEATURES_CURRENT
3542   done   done
3543  }  }
3544    

Legend:
Removed from v.2271  
changed lines
  Added in v.3040