added repo maintenance scripts

This commit is contained in:
Matthew Mosesohn 2013-05-15 20:31:16 +04:00
parent 377dad7909
commit 46c2d60d13
4 changed files with 179 additions and 16 deletions

View File

@ -7,11 +7,11 @@ selinux --disabled
# #url --url http://172.18.67.168/centos-repo/centos-6.3
# #url --url http://mirror.stanford.edu/yum/pub/centos/6.3/os/x86_64/
# #url --url http://mirror.centos.org/centos/6.3/os/x86_64/
url --url http://download.mirantis.com/centos-minimal/
url --url http://srv11-msk.msk.mirantis.net/centos-repo/centos-minimal/
network --bootproto=dhcp
# #repo --name=Base --mirrorlist=http://mirrorlist.centos.org/?release=6.3&arch=x86_64&repo=os
# #repo --name=Updates --mirrorlist=http://mirrorlist.centos.org/?release=6.3&arch=x86_64&repo=updates
repo --name=Mirantis --mirrorlist=http://download.mirantis.com/epel-fuel-folsom-2.1/mirror.external.list
repo --name=Mirantis --mirrorlist=http://download.mirantis.com/epel-fuel-folsom-2.1/mirror.internal-stage.list
keyboard us
rootpw r00tme
timezone --utc UTC
@ -119,20 +119,20 @@ cp -r ${SOURCE}/astute*.gem ${repodir}
tar zxf ${SOURCE}/fuel-modules.tgz -C /etc/puppet/modules
# Prepare local repository specification
#rm /etc/yum.repos.d/CentOS*.repo
cat > /etc/yum.repos.d/puppet.repo << EOF
[Puppetlabs-products]
name=Puppetlabs repo
baseurl=http://yum.puppetlabs.com/el/6/products/x86_64/
gpgcheck=0
EOF
cat > /etc/yum.repos.d/puppet-dependencies.repo << EOF
[Puppetlabs-dependencies]
name=Puppetlabs Dependencies repo
baseurl=http://yum.puppetlabs.com/el/6/dependencies/x86_64/
gpgcheck=0
EOF
rm /etc/yum.repos.d/CentOS*.repo
#cat > /etc/yum.repos.d/puppet.repo << EOF
#[Puppetlabs-products]
#name=Puppetlabs repo
#baseurl=http://yum.puppetlabs.com/el/6/products/x86_64/
#gpgcheck=0
#EOF
#
#cat > /etc/yum.repos.d/puppet-dependencies.repo << EOF
#[Puppetlabs-dependencies]
#name=Puppetlabs Dependencies repo
#baseurl=http://yum.puppetlabs.com/el/6/dependencies/x86_64/
#gpgcheck=0
#EOF
# Workaround for Hiera-1.2.1 behavior. Place link to required Hiera config file to Puppet directory
if [ ! -f /etc/puppet/hiera.yaml ] && [ ! -L /etc/puppet/hiera.yaml ] ; then

80
maintenance/functions.sh Executable file
View File

@ -0,0 +1,80 @@
#!/bin/bash
#Load in settings
. settings.conf
function sync_repo_osci {
release=$1
kojitag=$2
outdir=$3
binrepo="$REPOTOPDIR/$kojitag/$BINARYDIR/"
srcrepo="$REPOTOPDIR/$kojitag/$SRPMDIR/"
mkdir -p $outdir
cd $outdir
mkdir -p SRPMS x86_64 noarch
make_yum_conf "$binrepo" "$srcrepo"
reposync -c "$YUMCONF" --repo "$(get_repo_name "$binrepo")" --norepopath -p .
reposync -c "$YUMCONF" --source --repo "$(get_repo_name "$srcrepo")" --norepopath -p .
get_puppet27
mv *.x86_64.rpm x86_64
mv *.noarch.rpm noarch
mv *.src.rpm SRPMS
createrepo .
}
function get_puppet27 {
puppetver="2.7.19-1.el6"
kojitag="puppet27"
mkdir -p noarch/ SRPMS/
wget "$REPOTOPDIR/$kojitag/$BINARYDIR/puppet-$puppetver.noarch.rpm" -O noarch/puppet-$puppetver.noarch.rpm
wget "$REPOTOPDIR/$kojitag/$BINARYDIR/puppet-server-$puppetver.noarch.rpm" -O noarch/puppet-server-$puppetver.noarch.rpm
wget "$REPOTOPDIR/$kojitag/$SRPMDIR/puppet-$puppetver.src.rpm" -O noarch/puppet-$puppetver.src.rpm
}
function copy_to_public_mirror {
#Release here should be epel-fuel-folsom-2.x
#Strip tailing slash
path=$1
release=${1%/}
rsync -vazPL "$path" "$EXT_REPO/$1"
}
function make_yum_conf {
#Parameters: repo urls
cat > $YUMCONF << EOF
[main]
cachedir=/var/cache/yum
keepcache=1
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
EOF
for url in $@; do
#Strip tailing slash
url=${url%/}
if ! grep -q "http" <<< "$url"; then
echo "$url is not a valid url."
exit 1
fi
#Strip non alphanumeric so it can be a yum repo name
reponame=$(get_repo_name "$url")
cat >> $YUMCONF << EOF
[$reponame]
name=$reponame
baseurl=$url
gpgcheck=0
enabled=1
EOF
done
}
function get_repo_name {
#prints string with only alphanumeric characters
echo -en "$1" | sed 's/[^[:alnum:]]//g'
}
function cleanup {
rm -rf $TMPDIR
}

68
maintenance/maintenance.sh Executable file
View File

@ -0,0 +1,68 @@
#!/bin/bash
DIR="$(cd "$(dirname "$0")" && pwd)"
. "$DIR/functions.sh"
. "$DIR/settings.conf"
function usage {
cat << EOF
Repository Maintenance Tool:
This tool consists of two methods:
* import - Syncing repositories from OSCI
* publish - Publishing internal repository to download.mirantis.com
import:
-r RELEASETAG Fuel version being created
-k KOJITAG OSCI tag that we should fetch
-o OUTPUTDIR destination path for new repo
publish:
-r RELEASETAG
Examples:
$0 import -r 2.2 -k fuel-2.2 -o ./epel-fuel-folsom-2.2 <- all OpenStack packages and deps
$0 import -r 2.2 -k fuel-folsom -o ./epel-fuel-folsom-2.2 <- just OpenStack packages
$0 import -r 2.2 -k epel-fuel-folsom -o ./epel-fuel-folsom-2.2 <- just deps
$0 publish -r epel-fuel-folsom-2.2
EOF
}
if [ -z $3 ]; then
usage
exit 1
fi
case $1 in
import) method="import"
;;
publish) method="publish"
;;
*) echo "Unknown command $1"
usage
cleanup
exit 1
esac
shift
outdir=$PWD
while [ -n "$2" ]; do
case $1 in
-r) release=$2
shift 2
;;
-k) kojitag=$2
shift 2
;;
-o) outdir=$2
shift 2
;;
*) echo "Unknown option $1"
usage
cleanup
exit 1
;;
esac
done
if [[ "$method" == "import" ]];then
sync_repo_osci "$release" "$kojitag" "$outdir"
fi
if [[ "$method" == "publish" ]];then
copy_to_public_mirror "$release"
fi
cleanup

15
maintenance/settings.conf Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
if [ -z "$TMPDIR" ]; then
TMPDIR=$(mktemp -d /tmp/fuelmaint.XXXX)
fi
YUMCONF=$TMPDIR/yum.conf
OSCISERVER="http://osci-koji.srt.mirantis.net"
REPOTOPDIR="$OSCISERVER/mash"
BINARYDIR="/x86_64"
SRPMDIR="/source/SRPMS"
STAGEDIR="epel-fuel-folsom-stage"
EXTERNAL_MIRROR="repo.srt.mirantis.net"
EXT_REPO="rsync://$EXTERNAL_MIRROR/repo"