James Gardner


Mercurial Bundle Compression Error on Debian

Posted in Debian, Mercurial by thejimmyg on the August 26th, 2008

If you get this error when pushing to a repository:

hg push
pushing to https://mercuriate.3aims.com/project/...
http authorization required
realm: Dev Repo
user: xxx
password:
searching for changes
unknown bundle compression type

It is because you need to upgrade to mercurial 1.0 in backports:

$ wget http://www.backports.org/debian/pool/main/m/mercurial/mercurial-common_1.0.1-2~bpo40+1_all.deb
$ wget http://www.backports.org/debian/pool/main/m/mercurial/mercurial_1.0.1-2~bpo40+1_amd64.deb
$ dpkg -i mercurial-common_1.0.1-2~bpo40+1_all.deb mercurial_1.0.1-2~bpo40+1_amd64.deb

Building Firefox 3 on Mac OS X

Posted in Web, Software Releases, Mercurial by thejimmyg on the August 24th, 2008

First of all read the main build page at http://developer.mozilla.org/en/Mac_OS_X_Build_Prerequisites

I already have the following installed:

Getting Started

Download and install MacPorts 1.6.0 for your platform from http://www.macports.org/install.php

Install packages needed for grabbing and building Firefox:

$ sudo /opt/local/bin/port sync
$ sudo /opt/local/bin/port install mercurial libidl autoconf213

The second stage takes a long time because it builds lots of dependencies. It will stop three times while handling Python. Just keep running the command until everything works. Here’s the output I received:

james-gardners-macbook-air:~ james$ sudo /opt/local/bin/port sync
james-gardners-macbook-air:~ james$ sudo /opt/local/bin/port install mercurial libidl autoconf213
--->  Fetching bzip2
--->  Attempting to fetch bzip2-1.0.5.tar.gz from http://www.bzip.org/1.0.5/
--->  Verifying checksum(s) for bzip2
--->  Extracting bzip2
--->  Applying patches to bzip2
--->  Configuring bzip2
--->  Building bzip2 with target all
--->  Staging bzip2 into destroot
--->  Installing bzip2 1.0.5_1
--->  Activating bzip2 1.0.5_1
--->  Cleaning bzip2
--->  Fetching expat
--->  Attempting to fetch expat-2.0.1.tar.gz from http://downloads.sourceforge.net/expat
--->  Verifying checksum(s) for expat
--->  Extracting expat
--->  Configuring expat
--->  Building expat with target all
--->  Staging expat into destroot
--->  Installing expat 2.0.1_0
--->  Activating expat 2.0.1_0
--->  Cleaning expat
--->  Fetching gperf
--->  Attempting to fetch gperf-3.0.3.tar.gz from http://ftp.gnu.org/gnu/gperf
--->  Verifying checksum(s) for gperf
--->  Extracting gperf
--->  Configuring gperf
--->  Building gperf with target all
--->  Staging gperf into destroot
--->  Installing gperf 3.0.3_0
--->  Activating gperf 3.0.3_0
--->  Cleaning gperf
--->  Fetching libiconv
--->  Attempting to fetch libiconv-1.12.tar.gz from http://ftp.gnu.org/gnu/libiconv
--->  Verifying checksum(s) for libiconv
--->  Extracting libiconv
--->  Applying patches to libiconv
--->  Configuring libiconv
--->  Building libiconv with target all
--->  Staging libiconv into destroot
--->  Installing libiconv 1.12_0
--->  Activating libiconv 1.12_0
--->  Cleaning libiconv
--->  Fetching ncursesw
--->  Attempting to fetch ncurses-5.6.tar.gz from http://ftp.gnu.org/gnu/ncurses
--->  Verifying checksum(s) for ncursesw
--->  Extracting ncursesw
--->  Applying patches to ncursesw
--->  Configuring ncursesw
--->  Building ncursesw with target all
--->  Staging ncursesw into destroot
--->  Installing ncursesw 5.6_1
--->  Activating ncursesw 5.6_1
--->  Cleaning ncursesw
--->  Fetching ncurses
--->  Verifying checksum(s) for ncurses
--->  Extracting ncurses
--->  Applying patches to ncurses
--->  Configuring ncurses
--->  Building ncurses with target all
--->  Staging ncurses into destroot
--->  Installing ncurses 5.6_0
--->  Activating ncurses 5.6_0
--->  Cleaning ncurses
--->  Fetching gettext
--->  Attempting to fetch gettext-0.17.tar.gz from http://ftp.gnu.org/gnu/gettext
--->  Verifying checksum(s) for gettext
--->  Extracting gettext
--->  Applying patches to gettext
--->  Configuring gettext
--->  Building gettext with target all
--->  Staging gettext into destroot
--->  Installing gettext 0.17_3
--->  Activating gettext 0.17_3
--->  Cleaning gettext
--->  Fetching python25
--->  Attempting to fetch Python-2.5.2.tgz from http://www.python.org//ftp/python/2.5.2/
--->  Verifying checksum(s) for python25
--->  Extracting python25
--->  Applying patches to python25
--->  Configuring python25
--->  Building python25 with target all libpython2.5.dylib
--->  Staging python25 into destroot
--->  Installing python25 2.5.2_5+darwin_9
--->  Activating python25 2.5.2_5+darwin_9

To fully complete your installation and make python 2.5 the default, please run

    sudo port install python_select
    sudo python_select python25

--->  Cleaning python25
--->  Fetching py25-bz2
--->  Attempting to fetch Python-2.5.2.tar.bz2 from http://www.python.org/ftp/python/2.5.2/
--->  Verifying checksum(s) for py25-bz2
--->  Extracting py25-bz2
--->  Configuring py25-bz2
--->  Building py25-bz2 with target build
Error: Target org.macports.build returned: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py25-bz2/work/Python-2.5.2/Modules" && /opt/local/bin/python2.5 setup.py build " returned error 1
Command output: running build
running build_ext
building 'bz2' extension
creating build
creating build/temp.macosx-10.3-i386-2.5
-DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/include/ -I/opt/local/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c bz2module.c -o build/temp.macosx-10.3-i386-2.5/bz2module.o
unable to execute -DNDEBUG: No such file or directory
error: command '-DNDEBUG' failed with exit status 1

Error: The following dependencies failed to build: py25-bz2 py25-hashlib openssl zlib py25-zlib
Error: Status 1 encountered during processing.
james-gardners-macbook-air:~ james$ sudo /opt/local/bin/port install mercurial libidl autoconf213
Password:
--->  Building py25-bz2 with target build
--->  Staging py25-bz2 into destroot
--->  Installing py25-bz2 2.5.2_0
--->  Activating py25-bz2 2.5.2_0
--->  Cleaning py25-bz2
--->  Fetching zlib
--->  Attempting to fetch zlib-1.2.3.tar.bz2 from http://www.zlib.net/
--->  Attempting to fetch zlib-1.2.3.tar.bz2 from http://www.gzip.org/zlib/
--->  Verifying checksum(s) for zlib
--->  Extracting zlib
--->  Applying patches to zlib
--->  Configuring zlib
--->  Building zlib with target all
--->  Staging zlib into destroot
--->  Installing zlib 1.2.3_1
--->  Activating zlib 1.2.3_1
--->  Cleaning zlib
--->  Fetching openssl
--->  Attempting to fetch openssl-0.9.8h.tar.gz from http://www.openssl.org/source/
--->  Verifying checksum(s) for openssl
--->  Extracting openssl
--->  Applying patches to openssl
--->  Configuring openssl
--->  Building openssl with target all
--->  Staging openssl into destroot
--->  Installing openssl 0.9.8h_0
--->  Activating openssl 0.9.8h_0
--->  Cleaning openssl
--->  Fetching py25-hashlib
--->  Verifying checksum(s) for py25-hashlib
--->  Extracting py25-hashlib
--->  Configuring py25-hashlib
--->  Building py25-hashlib with target build
Error: Target org.macports.build returned: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_python_py25-hashlib/work/Python-2.5.2/Modules" && /opt/local/bin/python2.5 setup.py build " returned error 1
Command output: running build
running build_ext
building '_hashlib' extension
creating build
creating build/temp.macosx-10.3-i386-2.5
-DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c _hashopenssl.c -o build/temp.macosx-10.3-i386-2.5/_hashopenssl.o
unable to execute -DNDEBUG: No such file or directory
error: command '-DNDEBUG' failed with exit status 1

Error: The following dependencies failed to build: py25-hashlib py25-zlib
Error: Status 1 encountered during processing.
james-gardners-macbook-air:~ james$ sudo /opt/local/bin/port install mercurial libidl autoconf213
Password:
--->  Building py25-hashlib with target build
--->  Staging py25-hashlib into destroot
--->  Installing py25-hashlib 2.5.2_0
--->  Activating py25-hashlib 2.5.2_0
--->  Cleaning py25-hashlib
--->  Fetching py25-zlib
--->  Verifying checksum(s) for py25-zlib
--->  Extracting py25-zlib
--->  Configuring py25-zlib
--->  Building py25-zlib with target build
--->  Staging py25-zlib into destroot
--->  Installing py25-zlib 2.5.2_0
--->  Activating py25-zlib 2.5.2_0
--->  Cleaning py25-zlib
--->  Fetching mercurial
--->  Attempting to fetch mercurial-1.0.1.tar.gz from http://www.selenic.com/mercurial/release/
--->  Verifying checksum(s) for mercurial
--->  Extracting mercurial
--->  Configuring mercurial
--->  Building mercurial with target build
--->  Staging mercurial into destroot
--->  Installing mercurial 1.0.1_1
--->  Activating mercurial 1.0.1_1
--->  Cleaning mercurial
--->  Fetching pkgconfig
--->  Attempting to fetch pkg-config-0.23.tar.gz from http://pkg-config.freedesktop.org/releases/
--->  Verifying checksum(s) for pkgconfig
--->  Extracting pkgconfig
--->  Configuring pkgconfig
--->  Building pkgconfig with target all
--->  Staging pkgconfig into destroot
--->  Installing pkgconfig 0.23_0
--->  Activating pkgconfig 0.23_0
--->  Cleaning pkgconfig
--->  Fetching glib2
--->  Attempting to fetch glib-2.16.5.tar.bz2 from http://mandril.creatis.insa-lyon.fr/linux/gnome.org/sources/glib/2.16/
--->  Verifying checksum(s) for glib2
--->  Extracting glib2
--->  Applying patches to glib2
--->  Configuring glib2
--->  Building glib2 with target all
--->  Staging glib2 into destroot
--->  Installing glib2 2.16.5_0+darwin_9
--->  Activating glib2 2.16.5_0+darwin_9
--->  Cleaning glib2
--->  Fetching libidl
--->  Attempting to fetch libIDL-0.8.10.tar.bz2 from http://mandril.creatis.insa-lyon.fr/linux/gnome.org/sources/libIDL/0.8/
--->  Verifying checksum(s) for libidl
--->  Extracting libidl
--->  Applying patches to libidl
--->  Configuring libidl
--->  Building libidl with target all
--->  Staging libidl into destroot
--->  Installing libidl 0.8.10_0
--->  Activating libidl 0.8.10_0
--->  Cleaning libidl
--->  Fetching autoconf213
--->  Attempting to fetch autoconf-2.13.tar.gz from http://ftp.gnu.org/gnu/autoconf
--->  Verifying checksum(s) for autoconf213
--->  Extracting autoconf213
--->  Configuring autoconf213
--->  Building autoconf213 with target all
--->  Staging autoconf213 into destroot
--->  Installing autoconf213 2.13_0
--->  Activating autoconf213 2.13_0
--->  Cleaning autoconf213

Now get the Firefox source code using Mercurial:

hg clone http://hg.mozilla.org/mozilla-central

To build it you will need to modify your path to include the MacPorts software:

export PATH=$PATH:/opt/local/bin

Now you can start the build:

cd mozilla-central
make -f client.mk build

This command will run for hours but when it is finished you will have a Firefox build.

Run the build in a terminal like this (you have to close any existing Friefox browsers though):

./obj-ff/dist/bin/firefox-bin

Run the debug build by clicking on the MinefieldDebug icon in the same directory.

And here it is running:

Minefield

Mercurial Hosting using hg-admin-tools over SSH

Posted in Hosting, Mercurial by thejimmyg on the May 19th, 2008

In this article we’ll set up mercurial hosting over SSH. This is very similar to the Subversion setup described earlier but we’ll also make use of LShift’s hg-admin-tools to automate some parts of the set up.

I’ve got to say I don’t really understand the ssh-agent instructions from the README so this is my best stab. If it is wrong please let me know. There are some instructions here http://kb.iu.edu/data/aeww.html

First install mercurial, set up a new user and ensure you have Python 2.5:

apt-get install python2.5 python2.5-dev mercurial
adduser hgadmin

Then give the hgadmin user sudo priviledges with visudo before becoming hgadmin and moving to the home directory:

visudo
su hgadmin
cd

Create a .ssh directory:

mkdir ~/.ssh

You’ll also need an updated version of mercurial otherwise an import fails later on:

wget http://www.backports.org/debian/pool/main/m/mercurial/mercurial_0.9.5-2~bpo40+1_amd64.deb
sudo dkpg -i mercurial_0.9.5-2~bpo40+1_amd64.deb

At this point you need to have ssh-agent running and set up. Create a new key pair and copy the public key to the server like this:

james-gardners-macbook-air:~ james$ ssh-keygen -t dsa -f ~/.ssh/id_dsa -C "james@macbook.3aims.com"
Generating public/private dsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/james/.ssh/id_dsa.
Your public key has been saved in /Users/james/.ssh/id_dsa.pub.
The key fingerprint is:
46:1e:48:06:b4:cd:ff:c7:e0:2e:db:77:59:5e:d0:0d james@macbook.3aims.com

james-gardners-macbook-air:~ james$ scp ~/.ssh/id_dsa.pub hgadmin@78.47.146.254:.ssh/authorized_keys
hgadmin@78.47.146.254's password:

james-gardners-macbook-air:~ james$ scp ~/.ssh/id_dsa hgadmin@78.47.146.254:.ssh/
hgadmin@78.47.146.254's password:

Now you should be able to login as hgadmin using the password you set on your private key:

ssh hgadmin@78.47.146.254

Set up ssh-agent (I don’t know why we are doing this bit really but the install fails without it:

exec `ssh-agent`
ssh-add

This will add the .ssh/id_dsa key to ssh-agent so that in the next step when we run install, it will be added correctly when the command ssh-add -L is called:

We need to get the hg-admin-tools:

mkdir ~/lib
cd ~/lib
hg clone http://hg.opensource.lshift.net/hg-admin-tools

Make sure there isn’t already an hg user then run this:

cd hg-admin-tools
./install

This creates a new user called hg without password signins and runs hginit to setup the hgadmin repository.

Changing Permissions

Now that the software is installed you need to know how to administer it. Back on the machine you signed in from (in my case the Macbook) you can checkout the hgadmin repository:

hg clone http://hg@78.47.146.254/hgadmin

This works because the same key you used for password-less signin to the hgadmin account has been setup by the hginit script to allow you to signin with the same key to the hg user account.

Creating New Repositories

Users authorized to do so (such as yourself) can create new repositories like this:

mkdir new-repository
cd new-repository
hg init
hg clone . ssh://hg@78.47.146.254/my-project-name

You can then do things like this:

hg add *
hg commit -m "Adding initial files"
hg push ssh://hg@78.47.146.254/my-project-name

Then you can check out the changes somewhere else:

hg clone  ssh://hg@78.47.146.254/my-project-name new-copy-of-my-new-project

or update another checkout with the new changes:

hg pull
hg update

Each operation involving the server will prompt you for the password for your private key.

Back to the README

At this point you should be able to follow the README again. Particularly the HG-SSH-ACCESS.CONF section. It explains how you can add keys for new developers to the keys directory and configure permissions by changing the hg-ssh-access.conf. hen you check in changes some hooks are run to update the .ssh/authorized_keys file on the server to work with the new permissions.

Web Interface

Now let’s set up a web interface for the hosting. You can use hg serve to provide a web interface to a particular repository. For example to serve the new-project-name repository you would do this:

cd /home/hg/repos/new-project-name
hg serve

This would start a server on http://localhost:8000 to serve the repository. You can also customise the styles. An easier style to use is gitweb:

hg serve --style gitweb

You can create your own styles by copying and modifying an existing template:

sudo cp -r /var/lib/python-support/python2.4/mercurial/templates/gitweb/ /var/lib/python-support/python2.4/mercurial/templates/james
hg serve --style james

There’s documentation on how to do this at http://hgbook.red-bean.com/hgbookch11.html