mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 03:53:32 +01:00
purge-stale-projects.sh: Support --vcs
Support option --vcs. CVS is retired, but worked well as a test case for mixing multiple version-control systems in one tree. purge-stale-projects.sh is still pretty ugly and will have to go, but its API might still serve as a working template. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
841e3067a6
commit
c3c6cdc446
2 changed files with 73 additions and 55 deletions
|
|
@ -267,7 +267,7 @@ clean-all-dirs:
|
||||||
|
|
||||||
purge: $(SSH_WRAPPER_SH)
|
purge: $(SSH_WRAPPER_SH)
|
||||||
ifneq ($(PURGE_SH),/bin/bash purge-not-found)
|
ifneq ($(PURGE_SH),/bin/bash purge-not-found)
|
||||||
$(PURGE_SH)
|
$(PURGE_SH) --vcs git
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(PROJECTS_TXT):
|
$(PROJECTS_TXT):
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,28 @@ check_scm()
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
date=`date +'%Y%m%d'`
|
||||||
|
myname=`basename $0`
|
||||||
|
vcss="git"
|
||||||
|
|
||||||
|
opts=$(getopt -o C --long "vcs:" -n $myname -- "$@") || fatal "Failed to parse options $@"
|
||||||
|
eval set -- "$opts"
|
||||||
|
while [ "$1" != -- ]; do
|
||||||
|
case "$1" in
|
||||||
|
--vcs)
|
||||||
|
vcss="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
fatal "Unknown option $1"
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
vcss=$(echo -e $vcss | sed 's/[, ]\+/\n/g' | sort -u)
|
||||||
|
|
||||||
ssh=ssh
|
ssh=ssh
|
||||||
[ "$CVS_RSH" ] && ssh="$CVS_RSH"
|
[ "$CVS_RSH" ] && ssh="$CVS_RSH"
|
||||||
[ "$GIT_SSH" ] && ssh="$GIT_SSH"
|
[ "$GIT_SSH" ] && ssh="$GIT_SSH"
|
||||||
|
|
@ -51,21 +73,22 @@ ssh=`which $ssh`
|
||||||
[ "$JANWARE_USER" ] || JANWARE_USER=`whoami`
|
[ "$JANWARE_USER" ] || JANWARE_USER=`whoami`
|
||||||
ssh="$ssh -l $JANWARE_USER"
|
ssh="$ssh -l $JANWARE_USER"
|
||||||
|
|
||||||
for host in cvs.janware.com git.janware.com; do
|
for vcs in $vcss; do
|
||||||
|
case "$vcs" in
|
||||||
|
cvs|CVS) host=cvs.janware.com;;
|
||||||
|
git|Git) host=git.janware.com;;
|
||||||
|
esac
|
||||||
$ssh $host echo hallo >/dev/null 2>&1 || fatal "Can't ssh into host $host"
|
$ssh $host echo hallo >/dev/null 2>&1 || fatal "Can't ssh into host $host"
|
||||||
done
|
done
|
||||||
|
|
||||||
local_cvs_proj=`ls -d */CVS 2>/dev/null | sed 's%/[^/]*%%'`
|
|
||||||
local_git_proj=`ls -d */.git 2>/dev/null | sed 's%/[^/]*%%'`
|
|
||||||
remote_cvs_proj=`$ssh cvs.janware.com find /srv/cvs/proj -maxdepth 1 -mindepth 1 -type d -executable -readable | sed 's%.*/%%'`
|
|
||||||
remote_git_proj=`$ssh git.janware.com /opt/jw-pkg/bin/git-srv-admin.sh -j list-personal-projects`
|
|
||||||
|
|
||||||
date=`date +'%Y%m%d'`
|
|
||||||
myname=`basename $0`
|
|
||||||
|
|
||||||
trap goodbye EXIT INT QUIT KILL
|
trap goodbye EXIT INT QUIT KILL
|
||||||
scm_status=`mktemp /tmp/$myname""_XXXXXX`
|
scm_status=`mktemp /tmp/$myname""_XXXXXX`
|
||||||
|
|
||||||
|
for vcs in $vcss; do
|
||||||
|
case $vcs in
|
||||||
|
cvs|CVS)
|
||||||
|
local_cvs_proj=`ls -d */CVS 2>/dev/null | sed 's%/[^/]*%%'`
|
||||||
|
remote_cvs_proj=`$ssh cvs.janware.com find /srv/cvs/proj -maxdepth 1 -mindepth 1 -type d -executable -readable | sed 's%.*/%%'`
|
||||||
for p in $local_cvs_proj; do
|
for p in $local_cvs_proj; do
|
||||||
[ -L $p ] && continue
|
[ -L $p ] && continue
|
||||||
[ -d $p ] || continue
|
[ -d $p ] || continue
|
||||||
|
|
@ -80,26 +103,16 @@ for p in $local_cvs_proj; do
|
||||||
purged="$purged $p"
|
purged="$purged $p"
|
||||||
done
|
done
|
||||||
|
|
||||||
[ -d old ] && mv old purged
|
|
||||||
|
|
||||||
[ "$purged" ] && {
|
[ "$purged" ] && {
|
||||||
cp -p CVS/Entries CVS/Entries-$date-`date +'%H%M%S'`
|
cp -p CVS/Entries CVS/Entries-$date-`date +'%H%M%S'`
|
||||||
}
|
|
||||||
|
|
||||||
for p in $purged; do
|
for p in $purged; do
|
||||||
sed -i "/D\/$p\/\/\/\// d" CVS/Entries
|
sed -i "/D\/$p\/\/\/\// d" CVS/Entries
|
||||||
done
|
done
|
||||||
|
}
|
||||||
if [ -d dspc/src/CVS ]; then
|
;;
|
||||||
for i in dspcd shared; do
|
git|Git)
|
||||||
sed -i "/D\/$i\/\/\/\// d" dspc/src/CVS/Entries
|
local_git_proj=`ls -d */.git 2>/dev/null | sed 's%/[^/]*%%'`
|
||||||
done
|
remote_git_proj=`$ssh git.janware.com /opt/jw-pkg/bin/git-srv-admin.sh -j list-personal-projects`
|
||||||
fi
|
|
||||||
|
|
||||||
for i in dspider-btools dspider-shared; do
|
|
||||||
[ -L "$i" ] && rm $i
|
|
||||||
done
|
|
||||||
|
|
||||||
for p in $local_git_proj; do
|
for p in $local_git_proj; do
|
||||||
[ -L $p ] && continue
|
[ -L $p ] && continue
|
||||||
[ -d $p ] || continue
|
[ -d $p ] || continue
|
||||||
|
|
@ -111,4 +124,9 @@ for p in $local_git_proj; do
|
||||||
mv $p $n
|
mv $p $n
|
||||||
log "moving stale project \"$p\" to \"$n\""
|
log "moving stale project \"$p\" to \"$n\""
|
||||||
done
|
done
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
log "Unsupported version-control system >$vcs<, ignoring"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue