From c617573f7ca65da803615991419db926420f22b1 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Mon, 7 Jul 2008 20:46:40 +0000 Subject: o handle "unrequested orphans" (similar to "deborphan") --- urpmq | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'urpmq') diff --git a/urpmq b/urpmq index 09f9d090..e6b46707 100755 --- a/urpmq +++ b/urpmq @@ -50,6 +50,7 @@ usage: ") . N(" --sortmedia - sort media according to substrings separated by comma. ") . N(" --synthesis - use the given synthesis instead of urpmi db. ") . N(" --auto-select - automatically select packages to upgrade the system. +") . N(" --auto-orphans - list orphans ") . N(" --no-suggests - do not auto select \"suggested\" packages. ") . N(" --fuzzy - impose fuzzy search (same as -y). ") . N(" --keep - keep existing packages if possible, reject requested @@ -137,6 +138,27 @@ $options{nodepslist} = $options{list_aliases} || $options{list_url}; $options{nolock} = 1 if $options{nodepslist}; +#- print sub for query. +my $pkg_to_string = sub { + my ($pkg) = @_; + my $str = ''; + $options{group} and $str .= $pkg->group . '/'; + $str .= $pkg->name; + $options{version} and $str .= '-' . $pkg->version; + $options{release} and $str .= '-' . $pkg->release; + $options{arch} and $str .= '.' . $pkg->arch; + $str; +}; + +if ($options{auto_orphans}) { + !@names && !@src_names or $urpm->{fatal}(1, N("usage: \"urpmq --auto-orphans\" with no argument")); + $options{env} and $urpm->{fatal}(1, N("Can't use %s with %s", '--env', '--auto-orphans')); + require urpm::orphans; + my $orphans = urpm::orphans::get_orphans($urpm); + print "$_\n" foreach sort map { $pkg_to_string->($_) } @$orphans; + exit 0; +} + if ($options{env}) { print N("using specific environment on %s\n", $options{env}); #- setting new environment. @@ -487,14 +509,7 @@ $rpm_lock and $rpm_lock->unlock; #- print sub for query. my $query_sub = sub { my ($id) = @_; - my $pkg = $urpm->{depslist}[$id]; - my $str = ''; - $options{group} and $str .= $pkg->group . '/'; - $str .= $pkg->name; - $options{version} and $str .= '-' . $pkg->version; - $options{release} and $str .= '-' . $pkg->release; - $options{arch} and $str .= '.' . $pkg->arch; - $str; + $pkg_to_string->($urpm->{depslist}[$id]); }; my %hack_only_one; -- cgit v1.2.1