Migrate CVS repository to GForge
At work we were testdriving SourceForge Enterprise Edition. It is a great system to keep all your project information, source code, documents, bug reports and changes together, and linked. As you may have noticed, the pricing model of the Enterprise Edition is a well kept secret on the site. Our management bargained with the Colabnet people, but the costs (or TCO) were way to steep to keep SourceForge as our main system.
Another product which promises to do almost the same thing is GForge Advanced Server. GForge originally started as a fork of the (then open source) SourceForge code, and is not as advanced as SourceForge is today. But their pricing is more to the likings of our financial people, and we decided it has a good tradeoff between function and price.
Having said all this, we need to migrate a few projects from SourceForge to GForge. If you'd like to know how to do this, this article is for you. It describes how to get your CVS repository into GForge in 6 steps.
Step 1: Disabling writer access to CVS in SourceForge
To be on the safe side, block write access to the CVS repository to prevent people from committing (and loosing) changes. You can block access using the settings in your SourceForge project, or modifying the "writers" file to the CVSROOT of your repository. If you're not migrating from a SourceForge machine, you'll probably want to use the latter method.
Step 2: Getting the modules from SourceForge
Log into your SourceForge server, go to the root of the CVS tree for your project. In our example, we'll use "project1" and the modules "modulefoo" and "modulebar" (for the foobar minded). An example ssh session will look like this:
[root@projects /]# cd /cvsroot/project1
[root@projects project1]# ls -al
drwxrws--- 10 nobody reps1010 4096 Mar 4 20:12 .
drwxr-sr-x 10 root root 4096 Feb 20 13:59 ..
drwxrwsr-x 3 nobody reps1010 4096 Dec 28 14:23 CVSROOT
drwxrwsr-x 6 nobody reps1010 4096 Mar 4 14:26 modulefoo
drwxrwsr-x 5 nobody reps1010 4096 Mar 4 14:27 modulebar
[root@projects project1]#
tar -czf project1.tar.gz modulefoo modulebar
Please note that we do not put the CVSROOT in the tar file. This prevents us from overwriting the CVSROOT later on in the GForge repository. After building the tar file, we need to send it to the GForge machine. You can do this by a secure copy. Put the tar file in the home directory of the user you're using to connect to GForge during the copy. We'll move it later.
Remove the tar file from the SourceForge server and disconnect. We're done at the SourceForge server.
Step 3: Add CVS to your GForge project
We need a project to host our sourcefiles (and more). Using a web browser, connect to your GForge machine and create a project, or use an existing one if you've allready done so. Now go into the "Admin" tab of the project, and select "CVS repository" as your scm (Source Code Management) and press Submit:
After you've done this, you should have a proper CVS repository set up on your GForge server, in which we can unpack the tarfile we've just created.
Step 4: Unpack the tar file on the GForge machine
In this example, I'm using the root user for convenience. Depending on your administrator, maybe you're not allowed to be root (for good reason). Should you not have enough permissions to execute any of the following commands in the right locations, ask your administrator to execute Step 4 and 5 for you.
Log on to the GForge machine, and become root. Move the tar file to the cvsroot location of your project, and unpack the modules there. Your session should look something like this:
[root@gforge ~]# cd /cvsroot/project1
[root@gforge project1]# mv /home/someuser/project1.tar.gz .
[root@gforge project1]# tar -xzf project1.tar.gz
[root@gforge project1]# rm project1.tar.gz
[root@gforge project1]# ls -al
drwxrws--- 5 nobody project1 4096 Feb 20 14:20 .
drwxr-xr-x 12 root root 4096 Mar 4 19:49 ..
drwxrwsr-x 3 nobody project1 4096 Feb 20 14:19 CVSROOT
drwxrwsr-x 6 nobody 519 4096 Mar 3 11:57 modulefoo
drwxrwsr-x 7 nobody 519 4096 Feb 20 16:14 modulebar
[root@gforge project1]#
At this point, the modules are in GForge, but we can not access them yet.
Step 5: Setting the permissions
The files and folders in the modules are having the wrong ownership and permissions because they came from a different machine with different users. To be able to set the permissions, we need a username and a group to add to these files. When adding a project in GForge, a group with the same name as the project is also made.
First we need to change the ownership of the files, without touching the CVSROOT:
chown -R nobody:project1 modulefoo modulebar
Next, we need to set the permissions of all directories (except for CVSROOT) in the tree. We do this by recursively finding all directories in the modules and executing chmod against them. Type the following on 1 line, exactly as shown:
find modulefoo modulebar -type d -exec
chmod u+rwx,g+rwxs,o+rx,o-w {} \;
The files have slightly different permissions. You can set these by typing the following on 1 line, exactly as shown:
find modulefoo modulebar -type f -exec
chmod u+r,u-wx,g+r,g-wxs,o+r,o-wx {} \;
To check that everything has worked, take a look at the file and directory permissions of modulefoo:
[root@gforge project1]# ls -al modulefoo
drwxrwsr-x 6 nobody project1 4096 Mar 3 11:57 .
drwxrws--- 5 nobody project1 4096 Feb 20 14:20 ..
drwsrwsr-x 2 nobody project1 4096 Feb 20 14:20 Attic
-r--r--r-- 1 nobody project1 16330 Mar 3 11:57 build.properties,v
-r--r--r-- 1 nobody project1 15195 Mar 3 11:57 .cvsignore,v
...
Step 6: Restart and Check GForge Access
CVS access will now work, but in GForge you will get an error in the CVS browser. To get rid of this error you need to restart apache. As root, do:
cd /etc/init.d
apachectl restart
Close your ssh session. Open your browser and go to your GForge server. Open your project, and click on the "CVS" tab on the right. You should now see the root of the project, with modulefoo and modulebar as folders in a list. Congratulations, you're done.
Should you get the dreaded "Python error" with some rubbish text about not having enough permissions, you did not restart apache, or something went wrong while setting the file permissions and ownershisps. Double check them, and make sure you didn't touch the CVSROOT directory, or the current or parent directories. If you did, simply restore from your backup and retry :-)
Have fun migrating your projects.