summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Gordon <assafgordon@gmail.com>2014-11-05 01:27:25 (GMT)
committerA. Gordon <assafgordon@gmail.com>2014-11-05 01:27:25 (GMT)
commit93b656f958ab10e453d464bde0b57daf44be1bdc (patch)
tree143a58b767187cf7ba9273e9b3a9dff0b291d1a1
parent655b6adca5679ad95f7417431aeb47b8105c9987 (diff)
downloadgnu-sv-gitweb-93b656f958ab10e453d464bde0b57daf44be1bdc.zip
gnu-sv-gitweb-93b656f958ab10e453d464bde0b57daf44be1bdc.tar.gz
gnu-sv-gitweb-93b656f958ab10e453d464bde0b57daf44be1bdc.tar.bz2
Add CVS-to-GIT information.
-rw-r--r--README.md2
-rw-r--r--git-to-cvs/README-git-to-cvs.md13
-rwxr-xr-xgit-to-cvs/convert-cvsweb-to-git.sh37
-rwxr-xr-xgit-to-cvs/create-cvs-authormap.sh57
4 files changed, 109 insertions, 0 deletions
diff --git a/README.md b/README.md
index a46b98e..26d8c96 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,8 @@ server of <http://www.gnu.org> .
`vcs-server` - The setup on `vcs.sv.gnu.org` server .
+`cvs-to-git` - Scripts used to convert CVS repositories to GIT.
+
## Gitolite Setup
An earlier version of this project used gitolite3 (instead of the simple
diff --git a/git-to-cvs/README-git-to-cvs.md b/git-to-cvs/README-git-to-cvs.md
new file mode 100644
index 0000000..9a6219c
--- /dev/null
+++ b/git-to-cvs/README-git-to-cvs.md
@@ -0,0 +1,13 @@
+# GNU Savannah WebGit Project - CVS-to-GIT conversion
+
+Eric S. Raymond's `cvs-fast-export`
+(<http://www.catb.org/~esr/cvs-fast-export/cvs-fast-export.html>) was used to
+convert CVS repositories to GIT.
+
+The original repositories are on `vcs.sv.gnu.org:/web` .
+
+The script `create-cvs-authormap.sh` was run on `internal.sv.gnu.org` to
+generate the authors map file.
+
+The script `convert-cvsweb-to-git.sh` was used to convert all repositories
+from CVS to GIT.
diff --git a/git-to-cvs/convert-cvsweb-to-git.sh b/git-to-cvs/convert-cvsweb-to-git.sh
new file mode 100755
index 0000000..ba2b4b1
--- /dev/null
+++ b/git-to-cvs/convert-cvsweb-to-git.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+die()
+{
+ BASE=$(basename "$0")
+ echo "$BASE: error $@" >&2
+ exit 1
+}
+
+for dir in $(find web/ -maxdepth 1 -type d | sed 1d) ;
+do
+ BASE=$(basename "$dir")
+ test -d "git2/${BASE}.git" && continue
+ test -e "git2/${BASE}.failed" && continue
+
+ echo "converting $BASE"
+ if find "$dir" | cvs-fast-export -A authormap.txt > "git2/$BASE.fi" ;
+ then
+ mkdir "git2/${BASE}.git" || die "mkdir failed"
+ cd "git2/${BASE}.git" || die "cd failed"
+ git init --bare || die "git init failed in './git2/$BASE'"
+ if git fast-import < "../$BASE.fi" ; then
+ cd ../.. || die "cd.. failed"
+ rm -r "./git2/$BASE.fi"
+ echo "converting $BASE - done"
+ else
+ cd ../.. || die "cd.. failed"
+ die "git fast-import failed with './git2/$BASE.fi'"
+ rm -rf "./git2/$BASE.git"
+ touch git2/$BASE.failed || die "failed to touch $BASE.failed"
+ echo "converting $BASE - failed (at git-fast-export)"
+ fi
+ else
+ touch git2/$BASE.failed || die "failed to touch $BASE.failed"
+ echo "converting $BASE - failed (at cvs-fast-export)"
+ fi
+done
diff --git a/git-to-cvs/create-cvs-authormap.sh b/git-to-cvs/create-cvs-authormap.sh
new file mode 100755
index 0000000..6fd0a1a
--- /dev/null
+++ b/git-to-cvs/create-cvs-authormap.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+
+## Copyright (C) 2014 Assaf Gordon (agn@gnu.org)
+##
+## Copying and distribution of this file, with or without modification,
+## are permitted in any medium without royalty provided the copyright
+## notice and this notice are preserved.
+
+## This script reads the 'users' table in the Savane database,
+## and produces an 'authormap.txt' file which is compatible with
+## ESR's "cvs-fast-export".
+##
+## TODO:
+## How to handle non-ascii characters in real names (e.g. 'pixelbeat' user)?
+
+## Last update: 2014-10-21
+
+die()
+{
+BASE=$(basename "$0")
+echo "$BASE: error: $@" >&2
+exit 1
+}
+
+OUTPUT=authormap.txt
+
+DB=savane
+
+SQL="
+SELECT
+ user_name,
+ REPLACE(realname,CHAR(9),' '),
+ REPLACE(IF(email_hide = 'www',email,user_name),CHAR(9),' ') as email,
+ REPLACE(timezone,CHAR(9),' ')
+FROM
+ user
+WHERE
+ status = 'A'
+ORDER BY
+ user_name
+"
+
+##
+## Step 1:
+## Export the STRUCTURE of the omitted tables (no data)
+nice -n 19 \
+ mysql --batch -e "$SQL" "$DB" > "$OUTPUT.t" \
+ || die "failed to query authormap from MYSQL"
+
+##
+## Step 2:
+## re-format to work with 'authormap' parameter of cvs-fast-export:
+## http://www.catb.org/~esr/cvs-fast-export/cvs-fast-export.html
+awk -v FS="\t" 'NR>1 { print $1 "=" $2 " <" $3 "> " $4 }' \
+ < "$OUTPUT.t" > "$OUTPUT" \
+ || die "failed to format $OUTPUT.t with AWK"
+