#!/bin/bash
# tinyos-mirror.sh - Maintain a local git mirror of the tinyos CVS repository.
#
+# ------
+# NOTE: On or shortly after 2010-07-12, the official TinyOS repository was
+# migrated from CVS to Subversion, at http://tinyos-main.googlecode.com/svn.
+# As of this writing, tinyos-2.x-contrib remains hosted on CVS at sf.net.
+# ------
+#
# This utility allows updating a local mirror of the TinyOS CVS modules as
# a set of three git repositories, one per notable CVS module:
# # (don't need) tinyos-1.x -> tinyos-1.x.git
-# tinyos-2.x -> tinyos-2.x.git
+# # (deprecated) tinyos-2.x -> tinyos-2.x.git
# tinyos-2.x-contrib -> tinyos-2.x-contrib.git
#
# The utility actually allows both for creation and update of the local
# Ensure these variables are correct for your installation
-MODULES="tinyos-2.x tinyos-2.x-contrib"
+MODULES="tinyos-2.x-contrib"
GITBASE=/var/lib/git
UPGITBASE=git://hinrg.cs.hju.edu/git
CVSBASE=/var/lib/cvs
UPCVSROOT=:pserver:anonymous@tinyos.cvs.sourceforge.net:/cvsroot/tinyos
UPCVSRSYNC=rsync://tinyos.cvs.sourceforge.net/cvsroot/tinyos
+# Uncomment this or export DEBUG=-v in your shell to get verbose output
+#DEBUG=-v
+
# There should be no need to change anything below this line
do_backups()
filters="$filters --include '/$i' --include '/$i/**'"
done
filters="$filters --exclude '/**'"
- eval rsync -avz --delete --no-g --chmod=Dg+s,Du+w $links $filters $UPCVSRSYNC/ $CVSROOT
+ eval rsync -az $DEBUG --delete --no-g --chmod=Dg+s,Du+w $links $filters \
+ $UPCVSRSYNC/ $CVSROOT
if [ $? -ne 0 ]; then
echo "rsync failed"
exit 1
fi
echo "Mirror of the $i CVS module" > $i.git/description
- # This line allows us to do cvsimport directly into this git repo,
- # as git-cvsimport doesn't know how to work with bare repos.
+ # git-cvsimport doesn't know how to work with bare repos, so
+ # create in each repo a .git that is a symlink to itself.
ln -s ../$i.git $i.git/.git
fi
done
# Now, do the imports. We limit the number of commits to prevent memory
# leaks from taking out the VE. This command is incremental, just adding
# new commits since the last run.
- if [ ! -d $GITBASE/cvsimports ]; then
- rm -rf $GITBASE/cvsimports
- mkdir $GITBASE/cvsimports
- chgrp repo $GITBASE/cvsimports
- chmod 755 $GITBASE/cvsimports
- chmod g+s $GITBASE/cvsimports
- fi
- cd $GITBASE/cvsimports
+ cd $GITBASE
for i in $MODULES; do
if locks_present $i; then
echo "SKIP cvs module $i; locks present in the CVS repo."
else
echo "Import cvs module $i -> git"
- git cvsimport -v -o master -d $CVSROOT -C $i-import -i -k \
+ git cvsimport $DEBUG -o master -d $CVSROOT -C $i.git -i -k \
-L2000 $i
if [ $? -ne 0 ]; then
echo "cvsimport failed"
exit 1
fi
- if [ ! -f $i-import/.git/description ]; then
- echo "Mirror of the $i CVS module" > $i-import/.git/description
- fi
- fi
- done
-}
-
-do_push()
-{
- # Now we need to push the new commits in each of the import repos into the
- # bare repos which are the pseudo-centralized shared repos.
- cd $GITBASE/cvsimports
- for i in $MODULES; do
- echo "Push git import module cvsimports/$i-import -> $i.git"
- git --git-dir=$i-import/.git push --mirror ../$i.git/
- if [ $? -ne 0 ]; then
- echo "git push failed"
- exit 1
fi
done
}
# memory leaks from taking out the VE. This command is incremental, just
# adding new commits since the last run.
+ echo "Importing directly from remote CVS repository"
cd $GITBASE
for i in $MODULES; do
echo "Update from CVS module DIRECT $i -> git"
- git cvsimport -v -o master -d $UPCVSROOT -C $i.git -i -k -L2000 $i
+ git cvsimport $DEBUG -o master -d $UPCVSROOT -C $i.git -i -k -L2000 $i
if [ $? -ne 0 ]; then
echo "cvsimport failed"
exit 1
{
# Do the cvs-gitimports from the local CVS.
+ echo "Importing from local copy of remote CVS repository"
do_bare
do_import
- do_push
}
do_import_cvslocal()
# tinyos-1.x is 14 months old when the last update was 3/17/09, and
# tinyos-2.x-contrib.git is 5 months old when the last update was 4/7/09.
+ echo "Importing from remote git repositories"
fail=0
cd $GITBASE
for i in $MODULES; do
echo "$GITBASE must have permissions drwxr-sr-x" >&2
ret=1
fi
- if [ ! -d "$GITBASE/cvsimports" ]; then
- echo "$GITBASE/cvsimports is not a directory" >&2
- ret=1
- fi
fi
if [ ! -d "$CVSBASE" ]; then
echo "$CVSBASE is not a directory" >&2
if [ -n "$opt_modules" ]; then
MODULES="$opt_modules"
fi
-echo "Updating modules $MODULES"
+echo "Updating modules: $MODULES"
if [ "$option" = "--cvsdirect" ]; then
do_import_cvsdirect
exit 1
do_import_git
fi
+echo "Import actions complete."
exit 0