FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 02-17-2008, 04:44 PM
Mark Constable
 
Default Another clean repo script

On 18 Feb 2008 02:14, Roman Kyrylych wrote:
> ...
> Then we can forget about this corner case, it can be worked
> around by cache cleanup scripts based on filename parsing
> (available on BBS and ML).

Along these lines this could be useful for someone searching
through the list archives. It just removes old duplicates. I
need it to clean up my local custom repo when I move $PKGDEST
contents into it before rebuilding the repo database.

This construct has so far caught every package name I've thrown
at it...

pkgname=$(echo $FILENAME|sed 's/^(.*[^-][^0-9])-[0-9].*/1/')


mpkg_cleanrepo()
{
[ -n "$1" ] && WORK=$1 || WORK=/var/cache/pacman/pkg
[ -d $WORK ] && cd $WORK || {
echo "ERROR: $WORK does not exist" && return
}

local TMP=($(echo *.pkg*)) # to prevent set -e failing
[ ${#TMP[@]} -gt 1 ] && FILES=$(/bin/ls -v *.pkg*) || return

BEFORE_DU=$(du -sb|cut -f1)

for FILE in $FILES; do
NAME=$(echo $FILE|sed 's/^(.*[^-][^0-9])-[0-9].*/1/')
if [ "$PREV_NAME" = "$NAME" ]; then
# msg "$PREV_FILE
" 0 "REMOVED" 31
sudo rm $PREV_FILE
CNT_RM=$(($CNT_RM+1))
else
CNT_NOTRM=$(($CNT_NOTRM+1))
fi
PREV_FILE=$FILE
PREV_NAME=$NAME
done

AFTER_DU=$(du -sb|cut -f1)
DIFF_DU=$(($BEFORE_DU-$AFTER_DU))
CURRENT_DU=$(echo $((AFTER_DU/1000000))|sed ':a;s/B[0-9]{3}>/,&/;ta')
REMOVED_DU=$(echo $((DIFF_DU/1000000))|sed ':a;s/B[0-9]{3}>/,&/;ta')

if [ $CNT_RM -gt 0 ]; then
# msg "$(pwd)
" 33 "Package Path:" 31
printf "%-24s %4d %8sM
" "Packages removed" $CNT_RM $REMOVED_DU
printf "%-24s %4d %8sM
" "Remaining packages" $CNT_NOTRM $CURRENT_DU
fi
}

--markc

_______________________________________________
pacman-dev mailing list
pacman-dev@archlinux.org
http://archlinux.org/mailman/listinfo/pacman-dev
 

Thread Tools




All times are GMT. The time now is 08:36 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org