[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: yum downloadonly



On Fri, Jul 20, 2007 at 02:02:29PM -0400, Todd Zullinger wrote:
> Justin W wrote:
> > I've been keeping the cache, but now with so many updates, I've got
> > a bunch of older versions which have newer packages also downloaded.
> > Is there a utility which will cleanup the older packages and leave
> > the newer ones? If I can find that, I sure I could then devise a way
> > to combine yum, cron, "that" utility, rsync, createrepo, and the
> > priority plugin for yum to download the minimal amount of stuff for
> > multiple servers/desktops/virtual machines (right now I only have
> > one, and this problem is one of a couple reasons why I haven't
> > expanded yet).
> 
> Check out repomanage from yum-utils.  You could use it something like
> this to move old packages to an archive dir (or remove them):
> 
> repo=/path/to/cache
> archive=/path/to/archive
> repomanage --old $repo | while read package; do
>     mv "$package" $archive
> done
> 

This script makes use of repomanage easy. Check it out:
cut--------------------------cut------------------------------------cut
#!/bin/bash
# SCRIPTNAME: use-repomanage
# Move or remove old versions of rpms from repo cache OR
# List new packs in repos cache

if [ ! -x "`which repomanage 2>/dev/null`" ]; then
    echo "install yum-utils rpm to continue. exiting..."
    exit 1
fi

ARCHIVEDIR=SomeDirPath
CACHEDIR=/var/cache/yum
if [ ! -d "$ARCHIVEDIR" ]; then 
    echo "Please correct \$ARCHIVEDIR - invalid archive dir \"$ARCHIVEDIR\" exiting..."
    exit 1
fi

if     [ "$1" = -n -o "$1" =  new ]; then
	    ACTION=-n
elif   [ "$1" = "-o" -o "$1" = old ]; then
	    ACTION=-o
else
	    echo "script takes two arguments -o/old or -n/new"
	    exit 1
fi

for x in `find $CACHEDIR -depth -type d -name packages`
do
	echo -e "\033[1;44mprocessing repo:\033[0m\t\c"
	basename `dirname $x` $CACHEDIR
	repomanage $ACTION $x|while read package
	    do
		[ $ACTION = -n ] && ls -lh $package || mv $package $ARCHIVEDIR
	    done
done


if [ "`ls -lh $ARCHIVEDIR|head -1|awk '{ print $2 }'`" != 0 ]; then
    echo -e "\n\033[0mDo you want to clean ARCHIVEDIR $ARCHIVEDIR. You will save `ls -lh $ARCHIVEDIR|head -1` [\033[1mNo\033[0m/YeS] ? \c"
    read CONFIRM
    if [ "$CONFIRM" = YeS ]; then
	rm -f $ARCHIVEDIR/*.rpm
     else
	echo "Not confirmed..."
    fi
fi
cut--------------------------cut------------------------------------cut

HTH
-- 
vikram...
         ||||||||
         ||||||||
^^'''''^^||root||^^^'''''''^^
        // \\   ))
       //(( \\// \\
      // /\\ ||   \\
     || / )) ((    \\
-- 
Yes, Private DOBERMAN!!
-- 
~|~
 =


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]