1

I have two computers: one's online and fully updated, the other's offline. I want to download specific .deb files to deploy them on offline computers manually. For instance I want to install libapache2-mod-php5.

The problem is that on the online computer, all dependencies are already installed and are not picked up by the reinstall switch. build-essential is particularly problematic in that regard because it is essentially a metapackage.

On the online:

root@online:~/temp# apt-get install libapache2-mod-php5 --reinstall --yes -s
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Inst libapache2-mod-php5 [5.4.15-1~lucid+1] (5.4.15-1~lucid+1 PPA for PHP5:10.04/lucid)
Conf libapache2-mod-php5 (5.4.15-1~lucid+1 PPA for PHP5:10.04/lucid)

On the offline (which I made online for argument's sake)

root@offline:~# apt-get --print-uris install libapache2-mod-php5 --reinstall --yes -s
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap php5-common
Suggested packages:
  apache2-doc apache2-suexec apache2-suexec-custom php-pear php5-suhosin
The following NEW packages will be installed:
  apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap php5-common
0 upgraded, 10 newly installed, 0 to remove and 96 not upgraded.
Inst libapr1 (1.3.8-1ubuntu0.3 Ubuntu:10.04/lucid-updates)
Inst libaprutil1 (1.3.9+dfsg-3ubuntu0.10.04.1 Ubuntu:10.04/lucid-updates)
Inst libaprutil1-dbd-sqlite3 (1.3.9+dfsg-3ubuntu0.10.04.1 Ubuntu:10.04/lucid-updates)
Inst libaprutil1-ldap (1.3.9+dfsg-3ubuntu0.10.04.1 Ubuntu:10.04/lucid-updates)
Inst apache2.2-bin (2.2.14-5ubuntu8.10 Ubuntu:10.04/lucid-updates)
Inst apache2-utils (2.2.14-5ubuntu8.10 Ubuntu:10.04/lucid-updates)
Inst apache2.2-common (2.2.14-5ubuntu8.10 Ubuntu:10.04/lucid-updates)
Inst apache2-mpm-prefork (2.2.14-5ubuntu8.10 Ubuntu:10.04/lucid-updates)
Inst php5-common (5.3.2-1ubuntu4.19 Ubuntu:10.04/lucid-updates)
Inst libapache2-mod-php5 (5.3.2-1ubuntu4.19 Ubuntu:10.04/lucid-updates)
Conf libapr1 (1.3.8-1ubuntu0.3 Ubuntu:10.04/lucid-updates)
Conf libaprutil1 (1.3.9+dfsg-3ubuntu0.10.04.1 Ubuntu:10.04/lucid-updates)
Conf libaprutil1-dbd-sqlite3 (1.3.9+dfsg-3ubuntu0.10.04.1 Ubuntu:10.04/lucid-updates)
Conf libaprutil1-ldap (1.3.9+dfsg-3ubuntu0.10.04.1 Ubuntu:10.04/lucid-updates)
Conf apache2.2-bin (2.2.14-5ubuntu8.10 Ubuntu:10.04/lucid-updates)
Conf apache2-utils (2.2.14-5ubuntu8.10 Ubuntu:10.04/lucid-updates)
Conf apache2.2-common (2.2.14-5ubuntu8.10 Ubuntu:10.04/lucid-updates)
Conf apache2-mpm-prefork (2.2.14-5ubuntu8.10 Ubuntu:10.04/lucid-updates)
Conf php5-common (5.3.2-1ubuntu4.19 Ubuntu:10.04/lucid-updates)
Conf libapache2-mod-php5 (5.3.2-1ubuntu4.19 Ubuntu:10.04/lucid-updates)

I would like to be able to download all these deb files on the online computer without having to specify them one-by-one.

1 Answer 1

1

There's a gift waiting for you in /var/cache/apt/archives on the online computer - more specifically, a copy of every package it has downloaded (unless you cleared them out). You can grab them without having to download them.

It might be a bit trickier to build a full dependency graph to know which ones specifically you need, but nothing is stopping you from putting all of them on a harddrive and moving them around to the offline computers.

This post details how to create a Packages.gz for the folder of .deb files such that you can add the path to your /etc/apt/sources.list on each machine and install packages from it:

  1. Copy all the .debs to your flash drive or USB drive. We'll use /media/flash_drive as an example path.
  2. Run dpkg-scanpackages /media/flash_drive file | gzip > /media/flash-drive/Packages.gz
  3. On each offline computer, add deb file:/media/flash_drive to the /etc/apt/sources.list
  4. Connect and mount flash drive, and then use apt-update to load the list of packages.

In the future, repeat steps 1, 2, and 4 to add / update packages. If you can mount a file share over the network between the offline computers, then you can use that path instead of a flash drive to distribute the .debs! Many large companies with lots of linux machines will create these repository mirrors to reduce bandwidth.

6
  • (unless you cleared them out): what if I did?
    – Jeff
    May 16, 2013 at 17:51
  • Well, are the offline computers completely disconnected, or can they communitate to a linux box which is online? If they can communicate over the network to another linux box which is online, you can install something like apt-mirror to serve as a proxy on the online box. Otherwise... bring one of the offline boxes online, install everything, and then copy the packages. May 16, 2013 at 17:56
  • No, it's a hypothetical situation. I really want to know why you can't just redownload all dependencies automatically whether or not they're already installed.
    – Jeff
    May 16, 2013 at 18:00
  • Probably because it only downloads what it doesn't have. There's no reason to download something if it's not going to be used. Apt only thinks in terms of the system that it's operating on. Even on your offline system, there are a whole bunch of system packages which aren't listed because they're already installed on the system. There are many hypothetical answers to a hypothetical question, which is why we try to stick to practical, answerable questions based on actual problems that you face. May 16, 2013 at 18:02
  • I understand what you're saying. I'm still stuck, but at least now I know why.
    – Jeff
    May 16, 2013 at 18:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .