0

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/

Anwar
  • 76,649
schow
  • 3
  • Hi Muru, Thanks for looking into it. I went through the question you referred to but answers seems not be the one I'm looking for. USB or DVD image related answers not going to work. I have tried to use the --print-uri option, but that did not work. apt-mirror option has an issue, my Machine2 is behind proxy, though I have apt.conf file and .bashrc file configured with proxy settings, it seems it ignores it. I updated the proxy setting at /etc/environment file but no luck there. – schow Nov 06 '14 at 01:00
  • I primarily need to know two things:
    1. Is there a single command that can download a package with its dependency?
    2. Can I install the package along with its dependencies from this local repo available over apache2?

    The client machines are behind a restricted network and can talk only to a master node over intranet and has no access to internet.

    – schow Nov 06 '14 at 01:02
  • The USB and DVD are incidental (they're merely for transportation from a system with an net connection to another without one). What matters is how those packages are got onto the drive. After that, it doesn't really matter if you use USB or DVD or some network-based method. – muru Nov 06 '14 at 01:16
  • I have edited the question to make sense, It was really confusing between Machine 1 and Machine 2 – Anwar Nov 06 '14 at 16:28

2 Answers2

1

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.

Anwar
  • 76,649
  • 1
    Thanks Anwar for hitting the fundamental conceptual issue I had! I now understand the situation better. Thanks a lot! – schow Nov 06 '14 at 19:44
  • Just one qury taking your answer as queue if google chome nees a.deb and b.deb, can I download google-chrom.deb, a.deb and b.deb all together in a single command and these file should get downloaded at /my/local/repo directory of the connected machine and not at /var/cache/apt/archives/ ? – schow Nov 06 '14 at 20:09
  • Another way is, Noting every packages google-chrome depends on and putting them after sudo apt-get --reinstall install line in first machine. In this way, the connected machine will fetch the packages again, even if it is installed. You can also use --print-uris switch with apt-get to examine the download urls.

    A second tiresome way is, try to install google chrome in disconnected machine. Examine the dependency error message, note the missing package and download the package with connected machine, then put them in local repo and again recycle the process

    – Anwar Nov 07 '14 at 06:24
  • And a better approach is use synaptic. Synaptic has an option to display all dependency of a package. If a package is missing, it will show in in italic fonts. So, write down the package names and download them with connected machine and put them in local repo. If you want, I could help you will a screenshot – Anwar Nov 07 '14 at 06:26
  • @schow if any answer helps, try upvoting or accepting if it solves the problem. That will help future visitr – Anwar Nov 07 '14 at 10:32
0

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.

https://launchpad.net/dpkg-offline/

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.

roadmr
  • 34,222
  • 9
  • 81
  • 93
  • Thanks roadmr! I'll check this out. I had tried copying .deb using something like scp /var/cache/apt/archives/*.deb machine2:/somewhere and tried, but as you mentioned it did not solve the issue. Anyway, thanks again! – schow Nov 06 '14 at 20:12