I'm working on a script to show differences between config files on a system and those provided in the original package. I have pretty much all of it working, except for using apt to download packages without being root. Is there a simple way to do this?
Edit: I've looked into the 'hacky' wget scripting type options, but the main issue I have is how you would determine which repo to attempt to get the package from. It's not included in any apt-cache output that I can see.
You could set up passwordless
sudo
foraptitude --download-only
? Or you could parse the output of various apt commands and manually download the file from there. There are 3rd party libraries for dealing with libapt, like python-aptSimply
aptitude download
it:dget
does exactly what you want. From the man page:wget can be used to download packages to a user writable directory, which answers your question, unless you have a hidden requirement in your question to actually INSTALL the packages.
Try using the underlying pkg_apt libraries? Although, they are likely to make your script somewhat more complex, and iirc, are in perl, so require you using that.
The locations of the repositories are in /etc/apt/sources.list and /etc/apt/sources.list.d/* so you could use those to work out the list of repositories. Then try all of them with wget for the location of the package. It is brute force but would work.
For example, this entry deb http: / / us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse becomes wget http://us.archive.ubuntu.com/ubuntu/jaunty-updates/multiverse/i386/packagename