Breve Descripcion:
Subversion es un software de sistema de control de versiones. Es software libre bajo una licencia de tipo Apache/BSD y se le conoce también como svn por ser ese el nombre de la herramienta de línea de comandos. Una característica importante de Subversion es que los archivos versionados no tienen cada uno un número de revisión independiente. En cambio, todo el repositorio tiene un único número de versión que identifica un estado común de todos los archivos del repositorio en cierto punto del tiempo.
Instalación
1. Instalacion de Subversión y utilidades:
Primero instalamos los siguientes paquetes haciendo:
apt-get install subversion libapache2-svn libapache-mod-dav apache2 openssl gcc g++
2. Configuración del Apache2
2.1. Habilitación de SSL en Apache2
Para habilitar el Apache2 para que escuche en el puerto de SSL
a2enmod ssl
echo 'Listen 443' >> /etc/apache2/ports.conf
Generamos un Certificado SSL:
apache2-ssl-certificate
si el comando no existe, se lo puede descargar haciendo:
wget http://czarism.com/files/apache2-ssl.tar.gz
lo descomprimimos haciendo
tar zxvf apache2-ssl.tar.gz
mv apache2-ssl-certificate /usr/sbin
mv ssleay.cnf /usr/share/apache2
mkdir /etc/apache2/ssl
y luego generamos el certificado.
apache2-ssl-certificate
Por ejemplo se puede completar con:
Country Name (2 letter code)
:AR
State or Province Name (full name) [Some-State]:Buenos Aires
Locality Name (eg, city) []:Buenos Aires
Organization Name (eg, company; recommended) []:Taringa
Organizational Unit Name (eg, section) []:Taringa
server name (eg. ssl.domain.tld; required!!!) []:taringa.net
Email Address []:[email protected]
2.2. Configuración de SSL en Apache2
Primero copiamos el archivo default en uno nuevo
cp /etc/apache2/sites-enabled/000-default /etc/apache2/sites-enabled/ssl
Modificarlo para que luzca de la siguiente forma:
NameVirtualHost *:443
<VirtualHost *:443>
Agregar bajo virtual host
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLProtocol all
SSLCipherSuite HIGH:MEDIUM
3. Puesta a punto de SVN
3.1. Estructura Inicial
Hacemos que nuestro directorio base sea /home/svn:
mkdir /home/svn
mkdir /home/svn/permisos
chown www-data:www-data /home/svn
chmod 750 /home/svn
Generamos el archivo con usuarios y contraseñas:
su www-data -c "htpasswd -c -m /home/svn/permisos/dav_svn.passwd root"
Creamos un repositorio
svnadmin create /home/svn/test
chown -R www-data:www-data /home/svn/test
chmod -R g+ws /home/svn/test
Copiamos el archivo authz de ejemplo y le agregamos el usuario root al repositorio test:
cp /home/svn/test/conf/authz /home/svn/permisos/dav_svn.authz
echo "[test:/]" >> home/svn/permisos/dav_svn.authz
echo "root = rw" >> home/svn/permisos/dav_svn.authz
NOTA: Es lo mismo usar htpasswd que htpasswd2
3.2. Archivos de Configuración
Configurar /home/svn/test/conf/svnserver.conf para que quede de la siguiente manera
### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository. (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)
### Visit http://subversion.tigris.org/ for more information.
### These options control access to the repository for unauthenticated
### and authenticated users. Valid values are "write", "read",
### and "none". The sample settings below are the defaults.
anon-access = none
auth-access = read
auth-access = write
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the conf directory.
### Uncomment the line below to use the default password file.
password-db = passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control. Unless you specify a path
### starting with a /, the file's location is relative to the conf
### directory. If you don't specify an authz-db, no path-based access
### control is done.
### Uncomment the line below to use the default authorization file.
authz-db = authz
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa. The default realm
### is repository's uuid.
realm = Taringa Repository
Modificar /home/svn/test/conf/authz agregándole las siguientes líneas:
[/]
root = rw
Copiar los dos archivos al directorio de permisos
cp /home/svn/test/conf/svnserve.conf /home/svn/permisos
cp /home/svn/test/conf/authz /home/svn/permisos
4. Finalizacion de Apache2
Agregar en /etc/apache2/sites-enabled/ssl
<Location />
DAV svn
SVNParentPath /home/svn
AuthType Basic
AuthName "Taringa Subversion Repository"
AuthUserFile /home/svn/permisos/dav_svn.passwd
AuthzSVNAccessFile /home/svn/permisos/dav_svn.authz
Require valid-user
</Location>
Reiniciar Apache2
/etc/init.d/apache2 restart
5. Generación de Scripts
Estos scripts fueron hechos para simplificar la gestión del SVN, crearlos en /home/svn/permisos linkear contra /user/sbin
5.1. svnaddrep
#!/bin/sh
#
# svn projets creation
#
serv="https://127.0.0.1/"
cwd="/home/svn/"
if [ "$1" = "" ]; then
echo -n "Repository name: ";
read projet;
else
projet="$1";
fi
site="$serv$projet";
echo " svnadmin create $cwd$projet --fs-type fsfs";
svnadmin create $cwd$projet
echo " chown -R www-data:www-data $cwd$projet";
chown -R www-data:www-data $cwd$projet
cp /home/svn/permisos/authz $cwd$projet/conf
cp /home/svn/permisos/svnserve.conf $cwd$projet/conf
echo "[$projet:/]" >> /home/svn/permisos/dav_svn.authz;
echo "root = rw" >> /home/svn/permisos/dav_svn.authz;
echo -n "Add initial structure (root password requiered)?(y/n):";
while true; do
echo -n "Add initial structure (root password requiered)?(y/n):";
read yn;
case $yn in
[yY]* ) echo " svn mkdir $site/trunk $site/branches $site/tags -m
\"Subversion archive folder creation.\"";
svn mkdir $site/trunk $site/branches $site/tags -m "Subversion archive folder
creation.";break;;
[nN]* ) echo;exit;;
esac
done
echo "
##########################################
Finished!
Remember to add users...
##########################################";
5.2. svnadduser
#!/bin/sh
#
# svn user creation
#
if [ "$1" = "" ]; then
echo -n "Username:";
read user;
else
user="$1";
fi
su www-data -c "htpasswd -m /home/svn/permisos/dav_svn.passwd $user"
5.3. svndeluser
#!/bin/sh
#
# svn user creation
#
if [ "$1" = "" ]; then
echo -n "Username:";
read user;
else
user="$1";
fi
su www-data -c "htpasswd -D /home/svn/permisos/dav_svn.passwd $user"
Espero que les sirva, Saludos!
Fuentes:
http://es.wikipedia.org/wiki/Subversion
http://wiki.forum.nokia.com/index.php/Subversion_(SVN)_server_installation_guide
http://alephzarro.com/blog/2007/01/07/installation-of-subversion-on-ubuntu-with-apache-ssl-and-basicauth/
http://www.geocities.com/arhuaco/doc/subversion/apache-subversion-in-debian.html