The Hitchhiker’s Guide to an Ioke Dev Env From Source (part 1: Git)

In this series of posts I will guide you, the humble reader, through the install procedure to get a development environment for Ioke up and running. All the cool kids want to develop in Ioke nowadays, so let’s make you can as well!

The components we will be installing are:

These instructions are written for a non-expert who might not have too much experience with compiling things, using Git or Emacs. If you’re an expert you will find nothing new or exciting here! The environment I use is a freshly installed Kubuntu Intrepid Ibex box, although most of it should be similar, if not identical, to other Ubuntu/Debian based distributions.

The components listed above will all be installed manually – not using the package system. This is to allow us to get the freshest versions of what we need without depending on the packages in the distribution to be updated (or hunted down in alternative repositories). The only thing we will install from the distribution are the compilers, tools and development libraries used to compile the software.

Why do we not use the package system? Well, that’s a valid question. Most of the above can be installed from packages in custom repositories. It’s simple and convenient. However here we will not use if for two reasons:

  1. If packages are used we will depend on the repositories to be updated to use the latest version of some software, which can be annoying if we want to develop on the bleeding edge.
  2. It’s good to know how to compile things yourself – so by not using prepared packages we might learn something!

To keep control over our custom built software we’ll install it in dedicated directories under $HOME/opt instead of in the normal locations like /usr/bin. This allows us to get everything installed without needing root access (except to install the compilers etc from the distribution).

First Step

Don’t Panic!

Always sound advice to start with – especially if you are hitchhiking. I’m going to try to cover each step in detail, but if you think something is unclear – just leave a comment and I’ll try to clarify. So – grab your towel and let’s get going!

Install Git

For Emacs, emacs-starter-kit and Ioke we will use Git to retrieve the sources. Therefore the first thing we need to install is Git.

In the command line instructions below, all lines prefixed by the prompt <dir>$ are commands to be typed in. The rest are output or my comments.

Open a terminal window and create a new work directory under your home using the following instructions. In this directory we will work with downloaded source files and build the software.

~$ mkdir ~/work
~/work$ cd ~/work
~/work$ wget -O - http://kernel.org/pub/software/scm/git/git-1.6.1.tar.bz2 | tar xjv
... many lines...

The last command downloads the git source package and expands it in one go by piping it directly from wget to tar, which is told to expand it using bz2 with the j parameter. This is a convenient way to get packages off the net and unpacked, especially when there is no need to keep the package itself around.

The result is that we now have a git-1.6.1 directory in the work directory. Let’s see how we compile it:

~/work$ cd git-1.6.1/
~/work/git-1.6.1$ head INSTALL
 
                Git installation
 
Normally you can just do "make" followed by "make install", and that
will install the git programs in your own ~/bin/ directory.  If you want
to do a global install, you can do
 
        $ make prefix=/usr all doc info ;# as yourself
        # make prefix=/usr install install-doc install-html install-info ;# as root
 
~/work/git-1.6.1$

So – two commands. Simple enough! However, before we compile – we need to make sure all the relevant packages are installed:

~/work/git-1.6.1$ sudo apt-get install libcurl4-openssl-dev zlib1g-dev libexpat-dev tk8.5 asciidoc docbook2x

Depending on your internet connection, this could take quite a while, as we need to download the texlive distribution, among other things, to build all of the Git documentation. This is not strictly necessary, but here we’ll just do it for completeness’ sake.

Let’s build git and make sure it’s installed under our $HOME/opt directory as we said in the beginning:

~/work/git-1.6.1$ make prefix=~/opt/git-1.6.1 all doc info
... lots of lines...

Compiling Git will take some time as well. Go get a coffee (or perhaps a Pan Galactic Gargle Blaster – sweet like nectar).

Once the compile is done – install it. Note that we don’t need to do this as root as we’re installing under the user home directory:

~/work/git-1.6.1$ make prefix=~/opt/git-1.6.1 install install-doc install-html install-info

Let’s add it to the user’s path by linking it into the private bin directory. This depends on the standard Ubuntu bash shell profile script which adds ~/bin to the PATH variable. If a different shell is used you need to perform the appropriate steps yourself.

~/work/git-1.6.1$ mkdir ~/bin
~/work/git-1.6.1$ cd !$
~/bin$ ln -s ../opt/git-1.6.1/bin/git

Now close the shell/terminal, open a new one – and try the git command:

~$ git --version
git version 1.6.1

If you get the above output – great! You’re don! Sit back and relax for a bit before moving on to the next section.

However, if you don’t get the version output, but instead see the following message, review the previous instructions and make sure it works ok before continuing.

#INCORRECT OUTPUT - SOMETHING WAS MISSED!
#GO BACK AND REVIEW
~$ git                                                                                                                                                                                        
The program 'git' is currently not installed.  You can install it by typing:                                                                                                                  
sudo apt-get install git-core                                                                                                                                                                 
-bash: git: command not found

If you still can’t get it to work – drop me a comment!

Git in 30 Seconds

There are loads of good Git tutorials and information. You can find several on the official Git page and at GitHub (go sign up if you haven’t already, and fork me!).

Here is a quick run through of a few common Git commands you could try out with your freshly brewed cup of Git:

~$ cd
~$ mkdir gittest
~$ cd gittest/
~/gittest$ git init
Initialized empty Git repository in /home/melwin/gittest/.git/
~/gittest$ echo Test file! > test.txt
~/gittest$ git add test.txt
~/gittest$ git commit -m "Initial import."
[master (root-commit)]: created 79c091d: "Initial import."
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 test.txt
~/gittest$ echo Add line. >> test.txt
~/gittest$ git diff test.txt
diff --git a/test.txt b/test.txt
index 1cbaf90..3746f9e 100644
--- a/test.txt
+++ b/test.txt
@@ -1 +1,2 @@
 Test file!
+Add line.
~/gittest$ git commit -a -m "Add new line."
[master]: created b20f9a4: "Add new line."
 1 files changed, 1 insertions(+), 0 deletions(-)

If you can follow the above – great! First part finished. Next up is to install GNU Emacs from source and the emacs-starter-kit, which provides a decent default a set of configuration for Emacs.

Stay tuned!

/M

Update: Part 2: Emacs

7 Comments

  1. Guide to Ioke development environment | Ola Bini: Programming Language Synchronicity:

    [...] Wonderful! Martin Elwin posted the first part of a series on setting up an Ioke development environment. It’s fantastic to see people blog about Ioke, and Martin wrote some other pieces too. Especially the JSON parser is cool. You can see the development environment post here. [...]

  2. Martin:

    Awesome! I’ve been having a look at Ioke lately (really like it!) and wanted to set up a development environment for Ubuntu. I have to admit that my Linux skills are pretty much non-existent so I failed miserably so far. So thanks a lot and can’t wait for part 2… want to get started finally ;)

    Martin

  3. Martin:

    Glad to be of service. The next part, covering Emacs install, is almost ready…!

    Kindly,

    /Also Martin

  4. slavof:

    Hi!

    Great write up. Thank you very much for this. I am a little new to linux and git, so I have a question.

    I tried your steps, everything went ok (I assume that C-compiler warning about various file handling related functions like “ignoring return value of ‘ftruncate’, declared with attribute warn_unused_result” are ok), but install step (”sudo make prefix=/usr install install-doc install-html install-info”) ends with:

    ===
    if test -r /usr/share/info/dir; then \
    install-info –info-dir=/usr/share/info git.info ;\
    install-info –info-dir=/usr/share/info gitman.info ;\
    else \
    echo “No directory found in /usr/share/info” >&2 ; \
    fi

    No `START-INFO-DIR-ENTRY’ and no `This file documents’.
    install-info(git.info): unable to determine description for `dir’ entry – giving up

    No `START-INFO-DIR-ENTRY’ and no `This file documents’.
    install-info(gitman.info): unable to determine description for `dir’ entry – giving up
    make[1]: *** [install-info] Error 1
    make[1]: Leaving directory `/home/slavof/gitcore/git-1.6.1/Documentation’
    make: *** [install-info] Error 2

    ===

    after this it looks like that git 1.6. works normally.

    Is everything ok? Do you know what caused error described above?

    I tried this on fresh installation of Ubuntu 8.10.

    thanks is advance,
    Slavo.

  5. Martin:

    Oops! A small mistake there. The command you should run to install Git should be:

    make prefix=~/opt/git-1.6.1 install install-doc install-html install-info

    Not “sudo make prefix=/usr install install-doc install-html install-info”.

    The “make” and “make install” must use the same prefix, otherwise some of the Git commands will get confused, since they won’t be able to find themselves or necessary data.

    Hope that helps.

    Kindly,

    /M

  6. slavof:

    Thanks, Martin!

    OK. That works fine!

    I am looking forward to next part.

    btw, I don’t know if it a good idea, but it would be very nice to have also “remove” script/procedure, that clean things up from HOME dir and from other places where we put something that we install manually (i.e. not by apt-get/aptitude).

    thanks again,
    Slavo.

  7. Martin:

    The good thing with installing into ~/opt/ in dedicated directories for each piece of software is that we can just delete the complete directory from there – no need to do anything else as the normal environment isn’t affected.

    For instance, to remove Git, just do:

    $ rm -rf ~/opt/git-1.6.1 ~/bin/git

    And if you also want to remove the source we used:

    $ rm -rf ~/work/git-1.6.1

    That’s it!

    Kindly,

    /M

Leave a comment