Install source code in tar.gz packages in Kubuntu

Posted by Flo in Tricks on January 25th, 2009.
Tags: , , ,

If you’re the administrator of your Kubuntu installation, you probably have to install a program or two. The most popular applications are installable through the adept package manager, but sometimes you’ll need something that’s only distributed in tar.gz source packages. If you’re lucky, there’s a install.sh file in it, otherwise this guide may come in handy…

First things first: there’s not really a 100% standard way to install these source packages, but  in this guide I will discuss the most common way to do it. In other words, there may be a chance that you’ve got a package that needs another way of approach. If that’s the case, and if it’s a good package, it’s stated in the README file. 

This guide is structured in 3 steps, skip the ones you won’t need: In step 1 we’re going to find and extract the file, in step 2 we’re going to find the readme file and in step 3 we’re actually going to install the file using the standard procedure.

Step 1: finding and extracting the tar.gz archive

  1. You probably know where you’ve downloaded the tar.gz file, so let’s use Konsole to get there:  Alt+F2, type "Konsole" and press OK. Since we’re making an installation, it can be useful to open up the root shell. In the upper left corner, go to Session -> "new root-shell" and enter your password after that.
  2. Now browse your way to the folder where you’ve hidden your tar.gz package that contains the source. Use:

    cd path/to/your/folder/foldername/

    Some useful commands that you may need:
    dir                                  // shows the local folder’s contents.
    cd foldername            // opens the foldername folder.
    cd ..                               // you go up one folder (the reverse of cd foldername).

    If the containing folder has a very long name, it may be usefull to use the auto completing function of the shell: your tab key.
    For example: there are two folders in your current map: "lolfolder" and "lolabignamedfolder". You need to browse to the last one. You only need to type:

    cd lola

    then press tab, and you will get the command:

    cd lolabignamedfolder

    without typing everything… it’s a very useful utility, so remember it if you didn’t knew it already…

  3. After you’ve found the right folder use the following command to extract the archive:

    tar xvzf nameofthefile.tar.gz

    Remember that the auto completion function mentioned above can be really helpful here.
     

Step 2: Getting into the extracted folder, and search for the readme file.

  1. Go into the folder and list the content of it using:

    cd nameoftheextractedfile
    dir

  2. You can probably find a README.txt file in it, if so, open it using your favorite editor, in this example I will use nano, since it’s on every kubuntu installation.

    nano README.txt             // please note that the readme file can have e slightly different name.

  3. Read the readme file carefully. If nothing is said about the installation, you can probably follow step 3 of this guide, if there are some statements about the installation, READ them and use those steps to compile this piece of source code. Sometimes it states that you must install in a special folder,  like the "unix" folder that’s in the package. If that’s the case, browse to that folder after exiting your editor using the "cd foldername" command.

    If you’re finished reading, you can exit nano using: "CTRL + X"

Step 3: Basic installation of the source code.

  1. The installation requires you to be in the right folder, it’s usually the extracted folder if no other folder is stated in the readme file.
  2. First run the command:

    ./configure

    This command checks if your system is ready for the installation. You will see lines of text flashing by and if everything is OK, there will be no errors stated at the end. If there are errors, read them carefully. I will state the most given errors: 
    There’s a chance that this application needs uninstalled packages, install those package first and then run this command again.
    Sometimes the ./configure command returns that there’s no folder named that way. If that’s the case, you may be in the wrong folder, or there’s an install.sh file in the folder (see my other guide). If so, you may want to read the readme file again.
    Another popular error is that you may miss a compiler

  3. If the ./configure command succeeds, you need to run the following command:

    make

    This creates installable material… Or so it seems. However, Note that this command fails if the ./configure command failed. It’s usually OK if there’s a lot of text lines coming down and if it returns no errors. It can take a few minutes.

  4. If the make command succeeded, you’re ready to install the package. If you are logged in the root shell, you can use:

    make install

    If you’re in the normal shell, you need to put sudo in front of it, giving:

    sudo make install

    You will need to enter a password after that. If you forget sudo, it will return a permission denied error.

  5. If the installation succeeded, giving no errors, your package is installed. Hooray! You may want to clean up the mess that this method created by using:

    make clean

    But it doesn’t seem really necessary. You’re probably going to remove the extracted folder anyway.

A quick summation of the codes you needed in step 3:

./configure
make
make install
                          // sudo make install if you are not in a root shell

optional:

make clean

I hope this guide was useful, enjoy your newly installed application





One Response to “Install source code in tar.gz packages in Kubuntu”

  1. Jan says:

    What a great guide on a great site!

    Some comments though. First: How to read a readme file. You can print the contents of the readme file by typing:

    cat README

    This way you don’t have to start the resource intensive application nano. Also, you don’t have to close it afterwards, so this way you’ll not only end up needing less computer resources, but also less energy.

    Furthermore, the make clean isn’t really effective. To clean up the mess caused by the compilation of your app, you can delete by following the steps below:

    1) cd into the root of the directory of the source files (eg. “cd /path/to/source/files”)
    2) type “sudo rm -R map/” without the quote. You may need to type in your root password now.
    3) Wait some time. Afterwards reboot your computer to flush your RAM cache. The folder and compilation mess will now be effectively removed.

Leave a Reply

*