Get packages and dependencies for installing offline

Q I don't currently have a net connection to my Ubuntu box, but I do have access to a fast connection at college. Is there a tool I can use on the box that's connected to the net (a Windows PC) to grab dependencies? What I'm looking for is a way to enter the name of the software that I want to install and get back a list of dependencies that I can run in a Windows app to fetch the files and any others that the next one depends on.

A There are at least two ways to do this. The quick and easy option is to use the 'Generate package download script' option in Synaptic. Mark the packages you want to install, then select this option from the File menu, which will generate a shell script that you can run to download the packages. Then you transfer the packages to your Ubuntu box and either put them in /var/cache/apt/archives or use the 'Add downloaded packages' menu option in Synaptic to install them. The main disadvantage of this method is that the script requires wget, so you need this installed on the computer you use for the downloading. An alternative is to use apt-get from the command line with the --print-uris option. Apt-get will automatically try to install all dependencies, and the --print-uris option outputs the URIs of all the files it needs. You can use grep and cut to extract the URIs from the output with

As you can see, this includes the dependencies as well as the program itself. Copy download.list to a USB flash drive to take it to the computer with the faster internet connection. Many FTP programs and download managers will read a list of download URLs from a file, such as

wget --input-file myurilist

You can give more than one package name as 'pkgspec' However, you do need to run the apt-get update from time to time to keep up to date. If you are using another connection because your home computer is on a slow dial-up, there's no problem, as apt-get update doesn't download much. If you have no internet access at all, you can run apt-get --print-uris update and download the files elsewhere, then copy, unpack and rename the Sources files in /var/lib/apt/lists.