How to download a software package with all dependencies and sub-dependencies?
Similar questions have been asked already but none of them have solved my problem:
I need to install a package on a standalone Linux box, specifically kdbg. Now I tired the command
sudo apt-get install --download-only kdbg
on a box connected to the internet, but it only downloads the package and dependencies that I don't have installed. Some of those dependencies (that command downloaded 117 total packages) have sub dependencies, and those sub dependencies have even more dependencies and I'm going down a rabbit hole trying to fish those packages out of the repo.
Now I tried using a couple of other commands that supposedly will download all dependencies, even the ones I have installed. I've tried
-
apt-get download PACKAGE && apt-cache depends -i PACKAGE | awk '/Depends:/ {print $2}' | xargs apt-get download
and
-
apt-get download $(apt-rdepends <package>|grep -v "^ ")
.
Command one only downloads the direct dependencies, like the ones you'd find on packages.ubuntu.com if you were to search kdbg, and command two gives me the error message:
Can't select candidate version for package <package> as it has no candidate
for several different packages.
So, to restate my question, is there a way for me to download kdbg, all of its dependencies, all of those dependencies' dependencies, so on and so forth? Or perhaps I am using one of the above commands incorrectly?
Thanks in advance.
Solution 1:
You need to run a command that automatically resolves all the .deb file's dependencies and installs the .deb file and its missing dependencies with the same command. You will need a working internet connection (which you have) and your installed software to be updated with sudo apt update && sudo apt upgrade
to download any missing dependencies. Open the terminal and type:
apt download package-name apt install --simulate ./package-name.deb # dry run doesn't install anything
where package-name should be replaced by the name of the package that you are trying to download and package-name.deb should be replaced by the name of the .deb file that you are trying to install.
The second command doesn't install anything, it's just a dry run simulation to list the dependencies that need to be installed on the offline machine. You might also have to run the apt install --simulate ./package-name.deb
command again in case one or more of the .deb files that you download itself has unmet dependencies.
In case the Ubuntu is not installed on the computer that you are downloading packages from, then you can either boot from the same bootable media that you used to install Ubuntu and download the .deb files from an Ubuntu live session or visit the official Ubuntu Package Search website and download the .deb files manually.