--- trunk/mage/usr/lib/mage/mage4.functions.sh 2011/01/28 20:37:27 1209 +++ trunk/mage/usr/lib/mage/mage4.functions.sh 2011/05/12 21:29:31 1289 @@ -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 @@ -354,13 +371,17 @@ # sets fieldseperator to "§" instead of " " IFS=§ - while read pathto posix user group + while read pathto posix major minor user group do [ -z "${pathto}" ] && continue [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}" - mkfifo -m "${posix}" "${MROOT}${pathto}" - chown "${user}:${group}" "${MROOT}${pathto}" + mknod -m "${posix}" "${MROOT}${pathto}" + # make it optional atm !! + if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] + then + chown "${user}:${group}" "${MROOT}${pathto}" b "${major}" "${minor}" + fi done < ${BUILDDIR}/${pkgname}/.pipes # very important: unsetting the '§' fieldseperator @@ -399,8 +420,13 @@ [ -z "${pathto}" ] && continue [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}" - mknod -m ${posix} "${MROOT}${pathto}" c ${major} ${minor} - chown "${user}:${group}" "${MROOT}${pathto}" + mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}" + + # make it optional atm !! + if [[ ! -z ${user} ]] && [[ ! -z ${group} ]] + then + chown "${user}:${group}" "${MROOT}${pathto}" + fi done < ${BUILDDIR}/${pkgname}/.char # very important: unsetting the '§' fieldseperator @@ -426,7 +452,9 @@ # check needed global vars [ -z "${BUILDDIR}" ] && die "install_fifos() \$BUILDDIR not set." - [ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found" + # make it optional atm !! + #[ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && die "install_fifos() .fifo not found" + [ ! -f ${BUILDDIR}/${pkgname}/.fifo ] && return # sets fieldseperator to "§" instead of " " IFS=§ @@ -456,7 +484,7 @@ # sanity checks; abort if not given [ -z "${pkgname}" ] && die "build_doinstall() \$pkgname not given." - + # this is only a wrapper # NOTE: @@ -553,8 +581,11 @@ local i for i in .char .dirs .files .pipes .symlinks .fifo do - install -m 0644 ${BUILDDIR}/${pkgname}/${i} \ - ${dbrecorddir}/${i} + # make .fifo optional atm + if [[ -f ${BUILDDIR}/${pkgname}/${i} ]] + then + install -m 0644 ${BUILDDIR}/${pkgname}/${i} ${dbrecorddir}/${i} + fi done ;; esac @@ -1077,7 +1108,9 @@ # check needed global vars [ -z "${BUILDDIR}" ] && die "remove_fifos() \$BUILDDIR not set." - [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found" + # make it optional atm !! + #[ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && die "remove_fifos() .fifo not found" + [ ! -f ${MROOT}${INSTALLDB}/${pfull}/.fifo ] && return # sets fieldseperator to "§" instead of " " IFS=§ @@ -1239,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 @@ -1287,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 ]] @@ -1341,6 +1378,7 @@ local temp="$(mktemp -d)" local mirr mymirr local opt + local tar_opts # try to get the md5 marked as latest on the server latest_md5="mage-latest.md5" @@ -1384,7 +1422,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} ]] @@ -1394,10 +1432,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 @@ -2579,7 +2624,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} :(" @@ -3027,3 +3072,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 + else + # no busybox + return 1 + fi + fi +} + +# 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 +}