apt and automatic removal of unused dependencies

Martin Meredith martin at sourceguru.net
Tue Jul 5 12:32:46 CDT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

What about packages that have no dependencies? or dont depend on anything?

Michael Vogt wrote:
> Hi,
> 
> I build a testversion of apt and (most) of the dependent packages
> (aptitude, synaptic, python-apt) with support for automatic removal of
> unused depedencies. 
> 
> This feature was pioneered by Daniel Burrows aptitude [1] and it works
> by keeping track of what packages where installed as part of a
> automatic dependency resolution and what where installed manually. If
> a packages P was installed to satisfy a depedency and no other package
> needs that depedency anymore, P will be removed automatically.
> 
> The patched version of apt support keeping track of automatic
> depedencies now regardless if you install packages with apt-get,
> aptitutde, python-apt or synaptic. The removal will happen if you run: 
> $ sudo apt-get remove --auto-remove $packagename
> 
> Example (after a normal apt-get install licq):
> # apt-get remove licq
> Reading package lists... Done
> Building dependency tree... Done
> The following packages will be REMOVED:
>   licq licq-plugin-rms
> 0 upgraded, 0 newly installed, 2 to remove and 462 not upgraded.
> 
> # apt-get remove --auto-remove licq
> Reading package lists... Done
> Building dependency tree       
> Reading state information... Done
> We could delete libgpgme6
> The following packages will be REMOVED:
>   libgpgme6 licq licq-plugin-rms
> 0 upgraded, 0 newly installed, 3 to remove and 461 not upgraded.
> 
> Synaptic also supports this now and will automatically mark unused
> dependencies for removal (it ask kindly first of course before it
> removes anything). It can be turned off by starting synaptic with: 
> # synaptic -o Synaptic::AutoRemove=false 
> (it will save that option on exit).
> 
> Aptitude will work as before, but apt does not know about the
> information from aptitude. You will have to run the attached script to
> bring aptitudes information to apt. aptitude will not (yet) make use
> of the information from apt, but I'm in contact with Daniel and once
> we resolved the remaining (small) issues, he will add support for the
> new libapt support.
> 
> The repository (source, i386) is available at:
> 
> deb http://people.ubuntu.com/~mvo/apt/auto-remove /
> 
> signed with my gpg key.
> 
> Please test it and see if it is doing what it should do. Remember that
> this is pretty new code, so keep a backup copy of the breezy apt
> around in case there are problems (also it apt will only do
> auto-removals when run with --auto-remove, so it _should_ be pretty
> save). There may be some debug output here and there, sorry for
> that. If apt acts strange you can get debug information of what it is
> doing with: 
> 
> # apt-get -o Debug::pkgAutoRemove=true remove --auto-remove $packagename
> 
> 
> it also supports the config option:
> APT::NeverAutoremove 
> (for things like "^linux-kernel.*")
> 
> The code is available in
> michael.vogt at ubuntu.com--2005/apt--auto-mark--0 [2]
> 
> Cheers,
>  Michael
> 
> P.S. Please mail problems (like apt forgetting about auto installed
> packages, stupid suggestion to remove packages etc) to me
> directly. Keep a eye on /var/lib/apt/pkgstates, that's where it stores
> it's information. I'll be on vacation next week so don't worry if I
> don't answer immediately.
> 
> [1] And Daniel was very helpfull and answered all my silly questions
>     when I worked on the version for libapt
> [2] at http://people.ubuntu.com/~mvo/arch/ubuntu
> 
> 
> ------------------------------------------------------------------------
> 
> #!/usr/bin/env python
> 
> import apt_pkg
> import sys
> 
> parse = apt_pkg.ParseTagFile(open("/var/lib/aptitude/pkgstates"))
> out = open("/var/lib/apt/pkgstates","a")
> 
> while parse.Step() == True:
> 	change_reason = parse.Section.get("Last-Change") 
> 	if change_reason == "1" or change_reason == "2":
> 		out.write("Package: %s\n" % parse.Section.get("Package"))
> 		out.write("Auto-Installed: 1\n\n")
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCysQ+UNcmPOEdeBMRAoNTAJ9zI1+ZQC5hihUdgNYXsebuLhpgGACePxOf
mZL7BfoiTusiNfmZIGN6Us8=
=v10Y
-----END PGP SIGNATURE-----




More information about the ubuntu-devel mailing list