Magellan Linux

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

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

revision 1961 by niro, Thu Oct 25 07:07:28 2012 UTC revision 2225 by niro, Wed Oct 16 07:49:19 2013 UTC
# 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-size OK"
85     else
86     echo "${dest}: file is empty ;("
87     retval=127
88     fi
89     done < ${file}
90     if [[ ${retval} != 127 ]]
91     then
92     # insert an empty line for cosmetic
93     echo
94    
95     # be verbose here
96     ${cmd} -c ${file} #&> /dev/null
97     retval="$?"
98     fi
99    
100   popd &> /dev/null   popd &> /dev/null
101   else   else
102   retval=1   retval=1
# Line 102  mcheckemptydir() Line 124  mcheckemptydir()
124   return ${retval}   return ${retval}
125  }  }
126    
127    unpack_package()
128    {
129     local magefile="$1"
130     local pkg
131     local pkgtype
132     local tar_opts
133    
134     pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}"
135     pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"
136    
137     xtitle "[ Unpacking ${pkg} ]"
138    
139     # abort on virtual pkg
140     if [[ ${pkgtype} = virtual ]]
141     then
142     echo -ne " ${COLBLUE}---${COLDEFAULT}"
143     echo " !unpack virtual ${pkg/.${PKGSUFFIX}/} ... "
144     continue
145     fi
146    
147     # abort on sources pkg
148     if [[ ${pkgtype} = sources ]]
149     then
150     echo -ne " ${COLBLUE}---${COLDEFAULT}"
151     echo " !unpack sources ${pkg/.${PKGSUFFIX}/} ... "
152     continue
153     fi
154    
155     # busybox?
156     if need_busybox_support tar
157     then
158     tar_opts="xjf"
159     else
160     tar_opts="xjmf"
161     fi
162    
163     echo -e " ${COLBLUE}***${COLDEFAULT} unpacking ${pkg} ... "
164     tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"
165    }
166    
167  unpack_packages()  unpack_packages()
168  {  {
169   local list="$@"   local list="$@"
170   local magefile   local magefile
  local pkg  
  local pkgtype  
171   local count_current   local count_current
172   local count_total   local count_total
173   local tar_opts   local tar_opts
# Line 120  unpack_packages() Line 180  unpack_packages()
180    
181   for magefile in ${list}   for magefile in ${list}
182   do   do
183   pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}"   unpack_package "${magefile}"
  pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"  
   
184   (( 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}"  
185   done   done
186    
187   # add a crlf for a better view   # add a crlf for a better view
# Line 1605  syncmage_tarball() Line 1635  syncmage_tarball()
1635   then   then
1636   if ! mcheckemptydir ${MAGEDIR}   if ! mcheckemptydir ${MAGEDIR}
1637   then   then
1638   find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xarg --no-run-if-empty rm -r   find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xargs --no-run-if-empty rm -r
1639   fi   fi
1640   else   else
1641   rm -rf ${MAGEDIR}   rm -rf ${MAGEDIR}
# Line 1763  get_highest_magefile() Line 1793  get_highest_magefile()
1793   then   then
1794   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
1795   #for debug only   #for debug only
1796   mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"   mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" >&2
1797   fi   fi
1798   done   done
1799    
# Line 1887  count_protected_files() Line 1917  count_protected_files()
1917   count="$(echo ${oldprotected} | sed 's:.*\/._cfg\(.*\)_.*:\1:')"   count="$(echo ${oldprotected} | sed 's:.*\/._cfg\(.*\)_.*:\1:')"
1918   done   done
1919    
1920   # dirty hack to convert 0001 -> 1; 0120 -> 120 etc   # convert 0001 -> 1; 0120 -> 120 etc
1921   x="${#count}"   # use bash internal base functions to this task
1922     x="$((10#${count}))"
1923   for (( i=0; i<x; i++ ))   for (( i=0; i<x; i++ ))
1924   do   do
1925   if [[ ${count:${i}:1} != 0 ]]   if [[ ${count:${i}:1} != 0 ]]
# Line 2688  mage_install() Line 2719  mage_install()
2719   if [[ ${PKGTYPE} != virtual ]] && \   if [[ ${PKGTYPE} != virtual ]] && \
2720   [[ ${PKGTYPE} != sources ]]   [[ ${PKGTYPE} != sources ]]
2721   then   then
2722     unpack_package "${magefile}"
2723   echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... "   echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... "
2724   build_doinstall ${PKGNAME}   build_doinstall ${PKGNAME}
2725   fi   fi
# Line 3278  need_busybox_support() Line 3310  need_busybox_support()
3310   do   do
3311   if [[ -x ${busybox} ]]   if [[ -x ${busybox} ]]
3312   then   then
3313   if [[ $(readlink $(which ${cmd})) = ${busybox} ]]   if [[ $(readlink $(type -P ${cmd})) = ${busybox} ]]
3314   then   then
3315   # needs busybox support   # needs busybox support
3316   return 0   return 0
# Line 3341  known_mage_feature() Line 3373  known_mage_feature()
3373  {  {
3374   local feature="$1"   local feature="$1"
3375   local retval   local retval
3376    
3377   case "${feature}" in   case "${feature}" in
3378   autosvc|!autosvc) retval=0 ;;   autosvc|!autosvc) retval=0 ;;
3379   buildlog|!buildlog) retval=0 ;;   buildlog|!buildlog) retval=0 ;;
# Line 3350  known_mage_feature() Line 3382  known_mage_feature()
3382   compressdoc|!compressdoc) retval=0 ;;   compressdoc|!compressdoc) retval=0 ;;
3383   debug|!debug) retval=0 ;;   debug|!debug) retval=0 ;;
3384   distcc|!distcc) retval=0 ;;   distcc|!distcc) retval=0 ;;
3385     icecc|!icecc) retval=0 ;;
3386   kernelsrcunpack|!kernelsrcunpack) retval=0 ;;   kernelsrcunpack|!kernelsrcunpack) retval=0 ;;
3387   libtool|!libtool) retval=0 ;;   libtool|!libtool) retval=0 ;;
3388   linuxsymlink|!linuxsymlink) retval=0 ;;   linuxsymlink|!linuxsymlink) retval=0 ;;

Legend:
Removed from v.1961  
changed lines
  Added in v.2225