Tuesday·26·November·2013
Showing packages newer than in archive with aptitude //at 22:14 //by abe
I happens quite often that I install a manually built, newer version of some package on a machine. Occassionally I forget to remove it or to downgrade it to the version in the APT repo.
$ apt-show-versions | fgrep newer
easily finds those packages.
But usually when doing such a check, I want this list of packages in my aptitude TUI to have a look at the other versions of that package and to take actions. And I don’t want to manually search for each of the package manually.
This can be done with the following “one-liner”:
# aptitude -o "Aptitude::Pkg-Display-Limit=( `apt-show-versions | fgrep newer | awk -F '[ :]' '{printf "~n ^"$1"$ | "}' | sed -e 's/| *$//'` )"
It uses apt-show-version
’s output, searches for the right
packages, takes the first column and transforms it into an aptitude
search pattern matching all packages whose name is exactly one of the
listed packages.
But this solution is quite ugly and slow. So I wondered if this is also doable with pure aptitude search patterns which likely would also be faster.
And after some playing around I found the following working aptitude search term:
~i ?any-version(!~O.) !~U !~o
This matches all packages which which are installed and which have a
version which has no origin, i.e. no associated APT repository. Since
this also matches all hold packages as well as all packages not
available in any archive, I use !~U !~o
to exclude those
packages from that list again.
Since nobody can remember that nor wants to type that everytime needed, I added the following alias to my setup:
alias aptitude-newer-than-in-archive='aptitude -o "Aptitude::Pkg-Display-Limit=~i ?any-version(!~O.) !~U !~o"'
Only caveat so far:
It seems to also match packages from APT repos which haven’t set an “Origin”. This should not happen with any Debian or Ubuntu APT repository, but seems to happen occasionally with privately run APT repositories.
And using ~A
instead of ~O
, i.e. ~i
?any-version(!~A.)
, does not work for this case either, despite
it matches installed packages of which versions not in any available
archive exist. But unfortunately aptitude seems to remember in some
way if a package was in some archive in the past, so this only shows
packages installed with dpkg -i
, but not packages removed
from e.g. unstable but with older versions still being available in
stable.
Tagged as: alias, apt-show-versions, aptitude, awk, CLI, Debian, filter, grep, one-liner, Package Management, Quoting, UUUCO
// show without comments // write a comment
Related stories
Monday·08·August·2011
Finding libraries not marked as automatically installed with aptitude //at 17:26 //by abe
This is a direct followup on my blog posting Finding packages for deinstallation on the commandline with aptitude.
In the meantime on more alias for finding obosolete packages made it into my zsh configuration. It’s an alias to find installed libraries, …-data, …-common and other usually only automatically installed packages, which are not marked as being installed automatically nevertheless:
alias aptitude-review-unmarkauto-libraries='aptitude -o "Aptitude::Pkg-Display-Limit=( ^lib !-dev$ !-dbg$ !-utils$ !-tools$ !-bin$ !-doc$ !^libreoffice | -data$ | -common$ | -base$ !^r-base ) !~M"'
And yes, this pattern is slightly larger than those from the previous posting, so here’s the used filter in a little bit more readable way:
( ^lib !-dev$ !-dbg$ !-utils$ !-tools$ !-bin$ !-doc$ !^libreoffice | -data$ | -common$ | -base$ !^r-base ) !~M
It matches all non-automatically installed packages whose name starts with “lib”, but is neither a debug symbols package, a development header package, a documentation package, a package containing supplied commands, nor a libreoffice package.
Additionally it matches all non-automatically installed packages ending in -data, -common, or -base, but excludes r-base packages.
Of course you can then mark any erroneously unmarked library by pressing “M” (Shift-m).
If you press “g” for “Go” afterwards and wonder why nothing to remove shows up, be reminded that the filter limit is active in this view, too. So press “l” for “Limit” and then Ctrl-u to erase the current filter limit of this view and press enter to set the new (now empty) filter, et voilà…
Hope this is of help for some others, too.
Tagged as: aptitude, CLI, Debian, filter, nemo, Netbook, Package Management, pattern, Planet Debian, UUUCO
// show without comments // write a comment
Related stories
Saturday·09·April·2011
Finding packages for deinstallation on the commandline with aptitude //at 20:18 //by abe
Although I often don’t agree with Erich (especially if GNOME is involved ;-), he recently posted something on Planet Debian which I found very helpful.
I also own a netbook where disk space is sacre. It’s an ASUS EeePC 701 with just 4GB disk space. And it runs Debian Sid, so dependencies change often, leaving packages installed which formerly had hard dependencies on, but are now left with just recommendations pointing to it.
Quite a few times I asked myself if it’s possible to find those packages and if so, how to do it. Well, I don’t have to ask myself that anymore, since Erich recently posted the appropriate filter patterns for my favourite package manager aptitude for this task in his posting “Finding packages for deinstallation”. Thanks, Erich!
Since those filters aren’t very easy to remember, I’d like to extend the usefulness of his posting towards the commandline. I for myself added the following aliases to my shell setup:
alias aptitude-just-recommended='aptitude -o "Aptitude::Pkg-Display-Limit=!?reverse-depends(~i) ~M !?essential"' alias aptitude-also-via-dependency='aptitude -o "Aptitude::Pkg-Display-Limit=~i !~M ?reverse-depends(~i) !?essential"'
As youam suggested on
IRC, I also added the filter !?essential
since we won’t
touch essential packages when cleaning up the list of installed
packages anyway.
Hope this helps further.
Tagged as: aptitude, CLI, Debian, filter, nemo, Netbook, Other Blogs, Package Management, pattern, Planet Debian, UUUCO, youam
// show without comments // write a comment