Install SubversionSet up an Xserve from scratch part V |
Subversion a really cool tool for file versioning. When put to use in a consequent way, it's a great tool for collaborative software development.
Tweet
1. Startand initiate a session with your Xserve and log in as an administrator, but not as root.
2. Download a Mac OS X installer package for Subversion. You find one at WanDisco or at Apache Subversion. Also download the StartupItem for the Subversion server svnserve and the book Version Control with Subversion.
3. Double click the installers and install both items. Accept the defaults.
The other way to start subversion automatically via launchctl (Mac OS X) is described here: Relocate SVN Repos with SmartSVN
4a. Install SVN on Mac OS X
The Subversion (up to 1.5.*) installer installs everything in /usr/local/bin :
/usr/local/bin/svn
/usr/local/bin/svnadmin
/usr/local/bin/svndumpfilter
/usr/local/bin/svnlook
/usr/local/bin/svnserve
/usr/local/bin/svnsync
/usr/local/bin/svnversion
The 1.6 installer installs SVN in /opt/subversion/bin/ and links to these files in /usr/local/bin :
$ ls -l /usr/bin/svn*
lrwxr-xr-x 1 root wheel 23 17 apr 13:38 /usr/bin/svn -> /opt/subversion/bin/svn
lrwxr-xr-x 1 root wheel 28 17 apr 13:38 /usr/bin/svnadmin -> /opt/subversion/bin/svnadmin
lrwxr-xr-x 1 root wheel 33 17 apr 13:38 /usr/bin/svndumpfilter -> /opt/subversion/bin/svndumpfilter
lrwxr-xr-x 1 root wheel 27 17 apr 13:38 /usr/bin/svnlook -> /opt/subversion/bin/svnlook
lrwxr-xr-x 1 root wheel 28 17 apr 13:38 /usr/bin/svnserve -> /opt/subversion/bin/svnserve
lrwxr-xr-x 1 root wheel 27 17 apr 13:38 /usr/bin/svnsync -> /opt/subversion/bin/svnsync
lrwxr-xr-x 1 root wheel 30 17 apr 13:38 /usr/bin/svnversion -> /opt/subversion/bin/svnversion
If these links are not there, you can easily create them like so:
sudo ln -s /opt/subversion/bin/svn /usr/bin/svn
sudo ln -s /opt/subversion/bin/svnadmin /usr/bin/svnadmin
sudo ln -s /opt/subversion/bin/svndumpfilter /usr/bin/svndumpfilter
sudo ln -s /opt/subversion/bin/svnlook /usr/bin/svnlook
sudo ln -s /opt/subversion/bin/svnserve /usr/bin/svnserve
sudo ln -s /opt/subversion/bin/svnsync /usr/bin/svnsync
sudo ln -s /opt/subversion/bin/svnversion /usr/bin/svnversion
The above does probably not work anymore with Mac OS X El Capitan.
4b. Install SVN on Linux
On Linux, SVN is installed in /usr/bin/
Step 1: Setup Yum Repository
Firstly we need to configure yum repository in our system.
Create a new repo file /etc/yum.repos.d/wandisco-svn.repo and add following content as per your operating system version.
For CentOS/RHEL 6 Users:
[WandiscoSVN]
name=Wandisco SVN Repo
baseurl=http://opensource.wandisco.com/centos/6/svn-1.8/RPMS/$basearch/
enabled=1
gpgcheck=0
For CentOS/RHEL 5 Users:
[WandiscoSVN]
name=Wandisco SVN Repo
baseurl=http://opensource.wandisco.com/centos/5/svn-1.8/RPMS/$basearch/
enabled=1
gpgcheck=0
Step 2: Install Subversion Package
After adding above repository, install the Subversion package using yum command line package manager utility.
$ yum clean all
$ yum install subversion
or try:
$ yum update subversion
In case you face any issues with existing installed subversion, remove that (yum erase subversion) and try again with above commands.
Step 3: Verify Subversion Version
At this stage you have successfully install Subversion client on your system. Lets use following command to verify version of svn client.
$ svn --version
svn, version 1.8.9 (r1591380)
compiled May 1 2014, 14:46:40 on i686-pc-linux-gnu
Copyright (C) 2014 The Apache Software Foundation.
This software consists of contributions made by many people;
see the NOTICE file for more information.
Subversion is open source software, see http://subversion.apache.org/
Step 3: Start svnserve
Create a folder for your repositories:
$ mkdir /var/svn
For Linux (CentOS in my case) you can simple add the following statement to the file /etc/rc.local:
$ echo "svnserve -d -r /var/svn" >> /etc/rc.local
and start the server manually:
$ svnserve -d -r /var/svn
Go to step 6 to see how to create a repository or read Relocate SVN Repos with SmartSVN on how to move repositories.
4c. Continue with Mac OS X
If SVN does not show up when you do $ which svnserve, your PATH environment variable does not contain /user/local/bin. You can add this permanently for all users by doing the following:
$ cd /etc
$ sudo vi csh.login
Add :/usr/local/bin to the end of the setenv line. I my case it now looks like this:
setenv PATH "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
This change was for the csh-shell. Now for the bash-shell:
$ sudo vi profile (not .profile!)
Add :/usr/local/bin to the end of the PATH line. I my case it now looks like this:
PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
After this, type CTRL-D or close the Terminal window to logout. Create a new shell and type:
$ svn
You should now get the message Type 'svn help' for usage. If not check your PATH variable by typing $ echo $PATH and check if it contains /usr/local/bin.
5. The Subversion StartupItem installer installs everything in /library/startupitems/ :
$ ls -l /library/startupitems | grep vers
drwxr-xr-x 4 root wheel 136 Sep 27 10:54 Subversion
$ ls -l /library/startupitems/subversion
-rw-rw-r-- 1 root wheel 467 Sep 26 18:21 startupparameters.plist
-rwxrwxr-x 1 root wheel 220 Sep 27 10:54 subversion
The StartupItem starts the Subversion server as a standalone deamon. I prefer this, because it is the fastest way to get Subversion up and running.
For Linux installation, see Relocate Repositories with SmartSVN.
6. On this server, I have decided to create a root repository folder, named svn, under the /users/ folder because folders under /users/ are always preserved when you need to reinstall the OS for whatever reason :
$ cd /users
$ mkdir svn
Next, I created a repository to hold all my site files :
$ svnadmin create /users/svn/mysite
$ ls -l /users/svn/mysite
-rw-r--r-- 1 myself admin 229 Sep 26 18:57 README.txt
drwxr-xr-x 5 myself admin 170 Sep 27 11:02 conf
drwxr-xr-x 2 myself admin 68 Sep 26 18:57 dav
drwxr-sr-x 10 myself admin 340 Sep 26 18:57 db
-r--r--r-- 1 myself admin 2 Sep 26 18:57 format
drwxr-xr-x 11 myself admin 374 Sep 26 18:57 hooks
drwxr-xr-x 4 myself admin 136 Sep 26 18:57 locks
7. Since our server is a private server, we don't want anonymous users to have access and we want to grant access to a few programmers. Here's how to that. You must do this for every repository you create :
$ cd /users/svn/mysite/conf
$ ls -l
-rw-r--r-- 1 myself admin 684 Sep 26 18:57 authz
-rw-r--r-- 1 myself admin 309 Sep 26 18:57 passwd
-rw-r--r-- 1 myself admin 1451 Sep 27 11:02 svnserve.conf
Edit the svnserve.conf file and change (make sure you remove the comment (#) character) :
- anon-access into anon-access = none
- password-db into password-db = passwd
- realm into something like realm = MYSITE Repository
- There is at least one SVN-client out there that only accepts the realm as the name for the Repository.
8. Before I can start the server, I need to change the StartupItem and add the repository root to the server's start command. That way, nobody has to type the full path to the repository. All paths are from then on relative to the repository root folder :
$ cd /library/startupitems/subversion
$ sudo vi subversion
Add -r /users/svn after the -d option so that it looks like this :
StartService ()
{
/usr/local/bin/svnserve -d -r /Users/svn
}
9. Now start the server by copying the above line and paste it at the Terminal prompt:
$ /usr/local/bin/svnserve -d -r /Users/svn
10. Now, go for a nice client. You find a complete list at Wikipedia or find out more about SVN at WhoIsHostingThis.
11. If you need to move repositories from one server to another, read: Relocate SVN Repos with SmartSVN
That's it. Server up and running.