Magellan Linux

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

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

revision 2565 by niro, Wed Jan 29 12:20:18 2014 UTC revision 3041 by niro, Fri Jun 30 12:36:20 2017 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 71  mchecksum() Line 48  mchecksum()
48   *) die "mchecksum(): unknown method '${method}'" ;;   *) die "mchecksum(): unknown method '${method}'" ;;
49   esac   esac
50    
51   if [[ -d ${rundir} ]]   if [[ -f ${file} ]]
52   then   then
53   pushd ${rundir} &> /dev/null   if [[ -d ${rundir} ]]
54     then
55     pushd ${rundir} &> /dev/null
56    
57   # all file must be non-zero   # all file must be non-zero
58   retval=0   retval=0
59   while read sum dest   while read sum dest
60   do   do
61   if [ ! -s ${dest} ]   if [ ! -s ${dest} ]
62     then
63     echo "${dest}: file is empty ;("
64     retval=127
65     fi
66     done < ${file}
67     if [[ ${retval} != 127 ]]
68   then   then
69   echo "${dest}: file is empty ;("   # be verbose here
70   retval=127   ${cmd} -c ${file} #&> /dev/null
71     retval="$?"
72   fi   fi
  done < ${file}  
  if [[ ${retval} != 127 ]]  
  then  
  # be verbose here  
  ${cmd} -c ${file} #&> /dev/null  
  retval="$?"  
  fi  
73    
74   popd &> /dev/null   popd &> /dev/null
75     else
76     retval=1
77     fi
78   else   else
79     echo "missing checksum file '${file}' ;("
80   retval=1   retval=1
81   fi   fi
82    
# Line 185  unpack_packages() Line 168  unpack_packages()
168   if [ ${count_total} -gt 1 ]; then echo; fi   if [ ${count_total} -gt 1 ]; then echo; fi
169  }  }
170    
   
171  # fix_mtime path/to/$mtime/reffile $pathto/file  # fix_mtime path/to/$mtime/reffile $pathto/file
172  # creates a given reference file and fixes given file  # creates a given reference file and fixes given file
173  # returns new mtime  # returns new mtime
# Line 761  remove_database_entry() Line 743  remove_database_entry()
743   [ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist."   [ ! -f ${magefile} ] && die "remove_database_entry() ${magefile} not exist."
744    
745   # remove virtuals only if no other exist   # remove virtuals only if no other exist
746   if [[ $(count_installed_pkgs --pcat ${pcat} --pname ${pname}) -le 1 ]]   if [[ $(count_installed_pkgs --pcat=${pcat} --pname=${pname}) -le 1 ]]
747   then   then
748   # first unregister virtuals   # first unregister virtuals
749   provide="$(get_value_from_magefile PROVIDE ${magefile})"   provide="$(get_value_from_magefile PROVIDE ${magefile})"
# Line 790  count_installed_pkgs() Line 772  count_installed_pkgs()
772   local i   local i
773    
774   # very basic getops   # very basic getops
775   for i in $*   for i in $@
776   do   do
777   case $1 in   case ${i} in
778   --pcat|-c) shift; pcat="$1" ;;   --pcat*) pcat="${i#*=}" ;;
779   --pname|-n) shift; pname="$1" ;;   --pname*) pname="${i#*=}" ;;
780   esac   esac
  shift  
781   done   done
782    
783   # sanity checks; abort if not given   # sanity checks; abort if not given
# Line 1384  convertmirrors() Line 1365  convertmirrors()
1365    
1366   # check known uri schemes   # check known uri schemes
1367   case ${uri} in   case ${uri} in
1368   http://*|https://*|ftp://*|ftps://*) mirrors="" ;;   http://*|https://*|ftp://*|ftps://*|file://*) mirrors="" ;;
1369   mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;;   mirror://*) mirrors="${MIRRORS}"; scheme="mirror://"; addon="/sources" ;;
1370   package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;;   package://*) mirrors="${MIRRORS}"; scheme="package://"; addon="/${PACKAGES_SERVER_PATH}" ;;
1371   gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;;   gnu://*) mirrors="${GNU_MIRRORS}"; scheme="gnu://" ;;
# Line 1451  mdownload() Line 1432  mdownload()
1432   # get the name of the output file   # get the name of the output file
1433   outputfile="${mirror##*/}"   outputfile="${mirror##*/}"
1434    
1435   wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}"   case ${mirror} in
1436   retval="$?"   file://*)
1437     cp -v "${mirror//file:\/\/}" "${outputdir}/${outputfile}"
1438     retval="$?"
1439     ;;
1440     *)
1441     wget ${wget_opts} --output-document="${outputdir}/${outputfile}" "${mirror}"
1442     retval="$?"
1443     ;;
1444     esac
1445    
1446   if [[ ${retval} = 0 ]]   if [[ ${retval} = 0 ]]
1447   then   then
1448   break   break
# Line 1699  cleanpkg() Line 1689  cleanpkg()
1689   fi   fi
1690  }  }
1691    
 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  
 }  
   
   
1692  # unused?  # unused?
1693  #  #
1694  # # cuts full pathnames or versionized names down to basename  # # cuts full pathnames or versionized names down to basename
# Line 1758  pname2pcat() Line 1728  pname2pcat()
1728   echo "${categorie}"   echo "${categorie}"
1729  }  }
1730    
 # 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  
 }  
   
   
1731  # get_highest_magefile ${PCAT} ${PNAME}  # get_highest_magefile ${PCAT} ${PNAME}
1732  # fake at moment returns only stable pkgs (must set to be one)  # returns $HIGHEST_MAGEFILE
 # return $HIGHEST_MAGEFILE  
1733  get_highest_magefile()  get_highest_magefile()
1734  {  {
1735   local HIGHEST_MAGEFILE   local pcat="$1"
1736   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  
1737    
1738   echo "${HIGHEST_MAGEFILE}"   ${MLIBDIR}/highest_magefile ${MAGEDIR}/${pcat}/${pname}
1739   return 0   return 0
1740  }  }
1741    
   
1742  ###################################################  ###################################################
1743  # function is_config_protected                    #  # function is_config_protected                    #
1744  #       is_config_protected /path/to/file         #  #       is_config_protected /path/to/file         #
# Line 2286  is_newer_mage_version_available() Line 2202  is_newer_mage_version_available()
2202   fi   fi
2203  }  }
2204    
   
2205  # returns pname from pkgname  # returns pname from pkgname
2206  # pkgname2pname $PKGNAME  # pkgname2pname $PKGNAME
2207  pkgname2pname()  pkgname2pname()
# Line 2771  mage_install() Line 2686  mage_install()
2686   then   then
2687   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2688   echo -n "rebuilding environment ... "   echo -n "rebuilding environment ... "
2689   ${MLIBDIR}/env-rebuild.sh > /dev/null && \   ${MLIBDIR}/env-rebuild > /dev/null && \
2690   echo "done." || echo "failure."   echo "done." || echo "failure."
2691   unset MAGE_ENV_REBUILD   unset MAGE_ENV_REBUILD
2692   fi   fi
# Line 3036  mage_uninstall() Line 2951  mage_uninstall()
2951   then   then
2952   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2953   echo -n "rebuilding environment ... "   echo -n "rebuilding environment ... "
2954   ${MLIBDIR}/env-rebuild.sh > /dev/null && \   ${MLIBDIR}/env-rebuild > /dev/null && \
2955   echo "done." || echo "failure."   echo "done." || echo "failure."
2956   unset MAGE_ENV_REBUILD   unset MAGE_ENV_REBUILD
2957   fi   fi
# Line 3452  known_mage_feature() Line 3367  known_mage_feature()
3367   kernelsrcunpack|!kernelsrcunpack) retval=0 ;;   kernelsrcunpack|!kernelsrcunpack) retval=0 ;;
3368   libtool|!libtool) retval=0 ;;   libtool|!libtool) retval=0 ;;
3369   linuxsymlink|!linuxsymlink) retval=0 ;;   linuxsymlink|!linuxsymlink) retval=0 ;;
3370     multilib|!multilib) reval=0 ;;
3371   pkgbuild|!pkgbuild) retval=0 ;;   pkgbuild|!pkgbuild) retval=0 ;;
3372   pkgdistrotag|!pkgdistrotag) retval=0 ;;   pkgdistrotag|!pkgdistrotag) retval=0 ;;
3373     pkgmetadata|!pkgmetadata) retval=0 ;;
3374   purge|!purge) retval=0 ;;   purge|!purge) retval=0 ;;
3375   qalint|!qalint) retval=0 ;;   qalint|!qalint) retval=0 ;;
3376   regentree|!regentree) retval=0 ;;   regentree|!regentree) retval=0 ;;
# Line 3524  msetfeature() Line 3441  msetfeature()
3441   MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )   MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )
3442   fi   fi
3443    
3444   export MAGE_FEATURE_CURRENT   export MAGE_FEATURES_CURRENT
3445   done   done
3446  }  }
3447    

Legend:
Removed from v.2565  
changed lines
  Added in v.3041