summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--roles/git/make_checkout_seed/files/make-git-checkout-seed.sh47
-rw-r--r--roles/git/make_checkout_seed/tasks/main.yml13
2 files changed, 60 insertions, 0 deletions
diff --git a/roles/git/make_checkout_seed/files/make-git-checkout-seed.sh b/roles/git/make_checkout_seed/files/make-git-checkout-seed.sh
new file mode 100644
index 000000000..e873523b9
--- /dev/null
+++ b/roles/git/make_checkout_seed/files/make-git-checkout-seed.sh
@@ -0,0 +1,47 @@
+#!/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/rpms
+
+# Where we'll create the repos to tar up
+WORK_DIR=/srv/git_seed
+# Subdirectory makes cleanup easier
+SEED_DIR=$WORK_DIR/git-checkout
+
+# 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
+
+# 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
+ working_tree=$SEED_DIR/$(basename $repo .git)
+ 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
+ popd &>/dev/null
+ 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
+ fi
+done
+
+tar -cf - -C$WORK_DIR $(basename $SEED_DIR)|xz -2 > $OUTPUT_DIR/.git-seed-$DATE.tar.xz
+rm $OUTPUT_DIR/git-seed*tar.xz
+mv $OUTPUT_DIR/.git-seed-$DATE.tar.xz $OUTPUT_DIR/git-seed-$DATE.tar.xz
+ln -s git-seed-$DATE.tar.xz $OUTPUT_DIR/git-seed-latest.tar.xz
diff --git a/roles/git/make_checkout_seed/tasks/main.yml b/roles/git/make_checkout_seed/tasks/main.yml
new file mode 100644
index 000000000..86a35bdeb
--- /dev/null
+++ b/roles/git/make_checkout_seed/tasks/main.yml
@@ -0,0 +1,13 @@
+---
+# tasklist for setting up the Git checkout seed
+
+- name: create the destination directory
+ file: dest=/srv/git_seed owner=root group=root mode=0755 state=directory
+
+- name: install the script and schedule its execution
+ copy: src=make-git-checkout-seed.sh dest=/usr/local/bin/make-git-checkout-seed.sh mode=0755
+ cron: >
+ name="make-git-checkout-seed" cron_file="ansible-make-git-checkout-seed"
+ minute=0 hour=2
+ user=root
+ job='/usr/local/bin/lock-wrapper make-git-checkout-seed "/usr/local/bin/make-git-checkout-seed.sh | /usr/local/bin/nag-once fassync 1d 2>&1"'