first commit
This commit is contained in:
commit
6419447db9
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
usefile="/etc/portage/package.use/$1"
|
||||
touch /tmp/usefile
|
||||
|
||||
function addflag
|
||||
{
|
||||
if ! cat $usefile| tr ' ' '\n' |grep -e "^$1" ; then
|
||||
if [[ $(echo $1 | cut -c 1) == '-' ]]; then
|
||||
cat $usefile | sed -e 's/ '$(echo $1 | cut -c 2-)'//g' > /tmp/usefile
|
||||
printf " $1" >> /tmp/usefile
|
||||
else
|
||||
cat $usefile | sed -e 's/ -'$1'//g' > /tmp/usefile
|
||||
printf " $1" >> /tmp/usefile
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
echo "specify a package atom."
|
||||
exit
|
||||
elif [[ -z $2 ]]; then
|
||||
echo "specify some flags."
|
||||
exit
|
||||
elif [[ ! -f $usefile ]]; then
|
||||
if [[ ! -d $(dirname $usefile) ]]; then
|
||||
mkdir $(dirname $usefile)
|
||||
fi
|
||||
touch $usefile
|
||||
fi
|
||||
|
||||
printf "$1" > $usefile
|
||||
for i in $(echo ${BASH_ARGV[*]} | cut -f -$(( $BASH_ARGC -1 )) -d ' ')
|
||||
do
|
||||
addflag $i
|
||||
cat /tmp/usefile > $usefile
|
||||
done
|
||||
|
||||
rm /tmp/usefile
|
||||
exit
|
Loading…
Reference in New Issue