Magellan Linux

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

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

revision 1271 by niro, Wed Apr 27 08:42:24 2011 UTC revision 1502 by niro, Tue Aug 30 10:39:28 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 219  install_files() Line 228  install_files()
228   "${user}" \   "${user}" \
229   "${group}" \   "${group}" \
230   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
231   "${MROOT}${pathto}")" \   "${MROOT}${pathto}")" \
232   "${md5sum}"   "${md5sum}"
233   ;;   ;;
234    
# Line 246  install_files() Line 255  install_files()
255   "${user}" \   "${user}" \
256   "${group}" \   "${group}" \
257   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
258   "${dest_protected}")" \   "${dest_protected}")" \
259   "${md5sum}"   "${md5sum}"
260    
261   # update global MAGE_PROTECT_COUNTER   # update global MAGE_PROTECT_COUNTER
# Line 263  install_files() Line 272  install_files()
272   echo -en "${COLDEFAULT}"   echo -en "${COLDEFAULT}"
273   echo " === FILE: ${MROOT}${pathto}"   echo " === FILE: ${MROOT}${pathto}"
274   fi   fi
275   # simply do nothing here   # simply do nothing here - only fix mtime
276     fix_descriptor ${pkgname}/.files \
277     "${pathto}" \
278     "${posix}" \
279     "${user}" \
280     "${group}" \
281     "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
282     "${MROOT}${pathto}")" \
283     "${md5sum}"
284   ;;   ;;
285   esac   esac
286   done < ${BUILDDIR}/${pkgname}/.files   done < ${BUILDDIR}/${pkgname}/.files
# Line 467  build_doinstall() Line 484  build_doinstall()
484    
485   # sanity checks; abort if not given   # sanity checks; abort if not given
486   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."   [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given."
487    
488   # this is only a wrapper   # this is only a wrapper
489    
490   # NOTE:   # NOTE:
# Line 1255  fetch_packages() Line 1272  fetch_packages()
1272   local opt   local opt
1273   local count_current   local count_current
1274   local count_total   local count_total
1275     local wget_opts
1276    
1277   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."   [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}."
1278    
1279     # filter wget command if busybox was found
1280     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1281    
1282   # get count of total packages   # get count of total packages
1283   declare -i count_current=0   declare -i count_current=0
1284   declare -i count_total=0   declare -i count_total=0
# Line 1303  fetch_packages() Line 1324  fetch_packages()
1324   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1325   [[ ${VERBOSE} = off ]] && opt="--quiet"   [[ ${VERBOSE} = off ]] && opt="--quiet"
1326   wget \   wget \
1327   ${WGET_FETCH_OPTIONS} \   ${wget_opts} \
1328   --directory-prefix=${PKGDIR} \   --directory-prefix=${PKGDIR} \
1329   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}   ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg}
1330   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 1344  syncmage() Line 1365  syncmage()
1365   done   done
1366    
1367   # clean up backup files (foo~)   # clean up backup files (foo~)
1368   find ${MAGEDIR} -name *~ -exec rm '{}' ';'   find ${MAGEDIR} -name \*~ -exec rm '{}' ';'
1369    
1370   # check if a newer mage version is available   # check if a newer mage version is available
1371   is_newer_mage_version_available   is_newer_mage_version_available
# Line 1357  syncmage_tarball() Line 1378  syncmage_tarball()
1378   local temp="$(mktemp -d)"   local temp="$(mktemp -d)"
1379   local mirr mymirr   local mirr mymirr
1380   local opt   local opt
1381     local tar_opts
1382     local wget_opts
1383    
1384   # try to get the md5 marked as latest on the server   # try to get the md5 marked as latest on the server
1385   latest_md5="mage-latest.md5"   latest_md5="mage-latest.md5"
# Line 1364  syncmage_tarball() Line 1387  syncmage_tarball()
1387   # try to get the tarball marked as latest on the server   # try to get the tarball marked as latest on the server
1388   latest_tarball="mage-latest.tar.bz2"   latest_tarball="mage-latest.tar.bz2"
1389    
1390     # filter wget command if busybox was found
1391     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1392    
1393   for mirr in ${MIRRORS}   for mirr in ${MIRRORS}
1394   do   do
1395   # path without distribution   # path without distribution
# Line 1373  syncmage_tarball() Line 1399  syncmage_tarball()
1399   echo "fetching latest md5 from ${mymirr} ..."   echo "fetching latest md5 from ${mymirr} ..."
1400   [[ ${VERBOSE} = off ]] && opt="--quiet"   [[ ${VERBOSE} = off ]] && opt="--quiet"
1401   wget \   wget \
1402   ${WGET_FETCH_OPTIONS} \   ${wget_opts} \
1403   --directory-prefix=${temp} \   --directory-prefix=${temp} \
1404   ${opt} ${mymirr}/rsync/tarballs/${latest_md5}   ${opt} ${mymirr}/rsync/tarballs/${latest_md5}
1405    
1406   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1407   echo "fetching latest tarball from ${mymirr} ..."   echo "fetching latest tarball from ${mymirr} ..."
1408   wget \   wget \
1409   ${WGET_FETCH_OPTIONS} \   ${wget_opts} \
1410   --directory-prefix=${temp} \   --directory-prefix=${temp} \
1411   ${opt} ${mymirr}/rsync/tarballs/${latest_tarball}   ${opt} ${mymirr}/rsync/tarballs/${latest_tarball}
1412   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 1400  syncmage_tarball() Line 1426  syncmage_tarball()
1426   else   else
1427   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1428   echo -n "checking md5sum... "   echo -n "checking md5sum... "
1429   ( cd ${temp}; md5sum --check ${latest_md5} ) || die "md5 for ${latest_tarball} failed"   ( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed"
1430   fi   fi
1431    
1432   if [[ -d ${MAGEDIR} ]]   if [[ -d ${MAGEDIR} ]]
# Line 1410  syncmage_tarball() Line 1436  syncmage_tarball()
1436   rm -rf ${MAGEDIR}   rm -rf ${MAGEDIR}
1437   fi   fi
1438    
1439     if need_busybox_support tar
1440     then
1441     tar_opts="xjf"
1442     else
1443     tar_opts="xjmf"
1444     fi
1445    
1446   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1447   echo "updating mage-tree from tarball ..."   echo "updating mage-tree from tarball ..."
1448   # unpack in dirname of MAGEDIR, as the tarball has already the mage   # unpack in dirname of MAGEDIR, as the tarball has already the mage
1449   tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"   tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball"
1450    
1451   if [[ -d ${temp} ]]   if [[ -d ${temp} ]]
1452   then   then
# Line 1542  get_highest_magefile() Line 1575  get_highest_magefile()
1575   local magefile   local magefile
1576    
1577   # do not list the content of a directory, only the name (-d)   # do not list the content of a directory, only the name (-d)
1578   for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/*)   for magefile in $(ls --format=single-column -v -d ${MAGEDIR}/${PCAT}/${PNAME}/* 2> /dev/null)
1579   do   do
1580   [[ -z ${magefile} ]] && continue   [[ -z ${magefile} ]] && continue
1581   # we exclude subdirs (for stuff like a md5sum dir)   # we exclude subdirs (for stuff like a md5sum dir)
# Line 2429  mage_install() Line 2462  mage_install()
2462   if [[ -n ${MAGE_TARGETS} ]]   if [[ -n ${MAGE_TARGETS} ]]
2463   then   then
2464   # basic svn compat   # basic svn compat
2465   if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2466   then   then
2467   for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2   for i in ${SMAGESCRIPTSDIR}/*/${pname/${MAGE_TARGETS}/}/${pname/${MAGE_TARGETS}/}-${pver}-${pbuild}.smage2
2468   do   do
2469   smage2file="${i}"   smage2file="${i}"
2470   done   done
# Line 2442  mage_install() Line 2475  mage_install()
2475   elif [[ -n ${SPLIT_PACKAGE_BASE} ]]   elif [[ -n ${SPLIT_PACKAGE_BASE} ]]
2476   then   then
2477   # basic svn compat   # basic svn compat
2478   if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2479   then   then
2480   for i in ${SMAGESCRIPTSDIR}/trunk/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2   for i in ${SMAGESCRIPTSDIR}/*/${SPLIT_PACKAGE_BASE}/${SPLIT_PACKAGE_BASE}-${pver}-${pbuild}.smage2
2481   do   do
2482   smage2file="${i}"   smage2file="${i}"
2483   done   done
# Line 2454  mage_install() Line 2487  mage_install()
2487    
2488   else   else
2489   # basic svn compat   # basic svn compat
2490   if [[ -d ${SMAGESCRIPTSDIR}/trunk ]]   if [[ -d ${SMAGESCRIPTSDIR}/.svn ]]
2491   then   then
2492   for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2   for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2
2493   do   do
2494   smage2file="${i}"   smage2file="${i}"
2495   done   done
# Line 2595  md5sum_packages() Line 2628  md5sum_packages()
2628   then   then
2629   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2630   echo -ne "checking md5sum (${count_current}/${count_total}): "   echo -ne "checking md5sum (${count_current}/${count_total}): "
2631   ( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed"   ( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed"
2632   else   else
2633   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2634   echo -e "!! no md5sum file found for ${pkgfile} :("   echo -e "!! no md5sum file found for ${pkgfile} :("
# Line 3043  EOF Line 3076  EOF
3076   return 0   return 0
3077  }  }
3078    
3079    # need_busybox_support ${cmd}
3080    # return 0 (no error = needs busybox support) or return 1 (error = no busybox support required)
3081    need_busybox_support()
3082    {
3083     local cmd
3084     cmd="$1"
3085    
3086     if [[ -x /bin/busybox ]]
3087     then
3088     if [[ $(readlink $(which ${cmd})) = /bin/busybox ]]
3089     then
3090     # needs busybox support
3091     return 0
3092     fi
3093     fi
3094    
3095     # no busybox
3096     return 1
3097    }
3098    
3099    # busybox_filter_wget_options ${wget_opts}
3100    busybox_filter_wget_options()
3101    {
3102     local opts="$@"
3103     local i
3104     local fixed_opts
3105    
3106     if need_busybox_support wget
3107     then
3108     for i in ${opts}
3109     do
3110     # show only the allowed ones
3111     case ${i} in
3112     -c|--continue) fixed_opts+=" -c" ;;
3113     -s|--spider) fixed_opts+=" -s" ;;
3114     -q|--quiet) fixed_opts+=" -q" ;;
3115     -O|--output-document) shift; fixed_opts+=" -O $1" ;;
3116     --header) shift; fixed_opts+=" --header $1" ;;
3117     -Y|--proxy) shift; fixed_opts+=" -Y $1" ;;
3118     -P) shift; fixed_opts+=" -P $1" ;;
3119     --no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;;
3120     -U|--user-agent) shift; fixed_opts+=" -U ${i}" ;;
3121     # simply drop all other opts
3122     *) continue ;;
3123     esac
3124     done
3125    
3126     echo "${fixed_opts}"
3127     else
3128     echo "${opts}"
3129     fi
3130    }

Legend:
Removed from v.1271  
changed lines
  Added in v.1502