diff options
author | Francois Pons <fpons@mandriva.com> | 2002-07-23 18:25:42 +0000 |
---|---|---|
committer | Francois Pons <fpons@mandriva.com> | 2002-07-23 18:25:42 +0000 |
commit | d7a2c64f600aac4c2b504cb12fe00280af58ce53 (patch) | |
tree | 15b086b1c69bb47b3710bbdd28c5fe729cfec089 | |
parent | 8598875c5afcaef8d468ec31e3ad99abd081a414 (diff) | |
download | urpmi-d7a2c64f600aac4c2b504cb12fe00280af58ce53.tar urpmi-d7a2c64f600aac4c2b504cb12fe00280af58ce53.tar.gz urpmi-d7a2c64f600aac4c2b504cb12fe00280af58ce53.tar.bz2 urpmi-d7a2c64f600aac4c2b504cb12fe00280af58ce53.tar.xz urpmi-d7a2c64f600aac4c2b504cb12fe00280af58ce53.zip |
3.9-2mdk
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | rpm-find-leaves | 23 | ||||
-rw-r--r-- | urpm.pm | 6 | ||||
-rw-r--r-- | urpme | 67 | ||||
-rw-r--r-- | urpmi.spec | 12 |
5 files changed, 63 insertions, 47 deletions
@@ -7,7 +7,7 @@ URPMIDIR = $(PREFIX)/var/lib/urpmi URPMIDIR2 = $(PREFIX)/etc/urpmi LOCALEDIR = $(PREFIX)/usr/share/locale CFLAGS = -Wall -g -LIBRPM = -lrpm -lrpmio `perl -e 'use rpmtools; rpmtools::version_compare(qx(rpm -q --qf %{VERSION} rpm), "4.0.3") >= 0 and print "-lrpmdb"'` -lz -lbz2 -I/usr/include/rpm -lpopt +LIBRPM = -lrpm -lrpmio -lrpmdb -lz -lbz2 -I/usr/include/rpm -lpopt NAME = urpmi TAR = $(NAME).tar.bz2 diff --git a/rpm-find-leaves b/rpm-find-leaves index 32d9668c..5c7fb496 100644 --- a/rpm-find-leaves +++ b/rpm-find-leaves @@ -2,21 +2,24 @@ @ARGV and die "usage: rpm-find-leaves\n"; -use rpmtools; - -$db = rpmtools::db_open(''); -rpmtools::db_traverse($db, [ qw(name version release provides requires) ], sub { - push @packages, $_[0]; -}); -rpmtools::db_close($db); +use URPM; +my @packages; +{ + my $db = URPM::DB::open; + $db->traverse(sub { + my ($p) = @_; + $p->pack_header; + push @packages, $p; + }); +} foreach my $pkg (@packages) { - $l{$pkg->{name}} = 1; - push @{$provides{$_}}, $pkg->{name} foreach @{$pkg->{provides} || []}; + $l{$pkg->name} = 1; + push @{$provides{$_}}, $pkg->name foreach $pkg->provides_nosense; } foreach my $pkg (@packages) { - delete @l{grep { $_ ne $pkg->{name} } @{$provides{$_} || []}} foreach @{$pkg->{requires} || []}; + delete @l{grep { $_ ne $pkg->name } @{$provides{$_} || []}} foreach $pkg->requires_nosense; } print "$_\n" foreach sort keys %l; @@ -1879,8 +1879,10 @@ sub install { return fileno F; }; $options{callback_close} ||= sub { close F }; - $options{callback_inst} ||= \&install_logger; - $options{callback_trans} ||= \&install_logger; + if (keys %$install || keys %$upgrade) { + $options{callback_inst} ||= \&install_logger; + $options{callback_trans} ||= \&install_logger; + } @l = $trans->run($urpm, %options); } @@ -1,6 +1,7 @@ #!/usr/bin/perl # Copyright (C) 1999,2002 MandrakeSoft <pixel@linux-mandrake.com> +# <fpons@mandrakesoft.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -20,7 +21,8 @@ use strict; #use strict qw(subs vars refs); -use rpmtools; +use URPM; +use URPM::Resolve; use urpm; #- get I18N translation method. @@ -64,40 +66,42 @@ if ($matches || $maymatch) { } } -my %toremove; @toremove{@m} = (); -my $changed = 1; -while ($changed) { - $changed = 0; - local *F; - open F, "LANGUAGE=C rpm -e --test " . join(" ", keys %toremove) . " 2>&1 |"; - foreach (<F>) { - if (/package (\S+) is not installed/) { - delete $toremove{$1}; - } elsif (/is needed by (\S+)/ && ! exists $toremove{$1}) { - $toremove{$1} = 1; - $changed = 1; - } - } -} -if ( ! (@toremove = keys %toremove) ) { - print _("Nothing to remove.\n"); - exit(0); -} +my $urpm = new urpm; +my $state = {}; -#- check if a package to be removed is a part of basesystem requires. my %base; my @base = qw(basesystem); my %basepackages; -my $db = rpmtools::db_open(''); -while (defined($_ = shift @base)) { - exists $basepackages{$_} and next; - rpmtools::db_traverse_tag($db, /^\// ? 'path' : 'whatprovides', [ $_ ], [ qw(name version release requires) ], sub { - my ($p) = @_; - push @{$basepackages{$_} ||= []}, "$p->{name}-$p->{version}-$p->{release}"; - push @base, @{$p->{requires} || []}; - }); + +#- closure all package asked to be removed. +{ + my $db = URPM::DB::open; + foreach (@m) { + my ($n) = /(.*)-[^-]*-[^-]*/; + $db->traverse_tag('name', [ $n ], sub { + my ($p) = @_; + join('-', ($p->fullname)[0..2]) eq $_ or return; + $urpm->resolve_closure_ask_remove($db, $state, $p, undef); + }) or die _("unknown package ") . "$_\n"; + } + + #- if nothing need to be removed. + unless (%{$state->{ask_remove} || {}}) { + print _("Nothing to remove.\n"); + exit(0); + } + + #- check if a package to be removed is a part of basesystem requires. + while (defined($_ = shift @base)) { + exists $basepackages{$_} and next; + $db->traverse_tag(/^\// ? 'path' : 'whatprovides', [ $_ ], sub { + my ($p) = @_; + push @{$basepackages{$_} ||= []}, join '-', ($p->fullname)[0..2]; + push @base, $p->requires_nosense; + }); + } } -rpmtools::db_close($db); + foreach (values %basepackages) { my $n = @$_; foreach (@$_) { @@ -105,6 +109,7 @@ foreach (values %basepackages) { } } my $base_str = ''; +my @toremove = keys %{$state->{ask_remove}}; foreach (@toremove) { my $rn = $base{$_}; if ($rn) { @@ -121,8 +126,8 @@ if (@toremove > @l && !$auto) { print STDOUT "$msg:\n@toremove\n$askok" . _(" (Y/n) "); <STDIN> =~ /[$noexpr]/ and exit 0; } -system("rpm", "-e", @toremove); +$urpm->install('/', \@toremove, {}, {}); sub toMb { my $nb = $_[0] / 1024 / 1024; @@ -2,14 +2,14 @@ Name: urpmi Version: 3.9 -Release: 1mdk +Release: 2mdk License: GPL Source0: %{name}.tar.bz2 Source1: %{name}.logrotate Summary: User mode rpm install Requires: eject webfetch perl-DateManip >= 5.40 -PreReq: perl-Locale-gettext rpmtools >= 4.3-2mdk perl-URPM >= 0.50 -BuildRequires: bzip2-devel gcc-c++ gettext rpm-devel rpmtools +PreReq: perl-Locale-gettext rpmtools >= 4.3-6mdk perl-URPM >= 0.50-2mdk +BuildRequires: bzip2-devel gcc-c++ gettext rpm-devel >= 4.0.3 BuildRoot: %{_tmppath}/%{name}-buildroot BuildArch: noarch @@ -144,6 +144,12 @@ fi %changelog +* Tue Jul 23 2002 François Pons <fpons@mandrakesoft.com> 3.9-2mdk +- updated urpme to use perl-URPM and speed it up (no more + rpm -e --test ...). +- updated rpm-find-leaves to use perl-URPM. +- dropped build requires to rpmtools (but need rpm >= 4.0.3). + * Tue Jul 23 2002 François Pons <fpons@mandrakesoft.com> 3.9-1mdk - updated to use perl-URPM >= 0.50. |