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 2271 by niro, Fri Oct 25 07:28:23 2013 UTC branches/mage-next/src/mage4.functions.sh.in revision 2753 by niro, Thu Aug 14 14:29:11 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 1472  fetch_packages() Line 1447  fetch_packages()
1447   local list="$@"   local list="$@"
1448   local pkgname   local pkgname
1449   local pkgfile   local pkgfile
1450     local pcat
1451     local pname
1452   local mirr   local mirr
1453   local magefile   local magefile
1454   local md5file   local md5file
# Line 1479  fetch_packages() Line 1456  fetch_packages()
1456   local count_current   local count_current
1457   local count_total   local count_total
1458   local wget_opts   local wget_opts
1459     local fetching
1460    
1461   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."
1462    
# Line 1497  fetch_packages() Line 1475  fetch_packages()
1475   pkgfile="${pkgname}.${PKGSUFFIX}"   pkgfile="${pkgname}.${PKGSUFFIX}"
1476   pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"   pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"
1477    
1478     pcat=$(magename2pcat ${magefile})
1479     pname=$(magename2pname ${magefile})
1480     md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5"
1481    
1482   (( count_current++ ))   (( count_current++ ))
1483   xtitle "[ (${count_current}/${count_total}) Fetching ${pkgfile} ]"   xtitle "[ (${count_current}/${count_total}) Fetching ${pkgfile} ]"
1484    
# Line 1516  fetch_packages() Line 1498  fetch_packages()
1498   continue   continue
1499   fi   fi
1500    
1501   # abort if already exist   # check if FETCHING is required
1502   if [ -f ${PKGDIR}/${pkgfile} ]   if [ ! -f "${md5file}" ]
1503     then
1504     fetching=true
1505     else
1506     if mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 &> /dev/null
1507     then
1508     # md5's ok, no fetching required
1509     fetching=false
1510     else
1511     fetching=true
1512     fi
1513     fi
1514    
1515     if [[ ${fetching} = false ]]
1516   then   then
1517   echo -ne " ${COLBLUE}***${COLDEFAULT}"   echo -ne " ${COLBLUE}***${COLDEFAULT}"
1518   echo " fetch complete (${count_current}/${count_total}): ${pkgfile} ... "   echo " fetch complete (${count_current}/${count_total}): ${pkgfile} ... "
1519   continue   continue
1520     else
1521     echo -ne " ${COLBLUE}***${COLDEFAULT}"
1522     echo -e " fetching (${count_current}/${count_total}): ${pkgfile} ... "
1523     mdownload --uri "package://${pkgfile}" --dir "${PKGDIR}" || die "Could not download ${pkgfile}"
1524   fi   fi
1525    
1526   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}"  
1527   if [ ! -f ${PKGDIR}/${pkgfile} ]   if [ ! -f ${PKGDIR}/${pkgfile} ]
1528   then   then
1529   die "Package '${pkgfile}' after download not found in '${PKGDIR}'"   die "Package '${pkgfile}' after download not found in '${PKGDIR}'"
# Line 1677  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 2234  sminclude() Line 2211  sminclude()
2211   then   then
2212   for i in $*   for i in $*
2213   do   do
2214   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"   [[ ${SILENT} = 1 ]] || echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
2215   source ${SMAGESCRIPTSDIR}/include/${i}.sminc   source ${SMAGESCRIPTSDIR}/include/${i}.sminc
2216   done   done
2217   echo   [[ ${SILENT} = 1 ]] || echo
2218   fi   fi
2219  }  }
2220    
# Line 2264  is_newer_mage_version_available() Line 2241  is_newer_mage_version_available()
2241   fi   fi
2242  }  }
2243    
   
2244  # returns pname from pkgname  # returns pname from pkgname
2245  # pkgname2pname $PKGNAME  # pkgname2pname $PKGNAME
2246  pkgname2pname()  pkgname2pname()
# Line 2541  get_value_from_magefile() Line 2517  get_value_from_magefile()
2517   local SDEPEND   local SDEPEND
2518   local PROVIDE   local PROVIDE
2519   local PKGTYPE   local PKGTYPE
  local MAGE_TARGETS  
2520   local SPLIT_PACKAGE_BASE   local SPLIT_PACKAGE_BASE
2521   local preinstall   local preinstall
2522   local postinstall   local postinstall
# Line 2663  mage_install() Line 2638  mage_install()
2638   echo B:${pbuild}   echo B:${pbuild}
2639   fi   fi
2640    
2641   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} ]]  
2642   then   then
2643   # basic svn compat   # basic svn compat
2644   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
# Line 2763  mage_install() Line 2725  mage_install()
2725   then   then
2726   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2727   echo -n "rebuilding environment ... "   echo -n "rebuilding environment ... "
2728   ${MLIBDIR}/env-rebuild.sh > /dev/null && \   ${MLIBDIR}/env-rebuild > /dev/null && \
2729   echo "done." || echo "failure."   echo "done." || echo "failure."
2730   unset MAGE_ENV_REBUILD   unset MAGE_ENV_REBUILD
2731   fi   fi
# Line 3028  mage_uninstall() Line 2990  mage_uninstall()
2990   then   then
2991   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2992   echo -n "rebuilding environment ... "   echo -n "rebuilding environment ... "
2993   ${MLIBDIR}/env-rebuild.sh > /dev/null && \   ${MLIBDIR}/env-rebuild > /dev/null && \
2994   echo "done." || echo "failure."   echo "done." || echo "failure."
2995   unset MAGE_ENV_REBUILD   unset MAGE_ENV_REBUILD
2996   fi   fi
# Line 3046  mage_uninstall() Line 3008  mage_uninstall()
3008   unset -f postremove   unset -f postremove
3009  }  }
3010    
3011    # rerun_pkgfunctions [method] pkg1 pkg2 pkg3
3012    rerun_pkgfunctions()
3013    {
3014     local method
3015     local list
3016     local pcat
3017     local pname
3018     local pver
3019     local pbuild
3020     local magefile
3021     local i
3022    
3023     # very basic getops
3024     case $1 in
3025     --method) shift; method="$1" ;;
3026     esac
3027     shift
3028     local list="$@"
3029    
3030     # sanity check
3031     case ${method} in
3032     preinstall|postinstall) ;;
3033     preremove|postremove) ;;
3034     *) die "rerun_pkgfunctions(): Unknown method '${method}'." ;;
3035     esac
3036    
3037     if [[ -n ${MROOT} ]]
3038     then
3039     echo -ne ${COLRED}
3040     echo "!! running in MROOT=${MROOT}"
3041     echo -ne ${COLDEFAULT}
3042     echo
3043     fi
3044    
3045     for pkg in ${list}
3046     do
3047     pcat=$(dep2pcat ${pkg})
3048     pname=$(magename2pname ${pkg})
3049     pver=$(magename2pver ${pkg})
3050     pbuild=$(magename2pbuild ${pkg})
3051     magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
3052    
3053     if [ -e ${magefile} ]
3054     then
3055     source ${magefile}
3056     if [ -n "$(typeset -f ${method})" ]
3057     then
3058     echo -e " ${COLBLUE}***${COLDEFAULT} running ${method} for ${pkg} ... "
3059     ${method}
3060     else
3061     echo "No ${method}() for pkg '${pkg}' defined. Doing nothing."
3062     fi
3063     unset -f preinstall postinstall preremove postremove
3064     else
3065     die "Magefile '${magefile}' does not exist."
3066     fi
3067     done
3068    }
3069    
3070  show_etc_update_mesg()  show_etc_update_mesg()
3071  {  {
3072   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0
# Line 3385  known_mage_feature() Line 3406  known_mage_feature()
3406   kernelsrcunpack|!kernelsrcunpack) retval=0 ;;   kernelsrcunpack|!kernelsrcunpack) retval=0 ;;
3407   libtool|!libtool) retval=0 ;;   libtool|!libtool) retval=0 ;;
3408   linuxsymlink|!linuxsymlink) retval=0 ;;   linuxsymlink|!linuxsymlink) retval=0 ;;
3409     multilib|!multilib) reval=0 ;;
3410   pkgbuild|!pkgbuild) retval=0 ;;   pkgbuild|!pkgbuild) retval=0 ;;
3411   pkgdistrotag|!pkgdistrotag) retval=0 ;;   pkgdistrotag|!pkgdistrotag) retval=0 ;;
3412     pkgmetadata|!pkgmetadata) retval=0 ;;
3413   purge|!purge) retval=0 ;;   purge|!purge) retval=0 ;;
3414   qalint|!qalint) retval=0 ;;   qalint|!qalint) retval=0 ;;
3415   regentree|!regentree) retval=0 ;;   regentree|!regentree) retval=0 ;;
# Line 3457  msetfeature() Line 3480  msetfeature()
3480   MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )   MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )
3481   fi   fi
3482    
3483   export MAGE_FEATURE_CURRENT   export MAGE_FEATURES_CURRENT
3484   done   done
3485  }  }
3486    

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