Magellan Linux

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

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

revision 1272 by niro, Wed Apr 27 08:42:24 2011 UTC revision 1273 by niro, Wed Apr 27 09:45:07 2011 UTC
# Line 23  unpack_packages() Line 23  unpack_packages()
23   local pkgtype   local pkgtype
24   local count_current   local count_current
25   local count_total   local count_total
26     local tar_opts
27    
28   # get count of total packages   # get count of total packages
29   declare -i count_current=0   declare -i count_current=0
# Line 54  unpack_packages() Line 55  unpack_packages()
55   continue   continue
56   fi   fi
57    
58     # busybox?
59     if need_busybox_support tar
60     then
61     tar_opts="xjf"
62     else
63     tar_opts="xjmf"
64     fi
65    
66   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "   echo -e " ${COLBLUE}***${COLDEFAULT} unpacking (${count_current}/${count_total}): ${pkg} ... "
67   tar xjmf ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"   tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}"
68   done   done
69    
70   # add a crlf for a better view   # add a crlf for a better view
# Line 1255  fetch_packages() Line 1264  fetch_packages()
1264   local opt   local opt
1265   local count_current   local count_current
1266   local count_total   local count_total
1267     local wget_opts
1268    
1269   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."
1270    
1271     # filter wget command if busybox was found
1272     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1273    
1274   # get count of total packages   # get count of total packages
1275   declare -i count_current=0   declare -i count_current=0
1276   declare -i count_total=0   declare -i count_total=0
# Line 1303  fetch_packages() Line 1316  fetch_packages()
1316   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1317   [[ ${VERBOSE} = off ]] && opt="--quiet"   [[ ${VERBOSE} = off ]] && opt="--quiet"
1318   wget \   wget \
1319   ${WGET_FETCH_OPTIONS} \   ${wget_opts} \
1320   --directory-prefix=${PKGDIR} \   --directory-prefix=${PKGDIR} \
1321   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}
1322   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 1357  syncmage_tarball() Line 1370  syncmage_tarball()
1370   local temp="$(mktemp -d)"   local temp="$(mktemp -d)"
1371   local mirr mymirr   local mirr mymirr
1372   local opt   local opt
1373     local tar_opts
1374    
1375   # try to get the md5 marked as latest on the server   # try to get the md5 marked as latest on the server
1376   latest_md5="mage-latest.md5"   latest_md5="mage-latest.md5"
# Line 1400  syncmage_tarball() Line 1414  syncmage_tarball()
1414   else   else
1415   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1416   echo -n "checking md5sum... "   echo -n "checking md5sum... "
1417   ( cd ${temp}; md5sum --check ${latest_md5} ) || die "md5 for ${latest_tarball} failed"   ( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed"
1418   fi   fi
1419    
1420   if [[ -d ${MAGEDIR} ]]   if [[ -d ${MAGEDIR} ]]
# Line 1410  syncmage_tarball() Line 1424  syncmage_tarball()
1424   rm -rf ${MAGEDIR}   rm -rf ${MAGEDIR}
1425   fi   fi
1426    
1427     if need_busybox_support tar
1428     then
1429     tar_opts="xjf"
1430     else
1431     tar_opts="xjmf"
1432     fi
1433    
1434   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1435   echo "updating mage-tree from tarball ..."   echo "updating mage-tree from tarball ..."
1436   # unpack in dirname of MAGEDIR, as the tarball has already the mage   # unpack in dirname of MAGEDIR, as the tarball has already the mage
1437   tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"   tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1438    
1439   if [[ -d ${temp} ]]   if [[ -d ${temp} ]]
1440   then   then
# Line 2595  md5sum_packages() Line 2616  md5sum_packages()
2616   then   then
2617   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2618   echo -ne "checking md5sum (${count_current}/${count_total}): "   echo -ne "checking md5sum (${count_current}/${count_total}): "
2619   ( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed"   ( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed"
2620   else   else
2621   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2622   echo -e "!! no md5sum file found for ${pkgfile} :("   echo -e "!! no md5sum file found for ${pkgfile} :("
# Line 3043  EOF Line 3064  EOF
3064   return 0   return 0
3065  }  }
3066    
3067    # need_busybox_support ${cmd}
3068    # return 0 (no error = needs busybox support) or return 1 (error = no busybox support required)
3069    need_busybox_support()
3070    {
3071     local cmd
3072     cmd="$1"
3073    
3074     if [[ -x /bin/busybox ]]
3075     then
3076     if [[ $(readlink $(which ${cmd})) = /bin/busybox ]]
3077     then
3078     # needs busybox support
3079     return 0
3080     else
3081     # no busybox
3082     return 1
3083     fi
3084     fi
3085    }
3086    
3087    # busybox_filter_wget_options ${wget_opts}
3088    busybox_filter_wget_options()
3089    {
3090     local opts="$@"
3091     local i
3092     local fixed_opts
3093    
3094     if need_busybox_support wget
3095     then
3096     for i in ${opts}
3097     do
3098     # show only the allowed ones
3099     case ${i} in
3100     -c|--continue) fixed_opts+=" -c" ;;
3101     -s|--spider) fixed_opts+=" -s" ;;
3102     -q|--quiet) fixed_opts+=" -q" ;;
3103     -O|--output-document) shift; fixed_opts+=" -O $1" ;;
3104     --header) shift; fixed_opts+=" --header $1" ;;
3105     -Y|--proxy) shift; fixed_opts+=" -Y $1" ;;
3106     -P) shift; fixed_opts+=" -P $1" ;;
3107     --no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;;
3108     -U|--user-agent) shift; fixed_opts+=" -U ${i}" ;;
3109     # simply drop all other opts
3110     *) continue ;;
3111     esac
3112     done
3113    
3114     echo "${fixed_opts}"
3115     else
3116     echo "${opts}"
3117     fi
3118    }

Legend:
Removed from v.1272  
changed lines
  Added in v.1273