Monday, October 26, 2009

Fast Parallel Downloading (for apt-get and aptitude) #3

"aptitude" has more features, but is as low-hassle and scriptable as "apt-get". For instance, you can say "this package was automatically installed", which means if you don't need it any longer, it'll be automatically removed. Another perk is a direct way of asking "why was/wasn't this package installed?", to help sort out sometimes confusing package dependencies.

Alas, it doesn't have the "print-uris" trick which I relied upon in doing quick upgrades. I've found a simple workaround: use both aptitude and apt-get. The following script updates the list of available packages. It uses apt-get to download -- but not install -- all updates. Lastly, it uses aptitude to upgrade the packages, using the freshly-downloaded files. A "safe" upgrade won't delete a package to let another package be installed correctly, it just does installs.

For a one-line version, see morch's a previous comment.


cd /var/cache/apt/archives/
aptitude update
apt-get -y --print-uris -u upgrade | grep -o -e "http://[^\']+" \
| xargs -r -l3 -P5 wget -nv
aptitude -y safe-upgrade

No comments:

Post a Comment