From 01bba2d515aa5fd16275c522856021122bcc618d Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 14 Aug 2008 19:43:48 +0200 Subject: [PATCH] Perform clone in $reporoot instead of the cloning/ stage area. This simplifies the process and reconciling our data with the cloned repository. --- jobs/clonecheck.sh | 7 ++-- mirroring/clone.sh | 104 +++++++++++++++++++++++------------------------------ 2 files changed, 49 insertions(+), 62 deletions(-) rewrite mirroring/clone.sh (61%) diff --git a/jobs/clonecheck.sh b/jobs/clonecheck.sh index 5123179..28c828a 100755 --- a/jobs/clonecheck.sh +++ b/jobs/clonecheck.sh @@ -7,9 +7,10 @@ shopt -s nullglob cd "$cfg_mqueuedir"/to-clone get_repo_list_here | while read dir; do - mkdir -p "$cfg_mqueuedir/cloning/$(dirname "$dir")" - mv "$dir" "$cfg_mqueuedir/cloning/$(dirname "$dir")" - cd "$cfg_mqueuedir"/cloning + mkdir -m 0775 -p "$cfg_reporoot/$(dirname "$dir")" + chmod 0775 "$cfg_reporoot/$dir" + chown ."$cfg_owning_group" "$cfg_reporoot/$dir" + mv "$dir" "$cfg_reporoot/$(dirname "$dir")" "$cfg_basedir"/mirroring/clone.sh "$dir" exit # next dir at next cron invocation, to be safe done diff --git a/mirroring/clone.sh b/mirroring/clone.sh dissimilarity index 61% index 1132b09..de10dad 100755 --- a/mirroring/clone.sh +++ b/mirroring/clone.sh @@ -1,59 +1,45 @@ -#!/bin/bash - -. @basedir@/shlib.sh - -set -e - -projdir="$1" -proj="${projdir#.git}" -queuedir="$cfg_mqueuedir"/cloning - -bang_setup -bang_action="clone" -bang_trap() { - # This removes any remnants from "$cfg_reporoot"/$projdir _and_ gets rid - # of the group record. - perl -I@basedir@ -MGirocco::Project -e 'Girocco::Project->ghost('"'$proj'"')->delete;' - cd "$queuedir" && rm -rf "$projdir"/* "$projdir"/.banged && rmdir -p "$projdir" -} - -cd "$projdir" -url="$(cat base_url)" -mail="$(cat owner)" - -# First, the boring clone itself -ref=() -if [ -s objects/info/alternates ]; then - ref=(--reference "$(cat objects/info/alternates | sed 's#/objects$##')") -fi -bang git clone "${ref[@]}" --bare "$url" repodir - -# Double-check that we aren't going to overwrite anything existing -! [ -d "$cfg_reporoot/$projdir" ] - -# Set up fork container if necessary -lproj="$(echo "$proj" | sed 's/^\(.*\/\)\(.*\)/\1/')" -if [ z"$lproj" != z"$proj" ]; then - bang mkdir -m 0775 -p "$cfg_reporoot/$lproj" -fi - -# Move us into our new home -bang mv repodir "$cfg_reporoot/$projdir.git" -bang mv base_url ctags owner description homepage README.html "$cfg_reporoot/$projdir.git/" - -# Reconfigure -bang git --git-dir="$cfg_reporoot/$projdir.git" config --bool --add mirror.allowed true -bang git --git-dir="$cfg_reporoot/$projdir.git" update-server-info - -# Clean up the queue -cd "$queuedir" && rm -rf "$projdir"/* "$projdir"/.banged && rmdir -p "$projdir" -# NO bang BELOW THIS POINT! rm -r depends on cwd. - -mail -s "[$cfg_name] $proj clone completed" "$mail,$cfg_admin" <load('"'$proj'"')->delete;' +} + +cd "$cfg_reporoot/$projdir" +url="$(cat base_url)" +mail="$(cat owner)" + +# First, the boring clone itself +ref=() +if [ -s objects/info/alternates ]; then + ref=(--reference "$(cat objects/info/alternates | sed 's#/objects$##')") + bang rm objects/info/alternates + bang rmdir -p objects/info +fi +bang git clone "${ref[@]}" --bare "$url" repodir + +# Reconcile repodir and . +bang mv repodir/* . +bang rmdir repodir + +# Reconfigure +bang git config --bool --add mirror.allowed true +bang git update-server-info + +mail -s "[$cfg_name] $proj clone completed" "$mail,$cfg_admin" <