How do I generate a package download list?

First Note that, You must have the updated package indexes (these indexes are used by package management softwares to get information about the available packages online). So, you must download at least those index files.

To do so, open a terminal and give this command. (You must have a working internet connection for this step)

sudo apt-get update 

After you have the update package index files, use any of the method below:

Terminal way without synaptic

Use this command to generate an list of files needed to upgrade your system

sudo apt-get upgrade --allow-unauthenticated -y --print-uris | grep -o '\'http.*\' | tr "\'" " " > download-list 

The file download-list will be created in the current folder of the terminal.

Or, If you want to generate a download script for a specific package, use this command (see the update section below for another command)

sudo apt-get install <package-name> --allow-unauthenticated -y --print-uris | grep -o '\'http.*\' | tr "\'" " " > download-list

replace, <package-name> with actual name of the package. such as gtg for getting-things-gnome etc.

You can now use this file to feed any download manager which support input files with URLs.

For example to use this file with wget use this command below,

wget -c -i ./download-list

assuming download-list file is in the current directory of the terminal. The downloaded files will be stored in the current working directory of the terminal.

Update: I've found another command to generate package download list:

apt-get --allow-unauthenticated -y install --print-uris package-name | cut -d\' -f2 | grep http:// > download-list

Credit of the updated command: answerer of this post


Graphical way using Synaptic

Synaptic package manager has built-in feature to generate package download script and you don't even need to to use wget explicitly in terminal, Only executing the script is sufficient.

The procedure is as follows

  1. Install Synaptic Package Manager using terminal:

     sudo apt-get update 
     sudo apt-get install synaptic
    

    (First command is not required, if you have updated package index files, If you are not sure, use both).

  2. Then open Synaptic Package Manager by Typing Synaptic in the dash.

  3. Select a package in the right section of the window, Right Click → Mark it for installation. Alternatively, If you want to generate an upgrade script, push the button Mark All Upgrades in the toolbar. The image below uses the second method.

    image of upgrade push button

  4. When asked if you want to Mark additional required chanages, press the Mark button.

    image of additional mark window

  5. Then going to File --> Generate package download script, save the script as a file by give it a name and select a directory where to save it. Now, You have a script for package downloads.

If you want to download, Go to the scripts directory and run sh ./<script-name>. For example, if the name of the script is download-list and it is in your Downloads folder, the command is

cd ~/Downloads && sh ./download-list