How to install packages using dpkg or sudo apt install

Asked by mahesh kolekar

I am using

Sudo apt-get --download-only install package_name

to download packages and install them manually

So now there are a lot number of packages in my var/cache/apt folder

I do fresh installation frequently so every time I have to install every package with its dependencies

And its a hectic procedure to search and install and backtrack not satisfied dependencies

I tried to use dpkg and sudo apt install, both commands, not yet successful

So is there any way or any tutorial that will help to build packages from my local packages

And

Is there any command by which I can list related dependencies for a package

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Manfred Hampl
Solved:
Last query:
Last reply:
Revision history for this message
Manfred Hampl (m-hampl) said :
#1

Why are you using manual procedures for matching the dependencies? The command "sudo apt-get install packagename" should automatically download and install the named package together with all its dependencies.

Are you limited in the amount of data that you can download to this computer, or is this a computer without any network connection?

If you have a limited network connection, but access to another computer with good internet, you could proceed as follows:
Do "sudo apt-get update" to update the inventory of available packages on that system (just once, that is not much data usage).
Install synaptic package management ("sudo apt-get install synaptic", also just once, also not too much data needed).
Start synaptic, reload the package inventory (if not already done), mark all updates that are due or any other package installations that you want to do, and use the menu entry "File - Generate Package Download Script"
Save the script on a removable medium
Transfer that medium to another computer with good internet connection and execute it, saving the downloaded files into a specific directory on an removable medium.
Transfer that medium back to your original computer
Use synaptic "File - Add downloaded packages" to install all the packages that you have downloaded with help of the other computer.

see https://help.ubuntu.com/community/Synaptic/PackageDownloadScript

And a general answer: Package dependencies are visible among others on the internet on http://packages.ubuntu.com/ or can be shown with the "apt-cache depends pkgname" command (which, however, needs access to a current package directory, so it requires that "sudo apt-get update" was executed).

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#2

If you go to a system with web access and run:

sudo apt-get --download-only install `dpkg -l | awk {'print $2'}`

It will pull down all the debs for the installed packages and put them in /var/cache/apt/archives

You can then copy them to a good system and know that all deps are met. If the system is a laptop then I suggest you just move the system to where a wired connection can be used.

Revision history for this message
Ahmad Syukri Abdollah (syockit) said :
#3

If you are going to reuse backup "/var/cache/apt", then make sure to backup "/var/lib/apt/list/", and also your packages list (for example, use dpkg --get-selections).
This is because your APT packages list might not contain the same package versions as your backup one. If the version in your cache and the version in your current list mismatches, then it will attempt to download the one in the list (which is usually newer).

To list dependencies for a package, use "apt-cache depends <package name>".
If you have the previous list of installed packages, you can apt-get install everything all at once. I'm sure it's going to take a very long time to process the whole list.
Or you can go one by one using "apt-cache depends" and install packages that depend only on already installed packages. It's still hectic though.

Revision history for this message
mahesh kolekar (mailmahesh-kolekar) said :
#4

Hey Manfred I already installed packages I needed on my laptop

Now you suggested to generate "File - Generate Package Download Script" and save it to a USB drive and use it on another machine with good internet and by using "File - Add downloaded packages" with synaptic install on machine with no connectivity

So I want to ask if I already got all my packages can I be able to do above procedure without redownloading everything

My other desktop machine have Ubuntu 14.04 but due to some bios problem I have to do frequent fresh installations Its an old p4 machine but I want to keep it running

Previously I tried both lubuntu 14.04 and xubuntu 14.04

Revision history for this message
Best Manfred Hampl (m-hampl) said :
#5

I do not know how synaptic works when creating that download script - whether it checks first whether a file is already present in /var/cache/apt/archives or if it puts all files into the download script.

Maybe there is a better way for dealing with the Ubuntu 14.04 system. When you have that system working. you could create a backup copy of the whole installation on an external disk (e.g. with clonezilla), and when you have to reinstall that system, you could restore that backup copy. This should eliminate the need to re-download all updates since beginning, but only would need to download and install the updates that have been provided since the creation date of the backup.

Revision history for this message
mahesh kolekar (mailmahesh-kolekar) said :
#6

Thanks Manfred Hampl, that solved my question.

Revision history for this message
mahesh kolekar (mailmahesh-kolekar) said :
#7

Hey I used clonezilla and successfully created an image of my system

Sorry for late response as it took me 2-3 days to successfully create an image

Many thanks