Promote the new make-git-checkout-seed to prod.

This commit is contained in:
Ralph Bean 2016-02-22 16:35:58 +00:00
parent 5566d6a73e
commit 4971401cec
3 changed files with 22 additions and 90 deletions

View file

@ -3,14 +3,13 @@
# mkdir /srv/git_seed
# cron job to invoke file daily
# Need to setup OUTPUT_DIR to be served by apache
# modified by doteast
# modified by alda
# Where the git repos live. These are bare repos
ORIGIN_DIR=/srv/git/repositories
# Where we'll create the repos to tar up
WORK_DIR=/srv/git_seed
# Subdirectory makes cleanup easier
SEED_DIR=$WORK_DIR/git-checkout
@ -32,23 +31,34 @@ echo "$TIMESTAMP" > $SEED_DIR/TIMESTAMP
for repo in $ORIGIN_DIR/*.git ; do
working_tree=$SEED_DIR/$(basename $repo .git)
bname=$(basename $repo .git)
working_tree=$SEED_DIR/$bname
# uncomment to skip processing dead.package repos
# if [ -e $working_tree/dead.package ]; then
# continue
# fi
if [ -d $working_tree ] ; then
pushd $working_tree &> /dev/null
sed -i "s@url = .*@url = $repo@" $working_tree/.git/config
git pull --all &> /dev/null
sed -i "s@url = .*@url = git://pkgs.fedoraproject.org/$(basename $repo .git)@" $working_tree/.git/config
sed -i "s@url = .*@url = git://pkgs.fedoraproject.org/$bname@" $working_tree/.git/config
popd &>/dev/null
if [ -e $working_tree/$(basename $repo .git).spec ]; then
cp $working_tree/$(basename $repo .git).spec $SPEC_DIR/
if [ -e $working_tree/dead.package ]; then
rm -f $working_tree/$bname.spec
rm -f $SPEC_DIR/$bname.spec
elif [ -e $working_tree/$bname.spec ]; then
cp $working_tree/$bname.spec $SPEC_DIR/
fi
else
pushd $SEED_DIR &>/dev/null
git clone $repo &> /dev/null
popd &>/dev/null
sed -i "s@url = .*@url = git://pkgs.fedoraproject.org/$(basename $repo .git)@" $working_tree/.git/config
if [ -e $working_tree/$(basename $repo .git).spec ]; then
cp $working_tree/$(basename $repo .git).spec $SPEC_DIR/
sed -i "s@url = .*@url = git://pkgs.fedoraproject.org/$bname@" $working_tree/.git/config
if [ -e $working_tree/dead.package ]; then
rm -f $working_tree/$bname.spec
rm -f $SPEC_DIR/$bname.spec
elif [ -e $working_tree/$bname.spec ]; then
cp $working_tree/$bname.spec $SPEC_DIR/
fi
fi
done

View file

@ -1,73 +0,0 @@
#!/bin/sh
# Puppet notes -- script is file
# mkdir /srv/git_seed
# cron job to invoke file daily
# Need to setup OUTPUT_DIR to be served by apache
# Where the git repos live. These are bare repos
ORIGIN_DIR=/srv/git/repositories
# Where we'll create the repos to tar up
WORK_DIR=/srv/git_seed
# Subdirectory makes cleanup easier
SEED_DIR=$WORK_DIR/git-checkout
# subdirectory to collect rpm speciles
SPEC_DIR=$WORK_DIR/rpm-specs
# Where to store the seed tarball for download
OUTPUT_DIR=/srv/cache/lookaside/
# Instead of starting fresh each time, we'll try to use git pull to keep things synced
#rm -rf $WORK_DIR/*
mkdir -p $SEED_DIR
mkdir -p $SPEC_DIR
# Give people an indication of when this checkout was last synced
TIMESTAMP=`date --rfc-3339=seconds`
DATE=`date +'%Y%m%d'`
echo "$TIMESTAMP" > $SEED_DIR/TIMESTAMP
for repo in $ORIGIN_DIR/*.git ; do
bname=$(basename $repo .git)
working_tree=$SEED_DIR/$bname
# uncomment to skip processing dead.package repos
# if [ -e $working_tree/dead.package ]; then
# continue
# fi
if [ -d $working_tree ] ; then
pushd $working_tree &> /dev/null
sed -i "s@url = .*@url = $repo@" $working_tree/.git/config
git pull --all &> /dev/null
sed -i "s@url = .*@url = git://pkgs.fedoraproject.org/$bname@" $working_tree/.git/config
popd &>/dev/null
if [ -e $working_tree/dead.package ]; then
rm -f $working_tree/$bname.spec
rm -f $SPEC_DIR/$bname.spec
elif [ -e $working_tree/$bname.spec ]; then
cp $working_tree/$bname.spec $SPEC_DIR/
fi
else
pushd $SEED_DIR &>/dev/null
git clone $repo &> /dev/null
popd &>/dev/null
sed -i "s@url = .*@url = git://pkgs.fedoraproject.org/$bname@" $working_tree/.git/config
if [ -e $working_tree/dead.package ]; then
rm -f $working_tree/$bname.spec
rm -f $SPEC_DIR/$bname.spec
elif [ -e $working_tree/$bname.spec ]; then
cp $working_tree/$bname.spec $SPEC_DIR/
fi
fi
done
tar -cf - -C$WORK_DIR $(basename $SEED_DIR)|xz -2 > $OUTPUT_DIR/.git-seed-$DATE.tar.xz
tar -cf - -C$WORK_DIR $(basename $SPEC_DIR)|xz -2 > $OUTPUT_DIR/.rpm-specs-$DATE.tar.xz
rm $OUTPUT_DIR/git-seed*tar.xz
rm $OUTPUT_DIR/rpm-specs*tar.xz
mv $OUTPUT_DIR/.git-seed-$DATE.tar.xz $OUTPUT_DIR/git-seed-$DATE.tar.xz
mv $OUTPUT_DIR/.rpm-specs-$DATE.tar.xz $OUTPUT_DIR/rpm-specs-$DATE.tar.xz
ln -s git-seed-$DATE.tar.xz $OUTPUT_DIR/git-seed-latest.tar.xz
ln -s rpm-specs-$DATE.tar.xz $OUTPUT_DIR/rpm-specs-latest.tar.xz

View file

@ -4,13 +4,8 @@
- name: create the destination directory
file: dest=/srv/git_seed owner=root group=root mode=0755 state=directory
- name: install the staging version of the script and schedule its execution
copy: src=make-git-checkout-seed.sh.staging dest=/usr/local/bin/make-git-checkout-seed.sh mode=0755
when: env == 'staging'
- name: install the production version of the script and schedule its execution
copy: src=make-git-checkout-seed.sh dest=/usr/local/bin/make-git-checkout-seed.sh mode=0755
when: env != 'staging'
- name: install cron job.
cron: >