Pretty useful script. Let me know what you think, and modify how you'd like. #!/bin/bash #Shows unrequired packages and missing dependencies. #Author: Jerry Haltom <ssrit@larvalstage.net> if [ `whoami` != "root" ] then echo 'Only root can run this tool.' exit fi tmp="/tmp/$$" rm -rf ${tmp} > /dev/null 2>&1 mkdir ${tmp} > /dev/null 2>&1 rm ${tmp}/current ${tmp}/i > /dev/null 2>&1 touch ${tmp}/current ${tmp}/image ${tmp}/safe ${tmp}/needed #Retrieve currently merged packages. echo Retrieving currently merged packages. find /var/db/pkg -name '*.ebuild' \ | sed s:/var/db/pkg/:: \ | sed s/-[0-9].*// \ | sort \ | sort -u \ >> ${tmp}/current echo ' ' `cat ${tmp}/current | wc -l` 'currently merged packages.' echo #Open currently merged packages in text viewer for review. #${EDITOR} ${tmp}/current echo 'Retrieving desired packages.' #Retrieve system packages and add to image. emerge system -e -p \ | grep ^\\[ebuild \ | sed s/^...........................// \ | sed s/.....$// \ | sed s/-[0-9].*// \ | sort \ | sort -u \ >> ${tmp}/image echo ' ' `cat ${tmp}/image | wc -l` 'packages contained in system.' #Create local copy of world and ask user to verify it. #echo 'Please add or remove packages from world.' cp /var/cache/edb/world ${tmp}/world #${EDITOR} ${tmp}/world echo ' ' `cat ${tmp}/world | wc -l` 'packages contained in world.' echo #Retrieve world packages and dependencies and add to image. echo 'Listing world and total number of dependencies.' for pkg in `cat ${tmp}/world | sort | sort -u` do emerge ${pkg} -e -p \ | grep ^\\[ebuild \ | sed s/^...........................// \ | sed s/.....$// \ | sed s/-[0-9].*// \ > ${tmp}/pkg-deps echo ' ' ${pkg} `cat ${tmp}/pkg-deps | wc -l` cat ${tmp}/pkg-deps >> ${tmp}/image done echo #Cleanup image sort ${tmp}/image | sort -u > ${tmp}/image.new mv ${tmp}/image.new ${tmp}/image #Show user the final image. #echo 'Review the final destination system image.' #${EDITOR} ${tmp}/image #echo #Determine packages that exist in current but not in image. These packages are safe to clean up. echo 'These packages have no other packages depending on them.' for pkg in `cat ${tmp}/current` do if [ "`cat ${tmp}/image | grep -x ${pkg} | wc -l`" -eq "0" ] then echo ' ' ${pkg} 'has no currently depending packages.' echo ${pkg} >> ${tmp}/safe fi done echo ' Total of' `cat ${tmp}/safe | wc -l` 'packages.' echo #Determine packages that exist in image but not in current. These packages should be added. echo 'These packages are depended upon but are not present on the system.' for pkg in `cat ${tmp}/image` do if [ "`cat ${tmp}/current | grep -x ${pkg} | wc -l`" -eq "0" ] then echo ' ' ${pkg} 'is not present.' echo ${pkg} >> ${tmp}/needed fi done echo ' Total of' `cat ${tmp}/needed | wc -l` 'packages.' echo rm -rf ${tmp}
check out what I've hacked up based on your script at http://www.lostlogicx.com/ebuilds/depend.scr Let me know what you think and then I'll talk to karltk about including it in gentoolkit, I do find it quite convenient :)
Cool and all... except it's broken now. hehe. These packages have no other packages depending on them. app-admin/fam-oss-2.6.7 app-admin/gentoolkit-0.1.10 app-admin/gentoolkit-0.1.11 app-misc/screen-3.9.11-r2 app-office/gnumeric-1.0.6 app-text/ghostscript-6.53-r2 dev-java/blackdown-jre-1.3.1-r7 dev-lang/tcl-8.3.3-r1 dev-libs/glib-2.0.1-r5 ... continued. Ill be looking over it a bit later.
Ok looked over it a bit more. The reason I looped over emerge -ep $worldline is because emerge -ep apparently has a bug that does not list all the correct dependencies when done on world. I could never place the bug, but it did effect results.
well I didn't do it on "world" I did it on the list of packages IN world... the way you had it was just taking forever at runtime... not that hard to switch it really... hmm...
fixed. at a compromise in runtime... new version same place as the old. I'm going to talk to karltk as soon as I get a chance about including it... if he agrees with me that it is a convenient tool, would you be interested in making a man page for it?
Another update to the version posted on my website... MUCH faster by using a single qpkg call and an fgrep... I can probably still make it faster... but I haven't gotten to that yet.
I've been doing more work on this... added another feature that started as a bug... check it out at the URL posted previously... I think it is getting close to production ready.
OK so I have time on my hands... but I updated the script a wee bit more, now it parses multiple short opts together (ie. -CNvRUI) to do this I had to change the no color short option to -C, hope that doesn't bother anyone... how to import this functionality into qpkg... :)
Haha awesome. Looks like it really took off. Yes, I think this should be included in qpkg...
I poked at qpkg with a stick, due to the types of options that the original qpkg author used I can't make it parse combined shorts... I am beginning to more seriously consider karltk's previous suggestion of deprecating qpkg and rewriting it from scratch with a new name... Hmm... still haven't done the man page for dep-clean (or whatever we end up calling it in gentoolkit) any chance of you doing it, Jerry?
Sure. What are we going to call it?
Created attachment 2363 [details] man page for dep-clean Per our discussions...
Its in, thanks Jerry and Paul for your work on this!