Difference between revisions of "SVN"

From Blue-IT.org Wiki

Line 1: Line 1:
 +
== SVN Integration with https ==
 +
First of all your repository, e.g. /home/svn must be writable by the webserver:
 +
 +
MYREPO="/home/svn"
 +
chown -R www-data:www-data ${MYREPO}
 +
find ${MYREPO} -type d -exec chmod 2755 \{} \;
 +
find ${MYREPO} -not -type d -exec chmod 0644 \{} \;
 +
 +
Then you need mod_dav for apache2:
 +
 +
apt-get install libapache2-svn
 +
cd /etc/apache2/mods-available/
 +
vim dav_svn.conf
 +
 +
 +
To access an svn like [https://serverip/svn https://serverip/svn] do the following:
 +
 +
  <nowiki><Location /svn></nowiki>
 +
      DAV svn
 +
      SVNParentPath /path/to/svn
 +
      AuthType Basic
 +
      AuthName "Subversion Repository"
 +
      AuthUserFile /etc/apache2/dav_svn.passwd
 +
     
 +
      <nowiki># Allow access only with authentification</nowiki>
 +
      Require valid-user
 +
 
 +
    <nowiki># Allow acces with anonymous checkout</nowiki>
 +
    <nowiki>#<LimitExcept GET PROPFIND OPTIONS REPORT></nowiki>
 +
    <nowiki># </nowiki> Require valid-user
 +
    <nowiki>#</LimitExcept></nowiki>
 +
 
 +
  <nowiki></Location></nowiki>
 +
 +
 +
Now set an password for the first user:
 +
 +
htpasswd -c /etc/apache2/dav_svn.passwd  username1
 +
 +
 +
and for every one after that without “-c“ (because this in case will overwrite the file!!!)
 +
 +
htpasswd /etc/apache2/dav_svn.passwd  username2
 +
 +
Create a virtual host if you like:
 +
 +
SERVERIP="1.2.3.4"
 +
MAIL="webmaster@mydomain.com"
 +
DOMAIN="svn.example.com"
 +
DOCPATH="/var/www"
 +
SSLPATH="/var/kunden/ssl"
 +
CUSTOMER=""
 +
CHAINFILE="/var/kunden/ssl/CAcert_chain.pem"
 +
 +
<nowiki>cat << EOF > ${DOMAIN}.conf</nowiki>
 +
<nowiki><VirtualHost ${SERVERIP}:443></nowiki>
 +
  ServerAdmin webmaster@blue-it.org
 +
  ServerName  www.${DOMAIN}
 +
  ServerAlias ${DOMAIN}
 +
 +
  DocumentRoot ${DOCPATH}
 +
  <nowiki><Directory ${DOCPATH}></nowiki>
 +
    Options -MultiViews
 +
    allow from all
 +
  <nowiki></Directory></nowiki>
 +
  <nowiki># Possible values include: debug, info, notice, warn, error, crit,</nowiki>
 +
  <nowiki># alert, emerg.</nowiki>
 +
  LogLevel warn
 +
 +
  CustomLog /var/log/apache2/access.log combined
 +
  ErrorLog /var/log/apache2/error.log
 +
 +
  SSLEngine on
 +
  SSLCertificateFile ${SSLPATH}/${CUSTOMER}/${DOMAIN}.cert
 +
  SSLCertificateKeyFile ${SSLPATH}/${CUSTOMER}/${DOMAIN}.key
 +
  SSLCertificateChainFile ${CHAINFILE}
 +
 +
<nowiki></VirtualHost></nowiki>
 +
EOF
 +
 +
 +
Restart Apache:
 +
 +
/etc/init.d/apache2 restart
 +
 +
 +
= svnsync =
 +
Taken from:
 +
 +
* [http://www.thoughtspark.org/node/10 Clone Remote Subversion Repositories With svnsyn]
 +
 +
Create the following variables:
 +
 +
MYPATH="/home/svn"
 +
URL_TO_REPO_ROOT_TO_CLONE="https://axelpospischil@ssl.qwws.net/svn/mt_roadrunner"
 +
DEST_URL="/home/svn"
 +
 +
 +
(Note: „DEST_URL“ is the url to the Subversion repository you create in step 1.)
 +
 +
1. Create your local repository:
 +
 +
svnadmin create ${MYPATH}
 +
 +
 +
2. Create an empty pre-revprop-change hook script:
 +
 +
echo '#!/bin/bash' > ${MYPATH}/hooks/pre-revprop-change
 +
 +
 +
3. Make the pre-revprop-change hook script executable:
 +
 +
chmod +x ${MYPATH}/hooks/pre-revprop-change
 +
 +
 +
4. Initialize svnsync:
 +
 +
svnsync init file:⁄⁄⁄${MYPATH} ${URL_TO_REPO_ROOT_TO_CLONE}
 +
 +
 +
5. Synchronize:
 +
 +
svnsync sync ${DEST_URL}
 +
 +
 +
'''Subversion 1.6.x''' needs those added to the pre-revprop-change script:
 +
 +
    REPOS="$1"
 +
    REV="$2"
 +
    USER="$3"
 +
    PROPNAME="$4"
 +
    ACTION="$5"
 +
 +
 
== Einrichten unter Debian ==
 
== Einrichten unter Debian ==
 
1. Svn installieren:
 
1. Svn installieren:

Revision as of 17:16, 12 January 2012

SVN Integration with https

First of all your repository, e.g. /home/svn must be writable by the webserver:

MYREPO="/home/svn"
chown -R www-data:www-data ${MYREPO}
find ${MYREPO} -type d -exec chmod 2755 \{} \;
find ${MYREPO} -not -type d -exec chmod 0644 \{} \;

Then you need mod_dav for apache2:

apt-get install libapache2-svn
cd /etc/apache2/mods-available/
vim dav_svn.conf

To access an svn like https://serverip/svn do the following:

  <Location /svn>
      DAV svn
      SVNParentPath /path/to/svn
      AuthType Basic
      AuthName "Subversion Repository"
      AuthUserFile /etc/apache2/dav_svn.passwd
      
      # Allow access only with authentification
      Require valid-user
  
    # Allow acces with anonymous checkout
    #<LimitExcept GET PROPFIND OPTIONS REPORT>
    #  Require valid-user
    #</LimitExcept>
  
  </Location>

Now set an password for the first user:

htpasswd -c /etc/apache2/dav_svn.passwd  username1

and for every one after that without “-c“ (because this in case will overwrite the file!!!)

htpasswd /etc/apache2/dav_svn.passwd  username2

Create a virtual host if you like:

SERVERIP="1.2.3.4"
MAIL="webmaster@mydomain.com"
DOMAIN="svn.example.com"
DOCPATH="/var/www"
SSLPATH="/var/kunden/ssl"
CUSTOMER=""
CHAINFILE="/var/kunden/ssl/CAcert_chain.pem"

cat << EOF > ${DOMAIN}.conf
<VirtualHost ${SERVERIP}:443>
  ServerAdmin webmaster@blue-it.org
  ServerName  www.${DOMAIN}
  ServerAlias ${DOMAIN}

  DocumentRoot ${DOCPATH}
  <Directory ${DOCPATH}>
    Options -MultiViews
    allow from all
  </Directory>
  # Possible values include: debug, info, notice, warn, error, crit,
  # alert, emerg.
  LogLevel warn

  CustomLog /var/log/apache2/access.log combined
  ErrorLog /var/log/apache2/error.log

  SSLEngine on
  SSLCertificateFile ${SSLPATH}/${CUSTOMER}/${DOMAIN}.cert
  SSLCertificateKeyFile ${SSLPATH}/${CUSTOMER}/${DOMAIN}.key
  SSLCertificateChainFile ${CHAINFILE}

</VirtualHost>
EOF

Restart Apache:

/etc/init.d/apache2 restart

svnsync

Taken from:

Create the following variables:

MYPATH="/home/svn"
URL_TO_REPO_ROOT_TO_CLONE="https://axelpospischil@ssl.qwws.net/svn/mt_roadrunner"
DEST_URL="/home/svn"

(Note: „DEST_URL“ is the url to the Subversion repository you create in step 1.)

1. Create your local repository:

svnadmin create ${MYPATH}

2. Create an empty pre-revprop-change hook script:

echo '#!/bin/bash' > ${MYPATH}/hooks/pre-revprop-change

3. Make the pre-revprop-change hook script executable:

chmod +x ${MYPATH}/hooks/pre-revprop-change

4. Initialize svnsync:

svnsync init file:⁄⁄⁄${MYPATH} ${URL_TO_REPO_ROOT_TO_CLONE}

5. Synchronize:

svnsync sync ${DEST_URL}

Subversion 1.6.x needs those added to the pre-revprop-change script:

    REPOS="$1"
    REV="$2"
    USER="$3"
    PROPNAME="$4"
    ACTION="$5"

Einrichten unter Debian

1. Svn installieren:

apt-get update
apt-get install subversion

2. Eine svn Gruppe erstellen und einen Benutzer hinzufügen:

groupadd subversion
addgroup username subversion

3. Ein svn Repository erzeugen oder ein Vorhandenes kopieren

mkdir /home/svn/myrepo
rsync -av oldserver:/home/svn /home/.
chown -R root:subversion /home/svn
svnadmin create --fs-type fsfs /home/svn/myrepo/projekt1
svnadmin create --fs-type fsfs /home/svn/myrepo/projekt2

4. Einloggen via ssh (geht nur, wenn ein ssh-Schlüssel im Userverzeichnis generiert wurde)

ssh+svn://servername/home/svn/myrepo