Magellan Linux

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

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

revision 1583 by niro, Tue Dec 27 10:43:40 2011 UTC revision 1584 by niro, Wed Dec 28 12:23:50 2011 UTC
# Line 206  install_directories() Line 206  install_directories()
206   while read pathto posix user group   while read pathto posix user group
207   do   do
208   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
209   [[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR:  ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> DIR:  ${MROOT}${pathto}"
210    
211   # monitors /etc/env.d -> env-rebuild   # monitors /etc/env.d -> env-rebuild
212   [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true   [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true
# Line 282  install_files() Line 282  install_files()
282   case ${retval} in   case ${retval} in
283   # file is not protected - (over)write it   # file is not protected - (over)write it
284   0|3)   0|3)
285   [[ ${VERBOSE} = on ]] && echo -e "\t>>> FILE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> FILE: ${MROOT}${pathto}"
286   install -m "${posix}" -o "${user}" -g "${group}" \   install -m "${posix}" -o "${user}" -g "${group}" \
287   ${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \   ${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \
288   "${MROOT}${pathto}"   "${MROOT}${pathto}"
# Line 300  install_files() Line 300  install_files()
300    
301   # file is protected, write backup file   # file is protected, write backup file
302   2)   2)
303   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
304   then   then
305   echo -en "${COLRED}"   echo -en "${COLRED}"
306   echo -n "! prot "   echo -n "! prot "
# Line 331  install_files() Line 331  install_files()
331    
332   # file is protected but ignored, delete the update/do nothing   # file is protected but ignored, delete the update/do nothing
333   4)   4)
334   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
335   then   then
336   echo -en "${COLRED}"   echo -en "${COLRED}"
337   echo -n "! ignr "   echo -n "! ignr "
# Line 390  install_symlinks() Line 390  install_symlinks()
390   while read pathto posix link mtime   while read pathto posix link mtime
391   do   do
392   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
393   [[ ${VERBOSE} = on ]] && echo -e "\t>>> LINK: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> LINK: ${MROOT}${pathto}"
394    
395   ln -snf "${link}" "${MROOT}${pathto}"   ln -snf "${link}" "${MROOT}${pathto}"
396    
# Line 440  install_blockdevices() Line 440  install_blockdevices()
440   while read pathto posix major minor user group   while read pathto posix major minor user group
441   do   do
442   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
443   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> PIPE: ${MROOT}${pathto}"
444    
445   mknod -m "${posix}" "${MROOT}${pathto}"   mknod -m "${posix}" "${MROOT}${pathto}"
446   # make it optional atm !!   # make it optional atm !!
# Line 484  install_characterdevices() Line 484  install_characterdevices()
484   while read pathto posix major minor user group   while read pathto posix major minor user group
485   do   do
486   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
487   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> CHAR: ${MROOT}${pathto}"
488    
489   mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}"   mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}"
490    
# Line 528  install_fifos() Line 528  install_fifos()
528   while read pathto posix user group   while read pathto posix user group
529   do   do
530   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
531   [[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> FIFO: ${MROOT}${pathto}"
532    
533   mkfifo -m "${posix}" "${MROOT}${pathto}"   mkfifo -m "${posix}" "${MROOT}${pathto}"
534   chown "${user}:${group}" "${MROOT}${pathto}"   chown "${user}:${group}" "${MROOT}${pathto}"
# Line 862  remove_symlinks() Line 862  remove_symlinks()
862   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
863   if [ ! -L "${MROOT}${pathto}" ]   if [ ! -L "${MROOT}${pathto}" ]
864   then   then
865   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
866   echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}"
867   continue   continue
868   fi   fi
# Line 874  remove_symlinks() Line 874  remove_symlinks()
874   # 1=keep me   #   # 1=keep me   #
875   case ${retval} in   case ${retval} in
876   0)   0)
877   [[ ${VERBOSE} = on ]] && echo -e "\t<<< LINK: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< LINK: ${MROOT}${pathto}"
878   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
879   ;;   ;;
880    
881   1)   1)
882   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
883   echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}"
884   ;;   ;;
885   esac   esac
# Line 946  remove_files() Line 946  remove_files()
946    
947   if [ ! -e "${MROOT}${pathto}" ]   if [ ! -e "${MROOT}${pathto}" ]
948   then   then
949   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
950   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"
951   continue   continue
952   fi   fi
# Line 972  remove_files() Line 972  remove_files()
972   case ${retval} in   case ${retval} in
973   # file is not protected - delete it   # file is not protected - delete it
974   0|3)   0|3)
975   [[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< FILE: ${MROOT}${pathto}"
976   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
977   ;;   ;;
978    
979   # file is protected, do not delete   # file is protected, do not delete
980   2)   2)
981   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
982   then   then
983   echo -en "${COLRED}"   echo -en "${COLRED}"
984   echo -n "! prot "   echo -n "! prot "
# Line 989  remove_files() Line 989  remove_files()
989    
990   # file is protected but ignored, delete the update/do nothing   # file is protected but ignored, delete the update/do nothing
991   4)   4)
992   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
993   then   then
994   echo -en "${COLRED}"   echo -en "${COLRED}"
995   echo -n "! ignr "   echo -n "! ignr "
# Line 1001  remove_files() Line 1001  remove_files()
1001   esac   esac
1002   ;;   ;;
1003   1)   1)
1004   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1005   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"
1006   ;;   ;;
1007   esac   esac
# Line 1063  remove_blockdevices() Line 1063  remove_blockdevices()
1063   do   do
1064   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1065    
1066   [[ ${VERBOSE} = on ]] && echo -e "\t<<< PIPE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< PIPE: ${MROOT}${pathto}"
1067   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1068   done < ${MROOT}${INSTALLDB}/${pfull}/.pipes   done < ${MROOT}${INSTALLDB}/${pfull}/.pipes
1069    
# Line 1123  remove_characterdevices() Line 1123  remove_characterdevices()
1123   do   do
1124   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1125    
1126   [[ ${VERBOSE} = on ]] && echo -e "\t<<< CHAR: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< CHAR: ${MROOT}${pathto}"
1127   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1128   done < ${MROOT}${INSTALLDB}/${pfull}/.char   done < ${MROOT}${INSTALLDB}/${pfull}/.char
1129    
# Line 1185  remove_fifos() Line 1185  remove_fifos()
1185   do   do
1186   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1187    
1188   [[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< FIFO: ${MROOT}${pathto}"
1189   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1190   done < ${MROOT}${INSTALLDB}/${pfull}/.fifo   done < ${MROOT}${INSTALLDB}/${pfull}/.fifo
1191    
# Line 1246  remove_directories() Line 1246  remove_directories()
1246    
1247   if [ ! -d "${MROOT}${pathto}" ]   if [ ! -d "${MROOT}${pathto}" ]
1248   then   then
1249   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1250   echo -e "${COLRED}! exist${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1251   continue   continue
1252   fi   fi
# Line 1254  remove_directories() Line 1254  remove_directories()
1254   # exclude .keep directories   # exclude .keep directories
1255   if [ -f "${MROOT}${pathto}/.keep" ]   if [ -f "${MROOT}${pathto}/.keep" ]
1256   then   then
1257   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1258   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1259   continue   continue
1260   fi   fi
# Line 1267  remove_directories() Line 1267  remove_directories()
1267    
1268   if rmdir "${MROOT}${pathto}" &> /dev/null   if rmdir "${MROOT}${pathto}" &> /dev/null
1269   then   then
1270   [[ ${VERBOSE} = on ]] && echo -e "\t<<< DIR:  ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< DIR:  ${MROOT}${pathto}"
1271   else   else
1272   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1273   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1274   fi   fi
1275   done   done
# Line 1401  mdownload() Line 1401  mdownload()
1401   real_uris="$(convertmirrors ${uri})"   real_uris="$(convertmirrors ${uri})"
1402    
1403   # verbose or not   # verbose or not
1404   [[ ${VERBOSE} = off ]] && wget_opts="--quiet"   mqueryfeature "!verbose" && wget_opts="--quiet"
1405    
1406   # filter wget options if busybox was found   # filter wget options if busybox was found
1407   wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"   wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
# Line 1488  fetch_packages() Line 1488  fetch_packages()
1488   echo -ne " ${COLBLUE}***${COLDEFAULT}"   echo -ne " ${COLBLUE}***${COLDEFAULT}"
1489   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1490   mdownload --uri "package://${pkg}" --dir "${PKGDIR}" || die "Could not download ${pkg}"   mdownload --uri "package://${pkg}" --dir "${PKGDIR}" || die "Could not download ${pkg}"
   
1491   if [ ! -f ${PKGDIR}/${pkg} ]   if [ ! -f ${PKGDIR}/${pkg} ]
1492   then   then
1493   die "Package '${pkg}' after download not found in '${PKGDIR}'"   die "Package '${pkg}' after download not found in '${PKGDIR}'"
# Line 1551  syncmage_tarball() Line 1550  syncmage_tarball()
1550    
1551   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1552   echo "fetching latest md5 from ${mymirr} ..."   echo "fetching latest md5 from ${mymirr} ..."
1553   [[ ${VERBOSE} = off ]] && opt="--quiet"   mqueryfeature "!verbose" && opt="--quiet"
1554   wget \   wget \
1555   ${wget_opts} \   ${wget_opts} \
1556   --directory-prefix=${temp} \   --directory-prefix=${temp} \
# Line 1738  get_highest_magefile() Line 1737  get_highest_magefile()
1737   then   then
1738   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
1739   #for debug only   #for debug only
1740   [[ ${MAGEDEBUG} = on ]] && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"   mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"
1741   fi   fi
1742   done   done
1743    
# Line 2146  minclude() Line 2145  minclude()
2145   then   then
2146   for i in $*   for i in $*
2147   do   do
2148   [[ ${MAGEDEBUG} = on ]] && \   mqueryfeature "debug" && \
2149   echo "--- Including ${MAGEDIR}/include/${i}.minc"   echo "--- Including ${MAGEDIR}/include/${i}.minc"
2150   source ${MAGEDIR}/include/${i}.minc   source ${MAGEDIR}/include/${i}.minc
2151   done   done
2152   [[ ${MAGEDEBUG} = on ]] && echo   mqueryfeature "debug" && echo
2153   fi   fi
2154  }  }
2155    
# Line 3136  export_inherits() Line 3135  export_inherits()
3135   eval "${functions}() { ${include}_${functions} ; }"   eval "${functions}() { ${include}_${functions} ; }"
3136    
3137   # debug   # debug
3138   [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"   mqueryfeature "debug" && typeset -f "${functions}"
3139    
3140   shift   shift
3141   done   done
# Line 3274  have_root_privileges() Line 3273  have_root_privileges()
3273    
3274   return ${retval}   return ${retval}
3275  }  }
3276    
3277    known_mage_feature()
3278    {
3279     local feature="$1"
3280     local retval
3281    
3282     case "${feature}" in
3283     autosvc|!autosvc) retval=0 ;;
3284     buildlog|!buildlog) retval=0 ;;
3285     ccache|!ccache) retval=0 ;;
3286     check|!check) retval=0 ;;
3287     compressdoc|!compressdoc) retval=0 ;;
3288     distcc|!distcc) retval=0 ;;
3289     kernelsrcunpack|!kernelsrcunpack) retval=0 ;;
3290     libtool|!libtool) retval=0 ;;
3291     linuxsymlink|!linuxsymlink) retval=0 ;;
3292     pkgbuild|!pkgbuild) retval=0 ;;
3293     purge|!purge) retval=0 ;;
3294     qalint|!qalint) retval=0 ;;
3295     regentree|!regentree) retval=0 ;;
3296     stepbystep|!stepbystep) retval=0 ;;
3297     srcpkgbuild|!srcpkgbuild) retval=0 ;;
3298     srcpkgtarball|!srcpkgtarball) retval=0 ;;
3299     strip|!strip) retval=0 ;;
3300     *) retval=1 ;;
3301     esac
3302    
3303     return "${retval}"
3304    }
3305    
3306    load_mage_features()
3307    {
3308     echo "loading mage-features... "
3309     for i in ${MAGE_FEATURES_GLOBAL[*]} ${MAGE_FEATURES[*]}
3310     do
3311     FVERBOSE=off msetfeature ${i}
3312     done
3313    
3314     echo "done"
3315    }
3316    
3317    msetfeature()
3318    {
3319     local feature
3320     local count
3321     local i
3322     local found
3323    
3324     for feature in $@
3325     do
3326     found=0
3327     count="${#MAGE_FEATURES_CURRENT[*]}"
3328    
3329     if ! known_mage_feature "${feature}"
3330     then
3331     [[ ${FVERBOSE} = off ]] || echo "unkown feature ${feature}, ignoring it"
3332     return 3
3333     fi
3334    
3335     for ((i=0; i<count; i++))
3336     do
3337     if [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature} ]]
3338     then
3339     [[ ${FVERBOSE} = off ]] || echo "feature '${feature}' already enabled"
3340     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3341     found=1
3342     elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = !${feature} ]]
3343     then
3344     [[ ${FVERBOSE} = off ]] || echo "feature '${feature}' currently disabled, enabling it!"
3345     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3346     found=1
3347     elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature//!} ]]
3348     then
3349     [[ ${FVERBOSE} = off ]] || echo "feature '${feature//!}' currently enabled, disabling it!"
3350     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3351     found=1
3352     fi
3353     done
3354    
3355     # if the feature was not found after proccessing the whole array
3356     # it was not declared. in this case enable it
3357     if [[ ${found} = 0 ]]
3358     then
3359     [[ ${FVERBOSE} = off ]] || echo "feature '${feature}' was not declared, enabling it!"
3360     MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )
3361     fi
3362    
3363     export MAGE_FEATURE_CURRENT
3364     done
3365    }
3366    
3367    mqueryfeature()
3368    {
3369     local feature="$1"
3370     local retval=1
3371     local i
3372    
3373     if known_mage_feature "${feature}"
3374     then
3375     for i in ${MAGE_FEATURES_CURRENT[*]}
3376     do
3377     if [[ ${i} = ${feature} ]]
3378     then
3379     retval=0
3380     break # found break here
3381     fi
3382     done
3383     else
3384     retval=3
3385     fi
3386    
3387     return ${retval}
3388    }
3389    
3390    mprintfeatures()
3391    {
3392     echo "Global features:  ${MAGE_FEATURES_GLOBAL[*]}"
3393     echo "Local features:   ${MAGE_FEATURES[*]}"
3394     echo "Current features: ${MAGE_FEATURES_CURRENT[*]}"
3395    }

Legend:
Removed from v.1583  
changed lines
  Added in v.1584