--- trunk/mage/usr/lib/mage/mage4.functions.sh 2011/04/27 08:42:24 1271 +++ trunk/mage/usr/lib/mage/mage4.functions.sh 2011/08/30 10:39:28 1502 @@ -23,6 +23,7 @@ local pkgtype local count_current local count_total + local tar_opts # get count of total packages declare -i count_current=0 @@ -54,8 +55,16 @@ 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 xjmf ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" + tar ${tar_opts} ${PKGDIR}/${pkg} -C ${BUILDDIR} || die "Unpacking package ${pkg}" done # add a crlf for a better view @@ -219,7 +228,7 @@ "${user}" \ "${group}" \ "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ - "${MROOT}${pathto}")" \ + "${MROOT}${pathto}")" \ "${md5sum}" ;; @@ -246,7 +255,7 @@ "${user}" \ "${group}" \ "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ - "${dest_protected}")" \ + "${dest_protected}")" \ "${md5sum}" # update global MAGE_PROTECT_COUNTER @@ -263,7 +272,15 @@ echo -en "${COLDEFAULT}" echo " === FILE: ${MROOT}${pathto}" fi - # simply do nothing here + # simply do nothing here - only fix mtime + fix_descriptor ${pkgname}/.files \ + "${pathto}" \ + "${posix}" \ + "${user}" \ + "${group}" \ + "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \ + "${MROOT}${pathto}")" \ + "${md5sum}" ;; esac done < ${BUILDDIR}/${pkgname}/.files @@ -467,7 +484,7 @@ # sanity checks; abort if not given [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." - + # this is only a wrapper # NOTE: @@ -1255,9 +1272,13 @@ local opt local count_current local count_total + local wget_opts [ -z "${MIRRORS}" ] && die "You have no mirrors defined. Please edit your ${MAGERC}." + # filter wget command if busybox was found + wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" + # get count of total packages declare -i count_current=0 declare -i count_total=0 @@ -1303,7 +1324,7 @@ echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " [[ ${VERBOSE} = off ]] && opt="--quiet" wget \ - ${WGET_FETCH_OPTIONS} \ + ${wget_opts} \ --directory-prefix=${PKGDIR} \ ${opt} ${mirr}/${PACKAGES_SERVER_PATH}/${pkg} if [[ $? = 0 ]] @@ -1344,7 +1365,7 @@ done # clean up backup files (foo~) - find ${MAGEDIR} -name *~ -exec rm '{}' ';' + find ${MAGEDIR} -name \*~ -exec rm '{}' ';' # check if a newer mage version is available is_newer_mage_version_available @@ -1357,6 +1378,8 @@ local temp="$(mktemp -d)" local mirr mymirr local opt + local tar_opts + local wget_opts # try to get the md5 marked as latest on the server latest_md5="mage-latest.md5" @@ -1364,6 +1387,9 @@ # try to get the tarball marked as latest on the server latest_tarball="mage-latest.tar.bz2" + # filter wget command if busybox was found + wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" + for mirr in ${MIRRORS} do # path without distribution @@ -1373,14 +1399,14 @@ echo "fetching latest md5 from ${mymirr} ..." [[ ${VERBOSE} = off ]] && opt="--quiet" wget \ - ${WGET_FETCH_OPTIONS} \ + ${wget_opts} \ --directory-prefix=${temp} \ ${opt} ${mymirr}/rsync/tarballs/${latest_md5} echo -ne "${COLBLUE} --- ${COLDEFAULT}" echo "fetching latest tarball from ${mymirr} ..." wget \ - ${WGET_FETCH_OPTIONS} \ + ${wget_opts} \ --directory-prefix=${temp} \ ${opt} ${mymirr}/rsync/tarballs/${latest_tarball} if [[ $? = 0 ]] @@ -1400,7 +1426,7 @@ else echo -ne "${COLBLUE} --- ${COLDEFAULT}" echo -n "checking md5sum... " - ( cd ${temp}; md5sum --check ${latest_md5} ) || die "md5 for ${latest_tarball} failed" + ( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed" fi if [[ -d ${MAGEDIR} ]] @@ -1410,10 +1436,17 @@ rm -rf ${MAGEDIR} fi + if need_busybox_support tar + then + tar_opts="xjf" + else + tar_opts="xjmf" + fi + echo -ne "${COLBLUE} --- ${COLDEFAULT}" echo "updating mage-tree from tarball ..." # unpack in dirname of MAGEDIR, as the tarball has already the mage - tar xjmf ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball" + tar ${tar_opts} ${temp}/${latest_tarball} -C ${MAGEDIR%/*} || die "Unpacking tarball" if [[ -d ${temp} ]] then @@ -1542,7 +1575,7 @@ local magefile # do not list the content of a directory, only the name (-d) - 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) do [[ -z ${magefile} ]] && continue # we exclude subdirs (for stuff like a md5sum dir) @@ -2429,9 +2462,9 @@ if [[ -n ${MAGE_TARGETS} ]] then # basic svn compat - if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] + if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] then - 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 do smage2file="${i}" done @@ -2442,9 +2475,9 @@ elif [[ -n ${SPLIT_PACKAGE_BASE} ]] then # basic svn compat - if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] + if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] then - 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 do smage2file="${i}" done @@ -2454,9 +2487,9 @@ else # basic svn compat - if [[ -d ${SMAGESCRIPTSDIR}/trunk ]] + if [[ -d ${SMAGESCRIPTSDIR}/.svn ]] then - for i in ${SMAGESCRIPTSDIR}/trunk/*/${pname}/${pname}-${pver}-${pbuild}.smage2 + for i in ${SMAGESCRIPTSDIR}/*/${pname}/${pname}-${pver}-${pbuild}.smage2 do smage2file="${i}" done @@ -2595,7 +2628,7 @@ then echo -ne "${COLBLUE} *** ${COLDEFAULT}" echo -ne "checking md5sum (${count_current}/${count_total}): " - ( cd ${PKGDIR}; md5sum --check ${md5file}) || die "md5 for ${pkgfile} failed" + ( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed" else echo -ne "${COLBLUE} --- ${COLDEFAULT}" echo -e "!! no md5sum file found for ${pkgfile} :(" @@ -3043,3 +3076,55 @@ return 0 } +# need_busybox_support ${cmd} +# return 0 (no error = needs busybox support) or return 1 (error = no busybox support required) +need_busybox_support() +{ + local cmd + cmd="$1" + + if [[ -x /bin/busybox ]] + then + if [[ $(readlink $(which ${cmd})) = /bin/busybox ]] + then + # needs busybox support + return 0 + fi + fi + + # no busybox + return 1 +} + +# busybox_filter_wget_options ${wget_opts} +busybox_filter_wget_options() +{ + local opts="$@" + local i + local fixed_opts + + if need_busybox_support wget + then + for i in ${opts} + do + # show only the allowed ones + case ${i} in + -c|--continue) fixed_opts+=" -c" ;; + -s|--spider) fixed_opts+=" -s" ;; + -q|--quiet) fixed_opts+=" -q" ;; + -O|--output-document) shift; fixed_opts+=" -O $1" ;; + --header) shift; fixed_opts+=" --header $1" ;; + -Y|--proxy) shift; fixed_opts+=" -Y $1" ;; + -P) shift; fixed_opts+=" -P $1" ;; + --no-check-certificate) fixed_opts+=" --no-check-certificate ${i}" ;; + -U|--user-agent) shift; fixed_opts+=" -U ${i}" ;; + # simply drop all other opts + *) continue ;; + esac + done + + echo "${fixed_opts}" + else + echo "${opts}" + fi +}