Magellan Linux

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

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

revision 1603 by niro, Tue Jan 3 16:17:48 2012 UTC revision 2724 by niro, Tue Jul 22 14:21:01 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$
4    
5  COLRED="\033[1;6m\033[31m"  COLRED="\033[1;6m\033[31m"
6  COLGREEN="\033[1;6m\033[32m"  COLGREEN="\033[1;6m\033[32m"
# Line 46  mchecksum() Line 46  mchecksum()
46   local method   local method
47   local cmd   local cmd
48   local retval   local retval
49     local sum
50     local dest
51    
52   # very basic getops   # very basic getops
53   for i in $*   for i in $*
# Line 66  mchecksum() Line 68  mchecksum()
68   case ${method} in   case ${method} in
69   md5) cmd="md5sum" ;;   md5) cmd="md5sum" ;;
70   sha256) cmd="sha256sum" ;;   sha256) cmd="sha256sum" ;;
71   *) die "mchecksum(): unkown method '${method}'" ;;   *) die "mchecksum(): unknown method '${method}'" ;;
72   esac   esac
73    
74   if [[ -d ${rundir} ]]   if [[ -d ${rundir} ]]
75   then   then
76   pushd ${rundir} &> /dev/null   pushd ${rundir} &> /dev/null
77   ${cmd} -c ${file} &> /dev/null  
78   retval="$?"   # all file must be non-zero
79     retval=0
80     while read sum dest
81     do
82     if [ ! -s ${dest} ]
83     then
84     echo "${dest}: file is empty ;("
85     retval=127
86     fi
87     done < ${file}
88     if [[ ${retval} != 127 ]]
89     then
90     # be verbose here
91     ${cmd} -c ${file} #&> /dev/null
92     retval="$?"
93     fi
94    
95   popd &> /dev/null   popd &> /dev/null
96   else   else
97   retval=1   retval=1
# Line 82  mchecksum() Line 100  mchecksum()
100   return "${retval}"   return "${retval}"
101  }  }
102    
103    mcheckemptydir()
104    {
105     local dir="$1"
106     local retval=1
107    
108     if [[ ! -d ${dir} ]]
109     then
110     echo "mcheckemptydir(): '${dir}' is not a directory!"
111     retval=3
112     else
113     shopt -s nullglob dotglob
114     files=( ${dir}/* )
115     (( ${#files[*]} )) || retval=0
116     shopt -u nullglob dotglob
117     fi
118    
119     return ${retval}
120    }
121    
122    unpack_package()
123    {
124     local magefile="$1"
125     local pkgname
126     local pkgfile
127     local pkgtype
128     local tar_opts
129    
130     pkgname="$(get_value_from_magefile PKGNAME ${magefile})"
131     pkgfile="${pkgname}.${PKGSUFFIX}"
132     pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"
133    
134     xtitle "[ Unpacking ${pkg} ]"
135    
136     # abort on virtual pkg
137     if [[ ${pkgtype} = virtual ]]
138     then
139     echo -ne " ${COLBLUE}---${COLDEFAULT}"
140     echo " !unpack virtual ${pkgname} ... "
141     continue
142     fi
143    
144     # abort on sources pkg
145     if [[ ${pkgtype} = sources ]]
146     then
147     echo -ne " ${COLBLUE}---${COLDEFAULT}"
148     echo " !unpack sources ${pkgname} ... "
149     continue
150     fi
151    
152     # busybox?
153     if need_busybox_support tar
154     then
155     tar_opts="xjf"
156     else
157     tar_opts="xjmf"
158     fi
159    
160     echo -e " ${COLBLUE}***${COLDEFAULT} unpacking ${pkgfile} ... "
161     tar ${tar_opts} ${PKGDIR}/${pkgfile} -C ${BUILDDIR} || die "Unpacking package ${pkgfile}"
162    }
163    
164  unpack_packages()  unpack_packages()
165  {  {
166   local list="$@"   local list="$@"
167   local magefile   local magefile
  local pkg  
  local pkgtype  
168   local count_current   local count_current
169   local count_total   local count_total
170   local tar_opts   local tar_opts
# Line 100  unpack_packages() Line 177  unpack_packages()
177    
178   for magefile in ${list}   for magefile in ${list}
179   do   do
180   pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}"   unpack_package "${magefile}"
  pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"  
   
181   (( 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}"  
182   done   done
183    
184   # add a crlf for a better view   # add a crlf for a better view
# Line 151  fix_mtime() Line 198  fix_mtime()
198   mtime=$(stat -c %Y "${reference}")   mtime=$(stat -c %Y "${reference}")
199   touch \   touch \
200   --no-create \   --no-create \
201     --no-dereference \
202   --time=mtime \   --time=mtime \
203   --reference "${reference}" \   --reference="${reference}" \
204   "${pathto}"   "${pathto}"
205    
206   echo "${mtime}"   echo "${mtime}"
# Line 394  install_symlinks() Line 442  install_symlinks()
442    
443   ln -snf "${link}" "${MROOT}${pathto}"   ln -snf "${link}" "${MROOT}${pathto}"
444    
445  # # fix mtime and db   # fix mtime and db
446  # fix_descriptor ${pkgname}/.symlinks \   fix_descriptor ${pkgname}/.symlinks \
447  # "${pathto}" \   "${pathto}" \
448  # "${posix}" \   "${posix}" \
449  # "${link}" \   "${link}" \
450  # "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
451  # "${MROOT}${pathto}")"   "${MROOT}${pathto}")"
452    
453   done < ${BUILDDIR}/${pkgname}/.symlinks   done < ${BUILDDIR}/${pkgname}/.symlinks
454    
# Line 787  compare_mtime() Line 835  compare_mtime()
835    
836   mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)"   mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)"
837    
838   # if $pathto is a symlink than compare linked binary   # no extra handlink for symlinks anymore as fix_mtime
839   if [ -L "${MROOT}${pathto}" ]   # uses --no-dereference, compare directly
840   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  
841    
842   [[ ${mtime} = ${x} ]] && return 0   [[ ${mtime} = ${x} ]] && return 0
843    
# Line 1366  convertmirrors() Line 1403  convertmirrors()
1403   output+="${mirror}${addon}/${uri/${scheme}/}"   output+="${mirror}${addon}/${uri/${scheme}/}"
1404   done   done
1405   else   else
1406   output="${uri}"   output="${uri}"
1407   fi   fi
1408    
1409   echo "${output}"   echo "${output}"
# Line 1401  mdownload() Line 1438  mdownload()
1438   real_uris="$(convertmirrors ${uri})"   real_uris="$(convertmirrors ${uri})"
1439    
1440   # verbose or not   # verbose or not
1441   mqueryfeature "!verbose" && wget_opts="--quiet"   mqueryfeature "!verbose" && wget_opts+=" --quiet"
1442    
1443   # filter wget options if busybox was found   # filter wget options if busybox was found
1444   wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"   wget_opts+=" $(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1445    
1446   # create outputdir   # create outputdir
1447   [[ ! -d ${outputdir} ]] && install -d "${outputdir}"   [[ ! -d ${outputdir} ]] && install -d "${outputdir}"
# Line 1433  fetch_packages() Line 1470  fetch_packages()
1470  {  {
1471   local i   local i
1472   local list="$@"   local list="$@"
1473   local pkg   local pkgname
1474     local pkgfile
1475     local pcat
1476     local pname
1477   local mirr   local mirr
1478   local magefile   local magefile
1479   local md5file   local md5file
# Line 1441  fetch_packages() Line 1481  fetch_packages()
1481   local count_current   local count_current
1482   local count_total   local count_total
1483   local wget_opts   local wget_opts
1484     local fetching
1485    
1486   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."
1487    
# Line 1455  fetch_packages() Line 1496  fetch_packages()
1496    
1497   for magefile in ${list}   for magefile in ${list}
1498   do   do
1499   pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}"   pkgname="$(get_value_from_magefile PKGNAME ${magefile})"
1500     pkgfile="${pkgname}.${PKGSUFFIX}"
1501   pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"   pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"
1502    
1503     pcat=$(magename2pcat ${magefile})
1504     pname=$(magename2pname ${magefile})
1505     md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5"
1506    
1507   (( count_current++ ))   (( count_current++ ))
1508   xtitle "[ (${count_current}/${count_total}) Fetching ${pkg} ]"   xtitle "[ (${count_current}/${count_total}) Fetching ${pkgfile} ]"
1509    
1510   # abort on virtual pkg   # abort on virtual pkg
1511   if [[ ${pkgtype} = virtual ]]   if [[ ${pkgtype} = virtual ]]
1512   then   then
1513   echo -ne " ${COLBLUE}---${COLDEFAULT}"   echo -ne " ${COLBLUE}---${COLDEFAULT}"
1514   echo " !fetch virtual (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... "   echo " !fetch virtual (${count_current}/${count_total}): ${pkgname} ... "
1515   continue   continue
1516   fi   fi
1517    
# Line 1473  fetch_packages() Line 1519  fetch_packages()
1519   if [[ ${pkgtype} = sources ]]   if [[ ${pkgtype} = sources ]]
1520   then   then
1521   echo -ne " ${COLBLUE}---${COLDEFAULT}"   echo -ne " ${COLBLUE}---${COLDEFAULT}"
1522   echo " !fetch sources (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... "   echo " !fetch sources (${count_current}/${count_total}): ${pkgname} ... "
1523   continue   continue
1524   fi   fi
1525    
1526   # abort if already exist   # check if FETCHING is required
1527   if [ -f ${PKGDIR}/${pkg} ]   if [ ! -f "${md5file}" ]
1528     then
1529     fetching=true
1530     else
1531     if mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 &> /dev/null
1532     then
1533     # md5's ok, no fetching required
1534     fetching=false
1535     else
1536     fetching=true
1537     fi
1538     fi
1539    
1540     if [[ ${fetching} = false ]]
1541   then   then
1542   echo -ne " ${COLBLUE}***${COLDEFAULT}"   echo -ne " ${COLBLUE}***${COLDEFAULT}"
1543   echo " fetch complete (${count_current}/${count_total}): ${pkg} ... "   echo " fetch complete (${count_current}/${count_total}): ${pkgfile} ... "
1544   continue   continue
1545     else
1546     echo -ne " ${COLBLUE}***${COLDEFAULT}"
1547     echo -e " fetching (${count_current}/${count_total}): ${pkgfile} ... "
1548     mdownload --uri "package://${pkgfile}" --dir "${PKGDIR}" || die "Could not download ${pkgfile}"
1549   fi   fi
1550    
1551   echo -ne " ${COLBLUE}***${COLDEFAULT}"   # sanity check, not really needed but to be sure
1552   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} ]  
1553   then   then
1554   die "Package '${pkg}' after download not found in '${PKGDIR}'"   die "Package '${pkgfile}' after download not found in '${PKGDIR}'"
1555   fi   fi
1556   done   done
1557    
# Line 1545  syncmage_tarball() Line 1606  syncmage_tarball()
1606    
1607   for mirr in ${MIRRORS}   for mirr in ${MIRRORS}
1608   do   do
1609   # path without distribution   # path without distribution
1610   mymirr="${mirr%/*}"   # (only for stable|testing|unstable and not DISTROTAG)
1611     case ${mirr##*/} in
1612     stable|testing|unstable) mymirr="${mirr%/*}";;
1613     *) mymirr="${mirr}";;
1614     esac
1615    
1616   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1617   echo "fetching latest md5 from ${mymirr} ..."   echo "fetching latest md5 from ${mymirr} ..."
# Line 1579  syncmage_tarball() Line 1644  syncmage_tarball()
1644   else   else
1645   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1646   echo -n "checking md5sum... "   echo -n "checking md5sum... "
1647   ( 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"
1648   fi   fi
1649    
1650   if [[ -d ${MAGEDIR} ]]   if [[ -d ${MAGEDIR} ]]
1651   then   then
1652   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1653   echo "cleaning old mage-tree ${MAGEDIR}..."   echo "cleaning old mage-tree ${MAGEDIR}..."
1654   rm -rf ${MAGEDIR}   # honor mountpoints and empty dirs
1655     if mountpoint -q ${MAGEDIR}
1656     then
1657     if ! mcheckemptydir ${MAGEDIR}
1658     then
1659     find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xargs --no-run-if-empty rm -r
1660     fi
1661     else
1662     rm -rf ${MAGEDIR}
1663     fi
1664   fi   fi
1665    
1666   if need_busybox_support tar   if need_busybox_support tar
# Line 1645  xtitleclean() Line 1719  xtitleclean()
1719  }  }
1720    
1721    
1722  # cuts full pathnames or versionized names down to basename  # unused?
1723  choppkgname()  #
1724  {  # # cuts full pathnames or versionized names down to basename
1725   #we want this only if full name was used  # choppkgname()
1726   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]  # {
1727   then  # #we want this only if full name was used
1728   #cuts ARCH and PBUILD  # if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]
1729   #ARCH comes from ${MAGERC}  # then
1730   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")  # #cuts ARCH and PBUILD
1731    # #ARCH comes from ${MAGERC}
1732    # MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}$(print_distrotag)-r*.::g")
1733    #
1734    # #cuts version number
1735    # MAGENAME=$(basename ${MAGENAME%-*} .mage)
1736    # fi
1737    # }
1738    
  #cuts version number  
  MAGENAME=$(basename ${MAGENAME%-*} .mage)  
  fi  
 }  
1739    
1740  # get_categorie $PNAME, returns CATEGORIE  # get_categorie $PNAME, returns CATEGORIE
1741  # $1=pname  # $1=pname
# Line 1737  get_highest_magefile() Line 1814  get_highest_magefile()
1814   then   then
1815   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
1816   #for debug only   #for debug only
1817   mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"   mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" >&2
1818   fi   fi
1819   done   done
1820    
# Line 1844  count_protected_files() Line 1921  count_protected_files()
1921   local filename="${file##*/}"   local filename="${file##*/}"
1922   local count   local count
1923   local output   local output
1924     local oldprotected
1925   local i   local i
1926     local x
1927    
1928   declare -i count=0   # hack; do not honor a global set IFS like '§'
1929     local IFS
1930    
1931     count=0
1932    
1933   # check if there are already protected files   # check if there are already protected files
1934   for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" |   for oldprotected in $(find ${dirname} -iname "._cfg????_${filename}" |
1935   sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |   sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
1936   sort -t'%' -k3 -k2 | cut -f1 -d'%')   sort -t'%' -k3 -k2 | cut -f1 -d'%')
1937   do   do
1938   count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::")   count="$(echo ${oldprotected} | sed 's:.*\/._cfg\(.*\)_.*:\1:')"
1939     done
1940    
1941     # convert 0001 -> 1; 0120 -> 120 etc
1942     # use bash internal base functions to this task
1943     x="$((10#${count}))"
1944     for (( i=0; i<x; i++ ))
1945     do
1946     if [[ ${count:${i}:1} != 0 ]]
1947     then
1948     count="${count:${i}}"
1949     break
1950     fi
1951   done   done
1952   (( count ++ ))  
1953     count="$(( ${count}+1 ))"
1954    
1955   # fill output up with zeros   # fill output up with zeros
1956   for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done   for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
# Line 2161  sminclude() Line 2256  sminclude()
2256   then   then
2257   for i in $*   for i in $*
2258   do   do
2259   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"   [[ ${SILENT} = 1 ]] || echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
2260   source ${SMAGESCRIPTSDIR}/include/${i}.sminc   source ${SMAGESCRIPTSDIR}/include/${i}.sminc
2261   done   done
2262   echo   [[ ${SILENT} = 1 ]] || echo
2263   fi   fi
2264  }  }
2265    
# Line 2468  get_value_from_magefile() Line 2563  get_value_from_magefile()
2563   local SDEPEND   local SDEPEND
2564   local PROVIDE   local PROVIDE
2565   local PKGTYPE   local PKGTYPE
  local MAGE_TARGETS  
2566   local SPLIT_PACKAGE_BASE   local SPLIT_PACKAGE_BASE
2567   local preinstall   local preinstall
2568   local postinstall   local postinstall
# Line 2590  mage_install() Line 2684  mage_install()
2684   echo B:${pbuild}   echo B:${pbuild}
2685   fi   fi
2686    
2687   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} ]]  
2688   then   then
2689   # basic svn compat   # basic svn compat
2690   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
# Line 2645  mage_install() Line 2726  mage_install()
2726   if [[ ${PKGTYPE} != virtual ]] && \   if [[ ${PKGTYPE} != virtual ]] && \
2727   [[ ${PKGTYPE} != sources ]]   [[ ${PKGTYPE} != sources ]]
2728   then   then
2729     unpack_package "${magefile}"
2730   echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... "   echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... "
2731   build_doinstall ${PKGNAME}   build_doinstall ${PKGNAME}
2732   fi   fi
# Line 2733  md5sum_packages() Line 2815  md5sum_packages()
2815   pname=$(magename2pname ${magefile})   pname=$(magename2pname ${magefile})
2816   pkgname="$(get_value_from_magefile PKGNAME ${magefile})"   pkgname="$(get_value_from_magefile PKGNAME ${magefile})"
2817   md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5"   md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5"
2818   pkgfile="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}"   pkgfile="${pkgname}.${PKGSUFFIX}"
2819   pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"   pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"
2820    
2821   (( count_current++ ))   (( count_current++ ))
# Line 2743  md5sum_packages() Line 2825  md5sum_packages()
2825   if [[ ${pkgtype} = virtual ]]   if [[ ${pkgtype} = virtual ]]
2826   then   then
2827   echo -ne " ${COLBLUE}---${COLDEFAULT}"   echo -ne " ${COLBLUE}---${COLDEFAULT}"
2828   echo " !md5sum virtual (${count_current}/${count_total}): ${pkgfile/.${PKGSUFFIX}/} ... "   echo " !md5sum virtual (${count_current}/${count_total}): ${pkgname} ... "
2829   continue   continue
2830   fi   fi
2831    
# Line 2751  md5sum_packages() Line 2833  md5sum_packages()
2833   if [[ ${pkgtype} = sources ]]   if [[ ${pkgtype} = sources ]]
2834   then   then
2835   echo -ne " ${COLBLUE}---${COLDEFAULT}"   echo -ne " ${COLBLUE}---${COLDEFAULT}"
2836   echo " !md5sum sources (${count_current}/${count_total}): ${pkgfile/.${PKGSUFFIX}/} ... "   echo " !md5sum sources (${count_current}/${count_total}): ${pkgname} ... "
2837   continue   continue
2838   fi   fi
2839    
# Line 2759  md5sum_packages() Line 2841  md5sum_packages()
2841   then   then
2842   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2843   echo -ne "checking md5sum (${count_current}/${count_total}): "   echo -ne "checking md5sum (${count_current}/${count_total}): "
2844   ( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed"   mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 || die "md5 for ${pkgfile} failed"
2845   else   else
2846   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2847   echo -e "!! no md5sum file found for ${pkgfile} :("   echo -e "!! no md5sum file found for ${pkgfile} :("
# Line 2799  uninstall_packages() Line 2881  uninstall_packages()
2881   pbuild=$(magename2pbuild ${pkg})   pbuild=$(magename2pbuild ${pkg})
2882   can_pcat="${pcat}"   can_pcat="${pcat}"
2883   can_pname="${pname}"   can_pname="${pname}"
2884    
2885   if [ -z "${can_ver_list}" ]   if [ -z "${can_ver_list}" ]
2886   then   then
2887   can_ver_list=" ${pver}-${pbuild}"   can_ver_list=" ${pver}-${pbuild}"
# Line 2972  mage_uninstall() Line 3054  mage_uninstall()
3054   unset -f postremove   unset -f postremove
3055  }  }
3056    
3057    # rerun_pkgfunctions [method] pkg1 pkg2 pkg3
3058    rerun_pkgfunctions()
3059    {
3060     local method
3061     local list
3062     local pcat
3063     local pname
3064     local pver
3065     local pbuild
3066     local magefile
3067     local i
3068    
3069     # very basic getops
3070     case $1 in
3071     --method) shift; method="$1" ;;
3072     esac
3073     shift
3074     local list="$@"
3075    
3076     # sanity check
3077     case ${method} in
3078     preinstall|postinstall) ;;
3079     preremove|postremove) ;;
3080     *) die "rerun_pkgfunctions(): Unknown method '${method}'." ;;
3081     esac
3082    
3083     if [[ -n ${MROOT} ]]
3084     then
3085     echo -ne ${COLRED}
3086     echo "!! running in MROOT=${MROOT}"
3087     echo -ne ${COLDEFAULT}
3088     echo
3089     fi
3090    
3091     for pkg in ${list}
3092     do
3093     pcat=$(dep2pcat ${pkg})
3094     pname=$(magename2pname ${pkg})
3095     pver=$(magename2pver ${pkg})
3096     pbuild=$(magename2pbuild ${pkg})
3097     magefile="${MROOT}${INSTALLDB}/${pcat}/${pname}-${pver}-${pbuild}/${pname}-${pver}-${pbuild}.mage"
3098    
3099     if [ -e ${magefile} ]
3100     then
3101     source ${magefile}
3102     if [ -n "$(typeset -f ${method})" ]
3103     then
3104     echo -e " ${COLBLUE}***${COLDEFAULT} running ${method} for ${pkg} ... "
3105     ${method}
3106     else
3107     echo "No ${method}() for pkg '${pkg}' defined. Doing nothing."
3108     fi
3109     unset -f preinstall postinstall preremove postremove
3110     else
3111     die "Magefile '${magefile}' does not exist."
3112     fi
3113     done
3114    }
3115    
3116  show_etc_update_mesg()  show_etc_update_mesg()
3117  {  {
3118   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0   [ ${MAGE_PROTECT_COUNTER} -eq 0 ] && return 0
# Line 2999  pkgsearch() Line 3140  pkgsearch()
3140   local state   local state
3141   local descriptiom   local descriptiom
3142   local homepage   local homepage
3143     local license
3144   local i   local i
3145   local all_installed   local all_installed
3146   local ipver   local ipver
# Line 3035  pkgsearch() Line 3177  pkgsearch()
3177   state="$(get_value_from_magefile STATE ${magefile})"   state="$(get_value_from_magefile STATE ${magefile})"
3178   description="$(get_value_from_magefile DESCRIPTION ${magefile})"   description="$(get_value_from_magefile DESCRIPTION ${magefile})"
3179   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
3180     license="$(get_value_from_magefile LICENSE ${magefile})"
3181    
3182   # all installed   # all installed
3183   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
3184   do   do
3185   ipver="$(magename2pver ${i})"   ipver="$(magename2pver ${i})"
3186   ipbuild="$(magename2pbuild ${i})"   ipbuild="$(magename2pbuild ${i})"
3187    
3188   if [[ -z ${all_installed} ]]   if [[ -z ${all_installed} ]]
3189   then   then
3190   all_installed="${ipver}-${ipbuild}"   all_installed="${ipver}-${ipbuild}"
# Line 3050  pkgsearch() Line 3193  pkgsearch()
3193   fi   fi
3194   done   done
3195   [[ -z ${all_installed} ]] && all_installed="none"   [[ -z ${all_installed} ]] && all_installed="none"
3196    
3197   case ${state} in   case ${state} in
3198   stable) state=${COLGREEN}"[s] ";;   stable) state=${COLGREEN}"[s] ";;
3199   testing) state=${COLYELLOW}"[t] ";;   testing) state=${COLYELLOW}"[t] ";;
# Line 3074  pkgsearch() Line 3217  pkgsearch()
3217   "") continue;;   "") continue;;
3218   esac   esac
3219    
3220   deps="${deps} $(basename ${dep%-*})"   if [[ -z ${deps} ]]
3221     then
3222     deps="$(basename ${dep%-*})"
3223     else
3224     deps="${deps} $(basename ${dep%-*})"
3225     fi
3226   done << EOF   done << EOF
3227  ${depsfull}  ${depsfull}
3228  EOF  EOF
# Line 3085  EOF Line 3233  EOF
3233   "") continue;;   "") continue;;
3234   esac   esac
3235    
3236   sdeps="${sdeps} $(basename ${dep%-*})"   if [[ -z ${sdeps} ]]
3237     then
3238     sdeps="$(basename ${dep%-*})"
3239     else
3240     sdeps="${sdeps} $(basename ${dep%-*})"
3241     fi
3242   done << EOF   done << EOF
3243  ${sdepsfull}  ${sdepsfull}
3244  EOF  EOF
# Line 3095  EOF Line 3248  EOF
3248   echo "      Installed versions: ${all_installed}"   echo "      Installed versions: ${all_installed}"
3249   echo "      Description: ${description}"   echo "      Description: ${description}"
3250   echo "      Homepage: ${homepage}"   echo "      Homepage: ${homepage}"
3251   echo "      Depends: ${deps}"   if [[ ! -z ${license} ]]
3252     then
3253     echo "      License:  ${license}"
3254     fi
3255     echo "      Depends:  ${deps}"
3256   echo "      SDepends: ${sdeps}"   echo "      SDepends: ${sdeps}"
3257   echo   echo
3258    
# Line 3212  EOF Line 3369  EOF
3369  need_busybox_support()  need_busybox_support()
3370  {  {
3371   local cmd   local cmd
3372     local busybox
3373   cmd="$1"   cmd="$1"
3374    
3375   if [[ -x /bin/busybox ]]   for busybox in {,/usr}/bin/busybox
3376   then   do
3377   if [[ $(readlink $(which ${cmd})) = /bin/busybox ]]   if [[ -x ${busybox} ]]
3378   then   then
3379   # needs busybox support   if [[ $(readlink $(type -P ${cmd})) = ${busybox} ]]
3380   return 0   then
3381     # needs busybox support
3382     return 0
3383     fi
3384   fi   fi
3385   fi   done
3386    
3387   # no busybox   # no busybox
3388   return 1   return 1
# Line 3278  known_mage_feature() Line 3439  known_mage_feature()
3439  {  {
3440   local feature="$1"   local feature="$1"
3441   local retval   local retval
3442    
3443   case "${feature}" in   case "${feature}" in
3444   autosvc|!autosvc) retval=0 ;;   autosvc|!autosvc) retval=0 ;;
3445   buildlog|!buildlog) retval=0 ;;   buildlog|!buildlog) retval=0 ;;
3446   ccache|!ccache) retval=0 ;;   ccache|!ccache) retval=0 ;;
3447   check|!check) retval=0 ;;   check|!check) retval=0 ;;
3448   compressdoc|!compressdoc) retval=0 ;;   compressdoc|!compressdoc) retval=0 ;;
3449     debug|!debug) retval=0 ;;
3450   distcc|!distcc) retval=0 ;;   distcc|!distcc) retval=0 ;;
3451     icecc|!icecc) retval=0 ;;
3452   kernelsrcunpack|!kernelsrcunpack) retval=0 ;;   kernelsrcunpack|!kernelsrcunpack) retval=0 ;;
3453   libtool|!libtool) retval=0 ;;   libtool|!libtool) retval=0 ;;
3454   linuxsymlink|!linuxsymlink) retval=0 ;;   linuxsymlink|!linuxsymlink) retval=0 ;;
3455   pkgbuild|!pkgbuild) retval=0 ;;   pkgbuild|!pkgbuild) retval=0 ;;
3456     pkgdistrotag|!pkgdistrotag) retval=0 ;;
3457   purge|!purge) retval=0 ;;   purge|!purge) retval=0 ;;
3458   qalint|!qalint) retval=0 ;;   qalint|!qalint) retval=0 ;;
3459   regentree|!regentree) retval=0 ;;   regentree|!regentree) retval=0 ;;
3460   stepbystep|!stepbystep) retval=0 ;;   resume|!resume) retval=0 ;;
3461   srcpkgbuild|!srcpkgbuild) retval=0 ;;   srcpkgbuild|!srcpkgbuild) retval=0 ;;
3462   srcpkgtarball|!srcpkgtarball) retval=0 ;;   srcpkgtarball|!srcpkgtarball) retval=0 ;;
3463     static|!static) retval=0 ;;
3464     stepbystep|!stepbystep) retval=0 ;;
3465   strip|!strip) retval=0 ;;   strip|!strip) retval=0 ;;
3466     verbose|!verbose) retval=0 ;;
3467   *) retval=1 ;;   *) retval=1 ;;
3468   esac   esac
3469    
# Line 3325  msetfeature() Line 3492  msetfeature()
3492    
3493   if ! known_mage_feature "${feature}"   if ! known_mage_feature "${feature}"
3494   then   then
3495   [[ ${FVERBOSE} = off ]] || echo "unkown feature ${feature}, ignoring it"   [[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}"
3496   return 3   return 3
3497   fi   fi
3498    
# Line 3357  msetfeature() Line 3524  msetfeature()
3524   MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )   MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )
3525   fi   fi
3526    
3527   export MAGE_FEATURE_CURRENT   export MAGE_FEATURES_CURRENT
3528   done   done
3529  }  }
3530    
# Line 3378  mqueryfeature() Line 3545  mqueryfeature()
3545   fi   fi
3546   done   done
3547   else   else
3548     [[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}"
3549   retval=3   retval=3
3550   fi   fi
3551    
# Line 3386  mqueryfeature() Line 3554  mqueryfeature()
3554    
3555  mprintfeatures()  mprintfeatures()
3556  {  {
3557   echo "Global features:  ${MAGE_FEATURES_GLOBAL[*]}"   echo -e "${COLRED}Global features:${COLDEFAULT} ${MAGE_FEATURES_GLOBAL[*]}"
3558   echo "Local features:   ${MAGE_FEATURES[*]}"   echo -e "${COLYELLOW}Local features:${COLDEFAULT} ${MAGE_FEATURES[*]}"
3559   echo "Current features: ${MAGE_FEATURES_CURRENT[*]}"   echo -e "${COLGREEN}Current features:${COLDEFAULT} ${MAGE_FEATURES_CURRENT[*]}"
3560  }  }

Legend:
Removed from v.1603  
changed lines
  Added in v.2724