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 1650 by niro, Fri Jan 13 21:05:41 2012 UTC branches/mage-next/src/mage4.functions.sh.in revision 2811 by niro, Wed Sep 3 12:01:21 2014 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  # Magellan Linux Installer Functions (mage.functions.sh)  # Magellan Linux Installer Functions (mage.functions.sh)
3  # $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"  
 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  
4    
5  mage_setup()  mage_setup()
6  {  {
# Line 46  mchecksum() Line 23  mchecksum()
23   local method   local method
24   local cmd   local cmd
25   local retval   local retval
26     local sum
27     local dest
28    
29   # very basic getops   # very basic getops
30   for i in $*   for i in $*
# Line 72  mchecksum() Line 51  mchecksum()
51   if [[ -d ${rundir} ]]   if [[ -d ${rundir} ]]
52   then   then
53   pushd ${rundir} &> /dev/null   pushd ${rundir} &> /dev/null
54   ${cmd} -c ${file} &> /dev/null  
55   retval="$?"   # all file must be non-zero
56     retval=0
57     while read sum dest
58     do
59     if [ ! -s ${dest} ]
60     then
61     echo "${dest}: file is empty ;("
62     retval=127
63     fi
64     done < ${file}
65     if [[ ${retval} != 127 ]]
66     then
67     # be verbose here
68     ${cmd} -c ${file} #&> /dev/null
69     retval="$?"
70     fi
71    
72   popd &> /dev/null   popd &> /dev/null
73   else   else
74   retval=1   retval=1
# Line 82  mchecksum() Line 77  mchecksum()
77   return "${retval}"   return "${retval}"
78  }  }
79    
80    mcheckemptydir()
81    {
82     local dir="$1"
83     local retval=1
84    
85     if [[ ! -d ${dir} ]]
86     then
87     echo "mcheckemptydir(): '${dir}' is not a directory!"
88     retval=3
89     else
90     shopt -s nullglob dotglob
91     files=( ${dir}/* )
92     (( ${#files[*]} )) || retval=0
93     shopt -u nullglob dotglob
94     fi
95    
96     return ${retval}
97    }
98    
99    unpack_package()
100    {
101     local magefile="$1"
102     local pkgname
103     local pkgfile
104     local pkgtype
105     local tar_opts
106    
107     pkgname="$(get_value_from_magefile PKGNAME ${magefile})"
108     pkgfile="${pkgname}.${PKGSUFFIX}"
109     pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"
110    
111     xtitle "[ Unpacking ${pkg} ]"
112    
113     # abort on virtual pkg
114     if [[ ${pkgtype} = virtual ]]
115     then
116     echo -ne " ${COLBLUE}---${COLDEFAULT}"
117     echo " !unpack virtual ${pkgname} ... "
118     continue
119     fi
120    
121     # abort on sources pkg
122     if [[ ${pkgtype} = sources ]]
123     then
124     echo -ne " ${COLBLUE}---${COLDEFAULT}"
125     echo " !unpack sources ${pkgname} ... "
126     continue
127     fi
128    
129     # busybox?
130     if need_busybox_support tar
131     then
132     tar_opts="xjf"
133     else
134     tar_opts="xjmf"
135     fi
136    
137     echo -e " ${COLBLUE}***${COLDEFAULT} unpacking ${pkgfile} ... "
138     tar ${tar_opts} ${PKGDIR}/${pkgfile} -C ${BUILDDIR} || die "Unpacking package ${pkgfile}"
139    }
140    
141  unpack_packages()  unpack_packages()
142  {  {
143   local list="$@"   local list="$@"
144   local magefile   local magefile
  local pkg  
  local pkgtype  
145   local count_current   local count_current
146   local count_total   local count_total
147   local tar_opts   local tar_opts
# Line 100  unpack_packages() Line 154  unpack_packages()
154    
155   for magefile in ${list}   for magefile in ${list}
156   do   do
157   pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}"   unpack_package "${magefile}"
  pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"  
   
158   (( count_current++ ))   (( count_current++ ))
  xtitle "[ (${count_current}/${count_total}) Unpacking ${pkg} ]"  
   
  # abort on virtual pkg  
  if [[ ${pkgtype} = virtual ]]  
  then  
  echo -ne " ${COLBLUE}---${COLDEFAULT}"  
  echo " !unpack virtual (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... "  
  continue  
  fi  
   
  # abort on sources pkg  
  if [[ ${pkgtype} = sources ]]  
  then  
  echo -ne " ${COLBLUE}---${COLDEFAULT}"  
  echo " !unpack sources (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... "  
  continue  
  fi  
   
  # busybox?  
  if need_busybox_support tar  
  then  
  tar_opts="xjf"  
  else  
  tar_opts="xjmf"  
  fi  
   
  echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "  
  tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"  
159   done   done
160    
161   # add a crlf for a better view   # add a crlf for a better view
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 151  fix_mtime() Line 174  fix_mtime()
174   mtime=$(stat -c %Y "${reference}")   mtime=$(stat -c %Y "${reference}")
175   touch \   touch \
176   --no-create \   --no-create \
177     --no-dereference \
178   --time=mtime \   --time=mtime \
179   --reference "${reference}" \   --reference="${reference}" \
180   "${pathto}"   "${pathto}"
181    
182   echo "${mtime}"   echo "${mtime}"
# Line 394  install_symlinks() Line 418  install_symlinks()
418    
419   ln -snf "${link}" "${MROOT}${pathto}"   ln -snf "${link}" "${MROOT}${pathto}"
420    
421  # # fix mtime and db   # fix mtime and db
422  # fix_descriptor ${pkgname}/.symlinks \   fix_descriptor ${pkgname}/.symlinks \
423  # "${pathto}" \   "${pathto}" \
424  # "${posix}" \   "${posix}" \
425  # "${link}" \   "${link}" \
426  # "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
427  # "${MROOT}${pathto}")"   "${MROOT}${pathto}")"
428    
429   done < ${BUILDDIR}/${pkgname}/.symlinks   done < ${BUILDDIR}/${pkgname}/.symlinks
430    
# Line 713  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 742  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 787  compare_mtime() Line 810  compare_mtime()
810    
811   mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)"   mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)"
812    
813   # if $pathto is a symlink than compare linked binary   # no extra handlink for symlinks anymore as fix_mtime
814   if [ -L "${MROOT}${pathto}" ]   # uses --no-dereference, compare directly
815   then   x=$(stat -c %Y "${MROOT}${pathto}")
  # readlink -f resolves full path of linked file  
  x="$(readlink -f "${MROOT}${pathto}")"  
   
  # abort if target does not exists  
  # we keep safe here, theoretically the link can removed  
  [ ! -e "${x}" ] && return 1  
   
  x=$(stat -c %Y "${x}")  
  else  
  x=$(stat -c %Y "${MROOT}${pathto}")  
  fi  
816    
817   [[ ${mtime} = ${x} ]] && return 0   [[ ${mtime} = ${x} ]] && return 0
818    
# Line 1366  convertmirrors() Line 1378  convertmirrors()
1378   output+="${mirror}${addon}/${uri/${scheme}/}"   output+="${mirror}${addon}/${uri/${scheme}/}"
1379   done   done
1380   else   else
1381   output="${uri}"   output="${uri}"
1382   fi   fi
1383    
1384   echo "${output}"   echo "${output}"
# Line 1433  fetch_packages() Line 1445  fetch_packages()
1445  {  {
1446   local i   local i
1447   local list="$@"   local list="$@"
1448   local pkg   local pkgname
1449     local pkgfile
1450     local pcat
1451     local pname
1452   local mirr   local mirr
1453   local magefile   local magefile
1454   local md5file   local md5file
# Line 1441  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 1455  fetch_packages() Line 1471  fetch_packages()
1471    
1472   for magefile in ${list}   for magefile in ${list}
1473   do   do
1474   pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}"   pkgname="$(get_value_from_magefile PKGNAME ${magefile})"
1475     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 ${pkg} ]"   xtitle "[ (${count_current}/${count_total}) Fetching ${pkgfile} ]"
1484    
1485   # abort on virtual pkg   # abort on virtual pkg
1486   if [[ ${pkgtype} = virtual ]]   if [[ ${pkgtype} = virtual ]]
1487   then   then
1488   echo -ne " ${COLBLUE}---${COLDEFAULT}"   echo -ne " ${COLBLUE}---${COLDEFAULT}"
1489   echo " !fetch virtual (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... "   echo " !fetch virtual (${count_current}/${count_total}): ${pkgname} ... "
1490   continue   continue
1491   fi   fi
1492    
# Line 1473  fetch_packages() Line 1494  fetch_packages()
1494   if [[ ${pkgtype} = sources ]]   if [[ ${pkgtype} = sources ]]
1495   then   then
1496   echo -ne " ${COLBLUE}---${COLDEFAULT}"   echo -ne " ${COLBLUE}---${COLDEFAULT}"
1497   echo " !fetch sources (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... "   echo " !fetch sources (${count_current}/${count_total}): ${pkgname} ... "
1498   continue   continue
1499   fi   fi
1500    
1501   # abort if already exist   # check if FETCHING is required
1502   if [ -f ${PKGDIR}/${pkg} ]   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}): ${pkg} ... "   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
1527   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "   if [ ! -f ${PKGDIR}/${pkgfile} ]
  mdownload --uri "package://${pkg}" --dir "${PKGDIR}" || die "Could not download ${pkg}"  
  if [ ! -f ${PKGDIR}/${pkg} ]  
1528   then   then
1529   die "Package '${pkg}' after download not found in '${PKGDIR}'"   die "Package '${pkgfile}' after download not found in '${PKGDIR}'"
1530   fi   fi
1531   done   done
1532    
# Line 1545  syncmage_tarball() Line 1581  syncmage_tarball()
1581    
1582   for mirr in ${MIRRORS}   for mirr in ${MIRRORS}
1583   do   do
1584   # path without distribution   # path without distribution
1585   mymirr="${mirr%/*}"   # (only for stable|testing|unstable and not DISTROTAG)
1586     case ${mirr##*/} in
1587     stable|testing|unstable) mymirr="${mirr%/*}";;
1588     *) mymirr="${mirr}";;
1589     esac
1590    
1591   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1592   echo "fetching latest md5 from ${mymirr} ..."   echo "fetching latest md5 from ${mymirr} ..."
# Line 1579  syncmage_tarball() Line 1619  syncmage_tarball()
1619   else   else
1620   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1621   echo -n "checking md5sum... "   echo -n "checking md5sum... "
1622   ( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed"   mchecksum --rundir "${temp}" --file "${latest_md5}" --method md5 || die "md5 for ${latest_tarball} failed"
1623   fi   fi
1624    
1625   if [[ -d ${MAGEDIR} ]]   if [[ -d ${MAGEDIR} ]]
1626   then   then
1627   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1628   echo "cleaning old mage-tree ${MAGEDIR}..."   echo "cleaning old mage-tree ${MAGEDIR}..."
1629   rm -rf ${MAGEDIR}   # honor mountpoints and empty dirs
1630     if mountpoint -q ${MAGEDIR}
1631     then
1632     if ! mcheckemptydir ${MAGEDIR}
1633     then
1634     find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xargs --no-run-if-empty rm -r
1635     fi
1636     else
1637     rm -rf ${MAGEDIR}
1638     fi
1639   fi   fi
1640    
1641   if need_busybox_support tar   if need_busybox_support tar
# Line 1625  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 1684  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}"  
  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 1847  count_protected_files() Line 1822  count_protected_files()
1822   local filename="${file##*/}"   local filename="${file##*/}"
1823   local count   local count
1824   local output   local output
1825     local oldprotected
1826   local i   local i
1827     local x
1828    
1829   declare -i count=0   # hack; do not honor a global set IFS like '§'
1830     local IFS
1831    
1832     count=0
1833    
1834   # check if there are already protected files   # check if there are already protected files
1835   for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" |   for oldprotected in $(find ${dirname} -iname "._cfg????_${filename}" |
1836   sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |   sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
1837   sort -t'%' -k3 -k2 | cut -f1 -d'%')   sort -t'%' -k3 -k2 | cut -f1 -d'%')
1838   do   do
1839   count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::")   count="$(echo ${oldprotected} | sed 's:.*\/._cfg\(.*\)_.*:\1:')"
1840     done
1841    
1842     # convert 0001 -> 1; 0120 -> 120 etc
1843     # use bash internal base functions to this task
1844     x="$((10#${count}))"
1845     for (( i=0; i<x; i++ ))
1846     do
1847     if [[ ${count:${i}:1} != 0 ]]
1848     then
1849     count="${count:${i}}"
1850     break
1851     fi
1852   done   done
1853   (( count ++ ))  
1854     count="$(( ${count}+1 ))"
1855    
1856   # fill output up with zeros   # fill output up with zeros
1857   for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done   for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
# Line 2164  sminclude() Line 2157  sminclude()
2157   then   then
2158   for i in $*   for i in $*
2159   do   do
2160   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"   [[ ${SILENT} = 1 ]] || echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
2161   source ${SMAGESCRIPTSDIR}/include/${i}.sminc   source ${SMAGESCRIPTSDIR}/include/${i}.sminc
2162   done   done
2163   echo   [[ ${SILENT} = 1 ]] || echo
2164   fi   fi
2165  }  }
2166    
# Line 2194  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 2471  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 2593  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 2648  mage_install() Line 2626  mage_install()
2626   if [[ ${PKGTYPE} != virtual ]] && \   if [[ ${PKGTYPE} != virtual ]] && \
2627   [[ ${PKGTYPE} != sources ]]   [[ ${PKGTYPE} != sources ]]
2628   then   then
2629     unpack_package "${magefile}"
2630   echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... "   echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... "
2631   build_doinstall ${PKGNAME}   build_doinstall ${PKGNAME}
2632   fi   fi
# Line 2692  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 2736  md5sum_packages() Line 2715  md5sum_packages()
2715   pname=$(magename2pname ${magefile})   pname=$(magename2pname ${magefile})
2716   pkgname="$(get_value_from_magefile PKGNAME ${magefile})"   pkgname="$(get_value_from_magefile PKGNAME ${magefile})"
2717   md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5"   md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5"
2718   pkgfile="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}"   pkgfile="${pkgname}.${PKGSUFFIX}"
2719   pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"   pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"
2720    
2721   (( count_current++ ))   (( count_current++ ))
# Line 2746  md5sum_packages() Line 2725  md5sum_packages()
2725   if [[ ${pkgtype} = virtual ]]   if [[ ${pkgtype} = virtual ]]
2726   then   then
2727   echo -ne " ${COLBLUE}---${COLDEFAULT}"   echo -ne " ${COLBLUE}---${COLDEFAULT}"
2728   echo " !md5sum virtual (${count_current}/${count_total}): ${pkgfile/.${PKGSUFFIX}/} ... "   echo " !md5sum virtual (${count_current}/${count_total}): ${pkgname} ... "
2729   continue   continue
2730   fi   fi
2731    
# Line 2754  md5sum_packages() Line 2733  md5sum_packages()
2733   if [[ ${pkgtype} = sources ]]   if [[ ${pkgtype} = sources ]]
2734   then   then
2735   echo -ne " ${COLBLUE}---${COLDEFAULT}"   echo -ne " ${COLBLUE}---${COLDEFAULT}"
2736   echo " !md5sum sources (${count_current}/${count_total}): ${pkgfile/.${PKGSUFFIX}/} ... "   echo " !md5sum sources (${count_current}/${count_total}): ${pkgname} ... "
2737   continue   continue
2738   fi   fi
2739    
# Line 2762  md5sum_packages() Line 2741  md5sum_packages()
2741   then   then
2742   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2743   echo -ne "checking md5sum (${count_current}/${count_total}): "   echo -ne "checking md5sum (${count_current}/${count_total}): "
2744   ( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed"   mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 || die "md5 for ${pkgfile} failed"
2745   else   else
2746   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2747   echo -e "!! no md5sum file found for ${pkgfile} :("   echo -e "!! no md5sum file found for ${pkgfile} :("
# Line 2802  uninstall_packages() Line 2781  uninstall_packages()
2781   pbuild=$(magename2pbuild ${pkg})   pbuild=$(magename2pbuild ${pkg})
2782   can_pcat="${pcat}"   can_pcat="${pcat}"
2783   can_pname="${pname}"   can_pname="${pname}"
2784    
2785   if [ -z "${can_ver_list}" ]   if [ -z "${can_ver_list}" ]
2786   then   then
2787   can_ver_list=" ${pver}-${pbuild}"   can_ver_list=" ${pver}-${pbuild}"
# Line 2957  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 2975  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 3079  pkgsearch() Line 3117  pkgsearch()
3117   "") continue;;   "") continue;;
3118   esac   esac
3119    
3120   deps="${deps} $(basename ${dep%-*})"   if [[ -z ${deps} ]]
3121     then
3122     deps="$(basename ${dep%-*})"
3123     else
3124     deps="${deps} $(basename ${dep%-*})"
3125     fi
3126   done << EOF   done << EOF
3127  ${depsfull}  ${depsfull}
3128  EOF  EOF
# Line 3090  EOF Line 3133  EOF
3133   "") continue;;   "") continue;;
3134   esac   esac
3135    
3136   sdeps="${sdeps} $(basename ${dep%-*})"   if [[ -z ${sdeps} ]]
3137     then
3138     sdeps="$(basename ${dep%-*})"
3139     else
3140     sdeps="${sdeps} $(basename ${dep%-*})"
3141     fi
3142   done << EOF   done << EOF
3143  ${sdepsfull}  ${sdepsfull}
3144  EOF  EOF
# Line 3104  EOF Line 3152  EOF
3152   then   then
3153   echo "      License:  ${license}"   echo "      License:  ${license}"
3154   fi   fi
3155   echo "      Depends: ${deps}"   echo "      Depends:  ${deps}"
3156   echo "      SDepends: ${sdeps}"   echo "      SDepends: ${sdeps}"
3157   echo   echo
3158    
# Line 3221  EOF Line 3269  EOF
3269  need_busybox_support()  need_busybox_support()
3270  {  {
3271   local cmd   local cmd
3272     local busybox
3273   cmd="$1"   cmd="$1"
3274    
3275   if [[ -x /bin/busybox ]]   for busybox in {,/usr}/bin/busybox
3276   then   do
3277   if [[ $(readlink $(which ${cmd})) = /bin/busybox ]]   if [[ -x ${busybox} ]]
3278   then   then
3279   # needs busybox support   if [[ $(readlink $(type -P ${cmd})) = ${busybox} ]]
3280   return 0   then
3281     # needs busybox support
3282     return 0
3283     fi
3284   fi   fi
3285   fi   done
3286    
3287   # no busybox   # no busybox
3288   return 1   return 1
# Line 3287  known_mage_feature() Line 3339  known_mage_feature()
3339  {  {
3340   local feature="$1"   local feature="$1"
3341   local retval   local retval
3342    
3343   case "${feature}" in   case "${feature}" in
3344   autosvc|!autosvc) retval=0 ;;   autosvc|!autosvc) retval=0 ;;
3345   buildlog|!buildlog) retval=0 ;;   buildlog|!buildlog) retval=0 ;;
# Line 3296  known_mage_feature() Line 3348  known_mage_feature()
3348   compressdoc|!compressdoc) retval=0 ;;   compressdoc|!compressdoc) retval=0 ;;
3349   debug|!debug) retval=0 ;;   debug|!debug) retval=0 ;;
3350   distcc|!distcc) retval=0 ;;   distcc|!distcc) retval=0 ;;
3351     icecc|!icecc) retval=0 ;;
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 3371  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    
# Line 3401  mqueryfeature() Line 3456  mqueryfeature()
3456    
3457  mprintfeatures()  mprintfeatures()
3458  {  {
3459   echo "Global features:  ${MAGE_FEATURES_GLOBAL[*]}"   echo -e "${COLRED}Global features:${COLDEFAULT} ${MAGE_FEATURES_GLOBAL[*]}"
3460   echo "Local features:   ${MAGE_FEATURES[*]}"   echo -e "${COLYELLOW}Local features:${COLDEFAULT} ${MAGE_FEATURES[*]}"
3461   echo "Current features: ${MAGE_FEATURES_CURRENT[*]}"   echo -e "${COLGREEN}Current features:${COLDEFAULT} ${MAGE_FEATURES_CURRENT[*]}"
3462  }  }

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