Magellan Linux

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

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

revision 1675 by niro, Mon Feb 6 09:45:23 2012 UTC revision 2156 by niro, Wed Aug 14 07:25:43 2013 UTC
# Line 102  mcheckemptydir() Line 102  mcheckemptydir()
102   return ${retval}   return ${retval}
103  }  }
104    
105    unpack_package()
106    {
107     local magefile="$1"
108     local pkg
109     local pkgtype
110     local tar_opts
111    
112     pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}"
113     pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"
114    
115     xtitle "[ Unpacking ${pkg} ]"
116    
117     # abort on virtual pkg
118     if [[ ${pkgtype} = virtual ]]
119     then
120     echo -ne " ${COLBLUE}---${COLDEFAULT}"
121     echo " !unpack virtual ${pkg/.${PKGSUFFIX}/} ... "
122     continue
123     fi
124    
125     # abort on sources pkg
126     if [[ ${pkgtype} = sources ]]
127     then
128     echo -ne " ${COLBLUE}---${COLDEFAULT}"
129     echo " !unpack sources ${pkg/.${PKGSUFFIX}/} ... "
130     continue
131     fi
132    
133     # busybox?
134     if need_busybox_support tar
135     then
136     tar_opts="xjf"
137     else
138     tar_opts="xjmf"
139     fi
140    
141     echo -e " ${COLBLUE}***${COLDEFAULT} unpacking ${pkg} ... "
142     tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"
143    }
144    
145  unpack_packages()  unpack_packages()
146  {  {
147   local list="$@"   local list="$@"
148   local magefile   local magefile
  local pkg  
  local pkgtype  
149   local count_current   local count_current
150   local count_total   local count_total
151   local tar_opts   local tar_opts
# Line 120  unpack_packages() Line 158  unpack_packages()
158    
159   for magefile in ${list}   for magefile in ${list}
160   do   do
161   pkg="$(get_value_from_magefile PKGNAME ${magefile}).${PKGSUFFIX}"   unpack_package "${magefile}"
  pkgtype="$(get_value_from_magefile PKGTYPE ${magefile})"  
   
162   (( 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}"  
163   done   done
164    
165   # add a crlf for a better view   # add a crlf for a better view
# Line 171  fix_mtime() Line 179  fix_mtime()
179   mtime=$(stat -c %Y "${reference}")   mtime=$(stat -c %Y "${reference}")
180   touch \   touch \
181   --no-create \   --no-create \
182     --no-dereference \
183   --time=mtime \   --time=mtime \
184   --reference "${reference}" \   --reference="${reference}" \
185   "${pathto}"   "${pathto}"
186    
187   echo "${mtime}"   echo "${mtime}"
# Line 414  install_symlinks() Line 423  install_symlinks()
423    
424   ln -snf "${link}" "${MROOT}${pathto}"   ln -snf "${link}" "${MROOT}${pathto}"
425    
426  # # fix mtime and db   # fix mtime and db
427  # fix_descriptor ${pkgname}/.symlinks \   fix_descriptor ${pkgname}/.symlinks \
428  # "${pathto}" \   "${pathto}" \
429  # "${posix}" \   "${posix}" \
430  # "${link}" \   "${link}" \
431  # "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
432  # "${MROOT}${pathto}")"   "${MROOT}${pathto}")"
433    
434   done < ${BUILDDIR}/${pkgname}/.symlinks   done < ${BUILDDIR}/${pkgname}/.symlinks
435    
# Line 807  compare_mtime() Line 816  compare_mtime()
816    
817   mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)"   mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)"
818    
819   # if $pathto is a symlink than compare linked binary   # no extra handlink for symlinks anymore as fix_mtime
820   if [ -L "${MROOT}${pathto}" ]   # uses --no-dereference, compare directly
821   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  
822    
823   [[ ${mtime} = ${x} ]] && return 0   [[ ${mtime} = ${x} ]] && return 0
824    
# Line 1615  syncmage_tarball() Line 1613  syncmage_tarball()
1613   then   then
1614   if ! mcheckemptydir ${MAGEDIR}   if ! mcheckemptydir ${MAGEDIR}
1615   then   then
1616   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
1617   fi   fi
1618   else   else
1619   rm -rf ${MAGEDIR}   rm -rf ${MAGEDIR}
# Line 1880  count_protected_files() Line 1878  count_protected_files()
1878   local filename="${file##*/}"   local filename="${file##*/}"
1879   local count   local count
1880   local output   local output
1881     local oldprotected
1882   local i   local i
1883     local x
1884    
1885   declare -i count=0   # hack; do not honor a global set IFS like '§'
1886     local IFS
1887    
1888     count=0
1889    
1890   # check if there are already protected files   # check if there are already protected files
1891   for oldpretected in $(find ${dirname} -iname "._cfg????_${filename}" |   for oldprotected in $(find ${dirname} -iname "._cfg????_${filename}" |
1892   sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |   sed -e "s:\(^.*/\)\(._cfg*_\)\(/.*$\):\1\2\3\%\2\%\3:" |
1893   sort -t'%' -k3 -k2 | cut -f1 -d'%')   sort -t'%' -k3 -k2 | cut -f1 -d'%')
1894   do   do
1895   count=$(echo ${oldpretected} | cut -d_ -f2 | sed -e "s:cfg::")   count="$(echo ${oldprotected} | sed 's:.*\/._cfg\(.*\)_.*:\1:')"
1896   done   done
1897   (( count ++ ))  
1898     # convert 0001 -> 1; 0120 -> 120 etc
1899     # use bash internal base functions to this task
1900     x="$((10#${count}))"
1901     for (( i=0; i<x; i++ ))
1902     do
1903     if [[ ${count:${i}:1} != 0 ]]
1904     then
1905     count="${count:${i}}"
1906     break
1907     fi
1908     done
1909    
1910     count="$(( ${count}+1 ))"
1911    
1912   # fill output up with zeros   # fill output up with zeros
1913   for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done   for (( i=${#count}; i < 4; i++ )); do output="${output}0"; done
# Line 2681  mage_install() Line 2697  mage_install()
2697   if [[ ${PKGTYPE} != virtual ]] && \   if [[ ${PKGTYPE} != virtual ]] && \
2698   [[ ${PKGTYPE} != sources ]]   [[ ${PKGTYPE} != sources ]]
2699   then   then
2700     unpack_package "${magefile}"
2701   echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... "   echo -e " ${COLBLUE}***${COLDEFAULT} merging files into system ... "
2702   build_doinstall ${PKGNAME}   build_doinstall ${PKGNAME}
2703   fi   fi
# Line 3112  pkgsearch() Line 3129  pkgsearch()
3129   "") continue;;   "") continue;;
3130   esac   esac
3131    
3132   deps="${deps} $(basename ${dep%-*})"   if [[ -z ${deps} ]]
3133     then
3134     deps="$(basename ${dep%-*})"
3135     else
3136     deps="${deps} $(basename ${dep%-*})"
3137     fi
3138   done << EOF   done << EOF
3139  ${depsfull}  ${depsfull}
3140  EOF  EOF
# Line 3123  EOF Line 3145  EOF
3145   "") continue;;   "") continue;;
3146   esac   esac
3147    
3148   sdeps="${sdeps} $(basename ${dep%-*})"   if [[ -z ${sdeps} ]]
3149     then
3150     sdeps="$(basename ${dep%-*})"
3151     else
3152     sdeps="${sdeps} $(basename ${dep%-*})"
3153     fi
3154   done << EOF   done << EOF
3155  ${sdepsfull}  ${sdepsfull}
3156  EOF  EOF
# Line 3137  EOF Line 3164  EOF
3164   then   then
3165   echo "      License:  ${license}"   echo "      License:  ${license}"
3166   fi   fi
3167   echo "      Depends: ${deps}"   echo "      Depends:  ${deps}"
3168   echo "      SDepends: ${sdeps}"   echo "      SDepends: ${sdeps}"
3169   echo   echo
3170    
# Line 3254  EOF Line 3281  EOF
3281  need_busybox_support()  need_busybox_support()
3282  {  {
3283   local cmd   local cmd
3284     local busybox
3285   cmd="$1"   cmd="$1"
3286    
3287   if [[ -x /bin/busybox ]]   for busybox in {,/usr}/bin/busybox
3288   then   do
3289   if [[ $(readlink $(which ${cmd})) = /bin/busybox ]]   if [[ -x ${busybox} ]]
3290   then   then
3291   # needs busybox support   if [[ $(readlink $(which ${cmd})) = ${busybox} ]]
3292   return 0   then
3293     # needs busybox support
3294     return 0
3295     fi
3296   fi   fi
3297   fi   done
3298    
3299   # no busybox   # no busybox
3300   return 1   return 1
# Line 3434  mqueryfeature() Line 3465  mqueryfeature()
3465    
3466  mprintfeatures()  mprintfeatures()
3467  {  {
3468   echo "Global features:  ${MAGE_FEATURES_GLOBAL[*]}"   echo -e "${COLRED}Global features:${COLDEFAULT} ${MAGE_FEATURES_GLOBAL[*]}"
3469   echo "Local features:   ${MAGE_FEATURES[*]}"   echo -e "${COLYELLOW}Local features:${COLDEFAULT} ${MAGE_FEATURES[*]}"
3470   echo "Current features: ${MAGE_FEATURES_CURRENT[*]}"   echo -e "${COLGREEN}Current features:${COLDEFAULT} ${MAGE_FEATURES_CURRENT[*]}"
3471  }  }

Legend:
Removed from v.1675  
changed lines
  Added in v.2156