9

Is there any way to just download all Ubuntu repositories using apt-get? I am looking for something like :

sudo apt-get install --download-only *

So that I can access the downloaded repository in the directory /var/cache/apt/archives/.

Pandya
  • 34,843
  • 42
  • 126
  • 186
Nejat
  • 235
  • 1
  • 4
  • 9
  • possible duplicate of [How can I install software or packages without Internet (offline)?](http://askubuntu.com/questions/974/how-can-i-install-software-or-packages-without-internet-offline) – muru Oct 02 '14 at 12:54
  • Yeah. Indeed i have changed the address of the repositories to a local computer and i want to download all from there. – Nejat Oct 02 '14 at 12:55
  • You probably wan't something like: http://apt-mirror.github.io/ – azzid Oct 02 '14 at 12:57
  • I have tried that but it does not work properly when i change the address of the repositories in `mirror.list`. Where as the same addresses work well when defined in `sources.list`. So i am looking for an alternate way. – Nejat Oct 02 '14 at 12:59
  • Do you have enough disk-space to house all of those packages? – blade19899 Oct 02 '14 at 13:00
  • @blade19899 Yeah. I have more than 100 GB of free space. – Nejat Oct 02 '14 at 13:01
  • I'm not sure if 100GB is gonna be enough. But, i don't really know how large the entire trusty repository is. Do let us know! – blade19899 Oct 02 '14 at 13:02
  • @blade19899 mirroring binary amd64 and i386 for `trusty`,`trusty-security` and `trusty-updates` (`main`,`universe`,`multiverse`,`restricted`) takes me about 103GB. – muru Oct 02 '14 at 13:07
  • @muru, Nice. But, in what kind of real-life situation do you need this. Except to install when u don't have Internet. Sooner or later you still have to update them local packages. – blade19899 Oct 02 '14 at 13:09
  • @blade19899 Local mirror for college labs and other student use. The mirror is synced each day. – muru Oct 02 '14 at 13:10
  • @blade19899 You can significantly decrease the outgoing traffic in an organization if someone downloads it and others get locally. – Nejat Oct 02 '14 at 13:10
  • @Nejat for that purpose you should really use caching proxies. – muru Oct 02 '14 at 13:11

2 Answers2

9

First of all, this is not a convenient way. Instead of this you should use the method mention here. But as an answer to the question.

  • First create a file which contains names of all the available packages using apt-cache.

    apt-cache  dumpavail |grep -oP "(?<=Package: ).*" >> packagelist
    

    This will create a file packagelist with all the available packages.

  • Now create a simple script to download all the packages present in the file packagelist

    #!/bin/bash
    for package in `cat packagelist`
     do
        apt-get install -y --download-only $package   
     done
    
  • Save it.

  • Make it executable using

    chmod +x your_script_name
    
  • Now open terminal and login as root

    sudo -i
    cd /folder/of/you/script
    ./you_script_name
    

It will download all the available package depending upon your /etc/apt/sources.list in /var/cache/apt/archives directory

g_p
  • 18,154
  • 6
  • 56
  • 69
0

You can use a tool called apt-cacher. You can check this link for more info. Hope it helps.

Avishek Saha
  • 507
  • 3
  • 13
  • This does not get all repositories. When you get some packages just those are cached. I want some way to cache them all. – Nejat Oct 02 '14 at 13:14
  • Then you can use apt-mirror [check this link](https://www.packtpub.com/books/content/create-local-ubuntu-repository-using-apt-mirror-and-apt-cacher) – Avishek Saha Oct 02 '14 at 13:51