From 7d50c79c63e84c0b17c3fdc0dcf30f0645002f71 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Mon, 14 Dec 2015 10:36:03 -0800 Subject: Commit cfengine version of mastermirror-staging.sh as-is. Signed-off-by: Robin H. Johnson --- mastermirror-staging.sh | 92 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 mastermirror-staging.sh (limited to 'mastermirror-staging.sh') diff --git a/mastermirror-staging.sh b/mastermirror-staging.sh new file mode 100755 index 0000000..a7b286a --- /dev/null +++ b/mastermirror-staging.sh @@ -0,0 +1,92 @@ +#!/bin/bash +# distributed by cfengine + +# this takes about 1.5mins to run the first time. <45s thereafter + +# if the lv is really small (2G), the default inode ratio is too large. +# eg. mkfs.ext2 -i 4096 /dev/vg/var_mastermirror-staging + +# WARNING: Do NOT use CVS -D without resolving bug 183926 first, or bug 401633 happens. + +export CVSROOT="/var/cvsroot" +export GITROOT="/var/gitroot" + +CVS="/usr/bin/cvs -Q -T /mnt/cvstmp" +CVS_UP="${CVS} up -A -P -C -d" +CVS_CO="${CVS} -d ${CVSROOT} co -A -P" + +GIT="/usr/bin/git" +GIT_CL="${GIT} clone -q" +GIT_PL="${GIT} pull -q --ff-only --no-stat --no-rebase" + +WGET="/usr/bin/wget --timeout=2 -q" + +STAGING_DIR="/var/tmp/mastermirror-staging" +STAGING_CHANGELOG_DIR="/var/tmp/mastermirror-staging/changelogs" + +HERDS_XML_URI=https://api.gentoo.org/packages/herds.xml + +# TODO: we should probably be checking out to a directory and only rsyncing +# that on success of all checkouts. + +# sanity checking +if ! grep -sq ${STAGING_DIR} /proc/mounts; then + echo "lv not mounted" >&2 + exit 1 +fi + +# repo/gentoo (formerly CVS gentoo-x86) +if [[ ! -d ${STAGING_DIR}/gentoo-x86 ]] ; then + # not checked out yet, run initial co + ${GIT_CL} file://${GITROOT}/repo/gentoo.git/ ${STAGING_DIR}/gentoo-x86 +else + cd ${STAGING_DIR}/gentoo-x86 + ${GIT_PL} +fi + +# gentoo-news +if [[ ! -d ${STAGING_DIR}/gentoo-news ]]; then + # not checked out yet, run initial co + cd ${STAGING_DIR} + ${GIT_CL} file://${GITROOT}/data/gentoo-news.git/ gentoo-news +else + cd ${STAGING_DIR}/gentoo-news + ${GIT_PL} +fi + +# herds.xml +if [[ ! -d ${STAGING_DIR}/herds ]]; then + mkdir -p ${STAGING_DIR}/herds +fi +cd ${STAGING_DIR}/herds +f=herds.xml +${WGET} -q "${HERDS_XML_URI}" -O ${f}.tmp && mv -f ${f}{.tmp,} || rm -f ${f}.tmp + +# dtd +if [[ ! -d ${STAGING_DIR}/dtd ]]; then + # not checked out yet, run initial co + cd ${STAGING_DIR} + ${GIT_CL} file://${GITROOT}/data/dtd.git/ dtd +else + cd ${STAGING_DIR}/dtd + ${GIT_PL} +fi + +# glsa +if [[ ! -d ${STAGING_DIR}/glsa ]]; then + # not checked out yet, run initial co + cd ${STAGING_DIR} + ${GIT_CL} file://${GITROOT}/data/glsa.git/ glsa +else + cd ${STAGING_DIR}/glsa + ${GIT_PL} +fi + +# changelogs +if [[ ! -d ${STAGING_CHANGELOG_DIR} ]]; then + # not checked out yet, run initial co + ${GIT_CL} file://${GITROOT}/data/gentoo-changelogs.git/ ${STAGING_CHANGELOG_DIR} +else + cd ${STAGING_CHANGELOG_DIR} + ${GIT_PL} +fi -- cgit v1.2.3-65-gdbad