X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Message-ID: <4A38C6B0.5020700@bonhard.uklinux.net> Date: Wed, 17 Jun 2009 11:34:24 +0100 From: Fergus User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: Cygwin ML CC: Fergus Subject: Re: Is there a script to remove old packages from local disk Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Assume your local Cygwin repository is under some /pathname/ for example: /g/users/yourname/cygfiles/setup.ini AND /g/users/yourname/cygfiles/release/* or you can have spaces if you like: /h/my name/cygnus solutions/setup.ini AND /h/my name/cygnus solutions/release/* As setup.ini advances with time and you augment the subdirectory release/, it becomes bloated with more and more redundant files. It can be cleaned out using the following script with the syntax clean /pathname/ for example clean /g/users/yourname/cygfiles/ # note leading and trailing /s or clean /h/my\ name/cygnus\ solutions/ # note handling of spaces achieved eg by Tab-completion (By the way: the reason the script looks so horrible is entirely because it is constructed to cope with the possibility of spaces in the repository pathname. If there were guaranteed no spaces, the line-by-line syntax would be much easier. But the job the script does is very simple.) This is the script: #! /bin/sh # clean cat "$1setup.ini" | sed -n '/release\//p' | sed 's/^.*release\///g' |\ sed 's/\( [a-f0-9]*\)*$//g' | sort | uniq > setup.1 find "$1release/" -type f | sed -e 's/^.*release\///g' | sort > setup.2 diff setup.1 setup.2 | grep ">" > setup.3 cat setup.3 | sed -e 's:> :rm -vfr "'"$1"'release\/:g ; s/$/"/g' | bash If you are nervous about what you might delete you can replace the last line with cat setup.3 | sed -e 's:> :rm -vfr "'"$1"'release\/:g ; s/$/"/g' > setup.4 and then bash setup.4 when you are happy with what the script does. Key: setup.1 lists all the release files referred to in setup.ini, including [prev] and *src* setup.2 lists all the release files in your repository /pathname/ setup.3 identifies those files in your repository not referred to in setup.ini setup.4 is the script that deletes all these unnecessary files Fergus -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/