Identifying and Downloading Dependency for an Offline PC [duplicate]

Solution 1:

Check out Keryx; it's an offline repository manager.

How does it work? It lets you download updates and new programs (with dependencies) to your flash drive.

Its interface is similar to synaptic, but it works from a pendrive (it doesn't need installation). Unfortunately, the GUI needs wxwidgets, which don't come preinstalled on Ubuntu (they're cross-platform and installable from here and Ubuntu repository here). It can only install software in a Ubuntu system, but you can download the updates or new packages in any Linux, Windows or OS X.

Here you can find a tutorial.

Another detailed step-by-step tutorial is in this answer.

Launchpad also hosts downloadable files.

A screenshot:

Screenshoot

Solution 2:

A quick hack

A quick hack is to copy all the packages you downloaded for your install to his machine (detailed instructions here). The .deb files are stored in /var/cache/apt/archives, then in the other computer launch Synaptic and select File -> Add Package Downloaded and search the folder were you put the files and open it, accept all (or install from terminal using the command sudo dpkg -i DEB_PACKAGE_NAME).

NOTE:
This assumes that your package manager is not setup to delete the packages straight after install. It also assumes that you are running the same version of Ubuntu (10.10, 12.04, etc) and architecture version (32b or 64b).


A DVD repository

If you want the latest bug fixes and security patches available then have a look at this tutorial, which covers creating your own DVD repository.

Solution 3:

A USB repository

If you have a decent sized USB stick - assuming around 4-8Gb (or external hard drive) you can set up a custom copy of the Ubuntu repository and configure that as a local repository as covered in AptGet/Offline/Repository on help.ubuntu.com.

To get the actual package files (the .deb files), I suggest using apt-mirror.

The apt-mirror package will help you create a custom mirror which should be smaller than the 30Gb of the full repository. Install the package:

sudo apt-get install apt-mirror

and edit its configuration file

gksudo gedit /etc/apt-mirror/mirror.list

or since Ubuntu 14.04

gksudo gedit /etc/apt/mirror.list

Only include the repository sections you want. Here is a simple example that copies the binary .deb files from all 4 sections (main, restricted, universe and multiverse) as well as the latest bug fixes.

# apt-mirror configuration file
##
## The default configuration options (uncomment and change to override)
##
#
set base_path    /tmp/ubuntumirror
#

## Repositories to copy from - 

## use a mirror so you don't overload the main server!!!

# Lucid binaries - no source files
deb http://archive.ubuntu.com/ubuntu lucid main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu lucid-updates main restricted universe multiverse


## Clean up older .deb files no longer in the archive
clean http://archive.ubuntu.com/ubuntu

It is guesstimated that you will need around 15Gb of space for all 4 sections, without the source.

I have put the path for all the .deb files to be /tmp, make sure you have enough space so your hard drive does not fill up (if your hard drive does fill up and your computer freezes, /tmp should be cleared with a reboot).

If you just want the main files, remove the restricted, universe and multiverse names from the configuration file.

If you are using a different architecture (you have 64bit, but your friend has 32 bit) then add the following at the start of the mirror.list configuration file:

set defaultarch i386

Once you have the apt-mirror configuration you want, run apt-mirror and go do something fun or life changing as it will take hours or days to get the repository (depending on your connection and the Ubuntu mirror you are using).

Once you have the .deb files, copy the files to your USB memory stick (or external hard drive) and set up the local repository as per the article mentioned previously.

Test it works before taking it to your friend!

Solution 4:

Use apt-get with the --print-uris option to do it and add -qq so it would be quiet.

Use sed to remove extra characters added to some filenames (something like 3%2a) and to get the url, filename and md5sum of files. Use wget to download the files. Use md5sum to check if the files are downloaded properly.

You may use this to create a shell script for Linux or Mac OS (replace .cmd in the commands to .sh and do chmod a+x <filename> to add permission to execute the script) or a Windows Command batch file, and an MD5Sum file to make sure the files are downloaded correctly.

Commands

Create script:

sudo apt-get <<<apt-get command and options>>> --print-uris -qq | sed -n "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/wget -c \1/p" > script.cmd

Examples:

sudo apt-get install anjuta --print-uris -qq | sed -n "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/wget -c \1/p" > install-anjuta.cmd
sudo apt-get upgrade --print-uris -qq | sed -n "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/wget -c \1/p" > upgrade.cmd
sudo apt-get dist-upgrade --print-uris -qq | sed -n "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/wget -c \1/p" > dist-upgrade.cmd

Create md5sum file:

sudo apt-get <<<apt-get command and options>>> --print-uris -qq | sed -n -e "s/_[0-9]%[0-9a-f][0-9a-f]/_/" -e "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/\4  .\/\2/p" > md5sum.txt

Examples:

sudo apt-get install anjuta --print-uris -qq | sed -n -e "s/_[0-9]%[0-9a-f][0-9a-f]/_/" -e "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/\4  .\/\2/p" > md5sum.txt
sudo apt-get upgrade --print-uris -qq | sed -n -e "s/_[0-9]%[0-9a-f][0-9a-f]/_/" -e "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/\4  .\/\2/p" > md5sum.txt
sudo apt-get dist-upgrade --print-uris -qq | sed -n -e "s/_[0-9]%[0-9a-f][0-9a-f]/_/" -e "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) MD5Sum:\([^ ]\+\)/\4  .\/\2/p" > md5sum.txt

You need md5sum for Windows if you're using that operating system to download files.


Create script to download repository listings:

sudo apt-get update --print-uris -qq | sed -n "s/'\([^ ]\+\)' \([^ ]\+\) \([^ ]\+\) :/wget -c \1 -O \2.bz2/p" > update.cmd

Checking MD5 Sums

You may add these to the ends of scripts to check md5sum:

Linux:

md5sum --quiet -c md5sum.txt

Windows (uses older md5sum, does not support --quiet):

md5sum -c md5sum.txt

To add automatically to script:

echo -e "md5sum -c md5sum.txt\npause" >> script.cmd

Installing List Files (Update Command)

Run these commands to the target computer.

You need to use bunzip2 to extract the repository list files:

bunzip2 *.bz2

Then copy to listing folder (current folder only contains list files):

sudo cp * /var/lib/apt/lists/

Above combined (current folder may contain other files):

for listfile in `ls *.bz2`; do bunzip2 $listfile; sudo cp ${listfile%.bz2} /var/lib/apt/lists/; done

Faster Downloads

If you want to make downloading the files faster, try using Axel.

Replace wget -c ... -O ... with axel ... -o ....

Folder Hierarchy (Downloading files using Windows)

I usually create a folder like this:

  • apt-get/
    • bin/
      • msys-1.0.dll
      • msys-intl-8.dll
      • wget.exe
      • msys-iconv-2.dll
      • md5sum.exe
      • libeay32.dll
      • libintl3.dll
      • libssl32.dll
      • libiconv2.dll
    • update/
      • update.cmd
      • md5sum.txt
    • install/
      • install-foo.cmd
      • install-bar.cmd
      • upgrade.cmd
      • md5sum.txt

Then change wget in the lines above to ..\\bin\\wget.exe, md5sum to ..\\bin\\md5sum.exe, etc.

This will separate the *.deb files and list files into different folders.

Updating your system

  1. Boot to target computer that uses Ubuntu
  2. Create a script for update
  3. Boot to a computer with an internet connection
  4. Run update.sh (for Linux or Mac OS) or update.cmd (Windows)
  5. Go back to target computer
  6. Install list files
  7. Create a script for upgrade/dist-upgrade (add md5sum commands to end)
  8. Go back to computer with internet connection
  9. Run upgrade.sh/dist-upgrade.sh (Linux or Mac OS) or upgrade.cmd/dist-upgrade.cmd (Windows)
  10. Go back to target computer
  11. Copy *.deb files to cache: sudo cp *.deb /var/cache/apt/archives/
  12. Run: sudo apt-get upgrade or sudo apt-get dist-upgrade

Download Executables for Windows

Wget for Windows: http://gnuwin32.sourceforge.net/packages/wget.htm

md5sum for Windows: http://gnuwin32.sourceforge.net/packages/coreutils.htm or http://www.etree.org/cgi-bin/counter.cgi/software/md5sum.exe

You may also use the ones from MinGW, which are what I use. You only need wget.exe, md5sum.exe and the necessary shared libraries. Check the section "Folder Hierarchy".

Notes

  • I'm not entirely sure if everything above commands will work, since I haven't used them for a month now. Especially the update command, which I haven't tested today some parts of it.
  • To easily see the results of the commands, add a "pause" line in the end of the scripts, if using Windows.
  • I recommend to create shell scripts to update, upgrade and install packages if you're using these commands often.

Solution 5:

Step 1: Get the download URLs in a file :

Execute the following command replacing package-names with required ones, separating by a space.

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

Step 2: Copy this file (apturls) to a machine which has high-speed Internet access, and execute the following command to download the packages:

wget -i path-to-apturls-file 

Step 3: Now get those downloaded packages to your machine, and install them using :

cd path-to-the-downloaded-packages-directory

sudo dpkg -i *.deb

Done!