Tuesday, June 15, 2010

Using apt-get Offline

As I promised in this post I am going to write how to use apt-get offline. This is based on my experience as a student. After succeeding with apt-get I tried this with yum too and was able to do it in Fedora too. (I am not going to write about that because know I rarely use Fedora).

I used the following in steps in Ubuntu (can be used in any Debian based system) to install software using off line system.

1. Edit /etc/apt/source.lst to enable repositories you need. The following link gives you details on repositories (https://help.ubuntu.com/community/Repositories/Ubuntu). Read this first if you want to know more about repos (you will be offline when doing real stuff.)

2. Create a list of URLs that will download repository meta data. These files contain a list of all software available on the repository and their dependencies.
apt-get -qq --print-uris update | awk '{print $1}' | sed "s/'//g" > download

I will not go on to explain what the command does. But after executing the command the download file will contain a list of urls you need to download.

3. Download these files using a internet enabled machine. (use wget on Windows or Linux, use the url list).

4. Copy the downloaded files into /var/lib/apt/lists/. This will make the offline computer knowledgeable about the contents of the repositories. (These days the files are bzipped to save space and you may need to unzip them)

5. Now generate a list of all dependant files in the offline Linux box using
apt-get install -qq --print-uris < package_to_install> | awk '{print $1}' | sed "s/'//g" > packages

6. Download these files and copy them into /var/cache/apt/archives/

7. Know since all files are there install them.
apt-get install < package_to_install>

You will only need to follow steps 5 through 7 after the initial work is done.

PS: I used this method when I was a University student, where mobile broadband was not so common, expensive (may for a University student). It seems know for most students this is affordable. Yet these steps are useful if you want to speed up a installation by using the cached .deb files.

Wednesday, June 9, 2010

Installing software offline in Linux

Three or four years back as a university student when mobile broadband was not there and Internet connections cost more I started using Linux. The biggest challenge at that time for me was using it offline. Windows users can easily install a program offline just by clicking on the executable. Some Linux distributions have a collection of DVDs that have extra software which will allow at least old versions of some software to be installed offline but not Ubuntu (the version of Linux that I used that time). It seemed like there is no easy solution for installing new programs in Ubuntu offline.
There are several ways in which you can install a program in Linux. The first is to get the source of the program and compile it your self. This is not a practical solution at all for the general user. If you are to compile a usable program you should know what components are there in the program and how to enable them and disable them. For example compiling the Apache Web server requires some knowledge about features and decide whether they should be built or not and if they are to be built in what mode(static or dynamic). Making matters even worse you will need to find dependent libraries and install them before hand. I would not recommend this method. Use it only if you are making changes in sources.
The second method is to use a pre-compiled executables for Linux or generally Unix published by the program developers(as in the case of Sun JDK). The advantage is most of the extra libraries needed are packed in the executable and it will work for you. The downside is not all projects provide such executables and it does not get integrated with the system tightly.
The final method is to use the distributions package management system. Most Linux distributions has adapted such a system like Debian's .deb or Red Hat's .rpm as mechanisms to install new software. Installing a .deb will copy some files into your system and run some initializing script and most importantly store the details of the files added. These packages are structured as small units and they depend on many others. So the actual packages that should be installed to get something working depends on the current system state and can be tedious if installed manually without a tool which automatically does this (such as apt-get or aptitude). When offline these tools fail since they cannot download the necessary files.
In the next post I will write how I did this in Ubuntu.

First Post

Though this is the first post in this blog this is not my first blog post. Prior to this I had a blog and after three or four posts I stopped blogging. I was in doubt whether I could provide any original content with value for others. Anyway now I decided to start fresh again. I think this is a wise decision. It is always better to keep logs by individuals of interesting views and work. As people we all learn from others experience and part of our development is due to this knowledge transfer.

Hope to keep you updated.