--- euse 2008-03-06 10:39:55.827571464 +0100 +++ euse-modified 2008-03-06 12:56:53.842582269 +0100 @@ -26,6 +26,7 @@ -h | --help) MODE="showhelp";; -v | --version) MODE="showversion";; -i | --info) MODE="showdesc";; + -I | --info-installed) MODE="showinstdesc";; -l | --local) SCOPE="local";; -g | --global) SCOPE="global";; -a | --active) MODE="showflags";; @@ -317,6 +318,86 @@ fi } +# Works like showdesc() but displays only descriptions of which the appropriate +# ebuild is installed and prints the name of those packages. +showinstdesc() { + local descdir + local current_desc + local args + local foundone=0 + + args="${*:-*}" + + if [ -z "${SCOPE}" ]; then + SCOPE="global" showinstdesc ${args} + echo + SCOPE="local" showinstdesc ${args} + return + fi + + descdir="$(get_portdir)/profiles" + + [ "${SCOPE}" == "global" ] && echo "global use flags (searching: ${args})" + [ "${SCOPE}" == "local" ] && echo "local use flags (searching: ${args})" + echo "************************************************************" + + if [ "${args}" == "*" ]; then + args="$(get_useflaglist | sort -u)" + fi + + set ${args} + + while [ -n "${1}" ]; do + if [ "${SCOPE}" == "global" ]; then + desc=`grep "^${1} *-" "${descdir}/use.desc"` + if [ ! -z "$desc" ]; then + get_flagstatus "${1}" + echo $desc + # get list of installed packages matching this USE flag. + # equery does only display package names if it is called in + # backtick operators + packages="`equery hasuse -i ${1}`" + echo -n "Installed packages matching this USE flag: " + if [ -z "$packages" ]; then + foundone=0 + echo "none" + else + foundone=1 + echo + echo $packages | tr ' ' '\n' | while read line; do + # cut off package's version information + echo $line | sed -e 's/\-[0-9].*$//' + done + fi + fi + fi + # local flags are a bit more complicated as there can be multiple + # entries per flag and we can't pipe into printf + if [ "${SCOPE}" == "local" ]; then + OIFS="$IFS" + IFS=$'\n' + for line in `grep ":${1} *-" "${descdir}/use.local.desc" \ + | sed -e "s/^\([^:]\+\):\(${1}\) *- *\(.\+\)/\1|\2|\3/g"`; do + pkg="$(echo $line | cut -d\| -f 1)" + flag="$(echo $line | cut -d\| -f 2)" + desc="$(echo $line | cut -d\| -f 3)" + # print name only if package is installed + if [ `eix -Ie ${pkg} | wc -l` -gt 1 ]; then + foundone=1 + get_flagstatus "${flag}" + printf "%s (%s):\n%s\n\n" "${flag}" "${pkg}" "${desc}" + fi + done + IFS="$OIFS" + fi + shift + done + + if [ ${foundone} == 0 ]; then + echo "no matching entries found" + fi +} + # show a list of all currently active flags and where they are activated showflags() { local args