Artigos‎ > ‎Compartilhamento de Arquivos‎ > ‎SVN‎ > ‎

Subversion no Ubuntu


Primeiramente gostaria de salientar que não sou o autor principal do conteúdo deste artigo. A minha intenção é de mostrar o que outros autores tem realizado (referenciando links para o conteúdo original) neste blog até como um guia pessoal para uso próprio e ainda compartilhar minhas anotações e pequenas modificações que realizo no conteúdo, desejando que possa ajudar mais alguém em algum lugar.
First and foremost, I take no credit for any of this post’s content. I am really just taking what others have done (which I have links to bellow) and am putting it on my blog for a personal reference and hopefully the small changes that I made to their guides will help someone somewhere.

link: https://help.ubuntu.com/community/Subversion

sudo apt-get install subversion libapache2-svn

sudo mkdir -p /srv/svn
sudo addgroup subversion
sudo usermod -a -G  subversion manager
sudo usermod -a -G subversion aarvati
sudo usermod -a -G subversion www-data
sudo mkdir -p /srv/svn/edifast
sudo chown -R www-data:subversion /srv/svn/edifast 
sudo chgrp subversion /srv/svn
sudo chgrp subversion /srv/svn/edifast
sudo chmod -R g+rws /srv/svn/edifast

svnadmin --version

sudo svnadmin create /srv/svn/edifast
sudo chmod -R g+rws /srv/svn/


link: http://wiki.ivonet.nl/display/LINUX/Subversion+over+Apache2+on+Ubuntu
Acesso via web-dav no apache2 com subversion:
Crie o diretório:
sudo mkdir /var/www/svn/

Crie o arquivo abaixo:
sudo nano /etc/apache2/sites-available/svn-ssl
<IfModule mod_ssl.c>
<VirtualHost *:443>

ServerAdmin edifast@edifast.com.br
  ServerName svn.edifast.com.br
DocumentRoot /var/www/svn

        ErrorLog /var/log/apache2/svn-error.log
        # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
        LogLevel info
        CustomLog /var/log/apache2/svn-access.log combined
        CookieLog /var/log/apache2/svn-cookie.log


SSLEngine on
        SSLCertificateFile /etc/ssl/CA/certs/svn.edifast.com.br.crt
        SSLCertificateKeyFile /etc/ssl/CA/private/svn.edifast.com.br.key
                SSLCACertificateFile  /etc/ssl/CA/cacert.pem 


        BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

    <Location />
        Order deny,allow
        Allow from all
        AuthType Basic
        AuthName "Administradores"
        AuthUserFile /etc/subversion/dav_svn.passwd
        Require valid-user
        SSLRequireSSL
    </Location>


        <Location /svn>
            Order deny,allow
            Allow from all
            AuthType Basic
            AuthName "Subversion repositories"
            AuthUserFile /etc/subversion/dav_svn.passwd
            Require valid-user
            SSLRequireSSL

            DAV svn
            SVNParentPath /srv/svn
                        SVNIndexXSLT "/repos-web/view/repos.xsl"
              LimitXMLRequestBody 0
            SVNAutoversioning on
            ModMimeUsePathInfo on
            <IfModule mod_authz_svn.c>
                    AuthzSVNAccessFile /etc/subversion/dav_svn.authz
            </IfModule>
        </Location>

</VirtualHost>
</IfModule>

sudo chown www-data:subversion /var/www/svn/

Crie a senha para cada um dos usuários (a opção -c apenas para o primeiro):
sudo htpasswd -c /etc/subversion/dav_svn.passwd manager
sudo htpasswd /etc/subversion/dav_svn.passwd aarvati
cat /etc/subversion/dav_svn.passwd
sudo chgrp subversion /etc/subversion/dav_svn.passwd

link: http://svnbook.red-bean.com/en/1.6/svn.serverconfig.httpd.html#svn.serverconfig.httpd.authn.digest
Uma outra alternativa é utilizar autenticação Digest ao invés de basic:
AuthName "Subversion repository"
AuthType Digest 
AuthUserFile /etc/svn-auth.htdigest

E depois crie as senhas dos usuários com o htdigest:
### First time: use -c to create the file 
htdigest -c /etc/svn-auth.htdigest "Subversion repository" harry 
htdigest /etc/svn-auth.htdigest "Subversion repository" sally


sudo touch /etc/subversion/dav_svn.authz
sudo chgrp subversion /etc/subversion/dav_svn.authz
sudo gedit /etc/subversion/dav_svn.authz

### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###  - a single user,
###  - a group of users defined in a special [groups] section,
###  - an alias defined in a special [aliases] section,
###  - all authenticated users, using the '$authenticated' token,
###  - only anonymous users, using the '$anonymous' token,
###  - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').

[groups]
admin = manager, aarvati
 
[/]
$authenticated = r
@admin = rw
 
[edifast:/]
@admin = rw

sudo a2enmod authz_user
sudo a2enmod authz_svn
sudo a2enmod ssl
a2enmod rewrite 
sudo a2ensite svn-ssl

Aumente o tempo de conexão permitida pelo apache:
sudo nano /etc/apache2/apache2.conf
Timeout 50000
KeepAlive On
MaxKeepAliveRequests 0
KeepAliveTimeout 250000

sudo nano /etc/apache2/mods-available/ssl.conf
SSLSessionCacheTimeout 5000

E se necessário aumente também o tempo necessário no subversion:
sudo nano /etc/subversion/servers
[global]
ssl-authority-files =  /etc/ssl/CA/cacert.pem
http-timeout = 50000
http-library = serf

sudo service apache2 restart

Serviço pode ser iniciado como comando abaixo:
svnserve -d --foreground -r /srv/svn/

Vai precisar liberar a porta default 3690 no seu firewall ou roteador.

link: http://odyniec.net/articles/ubuntu-subversion-server/

sudo wget -O /etc/init.d/svnserve http://odyniec.net/articles/ubuntu-subversion-server/svnserve
sudo nano /etc/init.d/svnserve
Altere a linha: DAEMON_ARGS="-d -r /usr/local/svn/repos"
para: DAEMON_ARGS="-d -r /srv/svn"

sudo chmod +x /etc/init.d/svnserve
sudo update-rc.d svnserve defaults
sudo /etc/init.d/svnserve start

sudo gedit /etc/subversion/svnserve.passwd

[users] 
manager = somepassword 
aarvati = anotherpassword

sudo chmod 600 /etc/subversion/svnserve.passwd

sudo gedit /srv/svn/edifast/conf/svnserve.conf

[general]
anon-access = none
password-db = /etc/subversion/svnserve.passwd
authz-db =  /etc/subversion/dav_svn.authz
realm = Edifast



link: http://wiki.ivonet.nl/display/LINUX/Subversion+over+Apache2+on+Ubuntu
Ajustando a aparência das páginas web com REPOS STYLE: http://www.reposstyle.com/

Primeiro instale PHP: https://help.ubuntu.com/community/ApacheMySQLPHP#Installing_PHP_5
sudo apt-get install libapache2-mod-php5
sudo a2enmod php5

wget http://downloads.sourceforge.net/project/reposserver/reposstyle/repos-style-with-plugins-2.4.zip
sudo unzip repos-style-with-plugins-2.4.zip -d /var/www/svn/
sudo rm repos-style-with-plugins-2.4.zip
sudo chown -R www-data:subversion /var/www/svn/repos-web
sudo chgrp subversion /var/www/svn/repos-web
sudo chmod -R g+rws /var/www/svn/repos-web

Altere a configuração do Apache na seguinte linha:
sudo nano /etc/apache2/sites-available/svn-ssl
SVNIndexXSLT "/repos-web/view/repos.xsl"

Ajuste o arquivo abaixo:
sudo nano /var/www/svn/repos-web/open/log/index.php
As linhas:
$repo = 'file:///srv/svn';
$isParent = true;

sudo service apache2 restart

Para funcionar o svn-log do repos-plugins precisa ainda configurar:
4. Installation
========================================

Install this directory somewhere central on your server. Make sure the directory is visitable by the user running svn (www or svnserve) and that rssfeed.sh is executable.
For each of your repository, copy users.xml and populate.
Then add the following to your hooks/post-commit script (which you may need to create):

<path-to-svnlog-xslt>/rssfeed.sh \
    "<repository-url>" "$2" \
    "<feed-name>" "<feed-copyright-owner>" \
     "<feed-output-path>" \
     "<repository-base-URL-with-trailing-slash>" \
     "file://${1}/users.xml" "<log-tmp-output>"

See the comments in rssfeed.sh for more details.

Mais detalhes em: https://groups.google.com/forum/?fromgroups=#!forum/reposstyle
e em: https://groups.google.com/forum/?fromgroups=#!msg/reposstyle/teR5rlfzHpo/u5prTJmtvtAJ


Arquivo /srv/www/svn/repos-web/open/log/index.php

Correção para mostrar diretórios de caracteres non-ASCII como ç, ã, õ e etc:

<?php
setlocale(LC_CTYPE, "en_US.UTF-8");

Execute os comandos:
sudo dpkg-reconfigure locales
sudo locale-gen pt_BR.UTF-8
sudo locale-gen --no-purge --lang pt_BR
sudo apt-get install language-selector
gksu /usr/bin/gnome-language-selector

Antes:
cat /etc/default/locale
LANG="en_US.UTF-8"

sudo update-locale LANG=pt_BR.UTF-8


Depois de uma mudança manual:
sudo nano /etc/default/locale
LANG="pt_BR.UTF-8"
LANGUAGE="pt_BR:pt:pt_PT:en"

Trocar a configuração do terminal:
sudo dpkg-reconfigure console-setup


O URL específico do gadget não foi encontrado



Comments