Magellan Linux

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

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

revision 1549 by niro, Tue Dec 27 10:43:40 2011 UTC revision 1690 by niro, Thu Feb 16 12:00:59 2012 UTC
# Line 66  mchecksum() Line 66  mchecksum()
66   case ${method} in   case ${method} in
67   md5) cmd="md5sum" ;;   md5) cmd="md5sum" ;;
68   sha256) cmd="sha256sum" ;;   sha256) cmd="sha256sum" ;;
69   *) die "mchecksum(): unkown method '${method}'" ;;   *) die "mchecksum(): unknown method '${method}'" ;;
70   esac   esac
71    
72   if [[ -d ${rundir} ]]   if [[ -d ${rundir} ]]
73   then   then
74   pushd ${rundir} &> /dev/null   pushd ${rundir} &> /dev/null
75   ${cmd} -c ${file} &> /dev/null   # be verbose here
76     ${cmd} -c ${file} #&> /dev/null
77   retval="$?"   retval="$?"
78   popd &> /dev/null   popd &> /dev/null
79   else   else
# Line 82  mchecksum() Line 83  mchecksum()
83   return "${retval}"   return "${retval}"
84  }  }
85    
86    mcheckemptydir()
87    {
88     local dir="$1"
89     local retval=1
90    
91     if [[ ! -d ${dir} ]]
92     then
93     echo "mcheckemptydir(): '${dir}' is not a directory!"
94     retval=3
95     else
96     shopt -s nullglob dotglob
97     files=( ${dir}/* )
98     (( ${#files[*]} )) || retval=0
99     shopt -u nullglob dotglob
100     fi
101    
102     return ${retval}
103    }
104    
105  unpack_packages()  unpack_packages()
106  {  {
107   local list="$@"   local list="$@"
# Line 151  fix_mtime() Line 171  fix_mtime()
171   mtime=$(stat -c %Y "${reference}")   mtime=$(stat -c %Y "${reference}")
172   touch \   touch \
173   --no-create \   --no-create \
174     --no-dereference \
175   --time=mtime \   --time=mtime \
176   --reference "${reference}" \   --reference="${reference}" \
177   "${pathto}"   "${pathto}"
178    
179   echo "${mtime}"   echo "${mtime}"
# Line 206  install_directories() Line 227  install_directories()
227   while read pathto posix user group   while read pathto posix user group
228   do   do
229   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
230   [[ ${VERBOSE} = on ]] && echo -e "\t>>> DIR:  ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> DIR:  ${MROOT}${pathto}"
231    
232   # monitors /etc/env.d -> env-rebuild   # monitors /etc/env.d -> env-rebuild
233   [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true   [[ ${pathto} = /etc/env.d ]] && export MAGE_ENV_REBUILD=true
# Line 282  install_files() Line 303  install_files()
303   case ${retval} in   case ${retval} in
304   # file is not protected - (over)write it   # file is not protected - (over)write it
305   0|3)   0|3)
306   [[ ${VERBOSE} = on ]] && echo -e "\t>>> FILE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> FILE: ${MROOT}${pathto}"
307   install -m "${posix}" -o "${user}" -g "${group}" \   install -m "${posix}" -o "${user}" -g "${group}" \
308   ${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \   ${BUILDDIR}/${pkgname}/binfiles/"${pathto}" \
309   "${MROOT}${pathto}"   "${MROOT}${pathto}"
# Line 300  install_files() Line 321  install_files()
321    
322   # file is protected, write backup file   # file is protected, write backup file
323   2)   2)
324   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
325   then   then
326   echo -en "${COLRED}"   echo -en "${COLRED}"
327   echo -n "! prot "   echo -n "! prot "
# Line 331  install_files() Line 352  install_files()
352    
353   # file is protected but ignored, delete the update/do nothing   # file is protected but ignored, delete the update/do nothing
354   4)   4)
355   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
356   then   then
357   echo -en "${COLRED}"   echo -en "${COLRED}"
358   echo -n "! ignr "   echo -n "! ignr "
# Line 390  install_symlinks() Line 411  install_symlinks()
411   while read pathto posix link mtime   while read pathto posix link mtime
412   do   do
413   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
414   [[ ${VERBOSE} = on ]] && echo -e "\t>>> LINK: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> LINK: ${MROOT}${pathto}"
415    
416   ln -snf "${link}" "${MROOT}${pathto}"   ln -snf "${link}" "${MROOT}${pathto}"
417    
418  # # fix mtime and db   # fix mtime and db
419  # fix_descriptor ${pkgname}/.symlinks \   fix_descriptor ${pkgname}/.symlinks \
420  # "${pathto}" \   "${pathto}" \
421  # "${posix}" \   "${posix}" \
422  # "${link}" \   "${link}" \
423  # "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \   "$(fix_mtime "${BUILDDIR}/${pkgname}"/.mtime \
424  # "${MROOT}${pathto}")"   "${MROOT}${pathto}")"
425    
426   done < ${BUILDDIR}/${pkgname}/.symlinks   done < ${BUILDDIR}/${pkgname}/.symlinks
427    
# Line 440  install_blockdevices() Line 461  install_blockdevices()
461   while read pathto posix major minor user group   while read pathto posix major minor user group
462   do   do
463   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
464   [[ ${VERBOSE} = on ]] && echo -e "\t>>> PIPE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> PIPE: ${MROOT}${pathto}"
465    
466   mknod -m "${posix}" "${MROOT}${pathto}"   mknod -m "${posix}" "${MROOT}${pathto}"
467   # make it optional atm !!   # make it optional atm !!
# Line 484  install_characterdevices() Line 505  install_characterdevices()
505   while read pathto posix major minor user group   while read pathto posix major minor user group
506   do   do
507   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
508   [[ ${VERBOSE} = on ]] && echo -e "\t>>> CHAR: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> CHAR: ${MROOT}${pathto}"
509    
510   mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}"   mknod -m ${posix} "${MROOT}${pathto}" b "${major}" "${minor}"
511    
# Line 528  install_fifos() Line 549  install_fifos()
549   while read pathto posix user group   while read pathto posix user group
550   do   do
551   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
552   [[ ${VERBOSE} = on ]] && echo -e "\t>>> FIFO: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t>>> FIFO: ${MROOT}${pathto}"
553    
554   mkfifo -m "${posix}" "${MROOT}${pathto}"   mkfifo -m "${posix}" "${MROOT}${pathto}"
555   chown "${user}:${group}" "${MROOT}${pathto}"   chown "${user}:${group}" "${MROOT}${pathto}"
# Line 787  compare_mtime() Line 808  compare_mtime()
808    
809   mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)"   mtime="$(stat -c %Y ${MROOT}${INSTALLDB}/${pfull}/.mtime)"
810    
811   # if $pathto is a symlink than compare linked binary   # no extra handlink for symlinks anymore as fix_mtime
812   if [ -L "${MROOT}${pathto}" ]   # uses --no-dereference, compare directly
813   then   x=$(stat -c %Y "${MROOT}${pathto}")
  # readlink -f resolves full path of linked file  
  x="$(readlink -f "${MROOT}${pathto}")"  
   
  # abort if target does not exists  
  # we keep safe here, theoretically the link can removed  
  [ ! -e "${x}" ] && return 1  
   
  x=$(stat -c %Y "${x}")  
  else  
  x=$(stat -c %Y "${MROOT}${pathto}")  
  fi  
814    
815   [[ ${mtime} = ${x} ]] && return 0   [[ ${mtime} = ${x} ]] && return 0
816    
# Line 862  remove_symlinks() Line 872  remove_symlinks()
872   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
873   if [ ! -L "${MROOT}${pathto}" ]   if [ ! -L "${MROOT}${pathto}" ]
874   then   then
875   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
876   echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === LINK: ${MROOT}${pathto}"
877   continue   continue
878   fi   fi
# Line 874  remove_symlinks() Line 884  remove_symlinks()
884   # 1=keep me   #   # 1=keep me   #
885   case ${retval} in   case ${retval} in
886   0)   0)
887   [[ ${VERBOSE} = on ]] && echo -e "\t<<< LINK: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< LINK: ${MROOT}${pathto}"
888   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
889   ;;   ;;
890    
891   1)   1)
892   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
893   echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === LINK: ${MROOT}${pathto}"
894   ;;   ;;
895   esac   esac
# Line 946  remove_files() Line 956  remove_files()
956    
957   if [ ! -e "${MROOT}${pathto}" ]   if [ ! -e "${MROOT}${pathto}" ]
958   then   then
959   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
960   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === FILE: ${MROOT}${pathto}"
961   continue   continue
962   fi   fi
# Line 972  remove_files() Line 982  remove_files()
982   case ${retval} in   case ${retval} in
983   # file is not protected - delete it   # file is not protected - delete it
984   0|3)   0|3)
985   [[ ${VERBOSE} = on ]] && echo -e "\t<<< FILE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< FILE: ${MROOT}${pathto}"
986   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
987   ;;   ;;
988    
989   # file is protected, do not delete   # file is protected, do not delete
990   2)   2)
991   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
992   then   then
993   echo -en "${COLRED}"   echo -en "${COLRED}"
994   echo -n "! prot "   echo -n "! prot "
# Line 989  remove_files() Line 999  remove_files()
999    
1000   # file is protected but ignored, delete the update/do nothing   # file is protected but ignored, delete the update/do nothing
1001   4)   4)
1002   if [[ ${VERBOSE} = on ]]   if mqueryfeature "verbose"
1003   then   then
1004   echo -en "${COLRED}"   echo -en "${COLRED}"
1005   echo -n "! ignr "   echo -n "! ignr "
# Line 1001  remove_files() Line 1011  remove_files()
1011   esac   esac
1012   ;;   ;;
1013   1)   1)
1014   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1015   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"   echo -e "${COLRED}! mtime${COLDEFAULT} === FILE: ${MROOT}${pathto}"
1016   ;;   ;;
1017   esac   esac
# Line 1063  remove_blockdevices() Line 1073  remove_blockdevices()
1073   do   do
1074   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1075    
1076   [[ ${VERBOSE} = on ]] && echo -e "\t<<< PIPE: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< PIPE: ${MROOT}${pathto}"
1077   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1078   done < ${MROOT}${INSTALLDB}/${pfull}/.pipes   done < ${MROOT}${INSTALLDB}/${pfull}/.pipes
1079    
# Line 1123  remove_characterdevices() Line 1133  remove_characterdevices()
1133   do   do
1134   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1135    
1136   [[ ${VERBOSE} = on ]] && echo -e "\t<<< CHAR: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< CHAR: ${MROOT}${pathto}"
1137   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1138   done < ${MROOT}${INSTALLDB}/${pfull}/.char   done < ${MROOT}${INSTALLDB}/${pfull}/.char
1139    
# Line 1185  remove_fifos() Line 1195  remove_fifos()
1195   do   do
1196   [ -z "${pathto}" ] && continue   [ -z "${pathto}" ] && continue
1197    
1198   [[ ${VERBOSE} = on ]] && echo -e "\t<<< FIFO: ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< FIFO: ${MROOT}${pathto}"
1199   rm "${MROOT}${pathto}"   rm "${MROOT}${pathto}"
1200   done < ${MROOT}${INSTALLDB}/${pfull}/.fifo   done < ${MROOT}${INSTALLDB}/${pfull}/.fifo
1201    
# Line 1246  remove_directories() Line 1256  remove_directories()
1256    
1257   if [ ! -d "${MROOT}${pathto}" ]   if [ ! -d "${MROOT}${pathto}" ]
1258   then   then
1259   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1260   echo -e "${COLRED}! exist${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! exist${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1261   continue   continue
1262   fi   fi
# Line 1254  remove_directories() Line 1264  remove_directories()
1264   # exclude .keep directories   # exclude .keep directories
1265   if [ -f "${MROOT}${pathto}/.keep" ]   if [ -f "${MROOT}${pathto}/.keep" ]
1266   then   then
1267   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1268   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! .keep${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1269   continue   continue
1270   fi   fi
# Line 1267  remove_directories() Line 1277  remove_directories()
1277    
1278   if rmdir "${MROOT}${pathto}" &> /dev/null   if rmdir "${MROOT}${pathto}" &> /dev/null
1279   then   then
1280   [[ ${VERBOSE} = on ]] && echo -e "\t<<< DIR:  ${MROOT}${pathto}"   mqueryfeature "verbose" && echo -e "\t<<< DIR:  ${MROOT}${pathto}"
1281   else   else
1282   [[ ${VERBOSE} = on ]] && \   mqueryfeature "verbose" && \
1283   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"   echo -e "${COLRED}! empty${COLDEFAULT} === DIR:  ${MROOT}${pathto}"
1284   fi   fi
1285   done   done
# Line 1401  mdownload() Line 1411  mdownload()
1411   real_uris="$(convertmirrors ${uri})"   real_uris="$(convertmirrors ${uri})"
1412    
1413   # verbose or not   # verbose or not
1414   [[ ${VERBOSE} = off ]] && wget_opts="--quiet"   mqueryfeature "!verbose" && wget_opts+=" --quiet"
1415    
1416   # filter wget options if busybox was found   # filter wget options if busybox was found
1417   wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"   wget_opts+=" $(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
1418    
1419   # create outputdir   # create outputdir
1420   [[ ! -d ${outputdir} ]] && install -d "${outputdir}"   [[ ! -d ${outputdir} ]] && install -d "${outputdir}"
# Line 1488  fetch_packages() Line 1498  fetch_packages()
1498   echo -ne " ${COLBLUE}***${COLDEFAULT}"   echo -ne " ${COLBLUE}***${COLDEFAULT}"
1499   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "   echo -e " fetching (${count_current}/${count_total}): ${pkg} ... "
1500   mdownload --uri "package://${pkg}" --dir "${PKGDIR}" || die "Could not download ${pkg}"   mdownload --uri "package://${pkg}" --dir "${PKGDIR}" || die "Could not download ${pkg}"
   
1501   if [ ! -f ${PKGDIR}/${pkg} ]   if [ ! -f ${PKGDIR}/${pkg} ]
1502   then   then
1503   die "Package '${pkg}' after download not found in '${PKGDIR}'"   die "Package '${pkg}' after download not found in '${PKGDIR}'"
# Line 1546  syncmage_tarball() Line 1555  syncmage_tarball()
1555    
1556   for mirr in ${MIRRORS}   for mirr in ${MIRRORS}
1557   do   do
1558   # path without distribution   # path without distribution
1559   mymirr="${mirr%/*}"   # (only for stable|testing|unstable and not DISTROTAG)
1560     case ${mirr##*/} in
1561     stable|testing|unstable) mymirr="${mirr%/*}";;
1562     *) mymirr="${mirr}";;
1563     esac
1564    
1565   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1566   echo "fetching latest md5 from ${mymirr} ..."   echo "fetching latest md5 from ${mymirr} ..."
1567   [[ ${VERBOSE} = off ]] && opt="--quiet"   mqueryfeature "!verbose" && opt="--quiet"
1568   wget \   wget \
1569   ${wget_opts} \   ${wget_opts} \
1570   --directory-prefix=${temp} \   --directory-prefix=${temp} \
# Line 1580  syncmage_tarball() Line 1593  syncmage_tarball()
1593   else   else
1594   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1595   echo -n "checking md5sum... "   echo -n "checking md5sum... "
1596   ( cd ${temp}; md5sum -c ${latest_md5} ) || die "md5 for ${latest_tarball} failed"   mchecksum --rundir "${temp}" --file "${latest_md5}" --method md5 || die "md5 for ${latest_tarball} failed"
1597   fi   fi
1598    
1599   if [[ -d ${MAGEDIR} ]]   if [[ -d ${MAGEDIR} ]]
1600   then   then
1601   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
1602   echo "cleaning old mage-tree ${MAGEDIR}..."   echo "cleaning old mage-tree ${MAGEDIR}..."
1603   rm -rf ${MAGEDIR}   # honor mountpoints and empty dirs
1604     if mountpoint -q ${MAGEDIR}
1605     then
1606     if ! mcheckemptydir ${MAGEDIR}
1607     then
1608     find ${MAGEDIR} -mindepth 1 -maxdepth 1 | xarg --no-run-if-empty rm -r
1609     fi
1610     else
1611     rm -rf ${MAGEDIR}
1612     fi
1613   fi   fi
1614    
1615   if need_busybox_support tar   if need_busybox_support tar
# Line 1646  xtitleclean() Line 1668  xtitleclean()
1668  }  }
1669    
1670    
1671  # cuts full pathnames or versionized names down to basename  # unused?
1672  choppkgname()  #
1673  {  # # cuts full pathnames or versionized names down to basename
1674   #we want this only if full name was used  # choppkgname()
1675   if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]  # {
1676   then  # #we want this only if full name was used
1677   #cuts ARCH and PBUILD  # if [ -n "$(echo ${MAGENAME}|fgrep .mage)" ]
1678   #ARCH comes from ${MAGERC}  # then
1679   MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}-r*.::g")  # #cuts ARCH and PBUILD
1680    # #ARCH comes from ${MAGERC}
1681    # MAGENAME=$(echo ${MAGENAME} |sed -e "s:-${ARCH}$(print_distrotag)-r*.::g")
1682    #
1683    # #cuts version number
1684    # MAGENAME=$(basename ${MAGENAME%-*} .mage)
1685    # fi
1686    # }
1687    
  #cuts version number  
  MAGENAME=$(basename ${MAGENAME%-*} .mage)  
  fi  
 }  
1688    
1689  # get_categorie $PNAME, returns CATEGORIE  # get_categorie $PNAME, returns CATEGORIE
1690  # $1=pname  # $1=pname
# Line 1738  get_highest_magefile() Line 1763  get_highest_magefile()
1763   then   then
1764   HIGHEST_MAGEFILE=${magefile}   HIGHEST_MAGEFILE=${magefile}
1765   #for debug only   #for debug only
1766   [[ ${MAGEDEBUG} = on ]] && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"   mqueryfeature "debug" && echo "HIGHEST_MAGEFILE=${HIGHEST_MAGEFILE}"
1767   fi   fi
1768   done   done
1769    
# Line 2146  minclude() Line 2171  minclude()
2171   then   then
2172   for i in $*   for i in $*
2173   do   do
2174   [[ ${MAGEDEBUG} = on ]] && \   mqueryfeature "debug" && \
2175   echo "--- Including ${MAGEDIR}/include/${i}.minc"   echo "--- Including ${MAGEDIR}/include/${i}.minc"
2176   source ${MAGEDIR}/include/${i}.minc   source ${MAGEDIR}/include/${i}.minc
2177   done   done
2178   [[ ${MAGEDEBUG} = on ]] && echo   mqueryfeature "debug" && echo
2179   fi   fi
2180  }  }
2181    
# Line 2760  md5sum_packages() Line 2785  md5sum_packages()
2785   then   then
2786   echo -ne "${COLBLUE} *** ${COLDEFAULT}"   echo -ne "${COLBLUE} *** ${COLDEFAULT}"
2787   echo -ne "checking md5sum (${count_current}/${count_total}): "   echo -ne "checking md5sum (${count_current}/${count_total}): "
2788   ( cd ${PKGDIR}; md5sum -c ${md5file}) || die "md5 for ${pkgfile} failed"   mchecksum --rundir "${PKGDIR}" --file "${md5file}" --method md5 || die "md5 for ${pkgfile} failed"
2789   else   else
2790   echo -ne "${COLBLUE} --- ${COLDEFAULT}"   echo -ne "${COLBLUE} --- ${COLDEFAULT}"
2791   echo -e "!! no md5sum file found for ${pkgfile} :("   echo -e "!! no md5sum file found for ${pkgfile} :("
# Line 3000  pkgsearch() Line 3025  pkgsearch()
3025   local state   local state
3026   local descriptiom   local descriptiom
3027   local homepage   local homepage
3028     local license
3029   local i   local i
3030   local all_installed   local all_installed
3031   local ipver   local ipver
# Line 3036  pkgsearch() Line 3062  pkgsearch()
3062   state="$(get_value_from_magefile STATE ${magefile})"   state="$(get_value_from_magefile STATE ${magefile})"
3063   description="$(get_value_from_magefile DESCRIPTION ${magefile})"   description="$(get_value_from_magefile DESCRIPTION ${magefile})"
3064   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"   homepage="$(get_value_from_magefile HOMEPAGE ${magefile})"
3065     license="$(get_value_from_magefile LICENSE ${magefile})"
3066    
3067   # all installed   # all installed
3068   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})   for i in $(get_uninstall_candidates --pname ${pname} --pcat ${pcat})
3069   do   do
3070   ipver="$(magename2pver ${i})"   ipver="$(magename2pver ${i})"
3071   ipbuild="$(magename2pbuild ${i})"   ipbuild="$(magename2pbuild ${i})"
3072    
3073   if [[ -z ${all_installed} ]]   if [[ -z ${all_installed} ]]
3074   then   then
3075   all_installed="${ipver}-${ipbuild}"   all_installed="${ipver}-${ipbuild}"
# Line 3051  pkgsearch() Line 3078  pkgsearch()
3078   fi   fi
3079   done   done
3080   [[ -z ${all_installed} ]] && all_installed="none"   [[ -z ${all_installed} ]] && all_installed="none"
3081    
3082   case ${state} in   case ${state} in
3083   stable) state=${COLGREEN}"[s] ";;   stable) state=${COLGREEN}"[s] ";;
3084   testing) state=${COLYELLOW}"[t] ";;   testing) state=${COLYELLOW}"[t] ";;
# Line 3096  EOF Line 3123  EOF
3123   echo "      Installed versions: ${all_installed}"   echo "      Installed versions: ${all_installed}"
3124   echo "      Description: ${description}"   echo "      Description: ${description}"
3125   echo "      Homepage: ${homepage}"   echo "      Homepage: ${homepage}"
3126     if [[ ! -z ${license} ]]
3127     then
3128     echo "      License:  ${license}"
3129     fi
3130   echo "      Depends: ${deps}"   echo "      Depends: ${deps}"
3131   echo "      SDepends: ${sdeps}"   echo "      SDepends: ${sdeps}"
3132   echo   echo
# Line 3136  export_inherits() Line 3167  export_inherits()
3167   eval "${functions}() { ${include}_${functions} ; }"   eval "${functions}() { ${include}_${functions} ; }"
3168    
3169   # debug   # debug
3170   [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"   mqueryfeature "debug" && typeset -f "${functions}"
3171    
3172   shift   shift
3173   done   done
# Line 3274  have_root_privileges() Line 3305  have_root_privileges()
3305    
3306   return ${retval}   return ${retval}
3307  }  }
3308    
3309    known_mage_feature()
3310    {
3311     local feature="$1"
3312     local retval
3313    
3314     case "${feature}" in
3315     autosvc|!autosvc) retval=0 ;;
3316     buildlog|!buildlog) retval=0 ;;
3317     ccache|!ccache) retval=0 ;;
3318     check|!check) retval=0 ;;
3319     compressdoc|!compressdoc) retval=0 ;;
3320     debug|!debug) retval=0 ;;
3321     distcc|!distcc) retval=0 ;;
3322     kernelsrcunpack|!kernelsrcunpack) retval=0 ;;
3323     libtool|!libtool) retval=0 ;;
3324     linuxsymlink|!linuxsymlink) retval=0 ;;
3325     pkgbuild|!pkgbuild) retval=0 ;;
3326     pkgdistrotag|!pkgdistrotag) retval=0 ;;
3327     purge|!purge) retval=0 ;;
3328     qalint|!qalint) retval=0 ;;
3329     regentree|!regentree) retval=0 ;;
3330     resume|!resume) retval=0 ;;
3331     srcpkgbuild|!srcpkgbuild) retval=0 ;;
3332     srcpkgtarball|!srcpkgtarball) retval=0 ;;
3333     static|!static) retval=0 ;;
3334     stepbystep|!stepbystep) retval=0 ;;
3335     strip|!strip) retval=0 ;;
3336     verbose|!verbose) retval=0 ;;
3337     *) retval=1 ;;
3338     esac
3339    
3340     return "${retval}"
3341    }
3342    
3343    load_mage_features()
3344    {
3345     for i in ${MAGE_FEATURES_GLOBAL[*]} ${MAGE_FEATURES[*]}
3346     do
3347     FVERBOSE=off msetfeature ${i}
3348     done
3349    }
3350    
3351    msetfeature()
3352    {
3353     local feature
3354     local count
3355     local i
3356     local found
3357    
3358     for feature in $@
3359     do
3360     found=0
3361     count="${#MAGE_FEATURES_CURRENT[*]}"
3362    
3363     if ! known_mage_feature "${feature}"
3364     then
3365     [[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}"
3366     return 3
3367     fi
3368    
3369     for ((i=0; i<count; i++))
3370     do
3371     if [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature} ]]
3372     then
3373     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' already enabled${COLDEFAULT}"
3374     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3375     found=1
3376     elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = !${feature} ]]
3377     then
3378     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' currently disabled, enabling it!${COLDEFAULT}"
3379     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3380     found=1
3381     elif [[ ${MAGE_FEATURES_CURRENT[${i}]} = ${feature//!} ]]
3382     then
3383     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature//!}' currently enabled, disabling it!${COLDEFAULT}"
3384     MAGE_FEATURES_CURRENT[${i}]="${feature}"
3385     found=1
3386     fi
3387     done
3388    
3389     # if the feature was not found after proccessing the whole array
3390     # it was not declared. in this case enable it
3391     if [[ ${found} = 0 ]]
3392     then
3393     [[ ${FVERBOSE} = off ]] || echo -e "${COLBLUE}---${COLGREEN} Feature '${feature}' was not declared, enabling it!${COLDEFAULT}"
3394     MAGE_FEATURES_CURRENT=( ${MAGE_FEATURES_CURRENT[*]} "${feature}" )
3395     fi
3396    
3397     export MAGE_FEATURE_CURRENT
3398     done
3399    }
3400    
3401    mqueryfeature()
3402    {
3403     local feature="$1"
3404     local retval=1
3405     local i
3406    
3407     if known_mage_feature "${feature}"
3408     then
3409     for i in ${MAGE_FEATURES_CURRENT[*]}
3410     do
3411     if [[ ${i} = ${feature} ]]
3412     then
3413     retval=0
3414     break # found break here
3415     fi
3416     done
3417     else
3418     [[ ${FVERBOSE} = off ]] || echo -e "${COLRED}Unknown feature '${feature}', ignoring it${COLDEFAULT}"
3419     retval=3
3420     fi
3421    
3422     return ${retval}
3423    }
3424    
3425    mprintfeatures()
3426    {
3427     echo "Global features:  ${MAGE_FEATURES_GLOBAL[*]}"
3428     echo "Local features:   ${MAGE_FEATURES[*]}"
3429     echo "Current features: ${MAGE_FEATURES_CURRENT[*]}"
3430    }

Legend:
Removed from v.1549  
changed lines
  Added in v.1690