All pastes #827062 Raw Edit

useflags.sh

public shellscript v1 · immutable
#827062 ·published 2007-12-21 16:00 UTC
rendered paste body
#!/bin/bash# Script to search for unnecessary and duplicate useflags in your make.conf# by c0nv1ct (c0nv1ct@inbox.com) # License: GPLif [ -f chkflag.log ] then  echo "Deleting old log file"  rm chkflag.logfiif [ -f /usr/bin/eix ] then  echo "Starting search, please wait, this may take a few minutes..."  source /etc/make.conf  for flag in `echo $USE`   do    chkdup=`echo $USE | grep -wo -e $flag | grep -c -e $flag`    flag2=`echo $flag | sed -e 's/^-//'`    if [ -f chkflag.log ] && [ `awk '{ print $1 }' chkflag.log | grep -c -e $flag` -gt 0 ]     then echo "Skipping duplicate"    elif [ "$flag" == livecd ]     then echo "livecd should be removed" >> chkflag.log    elif [ -z `eix -IU --only-names -- "$flag2" | head -1` ] && [ "$chkdup" -gt 1 ]     then echo "$flag can be removed, all $chkdup instances of it" >> chkflag.log    elif [ -z `eix -IU --only-names -- $flag2 | head -1` ]     then echo "$flag can be removed" >> chkflag.log    elif [ "$chkdup" -gt 1 ]     then       echo "$flag has duplicates, `expr $chkdup - 1` instances can be removed" >> chkflag.log    fi  done  echo "Search complete."  if [ -f chkflag.log ]   then    less chkflag.log   else    echo "No problems found..."  fi  echo "All done" else  echo "This script requires eix, please emerge it."fi