aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2008-04-08 23:13:32 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2008-04-08 23:13:32 +0000
commitf6d6f4207f0b24c076a04e07259a36a3fdb160b7 (patch)
tree6e54e335ee88435d63ae9cc2767dac08d2859efe
parentc5c9b089625929bcb6fb22fcd0badd25707ad335 (diff)
downloadgsc-f6d6f4207f0b24c076a04e07259a36a3fdb160b7.tar.gz
gsc-f6d6f4207f0b24c076a04e07259a36a3fdb160b7.tar.bz2
* cvs/mksnapshot: Support git.
git-svn-id: file:///svnroot/gsc/trunk@321 d2de0444-eb31-0410-8365-af798a554d48
-rw-r--r--ChangeLog4
-rwxr-xr-xcvs/mksnapshot72
-rwxr-xr-xsvn/svn-import-cvs4
3 files changed, 63 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index 297187a..36269c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-04-09 Sergey Poznyakoff <gray@gnu.org.ua>
+
+ * cvs/mksnapshot: Support git.
+
2008-03-14 Sergey Poznyakoff <gray@gnu.org.ua>
* etc/links.txt: Update
diff --git a/cvs/mksnapshot b/cvs/mksnapshot
index 865c844..9bbb486 100755
--- a/cvs/mksnapshot
+++ b/cvs/mksnapshot
@@ -1,6 +1,6 @@
#! /bin/sh
# mksnapshot -- create daily CVS snapshots
-# Copyright 2005, 2007 Sergey Poznyakoff
+# Copyright 2005, 2007, 2008 Sergey Poznyakoff
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-CONFIG=$HOME/etc/cvsdaily.conf
+CONFIG=$HOME/etc/cvsdaily-ex.conf
MSG=/tmp/`basename $0`.$$
trap "rm -f $MSG" 1 2 13 15
@@ -38,6 +38,7 @@ EOF
cat - <<EOF
CVSROOT CVS repository directory
SVNROOT SVN repository directory
+ GITROOT GIT repository directory
WD Working directory
FTP Target directory where tarballs should be placed
@@ -95,8 +96,8 @@ do
done
# Check the consistency of the invocation
-[ -z "$CVSROOT" -a -z "$SVNROOT" ] && abort "Neither CVSROOT nor SVNROOT is set"
-export CVSROOT SVNROOT
+[ -z "$CVSROOT" -a -z "$SVNROOT" -a -z "$GITROOT" ] && abort "Neither CVSROOT nor SVNROOT nor GITROOT is set"
+export CVSROOT SVNROOT GITROOT
[ -n "$WD" ] || abort "WD undefined"
[ -d $WD ] || abort "$WD is not a directory"
[ -n "$FTP" ] || abort "FTP undefined"
@@ -131,7 +132,16 @@ no) VERBOSE=0;;
esac
cvs_get_change_date() {
- cvs -Q -d $1 co -p $2/ChangeLog 2>/dev/null | head -1
+# cvs -Q -d $1 co -p $2/ChangeLog 2>/dev/null | head -1
+ if [ -n "$3" ]; then
+ date="-D $3"
+ else
+ date=""
+ fi
+ cvs -Q -d $1 history -ac $date |
+ awk '{ gsub("[-:]", " ", $0)
+ print mktime($2 " " $3 " " $4 " " $5 " " $6 "00 " $7), $2 "-" $3 "-" $4 }' |
+ sort +0 -1 -n -r | head -n 1 | cut -d ' ' -f 2
}
cvs_get_sources() {
@@ -154,6 +164,21 @@ svn_release_sources() {
rm -rf $1
}
+git_get_change_date() {
+ git --git-dir=$1/$2.git rev-list --all --header --max-count=1 |
+ awk '$1 == "committer" {
+ print strftime("%Y-%m-%d %H:%M:%S", $(NF-1)) " " $NF;
+ }'
+}
+
+git_get_sources() {
+ git clone --depth=0 -q /$1/$2.git
+}
+
+git_release_sources() {
+ rm -rf $1
+}
+
# Process the specified CVS or SVN module.
# usage: module MODNAME ROOT getdate getsources relsources
# $1 $2 $3 $4 $5
@@ -165,7 +190,15 @@ module() {
get_sources=$4
release_sources=$5
- $get_change_date $root $modname |
+ lastfile=`ls -t "${modname}-"[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9].$TARSUF 2>/dev/null | head -n 1`
+ if [ -n "$lastfile" ]; then
+ lastdate=`echo "$lastfile" | \
+ sed "s|$modname-||;s|\.${TARSUF}\$||"`
+ else
+ lastdate=""
+ fi
+
+ $get_change_date $root $modname $lastdate |
sed -n 's/^\([0-9]\{4\}-[0-9][0-9]-[0-9][0-9]\).*/\1/p' |
while read last
do
@@ -178,11 +211,15 @@ module() {
if [ -r ${FTP}/${tarname} ]; then
echo "$tarname already exists"
else
- echo "Creating $tarname"
+ echo "Creating $tarname (from $root)"
if $get_sources $root $modname >$MSG; then
if [ -d $1 ]; then
tar -c $COMPRESS -f ${FTP}/$tarname \
- --exclude CVS --exclude .svn --exclude .cvsignore $1
+ --exclude CVS \
+ --exclude .svn \
+ --exclude .git \
+ --exclude .cvsignore \
+ --exclude .gitignore $1
$release_sources $modname || break
(
@@ -231,10 +268,21 @@ main_savane() {
(cd $WD || abort
SAVANE_CVSROOT=$CVSROOT
SAVANE_SVNROOT=$SVNROOT
+ SAVANE_GITROOT=$GITROOT
for module in `id -a |
sed 's/.*groups=//;s/[0-9][0-9]*(\([^)][^)]*\))/\1/g;s/,/ /g'`
do
- if [ -d $SAVANE_CVSROOT/$module ]; then
+ if [ -n "$SAVANE_GITROOT" -a -d $SAVANE_GITROOT/$module.git ]; then
+ module $module $SAVANE_GITROOT \
+ git_get_change_date \
+ git_get_sources \
+ git_release_sources
+ elif [ -n "$SAVANE_SVNROOT" -a -d $SAVANE_SVNROOT/$module ]; then
+ module $module $SAVANE_SVNROOT \
+ svn_get_change_date \
+ svn_get_sources \
+ svn_release_sources
+ elif [ -d $SAVANE_CVSROOT/$module ]; then
CVSROOT=$SAVANE_CVSROOT/$module
find $CVSROOT -type d \
-not -name CVSROOT \
@@ -248,12 +296,6 @@ main_savane() {
done
fi
- if [ -n "$SAVANE_SVNROOT" -a -d $SAVANE_SVNROOT/$module ]; then
- module $module $SAVANE_SVNROOT \
- svn_get_change_date \
- svn_get_sources \
- svn_release_sources
- fi
done)
}
diff --git a/svn/svn-import-cvs b/svn/svn-import-cvs
index b8d0dae..d494db2 100755
--- a/svn/svn-import-cvs
+++ b/svn/svn-import-cvs
@@ -184,13 +184,13 @@ trap 'cleanup' 1 2 13 15
##################################
echo "Creating temporary repository..."
-tar $TARV -C $CVSROOT/$PROJECT -c -f - $PROJECT | tar -x -f - -p || abort 1
+tar $TARV -C $CVSROOT -c -f - $PROJECT | tar -x -f - -p || abort 1
umask 002
echo "Converting to SVN repository..."
cvs2svn ${DRY_RUN:+--dry-run} $QUIET \
- -s $SVNROOT/$PROJECT --username=$USERNAME $TMPDIR/$PROJECT || abort 1
+ --encoding utf-8 -s $SVNROOT/$PROJECT --username=$USERNAME $TMPDIR/$PROJECT || abort 1
if [ -z "$DRY_RUN" ]; then
echo "Extracting a working copy..."

Return to:

Send suggestions and report system problems to the System administrator.