Magellan Linux

Diff of /branches/mage-next/src/mage4.functions.sh.in

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

trunk/mage/usr/lib/mage/mage4.functions.sh revision 2364 by niro, Mon Jan 6 12:53:31 2014 UTC branches/mage-next/src/mage4.functions.sh.in revision 2811 by niro, Wed Sep 3 12:01:21 2014 UTC
# Line 2  Line 2 
2  # Magellan Linux Installer Functions (mage.functions.sh)  # Magellan Linux Installer Functions (mage.functions.sh)
3  # $Id$  # $Id$
4    
 COLRED="\033[1;6m\033[31m"  
 COLGREEN="\033[1;6m\033[32m"  
 COLYELLOW="\033[1;6m\033[33m"  
 COLBLUE="\033[1;6m\033[34m"  
 COLMAGENTA="\033[1;6m\033[35m"  
 COLWHITE="\033[1;6m\033[37m"  
 COLGRAY="\033[0;6m\033[37m"  
 COLBOLD="\033[1m"  
 COLDEFAULT="\033[0m"  
   
 if [[ ${NOCOLORS} = true ]]  
 then  
  COLRED=""  
  COLGREEN=""  
  COLYELLOW=""  
  COLBLUE=""  
  COLMAGENTA=""  
  COLWHITE=""  
  COLGRAY=""  
  COLBOLD=""  
  COLDEFAULT=""  
 fi  
   
5  mage_setup()  mage_setup()
6  {  {
7   [ ! -d ${MROOT}${INSTALLDB} ] && \   [ ! -d ${MROOT}${INSTALLDB} ] && \
# Line 185  unpack_packages() Line 162  unpack_packages()
162   if [ ${count_total} -gt 1 ]; then echo; fi   if [ ${count_total} -gt 1 ]; then echo; fi
163  }  }
164    
   
165  # fix_mtime path/to/$mtime/reffile $pathto/file  # fix_mtime path/to/$mtime/reffile $pathto/file
166  # creates a given reference file and fixes given file  # creates a given reference file and fixes given file
167  # returns new mtime  # returns new mtime
# Line 761  remove_database_entry() Line 737  remove_database_entry()
737   [ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist."   [ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist."
738    
739   # remove virtuals only if no other exist   # remove virtuals only if no other exist
740   if [[ $(count_installed_pkgs --pcat ${pcat} --pname ${pname}) -le 1 ]]   if [[ $(count_installed_pkgs --pcat=${pcat} --pname=${pname}) -le 1 ]]
741   then   then
742   # first unregister virtuals   # first unregister virtuals
743   provide="$(get_value_from_magefile PROVIDE ${magefile})"   provide="$(get_value_from_magefile PROVIDE ${magefile})"
# Line 790  count_installed_pkgs() Line 766  count_installed_pkgs()
766   local i   local i
767    
768   # very basic getops   # very basic getops
769   for i in $*   for i in $@
770   do   do
771   case $1 in   case ${i} in
772   --pcat|-c) shift; pcat="$1" ;;   --pcat*) pcat="${i#*=}" ;;
773   --pname|-n) shift; pname="$1" ;;   --pname*) pname="${i#*=}" ;;
774   esac   esac
  shift  
775   done   done
776    
777   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 1699  cleanpkg() Line 1674  cleanpkg()
1674   fi   fi
1675  }  }
1676    
 xtitle()  
 {  
  if [[ ${TERM} = xterm ]]  
  then  
  echo -ne "\033]0;Mage: $1\007"  
  fi  
  return 0  
 }  
   
   
 xtitleclean()  
 {  
  if [[ ${TERM} = xterm ]]  
  then  
  echo -ne "\033]0;\007"  
  fi  
  return 0  
 }  
   
   
1677  # unused?  # unused?
1678  #  #
1679  # # cuts full pathnames or versionized names down to basename  # # cuts full pathnames or versionized names down to basename
# Line 1758  pname2pcat() Line 1713  pname2pcat()
1713   echo "${categorie}"   echo "${categorie}"
1714  }  }
1715    
 # check_stable_package /path/to/foo.mage  
 # returns 0=stable 1=unstable  
 check_stable_package()  
 {  
  # first check if this magefile is not blacklisted  
  blacklisted "$1" || return 1  
   
  local STATE  
  STATE="$(get_value_from_magefile STATE "$1")"  
   
  # state testing  
  if [[ ${USE_TESTING} = true ]] || [[ ${MAGE_DISTRIBUTION} = testing ]]  
  then  
  case ${STATE} in  
  testing|stable) return 0 ;;  
  *) return 1 ;;  
  esac  
  fi  
   
  # state unstable  
  if [[ ${USE_UNSTABLE} = true ]] || [[ ${MAGE_DISTRIBUTION} = unstable ]]  
  then  
  case ${STATE} in  
  unstable|testing|stable) return 0 ;;  
  *) return 1 ;;  
  esac  
  fi  
   
  # no use_state given = stable  
  case ${STATE} in  
  stable) return 0 ;;  
  *) return 1 ;;  
  esac  
 }  
   
   
1716  # get_highest_magefile ${PCAT} ${PNAME}  # get_highest_magefile ${PCAT} ${PNAME}
1717  # fake at moment returns only stable pkgs (must set to be one)  # returns $HIGHEST_MAGEFILE
 # return $HIGHEST_MAGEFILE  
1718  get_highest_magefile()  get_highest_magefile()
1719  {  {
1720   local HIGHEST_MAGEFILE   local pcat="$1"
1721   local PCAT="$1"   local pname="$2"
  local PNAME="$2"  
  local magefile  
   
  # do not list the content of a directory, only the name (-d)  
  for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/* 2> /dev/null)  
  do  
  [[ -z ${magefile} ]] && continue  
  # we exclude subdirs (for stuff like a md5sum dir)  
  [[ -d ${magefile} ]] && continue  
  if check_stable_package ${magefile}  
  then  
  HIGHEST_MAGEFILE=${magefile}  
  #for debug only  
  mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" >&2  
  fi  
  done  
1722    
1723   echo "${HIGHEST_MAGEFILE}"   ${MLIBDIR}/highest_magefile ${MAGEDIR}/${pcat}/${pname}
1724   return 0   return 0
1725  }  }
1726    
   
1727  ###################################################  ###################################################
1728  # function is_config_protected                    #  # function is_config_protected                    #
1729  #       is_config_protected /path/to/file         #  #       is_config_protected /path/to/file         #
# Line 2286  is_newer_mage_version_available() Line 2187  is_newer_mage_version_available()
2187   fi   fi
2188  }  }
2189    
   
2190  # returns pname from pkgname  # returns pname from pkgname
2191  # pkgname2pname $PKGNAME  # pkgname2pname $PKGNAME
2192  pkgname2pname()  pkgname2pname()
# Line 2563  get_value_from_magefile() Line 2463  get_value_from_magefile()
2463   local SDEPEND   local SDEPEND
2464   local PROVIDE   local PROVIDE
2465   local PKGTYPE   local PKGTYPE
  local MAGE_TARGETS  
2466   local SPLIT_PACKAGE_BASE   local SPLIT_PACKAGE_BASE
2467   local preinstall   local preinstall
2468   local postinstall   local postinstall
# Line 2685  mage_install() Line 2584  mage_install()
2584   echo B:${pbuild}   echo B:${pbuild}
2585   fi   fi
2586    
2587   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} ]]  
2588   then   then
2589   # basic svn compat   # basic svn compat
2590   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
# Line 2785  mage_install() Line 2671  mage_install()
2671   then   then
2672   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2673   echo -n "rebuilding environment ... "   echo -n "rebuilding environment ... "
2674   ${MLIBDIR}/env-rebuild.sh > /dev/null && \   ${MLIBDIR}/env-rebuild > /dev/null && \
2675   echo "done." || echo "failure."   echo "done." || echo "failure."
2676   unset MAGE_ENV_REBUILD   unset MAGE_ENV_REBUILD
2677   fi   fi
# Line 3050  mage_uninstall() Line 2936  mage_uninstall()
2936   then   then
2937   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2938   echo -n "rebuilding environment ... "   echo -n "rebuilding environment ... "
2939   ${MLIBDIR}/env-rebuild.sh > /dev/null && \   ${MLIBDIR}/env-rebuild > /dev/null && \
2940   echo "done." || echo "failure."   echo "done." || echo "failure."
2941   unset MAGE_ENV_REBUILD   unset MAGE_ENV_REBUILD
2942   fi   fi
# Line 3068  mage_uninstall() Line 2954  mage_uninstall()
2954   unset -f postremove   unset -f postremove
2955  }  }
2956    
2957    # rerun_pkgfunctions [method] pkg1 pkg2 pkg3
2958    rerun_pkgfunctions()
2959    {
2960     local method
2961     local list
2962     local pcat
2963     local pname
2964     local pver
2965     local pbuild
2966     local magefile
2967     local i
2968    
2969     # very basic getops
2970     case $1 in
2971     --method) shift; method="$1" ;;
2972     esac
2973     shift
2974     local list="$@"
2975    
2976     # sanity check
2977     case ${method} in
2978     preinstall|postinstall) ;;
2979     preremove|postremove) ;;
2980     *) die "rerun_pkgfunctions(): Unknown method '${method}'." ;;
2981     esac
2982    
2983     if [[ -n ${MROOT} ]]
2984     then
2985     echo -ne ${COLRED}
2986     echo "!! running in MROOT=${MROOT}"
2987     echo -ne ${COLDEFAULT}
2988     echo
2989     fi
2990    
2991     for pkg in ${list}
2992     do
2993     pcat=$(dep2pcat ${pkg})
2994     pname=$(magename2pname ${pkg})
2995     pver=$(magename2pver ${pkg})
2996     pbuild=$(magename2pbuild ${pkg})
2997     magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
2998    
2999     if [ -e ${magefile} ]
3000     then
3001     source ${magefile}
3002     if [ -n "$(typeset -f ${method})" ]
3003     then
3004     echo -e " ${COLBLUE}***${COLDEFAULT} running ${method} for ${pkg} ... "
3005     ${method}
3006     else
3007     echo "No ${method}() for pkg '${pkg}' defined. Doing nothing."
3008     fi
3009     unset -f preinstall postinstall preremove postremove
3010     else
3011     die "Magefile '${magefile}' does not exist."
3012     fi
3013     done
3014    }
3015    
3016  show_etc_update_mesg()  show_etc_update_mesg()
3017  {  {
3018   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0
# Line 3407  known_mage_feature() Line 3352  known_mage_feature()
3352   kernelsrcunpack|!kernelsrcunpack) retval=0 ;;   kernelsrcunpack|!kernelsrcunpack) retval=0 ;;
3353   libtool|!libtool) retval=0 ;;   libtool|!libtool) retval=0 ;;
3354   linuxsymlink|!linuxsymlink) retval=0 ;;   linuxsymlink|!linuxsymlink) retval=0 ;;
3355     multilib|!multilib) reval=0 ;;
3356   pkgbuild|!pkgbuild) retval=0 ;;   pkgbuild|!pkgbuild) retval=0 ;;
3357   pkgdistrotag|!pkgdistrotag) retval=0 ;;   pkgdistrotag|!pkgdistrotag) retval=0 ;;
3358     pkgmetadata|!pkgmetadata) retval=0 ;;
3359   purge|!purge) retval=0 ;;   purge|!purge) retval=0 ;;
3360   qalint|!qalint) retval=0 ;;   qalint|!qalint) retval=0 ;;
3361   regentree|!regentree) retval=0 ;;   regentree|!regentree) retval=0 ;;
# Line 3479  msetfeature() Line 3426  msetfeature()
3426   MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )   MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )
3427   fi   fi
3428    
3429   export MAGE_FEATURE_CURRENT   export MAGE_FEATURES_CURRENT
3430   done   done
3431  }  }
3432    

Legend:
Removed from v.2364  
changed lines
  Added in v.2811