summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--urpm.pm16
-rw-r--r--urpm/parallel_ka_run.pm24
-rw-r--r--urpm/parallel_ssh.pm29
-rw-r--r--urpme4
-rwxr-xr-xurpmi186
-rw-r--r--urpmi.spec11
-rwxr-xr-xurpmq7
7 files changed, 178 insertions, 99 deletions
diff --git a/urpm.pm b/urpm.pm
index 37433399..43c64a8c 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -1623,6 +1623,9 @@ sub register_rpms {
$error and $urpm->{fatal}(1, _("error registering local packages"));
$start <= $id and @requested{($start .. $id)} = (1) x ($id-$start+1);
+ #- distribute local packages to distant nodes directly in cache of each machine.
+ $urpm->{parallel_handler} and $urpm->{parallel_handler}->parallel_register_rpms(@_);
+
%requested;
}
@@ -1738,8 +1741,15 @@ sub search_packages {
sub resolve_dependencies {
my ($urpm, $state, $requested, %options) = @_;
- require URPM::Resolve;
-
+ if ($options{install_src}) {
+ #- only src will be installed, so only update $state->{selected} according
+ #- to src status of files.
+ foreach (%$requested) {
+ my $pkg = $urpm->{depslist}[$_] or next;
+ $pkg->arch eq 'src' or next;
+ $state->{selected}{$_} = undef;
+ }
+ }
if ($urpm->{parallel_handler}) {
#- build the global synthesis file first.
my $file = "$urpm->{cachedir}/partial/parallel.cz";
@@ -1753,6 +1763,8 @@ sub resolve_dependencies {
} else {
my $db;
+ require URPM::Resolve;
+
if ($options{rpmdb}) {
$db = new URPM;
$db->parse_synthesis($options{rpmdb});
diff --git a/urpm/parallel_ka_run.pm b/urpm/parallel_ka_run.pm
index 7c43b34d..1ce539d9 100644
--- a/urpm/parallel_ka_run.pm
+++ b/urpm/parallel_ka_run.pm
@@ -1,5 +1,19 @@
package urpm::parallel_ka_run;
+#- parallel copy
+sub parallel_register_rpms {
+ my ($parallel, $urpm, @files) = @_;
+
+ $urpm->{log}("parallel_ka_run: mput $parallel->{options} -- ".join(' ', @files)." $urpm->{cachedir}/rpms/");
+ system "mput", split(' ', $parallel->{options}), '--', @files, "$urpm->{cachedir}/rpms/";
+
+ #- keep trace of direct files.
+ foreach (@files) {
+ my $basename = (/^.*\/([^\/]*)$/ && $1) || $_;
+ $parallel->{line} .= "$urpm->{cachedir}/rpms/$basename";
+ }
+}
+
#- parallel resolve_dependencies
sub parallel_resolve_dependencies {
my ($parallel, $synthesis, $urpm, $state, $requested, %options) = @_;
@@ -11,7 +25,7 @@ sub parallel_resolve_dependencies {
$parallel->{synthesis} = $synthesis;
#- compute command line of urpm? tools.
- my $line = $options{auto_select} ? ' --auto-select' : '';
+ my $line = $parallel->{line} . ($options{auto_select} ? ' --auto-select' : '');
foreach (keys %$requested) {
if (/\|/) {
#- taken from URPM::Resolve to filter out choices, not complete though.
@@ -52,12 +66,14 @@ sub parallel_resolve_dependencies {
#- the following state should be cleaned for each iteration.
delete $state->{selected};
#- now try an iteration of urpmq.
- $urpm->{log}("parallel_ka_run: rshp -v $parallel->{options} -- urpmq --synthesis $synthesis -f $line ".join(' ', keys %chosen));
- open F, "rshp -v $parallel->{options} -- urpmq --synthesis $synthesis -fdu $line ".join(' ', keys %chosen)." |";
+ $urpm->{log}("parallel_ka_run: rshp -v $parallel->{options} -- urpmq --synthesis $synthesis -fduc $line ".join(' ', keys %chosen));
+ open F, "rshp -v $parallel->{options} -- urpmq --synthesis $synthesis -fduc $line ".join(' ', keys %chosen)." |";
while (defined ($_ = <F>)) {
chomp;
s/<([^>]*)>.*:->:(.*)/$2/ and $node = $1;
- if (/\|/) {
+ if (/^\@removing\@(.*)/) {
+ $state->{ask_remove}{$1}{$node};
+ } elsif (/\|/) {
#- distant urpmq returned a choices, check if it has already been chosen
#- or continue iteration to make sure no more choices are left.
$cont ||= 1; #- invalid transitory state (still choices is strange here if next sentence is not executed).
diff --git a/urpm/parallel_ssh.pm b/urpm/parallel_ssh.pm
index e376b8f8..41edfa39 100644
--- a/urpm/parallel_ssh.pm
+++ b/urpm/parallel_ssh.pm
@@ -1,5 +1,22 @@
package urpm::parallel_ssh;
+#- parallel copy
+sub parallel_register_rpms {
+ my ($parallel, $urpm, @files) = @_;
+
+ foreach (keys %{$parallel->{nodes}}) {
+ my $sources = join ' ', map { "'$_'" } @files;
+ $urpm->{log}("parallel_ssh: scp $sources $_:$urpm->{cachedir}/rpms");
+ system "scp $sources $_:$urpm->{cachedir}/rpms";
+ }
+
+ #- keep trace of direct files.
+ foreach (@files) {
+ my $basename = (/^.*\/([^\/]*)$/ && $1) || $_;
+ $parallel->{line} .= "$urpm->{cachedir}/rpms/$basename";
+ }
+}
+
#- parallel resolve_dependencies
sub parallel_resolve_dependencies {
my ($parallel, $synthesis, $urpm, $state, $requested, %options) = @_;
@@ -12,7 +29,7 @@ sub parallel_resolve_dependencies {
$parallel->{synthesis} = $synthesis;
#- compute command line of urpm? tools.
- my $line = $options{auto_select} ? ' --auto-select' : '';
+ my $line = $parallel->{line} . ($options{auto_select} ? ' --auto-select' : '');
foreach (keys %$requested) {
if (/\|/) {
#- taken from URPM::Resolve to filter out choices, not complete though.
@@ -53,11 +70,13 @@ sub parallel_resolve_dependencies {
delete $state->{selected};
#- now try an iteration of urpmq.
foreach my $node (keys %{$parallel->{nodes}}) {
- $urpm->{log}("parallel_ssh: ssh $node urpmq --synthesis $synthesis -f $line ".join(' ', keys %chosen));
- open F, "ssh $node urpmq --synthesis $synthesis -fdu $line ".join(' ', keys %chosen)." |";
+ $urpm->{log}("parallel_ssh: ssh $node urpmq --synthesis $synthesis -fduc $line ".join(' ', keys %chosen));
+ open F, "ssh $node urpmq --synthesis $synthesis -fduc $line ".join(' ', keys %chosen)." |";
while ($_ = <F>) {
chomp;
- if (/\|/) {
+ if (/^\@removing\@(.*)/) {
+ $state->{ask_remove}{$1}{$node};
+ } elsif (/\|/) {
#- distant urpmq returned a choices, check if it has already been chosen
#- or continue iteration to make sure no more choices are left.
$cont ||= 1; #- invalid transitory state (still choices is strange here if next sentence is not executed).
@@ -84,7 +103,7 @@ sub parallel_resolve_dependencies {
} while ($cont);
#- keep trace of what has been chosen finally (if any).
- $parallel->{line} = "$line ".join(' ', keys %chosen);
+ $parallel->{line} .= "$line ".join(' ', keys %chosen);
#- update ask_remove, ask_unselect too along with provided value.
#TODO
diff --git a/urpme b/urpme
index b175b9bc..a5a58a78 100644
--- a/urpme
+++ b/urpme
@@ -28,7 +28,7 @@ use urpm;
#- get I18N translation method.
import urpm _;
-my ($auto, $matches, $maymatch, @l, @m, @toremove, %base);
+my ($auto, $matches, $maymatch, @l, @m, %base);
my $askok = _("Is this OK?");
my $askrm = _("Remove them all?");
# Translator: Add here the keys which might be pressed in the "No"-case.
@@ -59,7 +59,7 @@ $state = {};
#- open database to examine packages...
{
- my $db = URPM::DB::open('/', 0); #- open in read/write mode directly (so open it only once).
+ my $db = URPM::DB::open;
@l = grep { !/^-/ } @ARGV;
if (!$matches) {
diff --git a/urpmi b/urpmi
index 1ee528b0..3772e333 100755
--- a/urpmi
+++ b/urpmi
@@ -41,6 +41,7 @@ my $rpm_opt = "vh";
my $use_provides = 1;
my $fuzzy = 0;
my $src = 0;
+my $install_src = 0;
my $clean = 0;
my $noclean = 0;
my $pre_clean_cache = 0;
@@ -80,6 +81,7 @@ usage:
") . _(" --auto-select - automatically select packages to upgrade the system.
") . _(" --fuzzy - impose fuzzy search (same as -y).
") . _(" --src - next package is a source package (same as -s).
+") . _(" --install-src - install only source package (no binaries).
") . _(" --clean - remove rpm from cache before anything else.
") . _(" --noclean - keep rpm not used in cache.
") . _(" --force - force invocation even if some packages do not exist.
@@ -132,6 +134,7 @@ while (defined($_ = shift @ARGV)) {
/^--auto-select$/ and do { $auto_select = 1; next };
/^--fuzzy$/ and do { $fuzzy = 1; next };
/^--src$/ and do { $src = 1; next };
+ /^--install-src$/ and do { $install_src = 1; next };
/^--clean$/ and do { $clean = 1; $noclean = 0; next };
/^--noclean$/ and do { $clean = $pre_clean_cache = $post_clean_cache = 0; $noclean = 1; next };
/^--(no-)?pre-clean$/ and do { $pre_clean_cache = !$1; next };
@@ -205,6 +208,13 @@ while (defined($_ = shift @ARGV)) {
my $urpm = new urpm;
my ($pid_out, $pid_err);
+#- use install_src to promote all names as src package.
+if ($install_src) {
+ @files and $urpm->{fatal}(1, _("What can be done with binary rpm files when using --install-src"));
+ push @src_names, @names;
+ @names = ();
+}
+
#- prepare bug report.
if ($bug) {
system("rm", "-rf", $bug);
@@ -222,7 +232,7 @@ if ($bug) {
}
if ($env) {
- print STDERR "using specific environment on $env\n";
+ print STDERR _("using specific environment on %s\n", $env);
$log = "$env/urpmi_env.log";
unlink $log;
#- setting new environment.
@@ -233,14 +243,7 @@ if ($env) {
} else {
if ($uid > 0) {
#- only src files are installable using urpmi.
- @names || @files and $urpm->{fatal}(1, _("Only superuser is allowed to install packages"));
-
- #- allow installation.
- if (@src_files) {
- system("rpm", "-i$rpm_opt", @src_files, ($root ? ("--root", $root) : ()));
- $? and message(_("Installation failed")), exit 1;
- }
- exit 0;
+ $install_src || $root or @names || @files and $urpm->{fatal}(1, _("Only superuser is allowed to install packages"));
} else {
#- allow log if not defined.
$log ||= "/var/log/urpmi.log";
@@ -277,6 +280,9 @@ if ($log) {
}
select STDERR; $| = 1; # make unbuffered
select STDOUT; $| = 1; # make unbuffered
+} else {
+ open SAVEOUT, ">&STDOUT"; select SAVEOUT; $| = 1;
+ open SAVEERR, ">&STDERR"; select SAVEERR; $| = 1;
}
#- use specific sync routine.
@@ -357,6 +363,7 @@ $urpm->resolve_dependencies($state, \%requested,
rpmdb => $env && "$env/rpmdb.cz",
auto_select => $auto_select,
callback_choices => \&ask_choice,
+ install_src => $install_src,
);
if (%{$state->{ask_unselect} || {}}) {
@@ -409,9 +416,9 @@ foreach my $pkg (sort { $a->name cmp $b->name } @{$urpm->{depslist}}[keys %{$sta
$ask_user ||= $pkg->flag_required || $auto_select || $parallel;
my $fullname = $pkg->fullname;
- if (!$env && $uid > 0 && $pkg->arch ne 'src') {
+ if (!$env && $install_src && $pkg->arch ne 'src') {
push @root_only, $fullname;
- } elsif ($uid > 0 || $pkg->arch ne 'src') {
+ } elsif ($install_src || $pkg->arch ne 'src') {
$sum += $pkg->size;
push @to_install, $fullname;
}
@@ -464,43 +471,60 @@ my %sources = $urpm->download_source_packages($local_sources, $list,
});
my %sources_install = %{$urpm->extract_packages_to_install(\%sources) || {}};
-if (%sources_install || %sources) {
- if ($verify_rpm) {
- my @invalid_sources;
+if ($verify_rpm) {
+ my @invalid_sources;
- foreach (values %sources_install, values %sources) {
- URPM::verify_rpm($_) =~ /NOT OK/ and push @invalid_sources, $_;
- }
+ foreach (values %sources_install, values %sources) {
+ URPM::verify_rpm($_) =~ /NOT OK/ and push @invalid_sources, $_;
+ }
- if (@invalid_sources) {
- my $msg = _("The following packages have bad signatures");
- my $msg2 = _("Do you want to continue installation ?");
- my $p = join "\n", @invalid_sources;
- if ($auto) {
- message("$msg:\n$p\n", 'noX');
- exit 1;
+ if (@invalid_sources) {
+ my $msg = _("The following packages have bad signatures");
+ my $msg2 = _("Do you want to continue installation ?");
+ my $p = join "\n", @invalid_sources;
+ if ($auto) {
+ message("$msg:\n$p\n", 'noX');
+ exit 1;
+ } else {
+ if ($X) {
+ my $ok = _("Ok");
+ my $cancel = _("Cancel");
+ `gmessage -default $cancel -buttons "$ok:0,$cancel:2" "$msg:\n$p\n\n$msg2"`;
+ $? and exit 1;
} else {
- if ($X) {
- my $ok = _("Ok");
- my $cancel = _("Cancel");
- `gmessage -default $cancel -buttons "$ok:0,$cancel:2" "$msg:\n$p\n\n$msg2"`;
- $? and exit 1;
- } else {
- $noexpr = _("Nn");
- $yesexpr = _("Yy");
- message_input("$msg:\n$p\n$msg2" . _(" (y/N) ")) =~ /[$yesexpr]/ or exit 1;
- }
+ $noexpr = _("Nn");
+ $yesexpr = _("Yy");
+ message_input("$msg:\n$p\n$msg2" . _(" (y/N) ")) =~ /[$yesexpr]/ or exit 1;
}
}
}
+}
+
+#- check for local files.
+if (my @missing = grep { m|^/| && ! -e $_ } values %sources_install, values %sources) {
+ message(_("Installation failed, some files are missing:\n%s\nYou may want to update your urpmi database",
+ join "\n", map { " $_" } @missing));
+ exit 2;
+}
+
+#- install source package only (whatever the user is root or not, but use rpm for that).
+if ($install_src) {
+ if (my @l = grep { /\.src\.rpm$/ } values %sources_install, values %sources) {
+ system("rpm", "-i$rpm_opt", @l, ($root ? ("--root", $root) : ()));
+ $? and message(_("Installation failed")), exit 1;
+ }
+ exit 0;
+}
- #- check for local files.
- if (my @missing = grep { m|^/| && ! -e $_ } values %sources_install, values %sources) {
- message(_("Installation failed, some files are missing:\n%s\nYou may want to update your urpmi database",
- join "\n", map { " $_" } @missing));
- exit 2;
+#- clean to remove any src package now.
+foreach (\%sources_install, \%sources) {
+ foreach my $id (keys %$_) {
+ my $pkg = $urpm->{depslist}[$id] or next;
+ $pkg->arch eq 'src' and delete $_->{$id};
}
-
+}
+
+if (%sources_install || %sources) {
if ($parallel) {
message(_("distributing %s\n", join(' ', values %sources_install, values %sources)), 'noX');
#- no remove are handle here, automatically done by each distant node.
@@ -511,63 +535,57 @@ if (%sources_install || %sources) {
message(_("installing %s\n", join(' ', values %sources_install, values %sources)), 'noX');
log_it(scalar localtime, " ", join(' ', values %sources_install, values %sources), "\n");
$urpm->{log}("starting installing packages");
- if ($uid > 0) {
- system("rpm", "-i$rpm_opt", values %sources_install, values %sources,
- ($root ? ("--root", $root) : ()), ($test ? ("--test", $test) : ()));
- $? and message(_("Installation failed")), exit 1;
- exit 0;
+ if ($X && !$root && !$test) {
+ system("rpm", "-e", "--nodeps", keys %{$state->{ask_remove} || {}});
+ system("grpmi", $WID ? ("--WID=$WID") : (),
+ (map { ("-noupgrade", $_) } values %sources_install), values %sources);
+ if ($?) {
+ #- grpmi handles --nodeps and --force by itself,
+ #- and $WID is defined when integrated in rpminst.
+ $WID or message(_("Installation failed"));
+ exit(($? >> 8) + 32); #- forward grpmi error + 32
+ }
} else {
- if ($X && !$root && !$test) {
- system("rpm", "-e", "--nodeps", keys %{$state->{ask_remove} || {}});
- system("grpmi", $WID ? ("--WID=$WID") : (),
- (map { ("-noupgrade", $_) } values %sources_install), values %sources);
- if ($?) {
- #- grpmi handles --nodeps and --force by itself,
- #- and $WID is defined when integrated in rpminst.
- $WID or message(_("Installation failed"));
- exit(($? >> 8) + 32); #- forward grpmi error + 32
- }
- } else {
- my @l = $urpm->install([ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources,
- translate_message => 1,
- oldpackage => $state->{oldpackage}, post_clean_cache => $post_clean_cache,
- test => $test, excludepath => $excludepath);
+ my @l = $urpm->install([ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources,
+ translate_message => 1,
+ oldpackage => $state->{oldpackage}, post_clean_cache => $post_clean_cache,
+ test => $test, excludepath => $excludepath);
+ if (@l) {
+ message(_("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l));
+
+ m|^/| && !-e $_ and exit 2 foreach values %sources_install, values %sources; #- missing local file
+ $auto || !$allow_nodeps && !$allow_force and exit 1; #- if auto has been set, avoid asking user.
+
+ $noexpr = _("Nn");
+ $yesexpr = _("Yy");
+ message_input(_("Try installation without checking dependencies? (y/N) "), $force && $yesexpr) =~ /[$yesexpr]/
+ or exit 1;
+ $urpm->{log}("starting installing packages without deps");
+ @l = $urpm->install([ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources,
+ translate_message => 1, nodeps => 1,
+ oldpackage => $state->{oldpackage}, post_clean_cache => $post_clean_cache,
+ test => $test, excludepath => $excludepath);
if (@l) {
- message(_("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l));
-
- m|^/| && !-e $_ and exit 2 foreach values %sources_install, values %sources; #- missing local file
- $auto || !$allow_nodeps && !$allow_force and exit 1; #- if auto has been set, avoid asking user.
-
- $noexpr = _("Nn");
- $yesexpr = _("Yy");
- message_input(_("Try installation without checking dependencies? (y/N) "), $force && $yesexpr) =~ /[$yesexpr]/
+ message(_("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l));
+ !$allow_force and exit 1;
+ message_input(_("Try installation even more strongly (--force)? (y/N) "), $force && $yesexpr) =~ /[$yesexpr]/
or exit 1;
- $urpm->{log}("starting installing packages without deps");
+ $urpm->{log}("starting force installing packages without deps");
@l = $urpm->install([ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources,
- translate_message => 1, nodeps => 1,
+ translate_message => 1, nodeps => 1, force => 1,
oldpackage => $state->{oldpackage}, post_clean_cache => $post_clean_cache,
test => $test, excludepath => $excludepath);
- if (@l) {
- message(_("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l));
- !$allow_force and exit 1;
- message_input(_("Try installation even more strongly (--force)? (y/N) "), $force && $yesexpr) =~ /[$yesexpr]/
- or exit 1;
- $urpm->{log}("starting force installing packages without deps");
- @l = $urpm->install([ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources,
- translate_message => 1, nodeps => 1, force => 1,
- oldpackage => $state->{oldpackage}, post_clean_cache => $post_clean_cache,
- test => $test, excludepath => $excludepath);
- @l and $urpm->fatal(2, _("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l));
- }
- } else {
- $test and message(_("Installation is possible"));
+ @l and $urpm->fatal(2, _("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l));
}
+ } else {
+ $test and message(_("Installation is possible"));
}
}
}
} else {
message(_("everything already installed"), $auto);
}
+
#- try to umount removable device which may have been mounted.
$urpm->try_umounting_removables;
diff --git a/urpmi.spec b/urpmi.spec
index 7984c94f..20fd1d0b 100644
--- a/urpmi.spec
+++ b/urpmi.spec
@@ -2,7 +2,7 @@
Name: urpmi
Version: 4.1
-Release: 10mdk
+Release: 11mdk
License: GPL
Source0: %{name}.tar.bz2
Source1: %{name}.logrotate
@@ -204,6 +204,15 @@ fi
%changelog
+* Tue Dec 10 2002 François Pons <fpons@mandrakesoft.com> 4.1-11mdk
+- fixed source installation in / when installing dependencies.
+- added --install-src to avoid probing on root/user mode.
+- fixed no log available when user mode.
+- changed obsoleted -c of urpmq to complete output with package
+ to removes (needed for parallel distributed urpme).
+- allow distribution of local files.
+- fixed small typos in urpme.
+
* Fri Dec 6 2002 François Pons <fpons@mandrakesoft.com> 4.1-10mdk
- fixed indexation when using --distrib-XXX for urpmi.addmedia.
- fixed wget output to be far more quietly.
diff --git a/urpmq b/urpmq
index 975feeca..445fd8c2 100755
--- a/urpmq
+++ b/urpmq
@@ -62,7 +62,7 @@ usage:
") . _(" -v - verbose mode.
") . _(" -d - extend query to package dependencies.
") . _(" -u - remove package if a more recent version is already installed.
-") . _(" -c - choose complete method for resolving requires closure.
+") . _(" -c - complete output with package to removes.
") . _(" -P - do not search in provides to find package.
") . _(" -R - reverse search to what requires package.
") . _(" -y - impose fuzzy search (same as --fuzzy).
@@ -341,6 +341,11 @@ my $query_sub = sub {
};
my %hack_only_one;
+if ($query->{complete}) {
+ foreach my $removal (keys %{$state->{ask_remove} || {}}) {
+ print '@removing@' . $removal . "\n";
+ }
+}
foreach my $id ($state->{selected} ? keys %{$state->{selected}} : keys %requested) {
my $class = $state->{selected}{$id} || $requested{$id};
if (ref $class eq 'ARRAY') {