#!/bin/bash # Script to search for unnecessary and duplicate useflags in your make.conf # by c0nv1ct (c0nv1ct@inbox.com) # License: GPL if [ -f chkflag.log ] then echo "Deleting old log file" rm chkflag.log fi if [ -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