Pages

Thursday, October 14, 2010

Setting your own private Mercurial server

update : the steps in this post has been updated for using mercurial 1.7.2

First of all I want to say that this wiki link is amazing, it's complete and robust. But even with the best guide sometime you've made mistakes. Never hurt to have many reference :)

So to simply put it,  this is my steps in implementing that guide. As a background i have an ubuntu server that i will be using as my own private mercurial server. I already have some code that works with google mercurial server. So its a matter switching repositories. And I also already have an apache server running on my server.

Now, Lucid lynx comes with mercurial 1.4. If you want to install Mercurial 1.5, 1.6, or 1.7 you need a new repo :

sudo add-apt-repository ppa:mercurial-ppa/releases
sudo apt-get update
sudo apt-get install mercurial

Don't forget to check the version using
hg -v

The steps

Pre-install

Installing mercurial in ubuntu is as easy as running
$>sudo apt-get install mercurial

Finding the hgweb.cgi file

First we need to find the hgweb.cgi file. Usually it resides in /usr/share/doc/mercurial-common/examples/hgweb.cgi . If you can't find it using locate or executing this command should do it.
$>find / -iname hgweb.cgi

go to the /usr/lib/cgi-bin/ and create hg directory. Copy the hgweb.cgi to /usr/lib/cgi-bin/hg/. Then make it executbale using this command
chmod  755

Creating the user and directories

Create user hguser with www-data as its group. it should have the /home/hguser as its default home. Now login as the hguser, change the .bashrc for hguser. You can use
vi ~/.bashrc

Add this line at the end of the file and save it:

umask 002

With the umask set, the file and directories created by the hguser will have group write permission. So the www-data (default apache user) can create and write any file in the repository. Now create hg directory for our repositories, so now we have /home/hguser/hg for our repositories yay !

for my setup I'm using 2 repositories, one for development and one for release. So under the hg directory, I created 2 other directory,
/home/hguser/hg/dev and
/home/hguser/hg/stable

Now you can logout from the hguser and back to your default user.

Setting the apache server

As I mention already have an apache2 server running. My server 80 is already used by something else, so i'm using another port for apache. Lets say port 9000. To do this you must edit the ports.conf file and make the changes accordingly. You can use this command :

sudo vi /etc/apache2/ports.conf


You also need to change the port on the default apache file to 9000. You can use this command :

sudo vi /etc/apach2/sites-enabled/000-default


still in the 000-default files, activate the cgi script. The easiest way is by using Script Alias, add the lines bellow to the 000-default files:
ScriptAlias /hg /usr/lib/cgi-bin/hg/hgweb.cgi

Setting Mercurial Repositories

To enable mercurial for multiple repository, it is easier to use the hgweb.config file.
First login as the hguser.
Create the hgweb.config under the hg directory

The hgweb.config file should contain :
[collections]
/home/hguser/hg/ = /home/hguser/hg/

edit the hgweb.cgi and update the config line to the line bellow :
config = "/home/hguser/hg/hgweb.config"

Restart the apache server, than you should be able to access http://yourserver/hg directory

Allowing Push

I'm allowing all authenticated user to push to the repository, and since the most important thing is make the repo up and running, I'm making SSL implementation none mandatory. So to allow push you need to edit the /etc/mercurial/hgrc and add the following line below

[web]
allow_push = *
push_ssl = false

Adding Authentication


To add the authentication to your mercurial server you need to add the line bellow to the 000-default file, just under the script alias should suffice.
<location /hg>
                AuthType Basic
                AuthName "Mercurial repositories"
                AuthUserFile /home/hguser/hg/hgusers
                Require valid-user
        </Location>

Now login as the hguser and go to the hg directory. To create the hgusers authentication file and create the first user you can use the comand bellow :
htpasswd -c /home/user/hg/hgusers frodo

to add another user you can remove the -c flag

htpasswd /home/user/hg/hgusers sam

restart apache and you should be able to to access the repo at :

http://www.yourserver.com:9000/hg/


Trouble Shooting

The trouble shooting section in the wiki is very good. I just highlight some here since I've encountered them in my installation. 

If you find the error message bellow in your apache2 error log. 

/var/lib/python-support/python2.6/mercurial/hgweb/common.py:24: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6

you're using and older mercurial that work quite right with the latest python implementation. To suppress it add the following lines to the hgweb.cgi immediately after any sys.path adjustment :

import warnings
warnings.simplefilter("ignore", DeprecationWarning)

And if you're able to create a new repo and synch it to your local komputer but  failing when pushing or cloning your existing repo to the server. Try  changing the hguser/hg directory permission recursively to 777. If that did work than you didn't set your permission correctly.

Good luck

Something ...

Has changed in me ... 

Sunday, October 10, 2010

Loosing home...

Why do the Aquarians travel the universe with its massive fleet
Why do the Kharak's people build a Mothership to travel the stars in a journey to take them Home.
Home...
What is home..

Its not just a place, a thing, people. Its everything that represent who you were.
So if you're planning to loose it, to leave everything behind
With nothing to comeback to,
What does that makes you ?

Never the less, I'm loosing my home ...

One more day ...

One more day, hold on for one more day. The only thing I'm holding on to. What the meaning of living if you cant see the future. What the meaning of passing the day when you feel nothing, no emotion. Just sitting here watching this blank screen. The only window that connect you with some world.

One more day, would i would be able to hold on for one more day ...

Wednesday, October 6, 2010

Kalau...

... semua orang berpegang kepada satu orang untuk selalu kuat. Sementara mereka berkutat dengan problem mereka masing-masing. Bukankah lama kelamaan orang ini akhirnya akan hancur juga ?

Tuesday, October 5, 2010

Enam Purnama Berlalu...

Akhirnya sampai juga ke tahap ini, enam bulan. Bukan waktu yang singkat tapi terasa begitu cepat berlalu.What am I doing ? What are the things that I've done ? ...

Enam bulan yang lalu, setelah membulatkan tekad. Gw membagi proses ini kedalam 2 tahap. Enam bulan pertama, dimana gw bebas melakukan apa saja, bereksperimen, membangun sebuah entity tanpa ada deadline, roadmap, atau role model. Hanya berusaha untuk fleksible dan take what ever live throw at me dalam mewujudkan keinginan gw. Lalu setelah enam bulan berlalu, di evaluasi, apakah ada yang bisa di seriusin, atau hanya sekedar keinginan, impian yang tidak punya pijakan di dunia nyata ?

Kalau memang ada, gunakan enam bulan berikutnya untuk serius, membuat sesuatu, moneytizing and turn it to business. Dan setelah satu tahun, kalau tidak berhasil, gunakan sisa waktu dan sisa tabungan untuk mencari kerja. Get back to the real life. That was the plan...

Sekarang, setelah merasakan, gw gak ingin kembali.Gw ingin berhasil di dunia ini. Kalau jatuh harus bisa bangun lagi. Kalau gagal, sedih , menangis meraung-raung lalu esok, coba lagi ! Buat hal baru, mulai kembali dari awal. Banyak yang bilang, di dunia baru ini, lu belum benar2 teruji sampai sudah merasakan sink to the bottom, not just ordinary bottom, but rock bottom !

So where am I now ? What about my evaluation ? To be honest, I don't know. Evaluation didn't seem to matter as much as before. That's what funny about this world. Today you can feel like a king, and tomorrow some how you just hit rock bottom. Becoming the lowest on the totem pool, so I learn to not carve  anything in stone.

I guess I'm kinda satisfied with where I am now. Don't have any money though. I'll be ecstatic if my position is a bit better economically, but this will suffice. So, what tomorrow will bring me ? I hope something nice. Tonight, I can only dream :)

Sleep Tight :)