From a73a3e74e32ec5360b62c68f8a80b55a4b79bfdd Mon Sep 17 00:00:00 2001 From: Francois Pons Date: Fri, 16 Feb 2001 13:01:02 +0000 Subject: *** empty log message *** --- po/Makefile | 4 +- po/POTFILES.in | 3 ++ urpm.pm | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ urpmi | 17 +++++-- urpmi.addmedia | 16 +++---- urpmi.removemedia | 15 +++++-- urpmi.spec | 8 +++- urpmi.update | 15 +++++-- urpmq | 13 +++--- 9 files changed, 191 insertions(+), 29 deletions(-) diff --git a/po/Makefile b/po/Makefile index 26e4596a..5f594bde 100644 --- a/po/Makefile +++ b/po/Makefile @@ -1,5 +1,5 @@ # Installation directories -localedir = $(prefix)/usr/share/locale +localedir = $(PREFIX)/usr/share/locale LANGS = $(shell ls *.po | xargs -i basename {} .po ) PGOAL = urpmi @@ -25,7 +25,7 @@ clean: ./create_placeholder xgettext --default-domain=`basename $@ .pot` --directory=.. \ --add-comments --keyword=__ --keyword=_ --keyword=N_ \ - --keyword=I_ --keyword=i18n + --keyword=I_ --keyword=i18n \ --files-from=./POTFILES.in && \ mv `basename $@ .pot`.po $@ diff --git a/po/POTFILES.in b/po/POTFILES.in index 05e90c70..7a9df3e3 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,6 +1,9 @@ _irpm placeholder.h +urpm.pm urpmf urpmi urpmi.addmedia +urpmi.update +urpmi.removemedia urpmq diff --git a/urpm.pm b/urpm.pm index c673cc20..69da34c4 100644 --- a/urpm.pm +++ b/urpm.pm @@ -924,6 +924,135 @@ sub filter_packages_to_upgrade { $packages; } +sub filter_minimal_packages_to_upgrade { + my ($urpm, $packages, $select_choices, %options) = @_; + + #- make a subprocess here for reading filelist, this is important + #- not to waste a lot of memory for the main program which will fork + #- latter for each transaction. + local (*INPUT, *OUTPUT_CHILD); pipe INPUT, OUTPUT_CHILD; + local (*INPUT_CHILD, *OUTPUT); pipe INPUT_CHILD, OUTPUT; + if (my $pid = fork()) { + close INPUT_CHILD; + close OUTPUT_CHILD; + select((select(OUTPUT), $| = 1)[0]); + + #- internal reading from interactive mode of parsehdlist. + #- takes a code to call with the line read, this avoid allocating + #- memory for that. + my $ask_child = sub { + my ($name, $tag, $code) = @_; + $code or die "no callback code for parsehdlist output"; + print OUTPUT "$name:$tag\n"; + + local $_; + while () { + chomp; + /^\s*$/ and last; + $code->($_); + } + }; + + my ($db, @packages) = (rpmtools::db_open(''), keys %$packages); + my ($id, %provides, %installed); + + #- select first level of packages, as in packages list will only be + #- examined deps of each. + @{$packages}{@packages} = (); + + #- at this level, compute global closure of what is requested, regardless of + #- choices for which all package in the choices are taken and their dependancies. + #- allow iteration over a modifying list. + while (defined($id = shift @packages)) { + if (ref $id) { + #- at this point we have almost only choices to resolves. + #- but we have to check if one package here is already selected + #- previously, if this is the case, use it instead. + foreach (@$id) { + exists $packages->{$_} and $id = undef, last; + } + defined $id or next; + + #- propose the choice to the user now, or select the best one (as it is supposed to be). + my @selection = $select_choices ? ($select_choices->($urpm, @$id)) : ($id->[0]); + foreach (@selection) { + unshift @packages, $_; + $packages->{$_} = undef; + } + } + my $pkg = $urpm->{params}{depslist}[$id]; + + #- iterate over requires of the packages, register them. + $ask_child->("$pkg->{name}-$pkg->{version}-$pkg->{release}", "requires", sub { + if ($_[0] =~ /^(\S*)\s*(\S*)\s*([^\s-]*)-?(\S*)/) { + exists $provides{$1} and return; + rpmtools::db_traverse_tag($db, + 'whatprovides', [ $1 ], + [ qw (name version release) ], sub { + $3 and eval(rpmtools::version_compare($_[0]{version}, $3) . $2 . 0) || return; + $4 and eval(rpmtools::version_compare($_[0]{release}, $4) . $2 . 0) || return; + print STDERR "providing [$1] as $_[0]{name}-$_[0]{version}-$_[0]{release}\n"; + $provides{$1} = "$_[0]{name}-$_[0]{version}-$_[0]{release}"; + }) or $provides{$1} = undef; + } + }); + + #- at this point, all unresolved provides (requires) should be fixed by + #- provides files, try to minimize choice at this level. + foreach (keys %provides) { + $provides{$_} and next; + print STDERR "trying to resolve [$_]\n"; + my (@choices, @upgradable_choices); + foreach (@{$urpm->{params}{provides}{$_}}) { + my $pkg = $urpm->{params}{info}{$_}; + if (! exists $packages->{$pkg->{id}}) { + #- prefer upgrade package that need to be upgraded, if they are present in the choice. + push @choices, $pkg; + rpmtools::db_traverse_tag($db, + 'name', [ $_ ], + [ qw(name version release) ], sub { + my ($p) = @_; + my $cmp = rpmtools::version_compare($pkg->{version}, $p->{version}); + $installed{$pkg->{id}} ||= !($cmp > 0 || $cmp == 0 && rpmtools::version_compare($pkg->{release}, $p->{release}) > 0) + }); + } + $installed{$pkg->{id}} and delete $packages->{$pkg->{id}}; + if (exists $packages->{$pkg->{id}} || $installed{$pkg->{id}}) { + #- the package is already selected, or installed with a better version and release. + @choices = @upgradable_choices = (); + last; + } + exists $installed{$pkg->{id}} and push @upgradable_choices, $pkg; + } + @upgradable_choices > 0 and @choices = @upgradable_choices; + if (@choices > 0) { + if (@choices == 1) { + $packages->{$choices[0]{id}} = undef; + unshift @packages, $choices[0]{id}; + } else { + push @packages, [ sort { $a->{id} <=> $b->{id} } @choices ]; + } + } + } + } + + rpmtools::db_close($db); + + #- no need to still use the child as this point, we can let him to terminate. + close OUTPUT; + close INPUT; + waitpid $pid, 0; + } else { + close INPUT; + close OUTPUT; + open STDIN, "<&INPUT_CHILD"; + open STDOUT, ">&OUTPUT_CHILD"; + exec "parsehdlist", "--interactive", map { "$urpm->{statedir}/$_->{hdlist}" } grep { ! $_->{ignore} } @{$urpm->{media}} + or rpmtools::_exit(1); + } + +} + #- select source for package selected. #- according to keys given in the packages hash. #- return a list of list containing the source description for each rpm, diff --git a/urpmi b/urpmi index 473803ec..b7526097 100755 --- a/urpmi +++ b/urpmi @@ -36,6 +36,7 @@ my $force = 0; my $X = 0; my $all = 0; my $complete = 0; +my $minimal = 0; my $rpm_opt = "-Uvh"; my $verbose = 0; @@ -87,6 +88,7 @@ for (@ARGV) { /[\?h]/ and do { usage; next }; /a/ and do { $all = 1; next }; /c/ and do { $complete = 1; next }; + /m/ and do { $minimal = 1; next }; /q/ and do { $rpm_opt = "-U"; next }; /v/ and do { $verbose = 1; next }; die "urpmi: unknown option \"-$1\", check usage with --help\n"; } next }; @@ -137,7 +139,7 @@ $urpm->relocate_depslist; #- basesystem is added to the list so if it need to be upgraded, all its dependancy #- will be updated too. my %packages; -$urpm->search_packages(\%packages, [ 'basesystem', @names], all => $all) or $force or exit 1; +$urpm->search_packages(\%packages, [ ($minimal ? () : ('basesystem')), @names], all => $all) or $force or exit 1; #- auto select package for upgrading the distribution. if ($auto_select) { @@ -151,7 +153,7 @@ if ($auto_select) { } #- filter to add in packages selected required packages. -$urpm->filter_packages_to_upgrade(\%packages, sub { +my $ask_choice = sub { my ($urpm, @choices_id) = @_; my $n = 1; #- default value. my @l = map { my $info = $urpm->{params}{depslist}[$_]; "$info->{name}-$info->{version}-$info->{release}" } @choices_id; @@ -174,7 +176,14 @@ $urpm->filter_packages_to_upgrade(\%packages, sub { } $choices_id[$n - 1]; -}, complete => $complete); +}; +if ($minimal) { + $urpm->read_provides; + $urpm->read_config; + $urpm->filter_minimal_packages_to_upgrade(\%packages, $ask_choice); +} else { + $urpm->filter_packages_to_upgrade(\%packages, $ask_choice, complete => $complete); +} #- package to install as a array of strings. my @to_install; @@ -208,7 +217,7 @@ if (!$auto) { } } -$urpm->read_config(); +$urpm->read_config; my ($local_sources, $list) = $urpm->get_source_packages(\%packages); unless ($local_sources || $list) { diff --git a/urpmi.addmedia b/urpmi.addmedia index 0ef150bf..8917a945 100755 --- a/urpmi.addmedia +++ b/urpmi.addmedia @@ -35,21 +35,21 @@ sub main { my $usage = sprintf( _("usage: urpmi.addmedia where is one of - file:// - ftp://:@/ with - ftp:/// with - http:/// with - removable__:// + file:// + ftp://:@/ with + ftp:/// with + http:/// with + removable_:// ")); $name or die $usage; my ($type, $dev) = $url =~ m,^(file|ftp|http|removable_(\w+)(?:_\d+)?)://, or die $usage; if ($type eq "removable") { - $dev && -e "/dev/$dev" or die( sprintf _( "$usage device `$dev' do not exist\n")); + $dev && -e "/dev/$dev" or die(sprintf _("%s\ndevice `%s' do not exist\n"), $usage, $dev); } elsif ($with eq "with") { - $relative_hdlist or die( sprintf _( "$usage missing\n")); + $relative_hdlist or die(sprintf _("%s\n missing\n"), $usage); } elsif ($with) { - $with eq "with" or die( sprintf _( "$usage `with' missing for ftp media\n")); + $with eq "with" or die(sprintf _("%s\n`with' missing for ftp media\n"), $usage); } my $urpm = new urpm; diff --git a/urpmi.removemedia b/urpmi.removemedia index 3f19faca..bfeb1f4b 100755 --- a/urpmi.removemedia +++ b/urpmi.removemedia @@ -20,13 +20,22 @@ #use strict qw(subs vars refs); use urpm; +# for i18n +use POSIX; +use Locale::GetText; + +setlocale (LC_ALL, ""); +Locale::GetText::textdomain ("urpmi"); + +import Locale::GetText I_; +*_ = *I_; sub main { my (@toremoves, %options); foreach (@_) { /^--?a/ and $options{all} = 1, next; - /^-/ and die "unknown options \"$_\"\n"; + /^-/ and die sprintf(_("unknown options \"%s\"\n"), $_); push @toremoves, $_; } @@ -35,9 +44,9 @@ sub main { if ($options{all}) { @toremoves = @entries; - @toremoves == 0 and die "nothing to remove (use urpmi.addmedia to add a media)\n"; + @toremoves == 0 and die _("nothing to remove (use urpmi.addmedia to add a media)\n"); } - @toremoves == 0 and die "missing the entry to remove\n(one of " . join(", ", @entries) . ")\n"; + @toremoves == 0 and die sprintf(_("missing the entry to remove\n(one of %s)\n"), join(", ", @entries)); $urpm->remove_media(@toremoves); $urpm->update_media; diff --git a/urpmi.spec b/urpmi.spec index a72ad43f..1933628e 100644 --- a/urpmi.spec +++ b/urpmi.spec @@ -2,7 +2,7 @@ Name: urpmi Version: 1.5 -Release: 2mdk +Release: 3mdk License: GPL Source0: %{name}.tar.bz2 Summary: User mode rpm install @@ -113,6 +113,12 @@ autoirpm.uninstall %changelog +* Fri Feb 16 2001 François Pons 1.5-3mdk +- added -m flag to urpmi for minimal upgrade. +- fixed urpmq olding approach of local rpm (added --force too + as in urpmi). +- fixed some i18n usage. + * Wed Feb 14 2001 François Pons 1.5-2mdk - removable medium are not automatically updated now. - remove need of number removable device when adding a new medium. diff --git a/urpmi.update b/urpmi.update index 7346de86..1982d287 100755 --- a/urpmi.update +++ b/urpmi.update @@ -20,6 +20,15 @@ #use strict qw(subs vars refs); use urpm; +# for i18n +use POSIX; +use Locale::GetText; + +setlocale (LC_ALL, ""); +Locale::GetText::textdomain ("urpmi"); + +import Locale::GetText I_; +*_ = *I_; sub main { my (@toupdates, %options); @@ -30,7 +39,7 @@ sub main { /^--?c/ and $options{noclean} = 0, next; /^--?f/ and $options{force} = 1, next; /^--?noa/ and next; #- default, keeped for compability. - /^-/ and die "unknown options \"$_\"\n"; + /^-/ and die sprintf(_("unknown options \"%s\"\n"), $_); push @toupdates, $_; } @@ -38,9 +47,9 @@ sub main { my @entries = map { $_->{name} } @{$urpm->{media}}; if ($options{all}) { - @entries == 0 and die "nothing to update (use urpmi.addmedia to add a media)\n"; + @entries == 0 and die _("nothing to update (use urpmi.addmedia to add a media)\n"); } else { - @toupdates == 0 and die "missing the entry to update\n(one of " . join(", ", @entries) . ")\n"; + @toupdates == 0 and die sprintf(_("missing the entry to update\n(one of %s)\n"), join(", ", @entries)); $urpm->select_media(@toupdates); #- force ignored media to be returned alive. diff --git a/urpmq b/urpmq index 17c6cffe..ce3599db 100755 --- a/urpmq +++ b/urpmq @@ -57,6 +57,7 @@ usage: --auto-select - automatically select packages for upgrading the system. --headers - extract headers for package listed from urpmi db to stdout (root only). + --force - force invocation even if some package does not exists. names or rpm files given on command line are queried. ", $urpm::VERSION))); @@ -68,6 +69,7 @@ for (@ARGV) { /^--help$/ and do { usage; next }; /^--auto-select$/ and do { $query->{auto_select} = 1; next }; /^--headers$/ and do { $query->{headers} = 1; next }; + /^--force$/ and do { $query->{force} = 1; next }; /^-(.*)$/ and do { foreach (split //, $1) { /[\?h]/ and do { usage; next }; /d/ and do { $query->{deps} = 1; next }; @@ -94,13 +96,8 @@ if (@files) { #- dependancies, of files provided. $urpm->read_provides; - #- compute depslist of files provided on command line. - $urpm->{params}->read_rpms($_) foreach @files; - $urpm->{params}->compute_depslist; - - #- gets full names of packages, sanity check of pathname. - m|(.*/)?(.*)\.[^.]+\.rpm$| and push @names, $2 foreach @files; - m|^/| or $_ = "./$_" foreach @files; + #- build closure with local package and return list of names. + push @names, $urpm->register_local_packages(@files); } #- reparse whole internal depslist to match against newer packages only. @@ -110,7 +107,7 @@ $urpm->{params}->relocate_depslist(); #- basesystem is added to the list so if it need to be upgraded, all its dependancy #- will be updated too. my %packages; -$urpm->search_packages(\%packages, [ @names ]) or exit 1; +$urpm->search_packages(\%packages, [ @names ]) or $query->{force} or exit 1; #- auto select package for upgrading the distribution. if ($query->{auto_select}) { -- cgit v1.2.1