For all answers i found about this topic, the solution was to create, in a certain computer A where i need to install the package, a file containing all dependencies it needs and then downloading it in another computer, let's call it B.
The thing is, i want to have a storage of certain critical software i need to work to be able to install them offline later on in case i have to format my desktop.
I REALLY DON'T CARE about having a lot of redundant .deb files in my computer, and I REALLY DON'T CARE if i'm going to store 1gb of files to install a 10mb software.
So, i want to have any possible dependency downloaded. Is there someway i can do this?
14 Answers
I would go with this:
apt-cache depends -i PACKAGE | awk '/Depends:/ {print $2}' | xargs apt-get download && apt-get download PACKAGE
Then you can install it with dpkg -i *.deb in the directory you downloaded these.
Is this a one-time thing, or something you want to keep updated? Are you mostly working online, and just want a local backup of all your packages, just in case?
There are several services that you can install that act as an APT proxy/cache. You point APT at your local cache, it will download from the Internet, and keep a locally cached copy of all the packages. This can be very useful if you have lots of computers on your network with an identical selection of packages.
My prefered apt cache is approx, but there is also apt-cacher-ng, and a few others. Each has minor differences about how caching can be configured.
I always use the minimal netinst installers to build my Debian based systems, which means my apt cache usually has almost all the packages to fully build my systems.
1run following python3 program:
import subprocess
olemas_olevad_pakid=set()
def r(pakk): t=subprocess.run(["apt-get", "download", pakk]) if t.stderr or t.returncode: #print("could not load package: Status: {p.returncode}, stdout: {p.stdout}, stderr: {p.stderr}".format(p=t), "paki nimi:", pakk) return False olemas_olevad_pakid.add(pakk) t=subprocess.run(["apt-cache", "depends", "-i", pakk], stdout=subprocess.PIPE) if t.stderr or t.returncode: print(t.stdout) exit(t.stderr) #print(":", t.stdout) needed_pacages=t.stdout.split(b"Depends: ")[1:] #print(pakk, "needs packages:", needed_pacages) for choices in needed_pacages: one_choice_made=False for needed_package in choices.split(b"\n"): needed_package=needed_package.strip(b"\n ") if needed_package in olemas_olevad_pakid or r(needed_package): one_choice_made=True break if not one_choice_made: print("PROBLEM: could not download any of", choices) return False return True
#for pakk in packages_to_download:
# print("pakk:",pakk)
# r(pakk)
r(input("package name:"))It will download all dependecies of all dependecies not only immediate dependencies.
But installing them with dpkg -i *.deb failed. Maybe because apt-cache depends -i package gives misinformation or some some.deb files still need internet connection to install.
run following python programm:
import subprocess
package=input("insert package name:")
t=subprocess.run(["apt-cache", "depends", "-i", package], stdout=subprocess.PIPE)
if t.stderr or t.returncode: print(t.stdout) exit(t.stderr)
#print(":", t.stdout)
needed_pacages=t.stdout.split(b"Depends: ")
print(package, "depends of", needed_pacages)
for choices in needed_pacages: one_choice_made=False for needed_package in choices.split(b"\n"): needed_package=needed_package.strip(b"\n ") t=subprocess.run(["apt-get", "download", needed_package]) if t.stderr or t.returncode: print("ERROR: Status: {p.returncode}, stdout: {p.stdout}, stderr: {p.stderr}".format(p=t), "package name:", needed_package) else: one_choice_made = True #print("downloaded",vajalik_pakk) break if not one_choice_made: print("could not get one of dependecies", choices) 1