apt-get install debian-wizard

Insider infos, master your Debian/Ubuntu distribution

  • About
    • About this blog
    • About me
    • My free software history
  • Support my work
  • Get the newsletter
  • More stuff
    • Support Debian Contributors
    • Other sites
      • My company
      • French Blog about Free Software
      • Personal Website (French)
  • Mastering Debian
  • Contributing 101
  • Packaging Tutorials
You are here: Home / Documentation / Debian Cleanup Tip #3: get rid of third-party packages

Debian Cleanup Tip #3: get rid of third-party packages

February 14, 2011 by Raphaël Hertzog

Last week, we learned how to get rid of obsolete packages. This time, we’re going to learn how to bring back your computer to a state close to a “pure” Ubuntu/Debian installation.

Thanks to the power of APT, it’s easy to add new external repositories and install supplementary software. Unfortunately some of those are not very well maintained. They might contain crappy packages or they might simply not be updated. An external package which was initially working well, can become a burden on system maintenance because it will be interfering with regular updates (for example by requiring a package that should be removed in newer versions of the system).

So my goal for today is to teach you how to identify the packages on your system that are not coming from Debian or Ubuntu. So that you can go through them from time to time and keep only those that you really need. Obsolete packages are a subset of those, but I’ll leave them alone. We took care of them last week.

Each (well-formed) APT repository comes with a “Release” file describing it (example). They provide some values that can be used by APT to identify packages contained in the repository. All official Debian repositories are documented with Origin=Debian (and Origin=Ubuntu for Ubuntu). You can verify the origin value associated to each repository (if any) in the output of apt-cache policy:

[...]
 500 http://ftp.debian.org/debian/ lenny/main i386 Packages
     release v=5.0.8,o=Debian,a=stable,n=lenny,l=Debian,c=main
     origin ftp.debian.org
[...]

From there on, we can simply ask aptitude to compute a list of packages which are both installed and not available in an official Debian repository:

$ aptitude search '?narrow(?installed, !?origin(Debian))!?obsolete'
or
$ aptitude search '~S ~i !~ODebian !~o'

You can replace “search” with “purge” or “remove” if you want to get rid of all the packages listed. But you’re more likely to want to remove only a subset of carefully chosen packages… you’re probably still using some of the software that you installed from external repositories.

With synaptic, you can also browse the content of each repository. Click on the “Origin” button and you have a list of repositories. You can go through the non-Debian repositories and look which packages are installed and up-to-date.

But you can do better, you can create a custom view. Click on the menu entry “Settings > Filter”. Click on “New” to create a new filter and name it “External packages”. Unselect everything in the “Status” tab and keep only “Installed”.

Go in the “Properties” tab and here add a new entry “Origin” “Excludes” “ftp.debian.org”. In fact you must replace “ftp.debian.org” with the hostname of your Debian/Ubuntu mirror. The one that appears on the “origin” line in the output of apt-cache policy (see the excerpt quoted above in this article).

Note that the term “Origin” is used to refer to two different things, a field in the release file but also the name of the host for an APT repository. It’s a bit confusing if you don’t pay attention.

Close the filters window with OK. You now have a new listing of “External packages” under the “Custom Filters” screen. You can see which packages are installed and up-to-date and decide whether you really want to keep it. If the package is also provided by Debian/Ubuntu and you want to go back to the version provided by your distribution, you can use the “Package > Force version…” menu entry.

Click here to subscribe to my free newsletter and get my monthly analysis on what’s going on in Debian and Ubuntu. Or just follow along via the RSS feed, Identi.ca, Twitter or Facebook.

Filed Under: Documentation, User Documentation Tagged With: aptitude, Cleanup, Debian, external, HOWTO, Origin, release, synaptic, Ubuntu

Comments

  1. Anonymous says

    February 14, 2011 at 10:45 am

    On a related note, aptitude can also check for packages which exist in Debian but not with the version you have: ?not(?narrow(?version(CANDIDATE), ?archive(unstable)))

    Replace “unstable” with “testing” or “stable” if you use those. This will also show you any packages you have installed from experimental; if you want to exclude those too, repeat the whole stanza once for each distribution you use.

    • Raphaël Hertzog says

      February 14, 2011 at 12:17 pm

      Or rather, if you want to find all installed packages which are not coming from the main Debian repository that are you’re tracking, you can use this (example with “testing” as the main repo):

      aptitude search '?narrow(?installed, !?archive(testing)?origin(Debian))'

      Beware it will show any package that is installed and that doesn’t match the version available in testing, including packages that you have not yet upgraded but also packages that you might have grabbed elsewhere (sid, experimental, etc.)

  2. Greg says

    February 14, 2011 at 11:05 am

    Great articles. Thanks a lot.
    If you dont mind i have a request.
    Could you do a round up of all Debian packaging related utilities you can think of when you’re done with this series? There are a lot of them in the repositories and its very hard to keep track. For example utilites like dctrl-tools you mentioned in the first article, deborphan and useful utilities like those? Maybe even a series with examples of usage for each one. Thanks again!

    • Raphaël Hertzog says

      February 14, 2011 at 12:05 pm

      Thanks for the feedback Greg, I have noted your suggestion and I might do it at some point.

  3. Paulus says

    February 14, 2011 at 11:19 am

    Elegant and very useful, thanks!

  4. debish says

    February 15, 2011 at 12:33 am

    Wonderful, once again.

    Thanks so much!

  5. Linulin says

    February 15, 2011 at 12:44 am

    I usually use a combination of deborphan and apt-show-versions |grep -v testing for the same purpose. Works good enough for testing-based installation + a few packages from unstable and experimental + a couple from external sources, and much easier to remember 😉

    BTW, Raphaël, on my system, your aptitude search command actually returns a list of manually recompiled official packages, and I definitely would not want to do a purge for them 😉

  6. Ana says

    February 21, 2011 at 11:09 pm

    Very interesting again Raphaël, but while reading through … this time … something regarding to repositories came to my mind. I have three different Ubuntu instalations, each of them with around 20 (yes twenty) external repositories defined. The thing is that every six months, after each version upgrade, I have to redefine them all to properly work … around 60 redefinitions … my godness !!!

    I think that one of your future tips (say tip number x) could be related to this issue and explain us a way to mitigate this lack of repository definitions’ flexibility after an upgrade.

    Thank you and regards.

    • Raphaël Hertzog says

      February 21, 2011 at 11:42 pm

      Hi Ana, I’m not sure I understand your request… it’s easy to edit /etc/apt/sources.list and do a search & replace on the distribution name for example.

      It might not be so convenient in the graphical interface however. 🙂

      But using 20 external repositories is a lot, are they really needed? It’s a failure of Debian/Ubuntu if so many useful applications are missing from the main repositories (or from backports if you need newer versions).

      • Ana says

        February 22, 2011 at 12:24 am

        Well … it is more related to ‘up to date’ applications than to missing applications.

        Some of the repositories doesn’t hold just one updated application but many dozens of them. So that you define some very useful and well known repositories … and in some way you’re granting having last stable updates from many apps … it’s so nice …

        Other repos are just upstream ppas … which are very useful too. One example (there’re lots) is … if you want having last Shutter 0.87 … you define (I do it through GUI) its ppa (ppa:shutter/ppa) … and you will have the last stable software. But coming back to my initial request, these ppa definitions turn unusable after an Ubuntu version upgrade. I have to delete them all and redefine them from the scratch (60 deletions and 60 definitions … 120 updates … things are getting worse 😉

        You suggested to edit /etc/apt/sources.list … but I can find there only the ‘oficial’ repos. I don’t know where the ‘manual added’ repository definitions are kept … so 120 updates … using GUI … ONE AT A TIME … … … yes … it’s a bit frustrating …

        • Raphaël Hertzog says

          February 22, 2011 at 12:49 am

          Look into /etc/apt/sources.list.d/ there’s probably one file with your repositories.

          I know it’s nice to have the latest versions, but unfortunately it’s also a source of problems because you’re using unofficial packages and upgrades are only tested with the official packages. If you encounter problems, you’re then on your own. So it’s a trade-off to consider…

          • Ana says

            February 22, 2011 at 1:39 am

            Yes … it seems they are here (/etc/apt/sources.list.d/) … they are 48 elements whose names are blablabla-bla-maverick.list and blablabla-bla-maverick.list.save (and whose content also points to maverick) … I guess that’s why they will turn unusable when I migrate from maverick to natty.

            You’re right when you say there’s a trade-off … in my particular case, my ONLY drawback so far is the 120 manual updates every single semester.

            From an end-user point of view … yes , I understand the trade-off you mean, but … even though this trade-off, I have been given the opportunity (and the power) to choose … using ‘apt’ utility … and this is great … there’s a trade-off but you still have the chance to choose. And … in my particular case … I am NOT having neither consistency nor logic problems with these ‘manually added’ software … my problem is structural … the freedom ‘apt’ utility is giving me … is broken when I am upgrading version release.

            I appretiate the freedom ‘apt’ utility is giving me (to be ‘out of the law’) … and I would like, in the future … one day … this freedom could be kept even while upgrading version releases.

            Thank you and regards Raphaël.

  7. Thibault Févry says

    February 26, 2011 at 2:06 am

    It looks like this is the only one of the Debian Cleanup Series that hasn’t the HOWTO tag, there maybe a reason, but just wanted to mention it in case you forgot it.

    • Raphaël Hertzog says

      February 26, 2011 at 10:05 am

      Fixed, thanks.

Trackbacks

  1. Linux Blog » Blog Archive » Čistíme systém snadno a rychle says:
    February 14, 2011 at 6:44 pm

    […] Hertzog píše, jak se zbavit starých nepotřebných balíků. Pro mnohé uživatele budou rovněž přínosné […]

  2. Garder un système Debian propre, astuce n°3 : se débarrasser des paquets externes à Debian says:
    September 14, 2011 at 11:22 am

    […] « Paquet > Forcer version ». Ceci est une traduction de mon article Debian Cleanup Tip #3: get rid of third-party packages contribuée par Weierstrass01. Ne manquez pas une occasion de parfaire vos connaissances de Debian […]

Get the Debian Handbook

Available as paperback and as ebook.
Book cover

Email newsletter

Get updates and exclusive content by email, join the Debian Supporters Guild:

Follow me

  • Email
  • Facebook
  • GitHub
  • RSS
  • Twitter

Discover my French books

Planets

  • Planet Debian

Archives

I write software, books and documentation. I'm a Debian developer since 1998 and run my own company. I want to share my passion and knowledge of the Debian ecosystem. Read More…

Tags

3.0 (quilt) Activity summary APT aptitude Blog Book Cleanup conffile Contributing CUT d-i Debconf Debian Debian France Debian Handbook Debian Live Distro Tracker dpkg dpkg-source Flattr Flattr FOSS Freexian Funding Git GNOME GSOC HOWTO Interview LTS Me Multiarch nautilus-dropbox News Packaging pkg-security Programming PTS publican python-django Reference release rolling synaptic Ubuntu WordPress

Recent Posts

  • Freexian is looking to expand its team with more Debian contributors
  • Freexian’s report about Debian Long Term Support, July 2022
  • Freexian’s report about Debian Long Term Support, June 2022
  • Freexian’s report about Debian Long Term Support, May 2022
  • Freexian’s report about Debian Long Term Support, April 2022

Copyright © 2005-2021 Raphaël Hertzog