User Tools

Site Tools


sourceforge:git_cvsimport

Table of Contents

git cvsimport

The old cvs repository for Crossfire can be accessed using the git-cvsimport Perl script.
git-cvsimport is usually located in the {prefix}/libexec/git-core/ directory.

Basic syntax is :

git cvsimport $GIT_CVSIMPORT_OPTS -C $module -o $module \
-d:pserver:anonymous@crossfire.cvs.sourceforge.net:/cvsroot/crossfire $module

Where $module is one of the many arch, maps, crossfire (server), client .

Prerequisites

The git-cvsimport script should install with the normal git make install .
Then it needs cvs installed.

Besides these above two it needs the separate cvsps binary installed.
CVSPS can be found for example at packages.debian.org 's search for filenames containing cvsps.

The cvsps source is comparatively small at around 60KB with only a simple Makefile.
make && make install should install the cvsps binary by default to /usr/local(/bin) .

Script

Bash script to import and create a git archive for the many cvs modules for Crossfire.
The script assumes to be placed inside the same directory as the directory 'git_cvsimport' .
The folder git_cvsimport will not be created by this script, the user has to do it manually.

The cvsps binary output gets written to a /tmp/gitXXXXXX.cvsps text file.
If a complete /tmp/gitXXXXXX.cvsps could be secured, it can be used to continue downloads
without re-run of the slow rlog part of the cobe by git-cvsimport using the -P option.

#!/bin/ash
 
ERROR=${ERROR:=1}
ERR=${ERR:-$ERROR} #ERR var already used as /dev/null OR /dev/stderr
_err(){
test "$ERROR" || return 0
echo -e "$0:ERROR:$*"  >&2
}
 
_exit(){
local RV
test "$*" || { _err "Usage:_exit EXITCODE MESSAGE"; }
RV=$1
[ "${RV//[[:digit:]]/}" ] && { _err "\$1 must be a digit number."; RV=255; } || shift
echo "$*" >&2
case ${MY_SELF##*/} in
ash*|bash*|sh*) return $RV;;
*) exit $RV;;
esac
}
 
#GIT_CVSIMPORT_OPTS="-R -v -p Z9,v -P ../gitc45EwN.cvsps"
GIT_CVSIMPORT_OPTS="-R -v -p Z9,v"
MAX_RETRIES=10
 
MY_SELF=`realpath "$0"`
MY_DIR=${MY_SELF%/*}
cd "$MY_DIR" || _exit 3 "Could not change into '$MY_DIR'/ ."
 
cd git_cvsimport || _exit 3 "Could not change into folder git_cvsimport/ ."
 
 
#trap "pidof cvsps && kill -2 `pidof cvsps`" INT
 
for d in CVSROOT CFJavaEditor arch client iso_arch \
 alternate_images cfclient_sdl crossfire jxclient \
 maps maps-bigworld sounds
do mkdir $VERB -p $d
done
 
MODULES=`ls -1`
test "$MODULES" || _exit 3 "No cvs modules available."
 
# MAIN CODE
for module in $MODULES
 
do
 
test -d "$module" || continue
 
# don't run rlog on already checked out 
#( and therefore downloaded ) folders
echo                        #DEBUG
echo '# ================== #'
echo $module/               #DEBUG
echo                        #DEBUG
ls -1A $module/ | head -n10 #DEBUG
echo                        #DEBUG
ls -1A $module/ | tail -n10 #DEBUG
 
test "`ls -1A $module/ | wc -l`" -le 1 || continue #if only a .git folder, continue download
 
 c=0
 while :; do
 
 git cvsimport $GIT_CVSIMPORT_OPTS -C $module -o $module \
  -d:pserver:anonymous@crossfire.cvs.sourceforge.net:/cvsroot/crossfire $module
 
 RV=$?
 test $RV = 0 && break 1
 echo Returnvalue $RV #DEBUG
 
 echo '# ================== #'
 c=$((c+1))
 test $c -ge ${MAX_RETRIES:-10} && break 1
 sleep 12
 
 if test $RV = 255; then #perl die() always returns 255
  unset SIZE_GIT
  SIZE_GIT=`du -s -BKiB $module/.git | awk '{print $1}' | grep -o -E '[0-9]+'`
  SIZE_GIT=${SIZE_GIT:-501}
  if test "$SIZE_GIT" -le 500; then
  rm -rf $module/.git  || break 2
  fi
 fi
 
 echo "$MY_SELF: Retrying..."
 done
 
sleep 12
 
done
 
_say_some_code(){
cat >&1 <<EoI
 
/* gitsrc/builtin/rev-parse.c */
static void die_no_single_rev(int quiet)
{
	if (quiet)
		exit(1);
	else
		die("Needed a single revision");
}
EoI
}
sourceforge/git_cvsimport.txt · Last modified: 2018/04/30 04:01 by karl