Mettre en oeuvre un serveur CVS
Le 19 décembre 2005 à 00:13.

CVS est un vénérable système de gestion de sources. Ce qui suit est plus une série de cas pratique qu'un tutorial à part entière

Création de la base de donnée

# racine du dossier cvs
export CVSROOT=/cvsroot

# ajout de l'utilisateur CVS
groupadd cvs
useradd cvs -g cvs

# initalisation du repository
mkdir $CVSROOT
cvs init

# attribution du repository à l'utilisateur cvs
chown cvs:cvs $CVSROOT -R
chmod gu+rwX $CVSROOT -R

Création de l'espace « Mot de passes »

su - cvs # passage en utilisateur cvs
export CVSROOT=/cvsroot
cvs co CVSROOT
cd CVSROOT
touch passwd
cvs add passwd
cvs update
cvs commit -m

# Ajouter laligne "passwd" à la fin du fichier checkoutlist
echo passwd >> checkoutlist
cvs update
cvs commit -m
cd ..
cvs release -d CVSROOT

Ajout des utilisateurs

créer dans /home/cvs le scripte qui suit et exécuter

cvsadduser login password
#!/usr/bin/perl -W
use strict;

my ($user_name, $password) = @ARGV;
if(!$user_name || !$password){print "Usage: $0 [username] [password]\n";exit;};

system ('cvs -Q co CVSROOT/passwd');
my $password_file = "CVSROOT/passwd";
open (INFILE, "$password_file") or die("Failed to open $password_file\n");

srand (time());
my $randletter = "(int (rand (26)) + (int (rand (1) + .5) % 2 ? 65 : 97))";
my $salt = sprintf ("<fo nt color="c">c", eval $randletter, eval $randletter);
my $plaintext = $password;
my $crypttext = crypt ($plaintext, $salt);

my $output;
my $switched = '0';

while (&lt;INFILE&gt;)
{
  if ($_=~m/^$user_name\Arf)
  {
    $_ =~ s/$user_name:.*:/$user_name:${crypttext}:/;
    print STDOUT "User $user_name exists, updating password\n";
    $switched = '1';
  };

  $output .= $_;
};

close INFILE;
if ($switched != '1')
{
  # add the new user
  open (OUTFILE, "&gt;&gt;$password_file") or die("Can't open $password_file\n");
  print OUTFILE "${user_name}\:${crypttext}\:cvs\n";
  #or print STDERR "couldn't push to $password_file\n";
}
else
{
  # update the file for new password
  open (OUTFILE, "&gt;$password_file") or die("Can't open $password_file\n");
  print OUTFILE $output
};

close OUTFILE;
system ('cvs update CVSROOT ; cvs commit -m "updating password file for $user_name" CVSROOT');
system ('cvs -Q release -d CVSROOT');

Ne pas oublier de mettre chaque utilisateur aillant acces à CVS dans le groupe CVS

Mise en place dans Xinetd

C'est une étape assez simple avec une drake 10.1, modifier le fichier /etc/xinet.d/cvs comme suit :

    service cvspserver
    {
      disable     = &lt;u&gt;no&lt;/u&gt;
      socket_type   = stream
      protocol    = tcp
      wait      = no
      user      = &lt;u&gt;cvs&lt;/u&gt;
      server      = /usr/sbin/cvspserver
      &lt;u&gt;passenv     = PATH&lt;/u&gt;
    }
  <code>


<H2>Redémarer xinetd</H2>

  <code type="sh">
    /sbin/service xinetd restart

Test...

Normalement c'est fini. Pour tester (USER est l'utilisateur créé plus, pas cvs:cvs) :

cvs -d :pserver:USER@localhost:/cvsroot login

Importation

Pour importer un dossier en tant que module, il faut se placer dans le dossier et taper la commande suivante :

cvs import -I ! -W "*.jar -k 'b'" -m "initial" NOM_MODULE yoran release

Erreur au login

cvs -d :pserver:gaston@machine_cvs:/cvsroot login

Logging in to :pserver:gaston@machine_cvs:/cvsroot
CVS password:
cvs login: CVSROOT must be an absolute pathname (not `${cvs.root}')
cvs login: when using local access method.
cvs login: warning: skipping invalid entry in password file at line 5

rm -rf ~/.cvspass
cvs -d :pserver:gaston@machine_cvs:/cvsroot login
Logging in to :pserver:gaston@machine_cvs:/cvsroot
CVS password:

Ajout d'un hook

Dans CVSROOT/hook.sh

#logger "hello"
      repository=echo $1 | cut -d" " -f1</a>
    repository=/minerva/cvsroot/$repository
    logger "Mise à jour des droits sur $repository"
    chmod gu+rwX,o-rwx $repository -Rf &gt; /dev/null
    chown :minerva  $repository -Rf &gt; /dev/null
    cat &gt; /dev/null
Dans CVSROOT/login
DEFAULT (/minerva/cvsroot/CVSROOT/hook.sh %{V})

Gestion automatique des binaires

Dans CVSROOT/cvswrapper

# This file affects handling of files based on their names.
#
# The -m option specifies whether CVS attempts to merge files.
#
# The -k option specifies keyword expansion (e.g. -kb for binary).
#
# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers)
#
#  wildcard   [option value][option value]...
# This file affects handling of files based on their names.
#
# The -m option specifies whether CVS attempts to merge files.
#
# The -k option specifies keyword expansion (e.g. -kb for binary).
#
# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers)
#
#  wildcard   [option value][option value]...
#
#  where option is one of
#  -m     update methodology  value: MERGE or COPY
#  -k     expansion mode    value: b, o, kkv, &amp;c
#
#  and value is a single-quote delimited value.
# For example:
#*.gif -k 'b'
*.CLASS -k 'b' -m 'COPY'
*.DOC -k 'b' -m 'COPY'
*.EAR -k 'b' -m 'COPY'
*.GIF -k 'b' -m 'COPY'
*.JPG -k 'b' -m 'COPY'
*.PDF -k 'b' -m 'COPY'
*.TAR -k 'b' -m 'COPY'
*.WAR -k 'b' -m 'COPY'
*.ZIP -k 'b' -m 'COPY'
*.avi -k 'b' -m 'COPY'
*.bin -k 'b' -m 'COPY'
*.bz  -k 'b' -m 'COPY'
*.bz2 -k 'b' -m 'COPY'
*.class -k 'b' -m 'COPY'
*.doc -k 'b' -m 'COPY'
*.ear -k 'b' -m 'COPY'
*.exe -k 'b' -m 'COPY'
*.gif -k 'b' -m 'COPY'
*.gz  -k 'b' -m 'COPY'
*.hqx -k 'b' -m 'COPY'
*.jar -k 'b' -m 'COPY'
*.jpeg  -k 'b' -m 'COPY'
*.jpg -k 'b' -m 'COPY'
*.mov -k 'b' -m 'COPY'
*.mp3 -k 'b' -m 'COPY'
*.mpg -k 'b' -m 'COPY'
*.pdf -k 'b' -m 'COPY'
*.png -k 'b' -m 'COPY'
*.ppt -k 'b' -m 'COPY'
*.rpm -k 'b' -m 'COPY'
*.sit -k 'b' -m 'COPY'
*.srpm  -k 'b' -m 'COPY'
*.swf -k 'b' -m 'COPY'
*.tar -k 'b' -m 'COPY'
*.tbz -k 'b' -m 'COPY'
*.tgz -k 'b' -m 'COPY'
*.tif -k 'b' -m 'COPY'
*.tiff  -k 'b' -m 'COPY'
*.war -k 'b' -m 'COPY'
*.xbm -k 'b' -m 'COPY'
*.xls -k 'b' -m 'COPY'
*.zip -k 'b' -m 'COPY'
*.sxc -k 'b' -m 'COPY'
*.sxw -k 'b' -m 'COPY'
*.psd -k 'b' -m 'COPY'
#

Commentaires

Poster un nouveau commentaire

Le contenu de ce champ est gardé secret et ne sera pas montré publiquement.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • To highlight piece of code, just surround them with <code type="language"> Your code &tl;/code>>. Language can be java,c++,bash,etc... Everything Geshi support.
  • Les lignes et les paragraphes vont à la ligne automatiquement.
  • Textual smileys will be replaced with graphical ones.
  • Les adresses de pages web et de messagerie électronique sont transformées en liens automatiquement.

Plus d'informations sur les options de formatage

Connexion utilisateur
Les derniers bavardages...