PDA

View Full Version : HOWTO: Download package dependencies for offline installation



sergiodlc
March 19th, 2009, 10:10 PM
Have you ever been into trying to install a package in a computer that is not connected to the network? Keep reading to find solutions to this problem.

Follow these Steps:


Find out what packages have to be downloaded

Case 1: You have a recent synaptic version.

The first step would be to open Synaptic and select the package(s) you want to install. Then go to File -> Generate package download script and save it naming it as you want (herein referred as download_script_file).

Case 2: You don't have a recent synaptic version or you are not using any window manager.

Use 106990 (attached). Type python grabpackages.py -h to see the help. This is the command you would use to download Inkscape (http://www.inkscape.org) and its dependencies:

python grabpackages.py -o download_script_file inkscape

Now take download_script_file to the computer with internet access.

Download the packages

Case 1: The computer with internet access has a linux OS with wget (http://www.gnu.org/software/wget/) installed.

Open a terminal and cd to a suitable directory (e.g. cd /tmp).

Create a directory to download the packages and cd into it:

mkdir packages_dir
cd packages_dir


Copy download_script_file into this directory and execute it:

sh download_script_file

The script begins to download the files using wget (http://www.gnu.org/software/wget/).

Case 2: You have a Windows/Linux box but wget (http://www.gnu.org/software/wget/) is not installed.

You could try one of these:


Install wget (http://www.gnu.org/software/wget/)

In Debian/Ubuntu:

sudo apt-get install wget

In Redhat/Fedora:

yum install wget

In Windows: see here (http://ubuntuforums.org/showthread.php?t=291071).

Generate an html page and download the packages from your browser

If you already have the download script file generated by synaptic, the easiest way is to use 106997 (attached):

python downloadscript2html.py download_script_file download_page.html

If not, 106990 (attached) will work too (using the --html option). Revisiting the Inkscape (http://www.inkscape.org) example:

python grabpackages.py --html -o download_page.html inkscape

Now open download_page.html in your browser and download the linked files in your download directory (here a download accelerator like DownThemAll (http://www.downthemall.net/) is very useful, specially with large files).



Copy the packages to your PC

Copy the .deb files you downloaded to /var/cache/apt/archives:

From the directory where the .deb files are stored type:

sudo cp *.deb /var/cache/apt/archives

or start Nautilus as root and copy the files in the usual way.

Install the packages

Just open a terminal and type

sudo apt-get install <package_name(s)>

replacing <package_name(s)> with the name(s) of the program(s) you wanted to install (E.g. inkscape).


This should be pretty much everything.

Note:

The attached scripts are written in Python (http://www.python.org). In some systems Python (http://www.python.org) is not installed by default. See http://www.python.org/download/ to solve this.

Additional references:

Ubuntu community help about Synaptic download script (https://help.ubuntu.com/community/Synaptic/PackageDownloadScript)
This thread (http://ubuntuforums.org/showthread.php?t=174354)

potwak
June 26th, 2009, 02:57 AM
Hi. Thanks for this good and usefull post, I am working in an offline PC and trying to learn Linux right now.

My problem is, the links from the generated html file is broken (please see attached zipped html file). I hope to install xchm on my Ubuntu 7.04 btw. Can you help me solve my problem?

I used this command to generate the html file:


python grabpackages.py --html -o download_page.html xchm
Here is an example of the link generated:


http://archive.ubuntu.com/ubuntu/pool/main/i/imagemagick/libmagick9_6.2.4.5.dfsg1-0.14ubuntu0.1_i386.deb
I hope someone could help.

stovicek
June 26th, 2009, 03:39 AM
I hope to install xchm on my Ubuntu 7.04 btw. Can you help me solve my problem?
The problem is going to be that your version of Ubuntu has reached its End Of Life (http://www.ubuntu.com/news/ubuntu-7.04-end-of-life). The links to packages created from the HOWTO are broken because those versions have been removed from Ubuntu's active repositories.

However, they do keep an archive of older packages at a different location. If you change the address in the link from archive.ubuntu.com to old-releases.ubuntu.com you may be able to at least get most of the packages you need.

scarf
July 11th, 2009, 09:26 AM
Have you ever been into trying to install a package in a computer that is not connected to the network? Keep reading to find solutions to this problem.

Follow these Steps:

[LIST=1]
Find out what packages have to be downloaded

Case 1: You have a recent synaptic version.

The first step would be to open Synaptic and select the package(s) you want to install. Then go to File -> Generate package download script and save it naming it as you want (herein referred as download_script_file).

does this only work if you don't have the package and all its dependencies already installed?

i already have a package and it's dependencies installed, and i want to install the same package+dependencies on another computer that isn't connected to the network.

when i select the "Generate package download script" option i get a file with just "#!/bin/sh" at the top.

i guess we are supposed to do this part on the computer that is not connected to the internet and doesn't have the package installed?

anyway, the python script has worked fine for me. thanks!

rshmelev
October 6th, 2009, 04:30 PM
Guys... this does not under Windows :( (Python 2.6.3 installed)

D:\>python grabpackages.py --html -o download_page.html inkscape
Traceback (most recent call last):
File "grabpackages.py", line 86, in <module>
packages = get_debs(args, options.repo, options.archivecheck)
File "grabpackages.py", line 50, in get_debs
archive = set(os.listdir('/var/cache/apt/archives'))
WindowsError: [Error 3] The system cannot find the path specified: '/var/cache/apt/archives/*.*'

D:\>python grabpackages.py -o download_script_file inkscape
Traceback (most recent call last):
File "grabpackages.py", line 86, in <module>
packages = get_debs(args, options.repo, options.archivecheck)
File "grabpackages.py", line 50, in get_debs
archive = set(os.listdir('/var/cache/apt/archives'))
WindowsError: [Error 3] The system cannot find the path specified: '/var/cache/apt/archives/*.*'

sh4d0w808
October 7th, 2009, 02:55 PM
Yes, because Windows doens't have /var/cache/apt/archives and very similar directories or filesystems...
As I see, this script is intended to work on Linux systems.

tsh3po
October 20th, 2009, 06:41 AM
Hi everyone...

Sorry to wake up a dead post like this, the thing is I plan on installing 9.04 server edition on my home PC and obviously run Vmware on it and manage my virtual machines via my desktop edition running on my lappy. Now the problem with this is that my home machine doesn't have internet access, I can only access the net only at work, now looking at this command
python grabpackages.py -o download_script_file inkscape I get confused. Can someone please explain to me if the "inkscape" part of the command means it will only download packages associated to it and if so, does it mean I have to do the same for every software I wanna install? while on it, is it possible to have updates downloaded using this method?

Please dont kill me as I havn't tried it yet, but I was hoping to use this method to download the headers needed for Vmware, will it work or am I going nuts?

Thanks in advance

kirzhanov
November 26th, 2009, 10:36 AM
Is it possible to use this script to download the packages for the 64-bit system? My system with an Internet connection uses packages for i386. It seems that I need to specify an alternate repository to download 64-bit packages, but I could not find the URL 64-bit Ubuntu repository... :(

Thanks

sergiodlc
December 9th, 2009, 02:36 AM
Is it possible to use this script to download the packages for the 64-bit system? My system with an Internet connection uses packages for i386. It seems that I need to specify an alternate repository to download 64-bit packages, but I could not find the URL 64-bit Ubuntu repository... :(

Thanks

The script admits the -r option to change the repository.

sergiodlc
December 9th, 2009, 02:50 AM
Hi everyone...

Sorry to wake up a dead post like this, the thing is I plan on installing 9.04 server edition on my home PC and obviously run Vmware on it and manage my virtual machines via my desktop edition running on my lappy. Now the problem with this is that my home machine doesn't have internet access, I can only access the net only at work, now looking at this command
python grabpackages.py -o download_script_file inkscape I get confused. Can someone please explain to me if the "inkscape" part of the command means it will only download packages associated to it and if so, does it mean I have to do the same for every software I wanna install? while on it, is it possible to have updates downloaded using this method?

Please dont kill me as I havn't tried it yet, but I was hoping to use this method to download the headers needed for Vmware, will it work or am I going nuts?

Thanks in advance

"inkscape" is just an example package. Instead you should write the package names (separated by spaces) of the packages you intend to install.

If you have ~30 GB of spare hard disk space in your laptop a much better solution would be to download the complete repository using apt-mirror, as explained here (http://ubuntuforums.org/showthread.php?t=599479). Then you can access the local repository in your laptop from your home PC (provided that they can be connected ;)).

Instead of VMWare I would suggest Virtualbox, an open source virtualization solution that works just fine.

Sergio

rahilm
December 9th, 2009, 08:43 AM
I've been using offline method for everything that is installed on my machine since 8.04.

The download script that synaptic generates is actually a bash script with wget commands. In other words, it is simply a text file containing the links, in my pc it is something like:
#!/bin/sh
wget -c <web address to that file>

So if you don't have wget installed, there isn't any need. Just open the file using a text editor and download all those files to a folder using any standard browser.

meka4996
December 19th, 2009, 05:47 PM
Apt-get command doesn't generate download script?? Come on! Why not?
Thanks for the grabpackages.py!

Apt-get command doesn't generate download script?? Come on! Why not?
Thanks for the grabpackages.py!

Compare with another mothod
http://www.tuxradar.com/answers/517

The list generated by grabpackages.py is very long, while the list generated by apt-get+grep+cut is short[as needed by apt-get] and easier
with fewer steps =)

sergiodlc
December 21st, 2009, 09:40 PM
Apt-get command doesn't generate download script?? Come on! Why not?
Thanks for the grabpackages.py!

Apt-get command doesn't generate download script?? Come on! Why not?
Thanks for the grabpackages.py!

Compare with another mothod
http://www.tuxradar.com/answers/517

The list generated by grabpackages.py is very long, while the list generated by apt-get+grep+cut is short[as needed by apt-get] and easier
with fewer steps =)

Yes, the list is longer because grabpackages.py lists any package needed even by the dependencies of the given package (you can activate an option to avoid listing packages that are already in your local cache). This way you don't end up frustrated for a missing package.

Udagama
January 25th, 2010, 07:47 PM
Vist:-
http://www.keryxproject.org/
then you can download packages with its dependencies at once using another online pc. That online pc could Ubuntu or windows pc.

ario
October 17th, 2010, 05:40 PM
Apt-get command doesn't generate download script?? Come on! Why not?
Thanks for the grabpackages.py!

Apt-get command doesn't generate download script?? Come on! Why not?
Thanks for the grabpackages.py!

Compare with another mothod
http://www.tuxradar.com/answers/517

The list generated by grabpackages.py is very long, while the list generated by apt-get+grep+cut is short[as needed by apt-get] and easier
with fewer steps =)

Thanks a lot! Using this command you can generate a summarized suitable list of all packages needed to update your command-line based system (For example Ubuntu Server Edition):

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

You can also change the work upgrade to install <package_name> to install any package with name <package_name>.
Hope this helps.