[csw-maintainers] Rremoving oldies / duplicates from experimental

Maciej Bliziński maciej at opencsw.org
Mon Aug 22 11:02:35 CEST 2011


>From the "Maciej's random shell snippets" series:

Let's suppose you're working on a project and putting files into
/home/experimental/project.  You build not just from one recipe, you
build from two or three, and you stick all packages you built into
your experimental directory.  You will likely end up with packages
from yesterday you want to remove, but you don't want to remove
everything, because there are older packages from the other build
recipe that you don't want to remove.  Typically it's annoying,
because you need to look for two files with the same catalogname,
architecture and OS release, but older REV stamp. For example:

libstdc++6-4.6.1,REV=2011.08.21-SunOS5.10-sparc-CSW.pkg.gz
libstdc++6-4.6.1,REV=2011.08.20-SunOS5.10-sparc-CSW.pkg.gz
libstdc++5-3.4.6,REV=2011.08.20-SunOS5.10-sparc-CSW.pkg.gz

One of the above packages can be removed. Can you tell which one, in 1
second? I can't. But shell can.

Here's a shell snippet that outputs rm commands you can execute to
clean up your experimental directory.  I broke it up into shorter
lines to ensure you can copy and paste it.

exp=/home/experimental/gcc4
ls ${exp}/ | gawk -F- '{print $1, $3, $4}' \
| sort | uniq -c \
| gegrep -v '^\s+1' \
| while read number catalogname osrel arch; do \
echo rm \
$(echo $exp/${catalogname}-*-${osrel}-${arch}* \
| gtr ' ' '\n' | ghead -n 1); done

If anyone has a cleverer way to clean up experimental directories, hit me!

Maciej


More information about the maintainers mailing list