Synaptic has a useful feature that generates a script to download all required .deb files. Unfortunately, Synaptic is not installed by default in Ubuntu any more, so my answer will have two parts.
How to install Synaptic on an offline computer:
You will need to download these packages on a connected computer:
To do this, open a browser to http://packages.ubuntu.com. Search for the package name for your Ubuntu release, click on the relevant search result, click on your architecture (i386 for 32 bit and amd64 for 64-bit) and choose a mirror. Repeat for each required package.
Once you've saved all the .deb files, move the files over to the offline computer and install them one by one in reverse order by opening them in Ubuntu Software Centre.
If you look at synaptic dependencies, you'll notice that it has more dependencies than the ones I've listed. I've only listed the ones that will be missing from a typical Ubuntu 12.10 desktop install.
How to install a particular package on an offline computer:
At this point, you have Synaptic installed on both your online and offline machines.
In the offline computer:
- Open Synaptic.
- Find the package you want to install, and tick the box. If Synaptic asks you to confirm whether you want to install dependencies as well, accept the confirmation.
- Click "File", "Generate package download script".
- Save the script on a USB stick.
Take the USB stick to an online computer running Ubuntu. On the online computer:
- Open a terminal, and navigate to the USB stick directory.
- Run the script. It will download all the required .deb files to the USB stick.
- Eject the USB stick safely.
On the offline computer, plug in the USB stick.
- Open Synaptic.
- Click "File", "Add downloaded packages".
- Navigate to the USB stick.
- Click "Apply".
(This presumes that you want to install a package that's in the "main" repo. If your package is in the "universe" repo, you will need to have run
sudo apt-get update while connected to the Internet some point in the past. The installer will do this for you automatically.)