|
|
fi | fi |
while [ -n "${1}" ]; do | while [ -n "${1}" ]; do |
case "${1}" in | case "${1}" in |
-h | --help) MODE="showhelp";; |
-h | --help) MODE="showhelp";; |
-v | --version) MODE="showversion";; |
-v | --version) MODE="showversion";; |
-i | --info) MODE="showdesc";; |
-i | --info) MODE="showdesc";; |
-l | --local) SCOPE="local";; |
-I | --info-installed) MODE="showinstdesc";; |
-g | --global) SCOPE="global";; |
-l | --local) SCOPE="local";; |
-a | --active) MODE="showflags";; |
-g | --global) SCOPE="global";; |
-E | --enable) MODE="modify"; ACTION="add";; |
-a | --active) MODE="showflags";; |
-D | --disable) MODE="modify"; ACTION="remove";; |
-E | --enable) MODE="modify"; ACTION="add";; |
-P | --prune) MODE="modify"; ACTION="prune";; |
-D | --disable) MODE="modify"; ACTION="remove";; |
|
-P | --prune) MODE="modify"; ACTION="prune";; |
-*) | -*) |
echo "ERROR: unknown option ${1} specified." | echo "ERROR: unknown option ${1} specified." |
echo | echo |
|
|
} | } |
| |
showhelp() { | showhelp() { |
echo "${PROGRAM_NAME} v${PROGRAM_VERSION}" |
cat << HELP |
echo |
${PROGRAM_NAME} v${PROGRAM_VERSION} |
echo "Syntax: ${PROGRAM_NAME} <option> [suboptions] [useflaglist]" |
|
echo |
Syntax: ${PROGRAM_NAME} <option> [suboptions] [useflaglist] |
echo "Options: -h, --help - show this message" |
|
echo " -v, --version - show version information" |
Options: -h, --help - show this message |
echo " -i, --info - show descriptions for the given useflags" |
-v, --version - show version information |
echo " -g, --global - show only global use flags (suboption)" |
-i, --info - show descriptions for the given useflags |
echo " -l, --local - show only local use flags (suboption)" |
-I, --info-installed - show descriptions for the given useflags and |
echo " -a, --active - show currently active useflags and their origin" |
their current impact on the installed system |
echo " -E, --enable - enable the given useflags" |
-g, --global - show only global use flags (suboption) |
echo " -D, --disable - disable the given useflags" |
-l, --local - show only local use flags (suboption) |
echo " -P, --prune - remove all references to the given flags from" |
-a, --active - show currently active useflags and their origin |
echo " make.conf to revert to default settings" |
-E, --enable - enable the given useflags |
echo |
-D, --disable - disable the given useflags |
echo "Notes: ${PROGRAM_NAME} currently only works for global flags defined" |
-P, --prune - remove all references to the given flags from |
echo " in make.globals, make.defaults or make.conf, it doesn't handle" |
make.conf to revert to default settings |
echo " use.defaults, use.mask or package.use yet (see portage(5) for details on" |
|
echo " these files). It also might have issues with cascaded profiles." |
Notes: ${PROGRAM_NAME} currently only works for global flags defined |
echo " If multiple options are specified only the last one will be used." |
in make.globals, make.defaults or make.conf, it doesn't handle |
|
use.defaults, use.mask or package.use yet (see portage(5) for details on |
|
these files). It also might have issues with cascaded profiles. |
|
If multiple options are specified only the last one will be used. |
|
HELP |
} | } |
| |
showversion() { | showversion() { |
echo "${PROGRAM_NAME} v${PROGRAM_VERSION}" |
cat << VER |
echo "Written by Marius Mauch" |
${PROGRAM_NAME} v${PROGRAM_VERSION} |
echo |
Written by Marius Mauch |
echo "Copyright (C) 2004 Gentoo Foundation, Inc." |
|
echo "This is free software; see the source for copying conditions." |
Copyright (C) 2004-2008 Gentoo Foundation, Inc. |
|
This is free software; see the source for copying conditions. |
|
VER |
} | } |
| |
# remove duplicate flags from the given list in both positive and negative forms | # remove duplicate flags from the given list in both positive and negative forms |
|
|
# Otherwise the status flags could be incorrect if a flag appers multiple times in | # Otherwise the status flags could be incorrect if a flag appers multiple times in |
# one location (like make.conf). | # one location (like make.conf). |
# Using python here as bash sucks for list handling. | # Using python here as bash sucks for list handling. |
|
# NOTE: bash isn't actually that bad at handling lists -- sh is. This may be |
|
# worth another look to avoid calling python unnecessariy. Or we could |
|
# just write the whole thing in python. ;) |
reduce_incrementals() { | reduce_incrementals() { |
echo $@ | python -c "import sys | echo $@ | python -c "import sys |
r=[] | r=[] |
|
|
fi | 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 -i foundone=0 |
|
local IFS |
|
|
|
args=("${@:-*}") |
|
|
|
case "${SCOPE}" in |
|
"global") echo "global use flags (searching: ${args})";; |
|
"local") echo "local use flags (searching: ${args})";; |
|
*) SCOPE="global" showinstdesc "${args[@]}" |
|
echo |
|
SCOPE="local" showinstdesc "${args[@]}" |
|
return;; |
|
esac |
|
|
|
descdir="$(get_portdir)/profiles" |
|
echo "************************************************************" |
|
|
|
if [ "${args}" = "*" ]; then |
|
args="$(get_useflaglist | sort -u)" |
|
fi |
|
|
|
set "${args[@]}" |
|
|
|
while [ -n "${1}" ]; do |
|
case "${SCOPE}" in |
|
"global") |
|
if desc=$(grep "^${1} *-" "${descdir}/use.desc"); then |
|
get_flagstatus "${1}" |
|
echo "$desc" |
|
# get list of installed packages matching this USE flag. |
|
IFS=$'\n' |
|
packages=($(equery -q -C hasuse -i "${1}" | awk '{ print $(NF-1) }')) |
|
foundone+=${#packages[@]} |
|
printf "Installed packages matching this USE flag: " |
|
if [ ${foundone} -gt 0 ]; then |
|
echo $'\n'"${packages[*]}" |
|
else |
|
echo "none" |
|
fi |
|
fi |
|
;; |
|
"local") |
|
# local flags are a bit more complicated as there can be multiple |
|
# entries per flag and we can't pipe into printf |
|
IFS=': ' # Use a space instead of a dash because dashes occur in cat/pkg |
|
while read pkg flag desc; do |
|
# print name only if package is installed |
|
# NOTE: If we implement bug #114086 's enhancement we can just use the |
|
# exit status of equery instead of a subshell and pipe to wc -l |
|
if [ $(equery -q -C list -i -e "${pkg}" | wc -l) -gt 0 ]; then |
|
foundone=1 |
|
get_flagstatus "${flag}" |
|
printf "%s (%s):\n%s\n\n" "${flag}" "${pkg}" "${desc#- }" |
|
fi |
|
done < <(grep ":${1} *-" "${descdir}/use.local.desc") |
|
;; |
|
esac |
|
shift |
|
done |
|
|
|
if [ ${foundone} -lt 1 ]; then |
|
echo "no matching entries found" |
|
fi |
|
} |
|
|
# show a list of all currently active flags and where they are activated | # show a list of all currently active flags and where they are activated |
showflags() { | showflags() { |
local args | local args |