jueves, diciembre 09, 2010

Migrating CVS repositories from Windows to Linux

I've been in these last few days migrating some CVS repositories from a Windows NT machine to a Linux (Ubuntu 10.04 desktop).
Following the philosophy <>, I'll explain the steps I followed in an exchematic way (and save you the odd headache with some "quirks" of CVS and especially M$-Windows.
For technical people, the migration was from CVSNT repositories hosted in CVSNT 2.5.03 (Scorpio) Build 2382 on Windows.
In Linux we have the opportunity to install both CVS and CVSNT. For compatibility, I installed (from the repositories) CVSNT. The version that was in the repositories was 2.5.04 (Zen) Build 3236, which guaranteed the compatibility.

Well, hands on keyboards:

.- In the Windows machine, stop CVS services, and make a zip, tar, 7zip .... what you want.

.- We copy it on the Linux machine and unpack it (tar xvfz ....., p7zip-d ......) to any folder on your hard disk (let's call it /home/ReposCVSwindows).
So, we'll have the contents of our repository (let's call it  repo1) in /home/ReposCVSwindows/repo1.

.- We are on the Linux machine. With root, create the repository, and start (let's do it by example in the folder /home/prose/ReposCVS)
sudo cvs -d /home/prosa/ReposCVS/repo1 init

.- Let's copy the contents of /home/ReposCVSwindows/repo1  to  /home/prose/ReposCVS/repo1. Be careful here. If we do it with a non-root user, it won't let us overwrite some files in CVSROOT. If we do it as root, then all files are copied to owner "root" and then it won't work as expected.
My solution was to use my favorite file manager (gnome-commander), starting the root version (File -> start gnome commander as root), and from there make the copy, replacing all existing files (there are several that are created in linux and not windows and of course they will not be overwritten).
In this way, we overwrite files without root permissions to files with root permissions, but keeping the non-root as owner (in our example prose).
(Sure there are some cp command option that does this, but gnome-commander does it in 2 seconds).

.- In the CVSROOT directory of the repository folder, we'll create a file named "admin" with content "prose" (or the name of the user of the machine). Thus, we tell CVS that this user can perform administrative tasks on the repository.

.- Now we have the repository fully copied. Now we will try to connect to it:
cvs -d :pserver:JuanMa@localhost:/home/prose/ReposCVS/repo1 login

(JuanMa is a user that we have imported from the windows - it comes in CVSROOT/passwd file -). It will ask for the password.

Here goes something inexplicable to me. Sometimes this has worked for me and I haven't had an error, but generally tends to respond:
cvs [login aborted]: Authorization failed: server localhost Rejected access to / home/prose/ReposCVS/repo1 for user JuanMa

I think it's a codification problem in the file passwd which, as I said, stores users. One way to save it with "linux format" is to create a new dummy user and force to write to this file:

cvs -d /home/prosa/ReposCVS/repo1 passwd -a -r prose jm1

(Put the password you want) (the "prose" parameter must be the actual user loged in Linux).

.- We see that the passwd file now has a new line with the new user jm1.

.- Open the file CVSROOT/passwd with vi (or substitutes - vim, gvim ...-), not gedit. Here we see that all lines except the last are the famous ending ^M
. We must remove it in all the lines.

.- Now we should be able to access the previous user:
cvs -d :pserver:JuanMa@localhost:/home/prosa/ReposCVS/repo1 login

.- Now we just put an alias to the repository
It is a way to access to /home/prosa/ReposCVS/repo1  as  /repo1.

To do this, we edit the file /etc/cvsnt/PServer.
Here we have that every repository has 2 lines: one with the path and the other with the name (they are identical initially). Change the second:

Repository1=/home/prosa/ReposCVS/repo1
Repository1Name=/repo1


A final problem to be solved:  users in M$-Windows who were created with write permissions, now couldn't write.
I solved this deleting the file "writers" of the CVSROOT folder (strange but true).


That's all. Enjoy.