APT

About APT pinning in various distributions and versions

One thing about APT pinning I've now learned for life is that you should always check the output of apt-cache policy. In various distributions and APT versions the pinning might behave a bit differently. Checking the output of apt-cache policy (note that there's no package name at the end of the command, thus it'll list your APT sources and their pinning values) reveals most probably the reason why your preferences file does not do whatever you wish it to do.

How to use PHP 5.2 with Debian Squeeze

Googling in the subject shows that you can downgrade PHP packages to Lenny versions without much trouble. However the already documented methods lacked a few things I consider important, thus I write down my own downgrade instructions for future reference.

How to list packages available (and installed) from a specific repository

I don't know of a simple APT command that could give the answer to the question of this post, thus I made a little awk script to filter the output of apt-cache policy to get what I want.

How to list/find installed packages that are not available from any of the configured APT repositories

During upgrades between releases of a Debian (or Ubuntu) system you can end up with a lot of trash ... packages left over from earlier releases. Using the following command you can find packages that are not available from any of the APT repositories you've configured in /etc/apt/sources.list (or /etc/apt/sources.list.d/*):
for pkg in $(dpkg --get-selections | awk '{print $1}'); do grep "^Package: $pkg\$" /var/lib/apt/lists/*binary*Packages > /dev/null 2>&1 || echo "$pkg"; done

These packages might have been manually installed or are remnants of a previous OS release. You should review the list and decide for yourself whether to keep them or purge them.

Note that the above command does not show packages for which the current version was manually installed from a DEB, but the package is available from a repository too.

For a more thorough list (packages for which the currently installed version is not from a repository ... including packages for which an update is available from the respective repository), try this:
apt-cache policy '.*' | awk '/^[a-z0-9]/{pkg = substr($1, 1, length($1) - 1)}/ *\*\*\*/ {getline; if (index($0, "/var/lib/dpkg/status") != 0) print pkg}' | sort
(Don't forget to upgrade all packages to the current latest version or they'll be listed too.)

APT: how to check what source does a package come from

The command is: apt-cache policy packagename
Example output for the "thunderbird" package on an up-to-date Ubuntu Karmic system:
$ apt-cache policy thunderbird
thunderbird:
  Installed: 2.0.0.24+build1+nobinonly-0ubuntu0.9.10.2
  Candidate: 2.0.0.24+build1+nobinonly-0ubuntu0.9.10.2
  Version table:
*** 2.0.0.24+build1+nobinonly-0ubuntu0.9.10.2 0
        500 http://archive.ubuntu.com karmic-updates/main Packages
        500 http://security.ubuntu.com karmic-security/main Packages
        100 /var/lib/dpkg/status
     2.0.0.23+build1+nobinonly-0ubuntu1 0
        500 http://archive.ubuntu.com karmic/main Packages

How to list automatically or "manually" installed packages

Aptitude (an APT front-end) has long been able to distinguish between packages as being automatically installed (based on some dependancy that another package required) or "manually" installed. Since Debian Lenny (5.0) this capability is integrated into the APT package management system and most probably Aptitude's functionality got a lot thinner (since it doesn't have to implement something that's already in APT's core).
I could not find a method to do this (ie. list the manual/auto installed status of packages) the APT-way, but Aptitude's search function does it well enough.
Here's the command to list automatically installed packages:
aptitude search '.*' | grep '^i.A' | less
And the trivial opposite (list of manually installed packages):
aptitude search '.*' | grep '^i.[^A]' | less

Feisty update broken due to end-of-life

Feisty got its End-Of-Life statement and it also means that the official Feisty repository was moved from http://archive.ubuntu.com/ to http://old-releases.ubuntu.com/. If you don't know what's going on and just run apt-get update, you'll see error messages like this ...

Listing reverse dependencies of a package in an Apt repository (Debian)

The basic method (I mean with default tools on a Debian system) is to use apt-cache:
apt-cache rdepends package
However I've found that this does not always give correct results.

Installing Opera on Ubuntu with APT

You can find the details here.

How to fix NO_PUBKEY errors in "apt-get update" operations

You can find the answer in this post, but I also document it here so I'll have a permanent copy.

Syndicate content