public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: Daniel Pielmeier <daniel.pielmeier@googlemail.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user]  Re: Question about difference between emerge --update world and emerge vigra
Date: Mon, 29 Sep 2008 22:33:27 +0200	[thread overview]
Message-ID: <48E13B97.5090900@googlemail.com> (raw)
In-Reply-To: <loom.20080925T181937-967@post.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 1831 bytes --]

James schrieb am 25.09.2008 20:32:
> Surely many folks would benefit from a formal, systematic approach
> to cleaning the world file?  I know every now and then, when a gentoo
> workstation gives me fits, I just emerge and unemerge things until
> it's happy (while multitasking too much). Often this leads to
> a polluted world file....... because I do not follow closely to
> the process details (distracted) during the repair-episode.
> 

Something in addition to this topic.

I asked on IRC (#gentoo-portage) if it is possible to show the reverse
dependencies of a package with portage. Zac Medico, one of the main
portage developers told me that it is possible with depclean.

emerge -pv --depclean <atom>

So I thought of writing a little script which calls this command for
every entry in the world file. As I have only limited programming skills
I wrote something quick in perl. It should be no problem to do it with a
shell script or something else too. It simply checks the output of
depclean for strings which only occur when the package has or has no
reverse dependencies. Then it prints the package to be checked and if it
is needed in world or not. It actually does not remove anything, so it
is up to you if you want to leave a package in world or not for whatever
reason you have.

The script could probably be improved in a few ways and it is slow as
depclean takes some time. It works for current stable portage. I don't
know if it will work for portage-2.2 as the output of depclean has
changed as far as I know.

Don't rely on this script to much. Because it works for me must not mean
it does for you. I have tested some cases and I worked every time until
now. So verify the output of a manual "emerge -pv --depclean <atom>" on
the "unneeded" entry first to be sure it is really not needed.

Regards,

Daniel


[-- Attachment #2: check-world.pl --]
[-- Type: text/plain, Size: 901 bytes --]

#!/usr/bin/perl
#
#
#

use strict;
use diagnostics;
use warnings;

my ($package,$status,$line) = ();
my @depclean = ();
my $vdb_path = qx(portageq vdb_path);
chomp($vdb_path);

format STDOUT_TOP =
Atom:                                            Status: (required in world)
.

format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$package, $status
.

print "Examining: $vdb_path/world\n\n";

open(WORLD,"<$vdb_path/world") || die("world: $!");

foreach $package (<WORLD>) {
	chomp $package;
	@depclean = qx(emerge -pv --depclean "$package");
	foreach $line ( @depclean ) {
		if ( $line =~ ">>> These are the packages that would be unmerged:" ) {
			$status = "needed";
			write;
		} elsif ( $line =~ ">>> No packages selected for removal by depclean" ) {
			$status = "unneeded";
			write;
		} else {
			$status = "Error: Something bad happened";
		}
	}
}



  reply	other threads:[~2008-09-29 20:33 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-25  4:05 [gentoo-user] Question about difference between emerge --update world and emerge vigra SOrCErEr
2008-09-25  5:13 ` Thomas Kahle
2008-09-25  6:16   ` Volker Armin Hemmann
2008-09-25  5:24 ` Marc Joliet
2008-09-25  6:24 ` Alan McKinnon
2008-09-25  9:54   ` SOrCErEr
2008-09-25 10:12     ` Vladimir Rusinov
2008-09-25 10:26       ` Alan McKinnon
2008-09-26  3:56         ` SOrCErEr
2008-09-25 10:23     ` Neil Bothwick
2008-09-25 10:27 ` Daniel Pielmeier
2008-09-25 15:08   ` [gentoo-user] " James
2008-09-25 15:29     ` Neil Bothwick
2008-09-25 15:51     ` Daniel Pielmeier
2008-09-25 18:32       ` James
2008-09-29 20:33         ` Daniel Pielmeier [this message]
2008-09-30 11:28           ` Paul Stear
2008-09-30 12:32             ` Daniel Pielmeier
2008-09-25 20:15       ` Alan McKinnon
2008-09-25 20:55         ` Paul Hartman
2008-09-25 21:43           ` Neil Bothwick
2008-09-25 21:59             ` Alan McKinnon
2008-09-25 22:53               ` Neil Bothwick
2008-09-25 15:51   ` [gentoo-user] " Hilco Wijbenga
2008-09-25 20:38     ` Alan McKinnon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48E13B97.5090900@googlemail.com \
    --to=daniel.pielmeier@googlemail.com \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox