Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This question already has an answer here:

Right now I have 2 computers:

  1. Has connection to the internet and has installed package A.
  2. Doesn't have connection to the WEB. On this PC I need to install package A.

I decided to download all needed packages using first PC and transfer them to the second PC via USB. I have searched how to get all needed packages for some deb installation and here's what I've found.

But when I run:

apt-get --print-uris --yes install A | grep ^\' | cut -d\' -f2 > downloads.list

on first PC I got empty file because this package is already installed there (and I don't want to uninstall it).

Also package A is very complicated and depends on package B which depends on package C and package C is not installed on the second PC.

So how can I download all needed packages? Or is there any other way of installing it?

share|improve this question

marked as duplicate by Alaukik, Eric Carvalho, Braiam, belacqua, karel May 11 at 2:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
I think you can generate a download script with Synaptic. help.ubuntu.com/community/SynapticHowto –  DaboRoss Jun 11 '13 at 20:03
add comment

5 Answers 5

There are 4 steps to setting up a simple repository for yourself

1.Install dpkg-dev
2.Put the packages in a directory
3.Create a script that will scan the packages and create a file apt-get update can read
4. Add a line to your sources.list pointing at your repository

Install dpkg-dev

Type in a terminal

sudo apt-get install dpkg-dev

The Directory

Create a directory where you will keep your packages. For this example, we'll use /usr/local/mydebs.

sudo mkdir -p /usr/local/mydebs

Now move your packages into the directory you've just created.

Previously downloaded Packages are generally stored on your system in the /var/cache/apt/archives directory. If you have installed apt-cacher you will have additional packages stored in its /packages directory.

The Script update-mydebs

It's a simple three liner:

#! /bin/bash
 cd /usr/local/mydebs
 dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

Cut and paste the above into gedit, and save it as update-mydebs in ~/bin. (the tilde '~' means your home directory. If ~/bin does not exist, create it: Ubuntu will put that directory in your PATH. It's a good place to put personal scripts). Next, make the script executable:

chmod u+x ~/bin/update-mydebs

How the script works:

dpkg-scanpackages looks at all the packages in mydebs, and the output is compressed and written to a file (Packages.gz) that apt-get update can read (see below for a reference that explains this in excruciating detail). /dev/null is an empty file; it is a substitute for an override file which holds some additional information about the packages, which in this case is not really needed. See deb-override(5) if you want to know about it.

Sources.list

add the line

deb file:/usr/local/mydebs ./

to your /etc/apt/sources.list, and you're done.

CD Option

You can burn the directory containing the debs to a CD and use that as a repository as well (good for sharing between computers). To use the CD as a repository, simply run

sudo apt-cdrom add

Using the Repository

Whenever you put a new deb in the mydebs directory, run

sudo update-mydebs
sudo apt-get update

Now your local packages can be manipulated with Synaptic, aptitude and the apt commands: apt-get, apt-cache, etc. When you attempt to apt-get install, any dependencies will be resolved for you, as long as they can be met.

Badly made packages will probably fail, but you won't have endured dpkg hell.

share|improve this answer
add comment

Cube

Cube is an offline package management system that enables Linux distribution users (Ubuntu, Linux Mint and other APT-based systems) to have applications installed to their system even without internet connection. Just run the cube in your Linux system, create your project in it, paste your project together with cube in a flashdrive and fly away to any computer with internet connection, open the cube and select your project, update your applications and download any applications you want, go back to your Linux system and install it directly. And that’s it! You can now use your new application :).

You can download cube at its launchpad page : https://launchpad.net/camicricube

share|improve this answer
add comment

Have you read the methods here?

Installing packages without an Internet connection

Mentioned there,

Keryx

(mentioned earlier by answerer @totti)

Keryx is a portable, cross-platform package manager for APT-based (Ubuntu, Debian) systems. It provides a graphical interface for gathering updates, packages, and dependencies for offline computers. Keryx is free and open source. You can get Keryx here: https://launchpad.net/keryx

Synaptic package download script

Here's how: https://help.ubuntu.com/community/Synaptic/PackageDownloadScript


... Not mentioned at that site:

AptMedium

Seems the best tailored for your use case, unfortunately super immature. link

apt-offline

Looks like the best command-line tool for the job. Unfortunately, the "howto"s always start with the assumption that you have "apt-offline" already installed on the offline machine, ignoring the obvious question of how it would have got there in the first place. link

share|improve this answer
add comment

keryx
It's a gui application for installing packages on complete offline system.

https://launchpad.net/keryx

http://www.omgubuntu.co.uk/2010/09/keryx-offline-package-installation-made-easy-in-ubuntu

.............................................................................................

apt-offline : CLI
Let offPC is the offline computer and onPC is the online computer.

  1. Install apt-offline on offPC

  2. Download apt-offline from onPC. (try: http://packages.debian.org/wheezy/all/apt-offline/download)

  3. Copy and paste the '.deb' file to offPC

  4. Install it by opening it. (or using sudo dpkg -i '/path/to/file/apt-offline.deb')

  5. Generate update link file [offPC]
    sudo apt-offline set /tmp/updateee --update

    Generating database of files that are needed for an update.

  6. Download update files using link file [onPC]
    sudo apt-offline get /tmp/updateee

    Downloading http://security.ubuntu.com/ubuntu/dists/quantal-security/main/binary-i386/Packages.bz2.
    http://security.ubuntu.com/ubuntu/dists/quantal-security/main/binary-i386/Packages.bz2 done.
    Downloading http://security.ubuntu.com/ubuntu/dists/quantal-security/restricted/binary-i386/Packages.bz2.
    http://security.ubuntu.com/ubuntu/dists/quantal-security/restricted/binary-i386/Packages.bz2 done.
    Downloading http://security.ubuntu.com/ubuntu/dists/quantal-security/main/i18n/Translation-en.bz2.
    http://security.ubuntu.com/ubuntu/dists/quantal-security/main/i18n/Translation-en.bz2 done..........

    Downloaded data to /tmp/apt-offline-downloads-5942

  7. Add downloaded update files to offPC
    sudo apt-offline install /tmp/apt-offline-downloads-5942/

    gpgv: Signature made Fri 21 Jun 2013 02:08:43 PM UTC using DSA key ID 437D05B5 gpgv: Good signature from "Ubuntu Archive Automatic Signing Key " gpgv: Signature made Fri 21 Jun 2013 02:08:43 PM UTC using RSA key ID C0B21F32 gpgv: Good signature from "Ubuntu Archive Automatic Signing Key (2012) "

  8. Generate package link file [offPC]
    sudo apt-offline set /tmp/package --update

  9. Download package files using link file [onPC]
    sudo apt-offline get /tmp/package
  10. Add downloaded package files to offPC
    sudo apt-offline install /tmp/apt-offline-downloads-5942/
  11. Install package Open terminal sudo apt-get install package_name or
    open software center, install package.

Note1: Before using the file (updateee, package), you have to transfer the file from offPC to onPC (using Pen drive or something). Also copy the folder containing downloaded file to onPC to offPC.

Note2: If you get an error

E: Unable to locate package package_name

while installing, that means the package is not known to the offPC. This occurs due to many reason. such as Personal package maintained be private parties. (Search PPA)
Try add software sources by opeing software sources (from unity), then tick on Universe and other filds

share|improve this answer
add comment

Check this folder /var/cache/apt/archives this should effectively contain all packages downloaded during the installation of package A, copy paste the same contents to /var/cache/apt/archives of second computer. try apt-get install package a

For this to work you have must have at least once did apt-get update (For getting package lists for reference on apt)

Else you can try dpkg -i packageA.deb and see missing packages and install the ones from the archives folder. (This method is ridiculous)

I had used apt cds before, try googling for creating apt cds from existing system.

share|improve this answer
    
I don't think that this is safe way - this solution may crash Ubuntu on second PC. –  ArtemStorozhuk Jun 11 '13 at 20:16
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.