Created
July 13, 2009 16:03
-
-
Save fapestniegd/146220 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export MIRROR_DIR="/opt/dists/redhat/rhel-i386-server-5/" | |
[ -d ${MIRROR_DIR} ] || mkdir -p ${MIRROR_DIR} | |
yum clean all | |
export LIST="" | |
export LIST_COUNTER=0 | |
export LIST_MAX=50 # not sure where the sweet spot is. | |
yum list available | awk ' { | |
if(on){if((NF==1)||(NF==3)){print $1;}} | |
if($0~"^Available Packages"){on=1;} | |
}'| \ | |
sed -e 's/\.i386$//' -e 's/\.noarch//' | \ | |
while read line;do | |
rpmname=$(yum info $line |sed -e 's/ //g'| awk -F: '{ | |
if($1~"^Name *"){n=$2;} | |
if($1~"^Version *"){v=$2;} | |
if($1~"^Release *"){r=$2;} | |
if($1~"^Arch *"){a=$2;} | |
} END { print n"."v"."r"."a".rpm" }') | |
if [ ! -f "${MIRROR_DIR}/${rpmname}" ];then | |
echo "Adding: $line [$rpmname]" | |
LIST="${LIST} ${line}" | |
LIST_COUNTER=$(expr ${LIST_COUNTER} + 1) | |
if [ ${LIST_COUNTER} -ge ${LIST_MAX} ];then | |
yum install -y --downloadonly $LIST --downloaddir=${MIRROR_DIR} | |
export LIST='' | |
export LIST_COUNTER=0 | |
fi | |
fi | |
done | |
yum install -y --downloadonly $LIST --downloaddir=${MIRROR_DIR} | |
# automerge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment