first commit

This commit is contained in:
sose 2019-02-09 06:27:04 -08:00
commit 6419447db9
1 changed files with 39 additions and 0 deletions

39
setflags.sh Normal file
View File

@ -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