Setting up CVS on Ubuntu 10.10

The instructions on the Ubuntu Help site had some errors. I come from a Windows background so a lot of this stuff is so endlessly confusing … but I tried to make the most of it. Here's what I did to get CVS working with pserver on Ubuntu 10.10 (Maverick Meerkat).

Just to summarize: cvs is the version control system itself (server or client I'm not sure?), xinetd is some sort of service (daemon) that starts and stops cvs. Some people use cvsd which is a pserver-only type server, but I didn't want to get intertwined with that. We're using pserver on a private firewall LAN, so nothing public therefore the low security of pserver isn't a big deal. Anything in italics is something you type into the console ok? Let's get started.

  1. Applications > Accessories > Terminal to get a command prompt
  2. sudo apt-get install cvs (Then enter your password and wait for install to download and install)
  3. sudo apt-get install xinetd (Should just download and install without asking for a password … last command is "Starting internet superserver xinetd [OK]")
  4. Now the Ubuntu documentation states "Once you install cvs, the repository will be automatically initialized. By default, the repository resides under the /var/lib/cvs directory.". This is NOT TRUE! I found my default repository in /srv/cvs/. The file structure you should see something like this
  5. I wanted to change this default location so I created a new directory called source in var. Just using the GUI, nothing fancy. Right-click and add new directory. Then I typed sudo cvs -d /var/source init. That should do it.
  6. Next I went to /etc/xinetd.d/cvspserver file (just create it if it doesn't exist … no file extension) and changed the code to look like this:
    service cvspserver
    {
    	port = 2401
    	socket_type = stream
    	protocol = tcp
    	user = root
    	wait = no
    	type = UNLISTED
    	server = /usr/bin/cvs
    	server_args = -f --allow-root /var/source pserver
    	disable = no
    }

    Keeping in mind the line server_args with "/var/source" should be changed to whatever you did in step 5 (i.e. "/var/cvs" or whatever)

  7. In command line run sudo /etc/init.d/xinetd restart to restart this xinetd server thingy-ma-bob.
  8. The original Ubuntu Help file says you can run sudo netstat -tap | grep cvs and you should be able to tell that the CVS server is working. My output was something like this: tcp        0      0 *:cvspserver            *:*                     LISTEN      10–9/xinetd. I'm assuming that's good.
  9. Now for usernames and password I made some Ubuntu system accounts for my developers. This link is pretty valuable (from the CVS manual) http://ximbiot.com/cvs/manual/cvs-1.11.23/cvs_2.html#SEC9 Basically what it says is that using pserver either you can create a file inside /srv/cvs/CVSROOT/ called passwd which will contain your usernames and password. Unfortunately they have to be encrypted using the UNIX crypt() method. Not sure how the hell to do this, so I just don't have a passwd file. They say you can copy it from /etc/passwd … but that file just has "x"s for the passwords. Whatever – the end result is that if CVS doesn't find a passwd file it reverts to using your Ubuntu users specified under System>Administration>Users and Groups. I think this is effectively using the /etc/passwd file anyways. I did find this link which had a cool perl script for creating passwords if you want to use the passwd file approach. I didn't end up using it though.
  10. The Ubuntu Help page then goes on about "Projects" and how to make them. I really have no clue what Projects are because in Windows I'm used to Modules. Modules are different blocks of code that you can check out into various sandboxes. Maybe they are one and the same. At this point I think so. So follow that approach if you want to make a new module.
  11. In my case I'm moving an old CVSNT repository into Ubuntu cvs, so I just copied my module (simply a folder with code in it) into the new folder (at the same level as the CVSROOT folder). That's it, I was able to check out that repository now.
  12. In the console I did cvs -d :pserver:mike@localhost:/var/source login. Then it asks you for a password, enter that and then you're "logged in" for some amount of time (I don't really know how that works). Now you can run a command like this: sudo cvs -d /var/source checkout MYCODE – where MYCODE is the folder name of your repository.
  13. To copy the repository history over I just copied and replaced the files history and val-tags in the CVSROOT folder. Didn't seem to cause any hiccups so I think it's safe to do.

Finally … now I can get my ass over to Windows and use TortoiseCVS and a beautiful nice GUI.

Edit: Damnit, needed to come back to Ubuntu and change file permissions up. On the "root" directory (so in my instance /var/source) I changed the group ownership of the source top level directory to a cvsusers group I made in the Users and Groups control panel (under System>Administration). I did this by entering: sudo chgrp cvsusers -R source . I also gave those group users read, write, and execute privileges with the following command sudo chmod 775 -R source. Always the bloody permissions!

To remove

  1. sudo apt-get remove xinetd
  2. sudo apt-get remove cvs
  3. Manually delete the srv/cvs folder.
  4. Delete etc/xinetd.d folder (it has your cvspserver file in it). That's about it.

Update – Git

If you're reading this, I am happy to let you know that I have successfully migrated our project to Git. This was one of the biggest leaps in productivity and source control since I installed CVS after using FTP and manually emailing files back and forth. If you're still using CVS, I compel you to please try set up Git for your project. It takes a bit of work to get into at first, but it will really be worth it in the not-so-long run. As with CVS, Git is just a tool and there are plenty of workflows to follow once you get started, so here are some links that I found useful. I plan on doing a blog post in the future about how I set up Git for my project.

I tried TortoiseGit and found it really lacking so I wouldn't even bother going down that path if you ask me. Right now on a Windows box I use a combination of SmartGit and commandline git commands for any hairy stuff.

The important point is that you can use Git exactly the same as you use CVS. In a linear path, you have a series of commits by various authors. For every CVS command there is a Git analog. One major difference is that Git commits apply to the entire sandbox, whereas in CVS they were file-by-file based. However where Git really shines is branching and merging. You can have several alternate realities of your code going at the same time. Eventually you start to think of your code as a single unit in various versions rather than worrying about the commits on a single file. It really is mind-boggling at times and can make you feel stupid, but I'm telling you from a long-time CVS user … stick with it, you won't regret it!

  • Jim Parker

    Great Info! Thanks for putting it up!

  • MikeMurko

    No problem Jim. Hope it was helpful.

  • Alex

    Hey thanks, easy, even easier than wind.o..

  • amos

    Great tutorial. Write more on other subjects.

  • Daniel

    Thanks a lot for this. It’s much more useful than other tutorials out there which led me nowhere.

  • MikeMurko

    No problemo! Yeah … I was pulling my hair out trying to get this working.

  • VIBHOR HADKE

    Thanks bro for giving the excat info of cvs

  • Ramadoss N

    ultimate 🙂 .. thanks buddy..

  • Gopinath Jay

    Thanks for your guide and i have one dout

    How to create the repository for the cvs in ubuntu let me

    I am waiting for the reply

  • Indrakesh

    hi all,
    how connect cvs server in ubuntu to client in window7

  • Me

    TortoiseSVN

  • ck

    Hi. Thank you very much. Based on this I managed to get the cvs running on the server side. But i fail to get TortoiseCVS to connect. I try as tortoise URL svn+ssh://[myserverip]/var/source. it prompts for user and password, but then simply doesnt allow connection. Any idea?