Ubuntu: Install software with its dependencies from a local repo over LAN [duplicate]


This question already has an answer here:

I have a couple of Ubuntu 14.04 64 bit boxes. One of them can talk to internet (say Machine1) and the other can not due to network restrictions (say Machine2).

Machine 2 needs some specific software to be installed, for example I may need to install google-chrome (just as an example) on this machine.

What I tried is to create a /localrepo/amd64 diretory on Machine 1. Downloaded the stable .deb package and put it in this /localrepo/amd64 directory. This directory has a link symbolic link at /var/www/html, so the machine at least over local network can access this directory.

I ran dpkg-scanpackages amd64 | gzip -9c > amd64/Packages.gz that generated a Packages.gz file.

On the Machine1 I edit the sources.list file to add

http://Machine2FQDN/localrepo amd64/  

I comment out all other lines that were trying to point to various ubuntu repos.

I do an apt-get update and then try to install the package, I got a dependency issue.

Now, my question is if I want all the dependencies for the .deb file to be downloaded at Machine1 localrepo diractory what is the way for it.

I have seen answers like run the apt-get install -f, which does not work in my case, I can not allow Machine 2 to talk to ubuntu repos directly and resolve dependencies via apt-get. I do not need every single package in cache to be copied to this local repo, I need only the specific associated dependency packages to get downloaded (not installed) when I download a package through a single command.

Do we have a solution for that?

Please let me know if you need any further information.

Note: I know running apt-cache depends google-chrome-stable lists the dependencies, but I need those dependencies to be downloaded to my own custom folder /localrepo/


The problem lies in here

I comment out all other lines that were trying to point to various ubuntu repos.

If you comment out all the repo lines from the disconnected machine, How will it get other necessary .deb files to satisfy request if your local repository cannot provide that file?

For example, If Google chrome requires a.deb and b.deb and You installed a.deb in your connected machine in some point in time. Later you downloaded b.deb for google chrome and put only b.deb in the local repository, missing the a.deb file in your local repo. In this case, the disconnected machine, which can only request to the Local repo cannot not get a.deb file and it will generate a dependency error message.

Permanent solution

If you really want this type of settings, then you should make sure that both of the PC are in the same state regarding packages installed. And anytime you install something in connected machine, you should backup the .deb files and put theme in the Local repo for disconnected machines.

Temporary solution

Another solution could be, running a Live system in the connected machine and download or install the required package in there. In this way, You can get all the required packages for a new Ubuntu installation. Which would be sufficient for the disconnected machine. Grab the .deb files, put them in Local repo and install from other machine.

Hope this will help.


If machine1 and machine2 were identical to each other, you could do this on machine 1:

 sudo apt-get install -dy your-package   scp /var/cache/apt/archives/*.deb machine2:/somewhere   # create your local repo with all those .debs  

Now, if you start installing software in machine1, this won't work, because then a package which is already installed and satisfies a dependency will not be downloaded again and thus will not be in /var/cache/apt/archives. This is also an issue if the machines were installed from essentially different Ubuntu versions/flavors (say, if machine1 is 14.04 desktop and machine2 is 12.04 server).

I wrote a tool called dpkg-offline which may help, you basically tell it which ISO you installed machine2 from (you need to have a local copy of the ISO) and which packages you wish to download, it will produce a tar.gz with all the dependencies needed to install those packages on a system that was cleanly installed from that reference ISO.

dpkg-offline doesn't work so well with 12.04 server (and older server versions), but if your machine2 is Ubuntu Desktop (any version since 10.04) or Ubuntu Server 12.10 or newer, it may just help.


to use it, install bzr and then bzr branch lp:dpkg-offline. You'll find a README and a detailed tutorial on how to use the tool.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »