We have setup two ubuntu machines at home, probably there will be another one on virtual machine. So, last night I decide to configure a CVS server for our hobby development purpose. Compared with CodeRight or Perforce, CVS is just a toy. But it is a good toy, free and sufficient for small development environment.
To install CVS on Ubuntu, the first thing is to install CVS (I said nothing!):
sudo apt-get install cvs
This will install the cvs pacakge and all the dependencies to your machine. You should do this step on each machine that you want either be the CVS server or works as a client.
Next, on the machine that will be the CVS server, you should create a directory and as the root directory for your CVS repository. The name and location of the directory could be arbitrary:
sudo mkdir /usr/local/cvsroot
Now, the next step is the set the access rights to the repository directory:
1. Create a group called cvs_user and add the users that need to access CVS to this group. You can do this by going to the menu item system/preference.
sudo chown -R :cvs_user /usr/local/cvsroot
This allows every one to access it.
Next, you need to initialize your cvs repository:
sudo cvs -d localhost:/usr/local/cvsroot init
The next step is to create CVS username and password, run the following command for each user you want to add to CVS:
sudo cvs -d localhost:/usr/local/cvsroot +[username]
This will prompt you for the password.
You may not want to type the long repository location "localhost:/usr/local/cvsroot" each time, you can avoid this by defining CVSROOT environment variable:
edit the shell configure batch file:
sudo vim ~/.bashrc
and add the following line:
export CVSROOT=localhost:/usr/local/cvsroot
on the CVS server, or
export CVSROOT=[server name or IP]:/usr/local/cvsroot
on all the other machines.
Ok. now you may want to try if the CVS server works. On any of your machine, create a test directoy, i.e. ~/test and put some files inside it. And then set current working directory to ~ and try the following command:
cvs import test test_vender test_start
which will import your local ~/test directory and create a branch with vendor label test_vender and release label test_start on it. You will be asked for your password first which will be the password you set for CVS earlier. Then you will be brought onto a text editor. CVS requires you write "something" to describe your submission, just write something like "Hey! This is my first CVS check-in!" and then save and exit. If you see CVS successfully imported your local directory, you are a nut! Now delete the local copy by:
rm -rf ~/test
and then checkout from the CVS repository by:
cvs co -r test_start test
Do you see your ~/test folder back? If so, conguratulations, you have succeeded!
You may not want to log into the CVS server every time by typing the password, so you can take advantage of the SSH public key mechanism.
Runt the following command:
sudo apt-get install ssh-keygen
If you have not installed ssh-keygen, this will install it. Next, run:
ssh-keygen
Press ENTER all the way and let it finish, and it will create two files in your ~/.ssh/ folder
cd ~/.ssh
scp id_rsa.pub [username]@[server name or IP]:~/
this will copy your public key to the CVS server. Then log into the CVS server and do the following:
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
rm ~/id_rsa.pub
This will add the public key to the authorized server list of the CVS server, so next time when your CVS client wants to get into the server, the server will trust it and let it go. You may want to find out additional information about ssh and ssh-keygen.
Now go back to the client machine and try a CVS command again. See, you are not asked for any password! Repeat the above steps for each client and you are all set.
Please let me know if there's anything unclear or wrong and I will further polish this instruction.
Wednesday, September 12, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment