Escolar Documentos
Profissional Documentos
Cultura Documentos
Estrutura de diretrios:
Verso 1.6:
/etc/apt/sources.list
deb http://ppa.launchpad.net/anders-kaseorg/subversion-1.6/
ubuntu jaunty main
deb-src http://ppa.launchpad.net/anders-kaseorg/subversion-
1.6/ubuntu jaunty main
nstala chaves
# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys
413576CB
# apt-get update
nstala subversion
#apt-get install subversion
Apache
<VirtualHost *>
ServerAdmin webmaster@localhost
ServerName svn.conab.gov.br
ErrorLog /var/log/apache2/svn-error.log
LogLevel warn
CustomLog /var/log/apache2/svn-access.log combined
ServerSignature On
#$ocation %& #$ocation %&
D'V s"n D'V s"n
SVNParentPath %home%s"n%repositorios SVNParentPath %home%s"n%repositorios
'uth()pe *asic 'uth()pe *asic
'uthName +SVN 'uthentication+ 'uthName +SVN 'uthentication+
'uth*asicPro"ider ldap 'uth*asicPro"ider ldap
Order 'llo,-Den) Order 'llo,-Den)
'llo, .rom 'll 'llo, .rom 'll
'uth$D'P/0$ 'uth$D'P/0$
+ldap1%%ldap2cona!2go"2!r%ou3usuarios-dc3matri4-dc3cona!-dc3go"-dc3! +ldap1%%ldap2cona!2go"2!r%ou3usuarios-dc3matri4-dc3cona!-dc3go"-dc3!
r5uid+ r5uid+
'uth4$D'P'uthoritati"e o.. 'uth4$D'P'uthoritati"e o..
'uth4SVN'ccessFile %home%s"n%permissoes%auth4 'uth4SVN'ccessFile %home%s"n%permissoes%auth4
0e6uire "alid-user 0e6uire "alid-user
#%$ocation& #%$ocation&
</VirtualHost>
<Location />
DAV svn
SVNParentPath /home/svn/repositorios
AuthType Basic
AuthName "SVN Authentication"
AuthBasicProvider ldap
Order Allow,Deny
Allow from All
AuthLDAPURL
"ldap://ldap.conab.gov.br/ou=usuarios,dc=matriz,dc=c
onab,dc=gov,dc=br?uid"
AuthzLDAPAuthoritative off
AuthzSVNAccessFile /home/svn/permissoes/authz
Require valid-user
</Location>
/etc/apache2/sites-available/svn
Apache
<Location />
DAV svn
SVNParentPath /home/svn/repositorios
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile
/home/svn/permissoes/autenticacao.passwd
AuthzSVNAccessFile
/home/svn/permissoes/autorizacao.authz
Require valid-user
</Location>
<Location /svn/myproject>
DAV svn
SVNPath /home/svn/myproject
AuthType Basic
AuthName "myproject subversion
repository"
AuthUserFile /etc/subversion/passwd
<LimitExcept GET PROPFND
OPTONS REPORT>
Require valid-user
</LimitExcept>
</Location>
Permisses
%home%s"n%permissoes%auth4
[groups]
DESENVOLVEDOR = pedro.costa
[/branches]
* = r
[/tags]
* = r
[/trunk]
* = r
[teste:/branches]
pedro.costa = rw
[teste:/tags]
pedro.costa =
[teste:/trunk]
@DESENVOLVEDOR = rw
Manuteno
Restaurar backup:
$ svnadmin load /path/to/newrepo < repos-dumpfile
<<< Started new txn, based on original revision 1
* adding path : A ... done.
* adding path : A/B ... done.
.
------- Committed new rev 1 (loaded from original rev 1) >>>
Manuteno
for REPOSTORO in $REPOSTOROS
do
#Revisao Corrente
CURR_REVSON=`/usr/local/bin/svnlook youngest /var/svn/$REPOSTORO`
#GRAVA A ULTMA REVSAO DE CADA REPOSTORO
echo "$CURR_REVSON" > /var/svn/backup/lastrevision/$REPOSTORO.txt
#Faz o Backup de cada repositorio
/usr/local/bin/svnadmin dump /var/svn/$REPOSTORO | /bin/gzip > /var/svn/backup/svnBK-$REPOSTORO-$dia-$mes-$ano.dump.gz
echo FAZENDO BACKUP DE: $REPOSTORO NA REVSAO: $CURR_REVSON . ARQUVO: svnBK-$REPOSTORO-$dia-$mes-$ano.dump.gz
# Se o arquivo existir e o seu Conteudo nao for vazio, transmite via smb
if [ ! -z svnBK-$REPOSTORO-$dia-$mes-$ano.dump.gz ]
then
echo TRASNMTNDO svnBK-$REPOSTORO-$dia-$mes-$ano.dump.gz ...
#Remove o backup de 1 dia anterior
smbclient //dfbsa10a/svn -U=$USER_SMB%$PASSWD_SMB -c "del svnBK-$REPOSTORO-$Odia-$Omes-$Oano.dump.gz" 2> /dev/null
smbclient //dfbsa10a/svn -U=$USER_SMB%$PASSWD_SMB -c "put svnBK-$REPOSTORO-$dia-$mes-$ano.dump.gz" 2> /dev/null
#Remove o backup de 1 dia anterior
#smbclient //gesin56/backup_svn -U=$USER_SMB%$PASSWD_SMB -c "del svnBK-$REPOSTORO-$Odia-$Omes-$Oano.dump.gz" 2> /dev/null
#smbclient //gesin56/backup_svn -U=$USER_SMB%$PASSWD_SMB -c "put svnBK-$REPOSTORO-$dia-$mes-$ano.dump.gz" 2> /dev/null
echo REMOVENDO ARQUVO ENVADO: svnBK-$REPOSTORO-$dia-$mes-$ano.dump.gz
#Remove o backup atual que foi tramitido via smb
rm -f /var/svn/backup/svnBK-$REPOSTORO-$dia-$mes-$ano.dump.gz 2> /dev/null
fi
done
Ferramentas
http://code.google.com/p/suafe/
http://svn.conab.gov.br/GCM/trunk/AutomatizarSVN
AutomatizaSVN
ConabSvnUtil.java
...
DAVRepositoryFactory.setup();
SVNURL url = SVNURL.parseURDecoded(repositoryURL + projeto + baselineDestino);
SVNRepository repository = SVNRepositoryFactory.create(url);
SVNAuthenticationManager authManager =
SVNWCUtil.createDefaultAuthenticationManager(usuario, senha);
repository.setAuthenticationManager(authManager);
long latestRevision = repository.getLatestRevision();
...
SVNEditor editor = repository.getCommitEditor("Criando copia de " + absoluteSrcPath + "
(Revisao: " + revisao + ") para: " + dstDir, null);
try {
SVNCommitnfo commitnfo = copyDir(editor, absoluteSrcPath, dstDir, srcRevision);
System.out.println("The directory was copied: " + commitnfo);
} catch (SVNException svne) {
editor.abortEdit();
throw svne;
}
...
AutomatizaSVN
<taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask" classpathref="project.classpath" />
<target name="criar_copia">
<echo>Criando o novo codeline [branch|tag] para o projeto: ${projeto}</echo>
<!-- Passo-1: Obter a reviso da qual ser criada a cpia -->
<input message="Reviso do ${projeto} (no precisa informar se for HEAD):" addproperty="revisao"
defaultvalue="HEAD" />
<!-- Passo-2: Compilar a classe a ser usada -->
<javac srcdir="${src.dir}" destdir="${build.dir}">
<classpath refid="project.classpath" />
</javac>
<!-- Passo-3: Executar a classe que far a cpia, recebendo os
parmetros necessrios -->
<java classname="br.gov.conab.svn.ConabSvnUtil" failonerror="true">
<arg value="${repository.URL}" /><arg value="${repository.user}" />
<classpath>
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
<pathelement location="${lib.dir}" />
<pathelement path="${build.dir}" />
</classpath>
</java>
</target>
AutomatizaSVN
<taskdef name="ssh" classname="com.sshtools.ant.Ssh" classpath="${lib.dir}/maverick-ant.jar" />
<target name="criar_repositorio" depends="iniciar" description="Cria um novo repositrio no servidor
do SVN (com a estrutura padro: trunk, branches, tags)">
<!-- Nome do repositrio a ser criado-->
<input message="Nome do repositrio:" addproperty="repositorio" />
<!-- Comandos para criao do repositrio -->
<ssh host="${repository.HOST}" username="${repository.host.user}" password="$
{repository.host.password}" version="2">
<exec cmd="svnadmin create ${home.repositorios}/${repositorio}" />
<exec cmd="svn mkdir file://${home.repositorios}/${repositorio}/trunk -m Trunk" />
<exec cmd="svn mkdir file://${home.repositorios}/${repositorio}/branches -m Branches" />
<exec cmd="svn mkdir file://${home.repositorios}/${repositorio}/tags -m Tags" />
<exec cmd="chown -R ${apache.user}.${apache.group} ${home.repositorios}/${repositorio}" />
</ssh>
<echo>Repositrio: ${repositorio} foi criado e pode ser acessado atravs da URL: ${repository.URL}/$
{repositorio}</echo>
</target>
StatSVN
http://www.statsvn.org/index.html
StatSVN
Gerar relatrio
java -jar statsvn.jar <logfile> <checked-out-module>
StatSVN
As imagens seguintes esto relacionadas ao trunk do SSCOE
StatSVN
StatSVN
StatSVN
StatSVN
StatSVN
StatSVN
Comandos Bsicos
Listar comandos
svn help
Fazer checkout
svn co http://svn.conab.gov.br/siscoe/branches/1.x
Adicionar arquivo
svn add arquivo.txt
Criar tag
svn copy http://svn.conab.gov.br/siscoe/branches/1.x
http://svn.conab.gov.br/siscoe/tags/1.0
Mover/Renomear arquivo
svn move arquivo.txt novo_nome.txt
Comitar
svn ci arquivo.txt -m "comitando arquivos
Procedimento p/ criacao de branches