greetings earthlings,
i did not found (nor did i look for long enough) any tools/scripts to
easily manage package.use file, so i did my own. now i started to think
that, if there really is not any, my creation would be sufficient
(although possibly buggy) for most users who wish to have "easy" control
over package.use.
yes, i know this is not the best place to "announce" but, this is not an
real announcement, this is an query for an superior solution which would
show my creation to be useless/dublicate/stupid. (if mine is
useless/stupid it would be nice, so i would not have to maintain it and
i also could use some real software).
-- husku
#!/bin/bash
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
UF="package.use"
if [[ -z $1 ]]; then
echo "guse.sh pkgspec [flag modifiers]"
echo " - list use-flags for package by leaving the modifiers out"
echo " - this little script fondles your package.use"
echo " - by using double-dash (--) you are doomed back to default"
echo "example:"
echo " guse.sh kopete qq privacy -yahoo -msn jabber --highlight"
echo
exit
fi
[[ -n $1 ]] && ROWS=`grep $1 $UF` && HITS=`echo "${ROWS}"|wc -l`
[[ $HITS -gt 1 ]] && echo "Duplicates" && echo "$ROWS" && exit
# search from portage
[[ $HITS -lt 1 ]] && OLD=`emerge --nospinner -s ${1}|grep \*|awk '{print $2}'` \
&& HITS=`echo "${OLD}"|wc -l` && NEWATOM="yes"
if [[ $HITS -gt 1 ]]; then
echo "All Candidates:"
echo "${OLD}"
exit
elif [[ $HITS -lt 1 ]]; then
echo Package\ atom\ not\ found
exit
else
if [[ -n $NEWATOM ]]; then
if [[ -n $2 ]]; then
for a; do
NEW="$NEW $a"
done
echo new: ${NEW:0}
echo ${NEW:0} >> $UF
else
equery uses $1
fi
else
OLD="${ROWS}";
OLD_sed=`echo "${OLD}"|sed 's/\ /\\\ /g'`
OLD_sed=`echo "${OLD_sed}"|sed 's/\\//\\\\\//g'`
ORIG_sed=$OLD_sed
if [[ -z $2 ]]; then
equery uses $1
echo Your\ custom\ Set:
echo $OLD
exit
fi
for a; do
loops=$(( $loops+1 ));
if [[ loops -gt 1 ]]; then
if [[ -n $a ]]; then
[[ `equery uses $1|grep ${a:1}|wc -l` -lt 1 ]]
&& echo Typo\:\ $a\ Does\ not\ exists && exit
if [[ ${a:0:1} == "-" && $OLD =~ " "${a:1} ]];
then
if [[ ${a:0:2} == "--" ]]; then
# remove
echo remove negative: ${a:1}
OLD_sed=`echo "${OLD_sed}"|sed
's/ '"${a:1}"'/ /g'`
else
# disable
echo disable: ${a:1}
OLD_sed=`echo "${OLD_sed}"|sed
's/'${a:1}'/'${a}'/g'`
fi
elif [[ ${a:0:1} != "-" && $OLD =~ " -"${a} ]];
then
# enable
echo enable: $a
OLD_sed=`echo "${OLD_sed}"|sed
's/-'${a}'/'${a}'/g'`
elif [[ $OLD =~ " ${a}" ]]; then
echo keeping: $a
else
if [[ ${a:0:2} = "--" ]]; then
# remove
echo remove positive: ${a:2}
OLD_sed=`echo "${OLD_sed}"|sed
's/ '${a:2}'/ /'`
else
OLD_sed="${OLD_sed}\\ $a"
echo add: $a
fi
fi
elif [[ -z $a ]]; then
echo This is what you have:
echo $OLD
exit
else
NEW="$OLD_sed\\ $a"
echo lisataan: $NEW
OLD_sed=$NEW
fi
else
echo ATOM: `echo $OLD|awk '{print $1}'`
fi
done
[[ "$OLD_sed" != "$ORIG_sed" ]] && sed -i.bak
's/'"${ORIG_sed}"'/'"${OLD_sed}"'/' $UF
fi
fi