Saturday, January 06, 2007

Virtual PC's, Linux & Subversion

Back in September I concluded that I would need to develop the client and server code to run on both Linux and Windows platforms. I dusted off an old PC, installed Fedora on it and then pretty much did nothing for 3 months.

The problem is that I only have one monitor and I can't afford to buy a new one. To build the source on the Linux machine it needs to connect to the Windows machine so I need both up and running at the same time so I really need two monitors.

Well Santa didn't bring me a monitor for Christmas so I am still in the same situation now. However, last month at work I encountered a similar problem. For work I am developing a server called a MOS server which needs to talk to something called an NCS server. Because they are both servers they both need to listen on the same ports and you cannot have two programs listening on the same ports on one computer. So I told my boss that I needed a second PC :-)

One of my clever colleagues suggested I try out Microsoft Virtual PC which is now free. I had never heard of it before but now that I've tried it I love it! Basically it allows you to run a computer within a computer. So, I setup a virtual installation of Windows XP and ran my NCS server on it. Then on my main machine I can run and debug my MOS server which is connecting to the NCS server in my virtual PC. They both have independent IP addresses so it all works fabulously.

The reason for all this waffle is that Virtual PC allows you to install any operating system you like. Well pretty much anyway. Here's a website that lists all the OS' that work. So my cunning mind figured that I could use this solution at home to build a virtual Linux machine. After much faffing and fiddling it all works!

Here's a rundown of exactly what I did to get this setup working:

1) Downloaded and installed Microsoft Virtual PC 2004 from here.

2) Downloaded the ISO images of the Fedora Core 6 distribution from here. Note that a DVD image is also available and I downloaded that at first but Virtual PC works from CD images only! Oh, and this link is to the torrent files - Bit Torrent is GOOD, google it if you dont know what it is!

3) Created a new Virtual PC. Follow the prompts, select 'new hard disk' and then click 'Start'. You will get a message about having the wrong disk but that is because the hard disk does not have an operating system installed on it yet. That is step 4...

4) I dragged the ISO file for CD 1 of the fedora installation to the little disk icon in the bottom left of the Virtual PC window and then hit the enter key. This started the installation process.

5) Now I had some problems with the graphical version of this so I opted to install the text version instead by typing 'linux text' at the prompt. Click here for a nice guide. To fix my graphics problem I followed the instructions in this guide.

6) Once installed you'll get the login prompt so you need to login as root with whatever password you selected at installation. Here I stayed stumped for hours - how on earth do you get the nice graphical desktop when you've used the text based installer? You type 'init 5' at the prompt. Simple huh?!

7) I forgot to install a subversion client at the time so I simply downloaded one from the internet using the browser. I chose RapinSVN.

8) Now the tricky bit - setting up the Windows subversion repository to use Apache. Or is that the other way around? Guides, guides, guides. Here's the one that I initially used for this. However, I still encountered problems. Firstly, I had no clue what to use as my server name when installing Apache. I googled around and first tried using localhost and this worked but of course I couldn't access it from Linux. I had to fiddle with the httpd.conf to get something working.

I found out that you can use your IP address so here is what I had to change:

Listen 192.168.0.2:80
ServerName 192.168.0.2:8080

Note that you must not have comments on the same line as other text. The guide shown above had comments and that gave my syntax errors which took me ages to figure out.

9) I started apache and nagivated to http://192.168.0.2/svn/using Firefox. This gave me a list of repositories. Note that I also had to do all the authorisation stuff mentioned in the guide linked in step 8.

There was also something else I misunderstood from that guide. When I first installed Subversion I just created my repository on the root of one of my drives but the SVNParentPath variable is to specify a parent for the ROOT of all repositories and it did not like me having just a drive letter so I created a root and some test repositories in there and that worked. I'll have to migrate my projects over later...

10) Now back on the Linux box, I was able to do exactly the same thing. I could load up my browser, type in the url from step 9 and I got my repository list. For RapidSVN, from the 'bookmarks' thing I right clicked and selected 'add existing repository' adding in the above URL but I had to extend it to include the actual name of a repo, and not just the root.

Viola! This worked! Here is a screenshot of the results of the above steps running in my virtual PC:


So, now that I've got that sorted I have no more excuses and I can get started!

3 comments:

Jon Skeet said...

Any particular reason for needing Apache and Subversion integration? I've never bothered with the http/https SVN protocols (or WebDAV and the like) - I just run svnserve as a service under Windows (see the Subversion installation notes) and use svn://... from other boxes.

Admittedly that makes it harder to get through firewalls - maybe that was the reason?

On Subversion clients - the one client I'd say everyone ought to install is the command line one. GUIs are great for many things, but it can sometimes be tricky to know exactly what they're going to do when it comes to merging, branching etc - I always prefer to do that kind of thing from the command line.

Caroline Middlebrook said...

Hi Jon,

I originally tried svnserve when I first setup the repository and I couldn't get it to work so I just used the file// protocol to access it locally.

I happened to stumble across a tutorial for setting up svn with apache so thought I'd try it and just didn't bother trying out svnserve again.

The command line interface is there, I used that to create the initial repositories and move stuff around betweem them.

Emma Middlebrook said...

Hi Caroline,

I've got svnservice running as a windows service. It comes with a readme.txt that tells you exactly what to do to get it to appear in your windows services area and then you can just set it up to start automatically after you boot your pc. I can show you if you like?

Emma