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: Re-add purge-stale-projects.sh, needed for purging
Without purge-stale-projects.sh, projects not longer in the upstream directory don't get purged, so add it back. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
0c9fd98009
commit
4074486735
1 changed files with 114 additions and 0 deletions
114
scripts/purge-stale-projects.sh
Normal file
114
scripts/purge-stale-projects.sh
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
#!/bin/bash
|
||||
|
||||
log()
|
||||
{
|
||||
echo $@
|
||||
}
|
||||
|
||||
fatal()
|
||||
{
|
||||
log $@
|
||||
exit 1
|
||||
}
|
||||
|
||||
goodbye()
|
||||
{
|
||||
rm -f $scm_status
|
||||
}
|
||||
|
||||
check_scm()
|
||||
{
|
||||
local p=$1
|
||||
if [ -d $p/.git ]; then
|
||||
log + checking git
|
||||
#git -C $p pull --no-edit || fatal "git pull failed, giving up"
|
||||
if git -C $p status --porcelain --untracked-files=no | grep -v '^??' | grep -q . ; then
|
||||
git -C $p status
|
||||
fatal "git in project \"$p\" has locally modified files, giving up"
|
||||
fi
|
||||
else
|
||||
log + checking cvs
|
||||
#cvs update -dP $p
|
||||
cvs status $p > $scm_status 2>&1
|
||||
if [ $? != 0 ]; then
|
||||
cat $scm_status
|
||||
fatal "\n======== cvs status failed in project \"$p\", giving up."
|
||||
fi
|
||||
grep -qi "locally modified" $scm_status && \
|
||||
fatal "cvs copy in project \"$p\" has locally modified files, giving up"
|
||||
grep -qi "needs" $scm_status && \
|
||||
fatal "+ cvs copy in project \"$p\" is out-of-date, giving up"
|
||||
fi
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
ssh=ssh
|
||||
[ "$CVS_RSH" ] && ssh="$CVS_RSH"
|
||||
[ "$GIT_SSH" ] && ssh="$GIT_SSH"
|
||||
ssh=`which $ssh`
|
||||
[ -x "$ssh" ] || fatal "SSH executable \"$ssh\" not found"
|
||||
[ "$JANWARE_USER" ] || JANWARE_USER=`whoami`
|
||||
ssh="$ssh -l $JANWARE_USER"
|
||||
|
||||
for host in cvs.janware.com git.janware.com; do
|
||||
$ssh $host echo hallo >/dev/null 2>&1 || fatal "Can't ssh into host $host"
|
||||
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 git-srv-admin.sh -j list-personal-projects`
|
||||
|
||||
date=`date +'%Y%m%d'`
|
||||
myname=`basename $0`
|
||||
|
||||
trap goodbye EXIT INT QUIT KILL
|
||||
scm_status=`mktemp /tmp/$myname""_XXXXXX`
|
||||
|
||||
for p in $local_cvs_proj; do
|
||||
[ -L $p ] && continue
|
||||
[ -d $p ] || continue
|
||||
echo $remote_cvs_proj | grep -q "\(^\| \)$p\($\| \)" && continue
|
||||
n=purged/cvs/$date/$p
|
||||
mkdir -p `dirname $n`
|
||||
echo "--------------- moving stale cvs project $p to $n"
|
||||
if ! make -C $p distclean; then echo "distclean failed, ignoring"; fi
|
||||
if ! make -C $p clean; then echo "clean failed, ignoring"; fi
|
||||
mv $p $n
|
||||
sed -i "/\/$p\// d" CVS/Entries
|
||||
purged="$purged $p"
|
||||
done
|
||||
|
||||
[ -d old ] && mv old purged
|
||||
|
||||
[ "$purged" ] && {
|
||||
cp -p CVS/Entries CVS/Entries-$date-`date +'%H%M%S'`
|
||||
}
|
||||
|
||||
for p in $purged; do
|
||||
sed -i "/D\/$p\/\/\/\// d" CVS/Entries
|
||||
done
|
||||
|
||||
if [ -d dspc/src/CVS ]; then
|
||||
for i in dspcd shared; do
|
||||
sed -i "/D\/$i\/\/\/\// d" dspc/src/CVS/Entries
|
||||
done
|
||||
fi
|
||||
|
||||
for i in dspider-btools dspider-shared; do
|
||||
[ -L "$i" ] && rm $i
|
||||
done
|
||||
|
||||
for p in $local_git_proj; do
|
||||
[ -L $p ] && continue
|
||||
[ -d $p ] || continue
|
||||
echo $remote_git_proj | grep -q "\(^\| \)$p\($\| \)" && continue
|
||||
check_scm $p
|
||||
echo done checking scm
|
||||
n=purged/git/$date/$p
|
||||
mkdir -p `dirname $n`
|
||||
mv $p $n
|
||||
log "moving stale project \"$p\" to \"$n\""
|
||||
done
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue