Mettre en oeuvre un serveur CVS
Le 19 décembre 2005, à 0:13 par Ulhume...
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 (<
;INFILE
>
;)
{
if ($_=~m/^
$user_name\
)
{
$_ =~ 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
, ">>$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
, ">$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 = <u>no</u>
socket_type = stream
protocol = tcp
wait = no
user = <u>cvs</u>
server = /usr/sbin/cvspserver
<u>passenv = PATH</u>
}
<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
>
/dev
/null
chown :minerva
$repository -Rf
>
/dev
/null
cat >
/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, &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'
#