Magellan Linux

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

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

revision 2167 by niro, Wed Aug 14 14:07:00 2013 UTC revision 2271 by niro, Fri Oct 25 07:28:23 2013 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 72  mchecksum() Line 74  mchecksum()
74   if [[ -d ${rundir} ]]   if [[ -d ${rundir} ]]
75   then   then
76   pushd ${rundir} &> /dev/null   pushd ${rundir} &> /dev/null
77   # be verbose here  
78   ${cmd} -c ${file} #&> /dev/null   # all file must be non-zero
79   retval="$?"   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 105  mcheckemptydir() Line 122  mcheckemptydir()
122  unpack_package()  unpack_package()
123  {  {
124   local magefile="$1"   local magefile="$1"
125   local pkg   local pkgname
126     local pkgfile
127   local pkgtype   local pkgtype
128   local tar_opts   local tar_opts
129    
130   pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}"   pkgname="$(get_value_from_magefile PKGNAME ${magefile})"
131     pkgfile="${pkgname}.${PKGSUFFIX}"
132   pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"   pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"
133    
134   xtitle "[ Unpacking ${pkg} ]"   xtitle "[ Unpacking ${pkg} ]"
# Line 118  unpack_package() Line 137  unpack_package()
137   if [[ ${pkgtype} = virtual ]]   if [[ ${pkgtype} = virtual ]]
138   then   then
139   echo -ne " ${COLBLUE}---${COLDEFAULT}"   echo -ne " ${COLBLUE}---${COLDEFAULT}"
140   echo " !unpack virtual ${pkg/.${PKGSUFFIX}/} ... "   echo " !unpack virtual ${pkgname} ... "
141   continue   continue
142   fi   fi
143    
# Line 126  unpack_package() Line 145  unpack_package()
145   if [[ ${pkgtype} = sources ]]   if [[ ${pkgtype} = sources ]]
146   then   then
147   echo -ne " ${COLBLUE}---${COLDEFAULT}"   echo -ne " ${COLBLUE}---${COLDEFAULT}"
148   echo " !unpack sources ${pkg/.${PKGSUFFIX}/} ... "   echo " !unpack sources ${pkgname} ... "
149   continue   continue
150   fi   fi
151    
# Line 138  unpack_package() Line 157  unpack_package()
157   tar_opts="xjmf"   tar_opts="xjmf"
158   fi   fi
159    
160   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking ${pkg} ... "   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking ${pkgfile} ... "
161   tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"   tar ${tar_opts} ${PKGDIR}/${pkgfile} -C ${BUILDDIR} || die "Unpacking package ${pkgfile}"
162  }  }
163    
164  unpack_packages()  unpack_packages()
# Line 1384  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 1451  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 mirr   local mirr
1476   local magefile   local magefile
1477   local md5file   local md5file
# Line 1473  fetch_packages() Line 1493  fetch_packages()
1493    
1494   for magefile in ${list}   for magefile in ${list}
1495   do   do
1496   pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}"   pkgname="$(get_value_from_magefile PKGNAME ${magefile})"
1497     pkgfile="${pkgname}.${PKGSUFFIX}"
1498   pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"   pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"
1499    
1500   (( count_current++ ))   (( count_current++ ))
1501   xtitle "[ (${count_current}/${count_total}) Fetching ${pkg} ]"   xtitle "[ (${count_current}/${count_total}) Fetching ${pkgfile} ]"
1502    
1503   # abort on virtual pkg   # abort on virtual pkg
1504   if [[ ${pkgtype} = virtual ]]   if [[ ${pkgtype} = virtual ]]
1505   then   then
1506   echo -ne " ${COLBLUE}---${COLDEFAULT}"   echo -ne " ${COLBLUE}---${COLDEFAULT}"
1507   echo " !fetch virtual (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... "   echo " !fetch virtual (${count_current}/${count_total}): ${pkgname} ... "
1508   continue   continue
1509   fi   fi
1510    
# Line 1491  fetch_packages() Line 1512  fetch_packages()
1512   if [[ ${pkgtype} = sources ]]   if [[ ${pkgtype} = sources ]]
1513   then   then
1514   echo -ne " ${COLBLUE}---${COLDEFAULT}"   echo -ne " ${COLBLUE}---${COLDEFAULT}"
1515   echo " !fetch sources (${count_current}/${count_total}): ${pkg/.${PKGSUFFIX}/} ... "   echo " !fetch sources (${count_current}/${count_total}): ${pkgname} ... "
1516   continue   continue
1517   fi   fi
1518    
1519   # abort if already exist   # abort if already exist
1520   if [ -f ${PKGDIR}/${pkg} ]   if [ -f ${PKGDIR}/${pkgfile} ]
1521   then   then
1522   echo -ne " ${COLBLUE}***${COLDEFAULT}"   echo -ne " ${COLBLUE}***${COLDEFAULT}"
1523   echo " fetch complete (${count_current}/${count_total}): ${pkg} ... "   echo " fetch complete (${count_current}/${count_total}): ${pkgfile} ... "
1524   continue   continue
1525   fi   fi
1526    
1527   echo -ne " ${COLBLUE}***${COLDEFAULT}"   echo -ne " ${COLBLUE}***${COLDEFAULT}"
1528   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "   echo -e " fetching (${count_current}/${count_total}): ${pkgfile} ... "
1529   mdownload --uri "package://${pkg}" --dir "${PKGDIR}" || die "Could not download ${pkg}"   mdownload --uri "package://${pkgfile}" --dir "${PKGDIR}" || die "Could not download ${pkgfile}"
1530   if [ ! -f ${PKGDIR}/${pkg} ]   if [ ! -f ${PKGDIR}/${pkgfile} ]
1531   then   then
1532   die "Package '${pkg}' after download not found in '${PKGDIR}'"   die "Package '${pkgfile}' after download not found in '${PKGDIR}'"
1533   fi   fi
1534   done   done
1535    
# Line 1771  get_highest_magefile() Line 1792  get_highest_magefile()
1792   then   then
1793   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
1794   #for debug only   #for debug only
1795   mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"   mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" >&2
1796   fi   fi
1797   done   done
1798    
# Line 2786  md5sum_packages() Line 2807  md5sum_packages()
2807   pname=$(magename2pname ${magefile})   pname=$(magename2pname ${magefile})
2808   pkgname="$(get_value_from_magefile PKGNAME ${magefile})"   pkgname="$(get_value_from_magefile PKGNAME ${magefile})"
2809   md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5"   md5file="${MAGEDIR}/${pcat}/${pname}/md5/${pkgname}.md5"
2810   pkgfile="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}"   pkgfile="${pkgname}.${PKGSUFFIX}"
2811   pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"   pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"
2812    
2813   (( count_current++ ))   (( count_current++ ))
# Line 2796  md5sum_packages() Line 2817  md5sum_packages()
2817   if [[ ${pkgtype} = virtual ]]   if [[ ${pkgtype} = virtual ]]
2818   then   then
2819   echo -ne " ${COLBLUE}---${COLDEFAULT}"   echo -ne " ${COLBLUE}---${COLDEFAULT}"
2820   echo " !md5sum virtual (${count_current}/${count_total}): ${pkgfile/.${PKGSUFFIX}/} ... "   echo " !md5sum virtual (${count_current}/${count_total}): ${pkgname} ... "
2821   continue   continue
2822   fi   fi
2823    
# Line 2804  md5sum_packages() Line 2825  md5sum_packages()
2825   if [[ ${pkgtype} = sources ]]   if [[ ${pkgtype} = sources ]]
2826   then   then
2827   echo -ne " ${COLBLUE}---${COLDEFAULT}"   echo -ne " ${COLBLUE}---${COLDEFAULT}"
2828   echo " !md5sum sources (${count_current}/${count_total}): ${pkgfile/.${PKGSUFFIX}/} ... "   echo " !md5sum sources (${count_current}/${count_total}): ${pkgname} ... "
2829   continue   continue
2830   fi   fi
2831    
# Line 2852  uninstall_packages() Line 2873  uninstall_packages()
2873   pbuild=$(magename2pbuild ${pkg})   pbuild=$(magename2pbuild ${pkg})
2874   can_pcat="${pcat}"   can_pcat="${pcat}"
2875   can_pname="${pname}"   can_pname="${pname}"
2876    
2877   if [ -z "${can_ver_list}" ]   if [ -z "${can_ver_list}" ]
2878   then   then
2879   can_ver_list=" ${pver}-${pbuild}"   can_ver_list=" ${pver}-${pbuild}"
# Line 3288  need_busybox_support() Line 3309  need_busybox_support()
3309   do   do
3310   if [[ -x ${busybox} ]]   if [[ -x ${busybox} ]]
3311   then   then
3312   if [[ $(readlink $(which ${cmd})) = ${busybox} ]]   if [[ $(readlink $(type -P ${cmd})) = ${busybox} ]]
3313   then   then
3314   # needs busybox support   # needs busybox support
3315   return 0   return 0

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