Saturday, March 28, 2009

How a non-root user can use apt-get download-only feature?

Some time all you need is just getting required *.deb files to install some programs, for example, to another system that don't have Internet connection. Of course, under root you can use --download-only parameter as:

# apt-get --download-only install wesnoth

(or on Ubuntu $ sudo apt-get --download-only install wesnoth)

Then copy downloaded files from /var/cache/apt/archives. But even if you don't have root permissions the following pipe gives you desired result:

$ apt-get --yes --print-uris install wesnoth | grep --regex 'tp://.*deb' | cut -d ' ' -f1 | sed "s/^'//g;s/'$//g" | wget -i -

As you can see, wget accept URL from input (stdin) with -i option.

1 comment:

Anonymous said...

doesn't work if the package is already installed on the system though. you can use reinstall for those..