--- trunk/mage/usr/lib/mage/mage4.functions.sh 2011/12/28 12:06:30 1583 +++ trunk/mage/usr/lib/mage/mage4.functions.sh 2011/12/28 12:23:50 1584 @@ -206,7 +206,7 @@ while read pathto posix user group do [ -z "${pathto}" ] && continue - [[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR: ${MROOT}${pathto}" + mqueryfeature "verbose" && echo -e "\t>>> DIR: ${MROOT}${pathto}" # monitors /etc/env.d -> env-rebuild [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true @@ -282,7 +282,7 @@ case ${retval} in # file is not protected - (over)write it 0|3) - [[ ${VERBOSE} = on ]] && echo -e "\t>>> FILE: ${MROOT}${pathto}" + mqueryfeature "verbose" && echo -e "\t>>> FILE: ${MROOT}${pathto}" install -m "${posix}" -o "${user}" -g "${group}" \ ${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \ "${MROOT}${pathto}" @@ -300,7 +300,7 @@ # file is protected, write backup file 2) - if [[ ${VERBOSE} = on ]] + if mqueryfeature "verbose" then echo -en "${COLRED}" echo -n "! prot " @@ -331,7 +331,7 @@ # file is protected but ignored, delete the update/do nothing 4) - if [[ ${VERBOSE} = on ]] + if mqueryfeature "verbose" then echo -en "${COLRED}" echo -n "! ignr " @@ -390,7 +390,7 @@ while read pathto posix link mtime do [ -z "${pathto}" ] && continue - [[ ${VERBOSE} = on ]] && echo -e "\t>>> LINK: ${MROOT}${pathto}" + mqueryfeature "verbose" && echo -e "\t>>> LINK: ${MROOT}${pathto}" ln -snf "${link}" "${MROOT}${pathto}" @@ -440,7 +440,7 @@ while read pathto posix major minor user group do [ -z "${pathto}" ] && continue - [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}" + mqueryfeature "verbose" && echo -e "\t>>> PIPE: ${MROOT}${pathto}" mknod -m "${posix}" "${MROOT}${pathto}" # make it optional atm !! @@ -484,7 +484,7 @@ while read pathto posix major minor user group do [ -z "${pathto}" ] && continue - [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}" + mqueryfeature "verbose" && echo -e "\t>>> CHAR: ${MROOT}${pathto}" mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}" @@ -528,7 +528,7 @@ while read pathto posix user group do [ -z "${pathto}" ] && continue - [[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}" + mqueryfeature "verbose" && echo -e "\t>>> FIFO: ${MROOT}${pathto}" mkfifo -m "${posix}" "${MROOT}${pathto}" chown "${user}:${group}" "${MROOT}${pathto}" @@ -862,7 +862,7 @@ [ -z "${pathto}" ] && continue if [ ! -L "${MROOT}${pathto}" ] then - [[ ${VERBOSE} = on ]] && \ + mqueryfeature "verbose" && \ echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}" continue fi @@ -874,12 +874,12 @@ # 1=keep me # case ${retval} in 0) - [[ ${VERBOSE} = on ]] && echo -e "\t<<< LINK: ${MROOT}${pathto}" + mqueryfeature "verbose" && echo -e "\t<<< LINK: ${MROOT}${pathto}" rm "${MROOT}${pathto}" ;; 1) - [[ ${VERBOSE} = on ]] && \ + mqueryfeature "verbose" && \ echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}" ;; esac @@ -946,7 +946,7 @@ if [ ! -e "${MROOT}${pathto}" ] then - [[ ${VERBOSE} = on ]] && \ + mqueryfeature "verbose" && \ echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}" continue fi @@ -972,13 +972,13 @@ case ${retval} in # file is not protected - delete it 0|3) - [[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}" + mqueryfeature "verbose" && echo -e "\t<<< FILE: ${MROOT}${pathto}" rm "${MROOT}${pathto}" ;; # file is protected, do not delete 2) - if [[ ${VERBOSE} = on ]] + if mqueryfeature "verbose" then echo -en "${COLRED}" echo -n "! prot " @@ -989,7 +989,7 @@ # file is protected but ignored, delete the update/do nothing 4) - if [[ ${VERBOSE} = on ]] + if mqueryfeature "verbose" then echo -en "${COLRED}" echo -n "! ignr " @@ -1001,7 +1001,7 @@ esac ;; 1) - [[ ${VERBOSE} = on ]] && \ + mqueryfeature "verbose" && \ echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}" ;; esac @@ -1063,7 +1063,7 @@ do [ -z "${pathto}" ] && continue - [[ ${VERBOSE} = on ]] && echo -e "\t<<< PIPE: ${MROOT}${pathto}" + mqueryfeature "verbose" && echo -e "\t<<< PIPE: ${MROOT}${pathto}" rm "${MROOT}${pathto}" done < ${MROOT}${INSTALLDB}/${pfull}/.pipes @@ -1123,7 +1123,7 @@ do [ -z "${pathto}" ] && continue - [[ ${VERBOSE} = on ]] && echo -e "\t<<< CHAR: ${MROOT}${pathto}" + mqueryfeature "verbose" && echo -e "\t<<< CHAR: ${MROOT}${pathto}" rm "${MROOT}${pathto}" done < ${MROOT}${INSTALLDB}/${pfull}/.char @@ -1185,7 +1185,7 @@ do [ -z "${pathto}" ] && continue - [[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}" + mqueryfeature "verbose" && echo -e "\t<<< FIFO: ${MROOT}${pathto}" rm "${MROOT}${pathto}" done < ${MROOT}${INSTALLDB}/${pfull}/.fifo @@ -1246,7 +1246,7 @@ if [ ! -d "${MROOT}${pathto}" ] then - [[ ${VERBOSE} = on ]] && \ + mqueryfeature "verbose" && \ echo -e "${COLRED}! exist${COLDEFAULT} === DIR: ${MROOT}${pathto}" continue fi @@ -1254,7 +1254,7 @@ # exclude .keep directories if [ -f "${MROOT}${pathto}/.keep" ] then - [[ ${VERBOSE} = on ]] && \ + mqueryfeature "verbose" && \ echo -e "${COLRED}! .keep${COLDEFAULT} === DIR: ${MROOT}${pathto}" continue fi @@ -1267,9 +1267,9 @@ if rmdir "${MROOT}${pathto}" &> /dev/null then - [[ ${VERBOSE} = on ]] && echo -e "\t<<< DIR: ${MROOT}${pathto}" + mqueryfeature "verbose" && echo -e "\t<<< DIR: ${MROOT}${pathto}" else - [[ ${VERBOSE} = on ]] && \ + mqueryfeature "verbose" && \ echo -e "${COLRED}! empty${COLDEFAULT} === DIR: ${MROOT}${pathto}" fi done @@ -1401,7 +1401,7 @@ real_uris="$(convertmirrors ${uri})" # verbose or not - [[ ${VERBOSE} = off ]] && wget_opts="--quiet" + mqueryfeature "!verbose" && wget_opts="--quiet" # filter wget options if busybox was found wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" @@ -1488,7 +1488,6 @@ echo -ne " ${COLBLUE}***${COLDEFAULT}" echo -e " fetching (${count_current}/${count_total}): ${pkg} ... " mdownload --uri "package://${pkg}" --dir "${PKGDIR}" || die "Could not download ${pkg}" - if [ ! -f ${PKGDIR}/${pkg} ] then die "Package '${pkg}' after download not found in '${PKGDIR}'" @@ -1551,7 +1550,7 @@ echo -ne "${COLBLUE} --- ${COLDEFAULT}" echo "fetching latest md5 from ${mymirr} ..." - [[ ${VERBOSE} = off ]] && opt="--quiet" + mqueryfeature "!verbose" && opt="--quiet" wget \ ${wget_opts} \ --directory-prefix=${temp} \ @@ -1738,7 +1737,7 @@ then HIGHEST_MAGEFILE=${magefile} #for debug only - [[ ${MAGEDEBUG} = on ]] && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" + mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}" fi done @@ -2146,11 +2145,11 @@ then for i in $* do - [[ ${MAGEDEBUG} = on ]] && \ + mqueryfeature "debug" && \ echo "--- Including ${MAGEDIR}/include/${i}.minc" source ${MAGEDIR}/include/${i}.minc done - [[ ${MAGEDEBUG} = on ]] && echo + mqueryfeature "debug" && echo fi } @@ -3136,7 +3135,7 @@ eval "${functions}() { ${include}_${functions} ; }" # debug - [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}" + mqueryfeature "debug" && typeset -f "${functions}" shift done @@ -3274,3 +3273,123 @@ return ${retval} } + +known_mage_feature() +{ + local feature="$1" + local retval + + case "${feature}" in + autosvc|!autosvc) retval=0 ;; + buildlog|!buildlog) retval=0 ;; + ccache|!ccache) retval=0 ;; + check|!check) retval=0 ;; + compressdoc|!compressdoc) retval=0 ;; + distcc|!distcc) retval=0 ;; + kernelsrcunpack|!kernelsrcunpack) retval=0 ;; + libtool|!libtool) retval=0 ;; + linuxsymlink|!linuxsymlink) retval=0 ;; + pkgbuild|!pkgbuild) retval=0 ;; + purge|!purge) retval=0 ;; + qalint|!qalint) retval=0 ;; + regentree|!regentree) retval=0 ;; + stepbystep|!stepbystep) retval=0 ;; + srcpkgbuild|!srcpkgbuild) retval=0 ;; + srcpkgtarball|!srcpkgtarball) retval=0 ;; + strip|!strip) retval=0 ;; + *) retval=1 ;; + esac + + return "${retval}" +} + +load_mage_features() +{ + echo "loading mage-features... " + for i in ${MAGE_FEATURES_GLOBAL[*]} ${MAGE_FEATURES[*]} + do + FVERBOSE=off msetfeature ${i} + done + + echo "done" +} + +msetfeature() +{ + local feature + local count + local i + local found + + for feature in $@ + do + found=0 + count="${#MAGE_FEATURES_CURRENT[*]}" + + if ! known_mage_feature "${feature}" + then + [[ ${FVERBOSE} = off ]] || echo "unkown feature ${feature}, ignoring it" + return 3 + fi + + for ((i=0; i