Magellan Linux

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

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

revision 1758 by niro, Sat Feb 18 13:48:34 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 1898  count_protected_files() Line 1929  count_protected_files()
1929   fi   fi
1930   done   done
1931    
1932   count="${count}+1"   count="$(( ${count}+1 ))"
1933    
1934   # fill output up with zeros   # fill output up with zeros
1935   for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done   for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
# 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 3119  pkgsearch() Line 3151  pkgsearch()
3151   "") continue;;   "") continue;;
3152   esac   esac
3153    
3154   deps="${deps} $(basename ${dep%-*})"   if [[ -z ${deps} ]]
3155     then
3156     deps="$(basename ${dep%-*})"
3157     else
3158     deps="${deps} $(basename ${dep%-*})"
3159     fi
3160   done << EOF   done << EOF
3161  ${depsfull}  ${depsfull}
3162  EOF  EOF
# Line 3130  EOF Line 3167  EOF
3167   "") continue;;   "") continue;;
3168   esac   esac
3169    
3170   sdeps="${sdeps} $(basename ${dep%-*})"   if [[ -z ${sdeps} ]]
3171     then
3172     sdeps="$(basename ${dep%-*})"
3173     else
3174     sdeps="${sdeps} $(basename ${dep%-*})"
3175     fi
3176   done << EOF   done << EOF
3177  ${sdepsfull}  ${sdepsfull}
3178  EOF  EOF
# Line 3144  EOF Line 3186  EOF
3186   then   then
3187   echo "      License:  ${license}"   echo "      License:  ${license}"
3188   fi   fi
3189   echo "      Depends: ${deps}"   echo "      Depends:  ${deps}"
3190   echo "      SDepends: ${sdeps}"   echo "      SDepends: ${sdeps}"
3191   echo   echo
3192    
# Line 3261  EOF Line 3303  EOF
3303  need_busybox_support()  need_busybox_support()
3304  {  {
3305   local cmd   local cmd
3306     local busybox
3307   cmd="$1"   cmd="$1"
3308    
3309   if [[ -x /bin/busybox ]]   for busybox in {,/usr}/bin/busybox
3310   then   do
3311   if [[ $(readlink $(which ${cmd})) = /bin/busybox ]]   if [[ -x ${busybox} ]]
3312   then   then
3313   # needs busybox support   if [[ $(readlink $(type -P ${cmd})) = ${busybox} ]]
3314   return 0   then
3315     # needs busybox support
3316     return 0
3317     fi
3318   fi   fi
3319   fi   done
3320    
3321   # no busybox   # no busybox
3322   return 1   return 1
# Line 3327  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 3336  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 ;;
# Line 3441  mqueryfeature() Line 3488  mqueryfeature()
3488    
3489  mprintfeatures()  mprintfeatures()
3490  {  {
3491   echo "Global features:  ${MAGE_FEATURES_GLOBAL[*]}"   echo -e "${COLRED}Global features:${COLDEFAULT} ${MAGE_FEATURES_GLOBAL[*]}"
3492   echo "Local features:   ${MAGE_FEATURES[*]}"   echo -e "${COLYELLOW}Local features:${COLDEFAULT} ${MAGE_FEATURES[*]}"
3493   echo "Current features: ${MAGE_FEATURES_CURRENT[*]}"   echo -e "${COLGREEN}Current features:${COLDEFAULT} ${MAGE_FEATURES_CURRENT[*]}"
3494  }  }

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