diff options
author | Francois Pons <fpons@mandriva.com> | 2002-08-23 13:06:55 +0000 |
---|---|---|
committer | Francois Pons <fpons@mandriva.com> | 2002-08-23 13:06:55 +0000 |
commit | 8b2c021aec0970390f312dde7edeca56b94f866c (patch) | |
tree | d97e469e89fbc8fad111e4508827d6acb8eab642 | |
parent | 322c43fcc2f685124a1705a12837e7875e50d767 (diff) | |
download | urpmi-8b2c021aec0970390f312dde7edeca56b94f866c.tar urpmi-8b2c021aec0970390f312dde7edeca56b94f866c.tar.gz urpmi-8b2c021aec0970390f312dde7edeca56b94f866c.tar.bz2 urpmi-8b2c021aec0970390f312dde7edeca56b94f866c.tar.xz urpmi-8b2c021aec0970390f312dde7edeca56b94f866c.zip |
4.0-1mdk
-rw-r--r-- | urpm.pm | 177 | ||||
-rwxr-xr-x | urpmi | 160 | ||||
-rw-r--r-- | urpmi.spec | 28 | ||||
-rwxr-xr-x | urpmq | 38 |
4 files changed, 244 insertions, 159 deletions
@@ -532,41 +532,107 @@ sub configure { my ($urpm, %options) = @_; $urpm->clean; - $urpm->read_config(%options); - if ($options{media}) { - $urpm->select_media(split ',', $options{media}); - foreach (grep { !$_->{modified} } @{$urpm->{media} || []}) { - #- this is only a local ignore that will not be saved. - $_->{ignore} = 1; - } - } - foreach (grep { !$_->{ignore} && (!$options{update} || $_->{update}) } @{$urpm->{media} || []}) { - delete @{$_}{qw(start end)}; - if ($options{callback}) { - if (-s "$urpm->{statedir}/$_->{hdlist}" > 32) { - $urpm->{log}(_("examining hdlist file [%s]", "$urpm->{statedir}/$_->{hdlist}")); - eval { ($_->{start}, $_->{end}) = $urpm->parse_hdlist("$urpm->{statedir}/$_->{hdlist}", 0) }; - } - unless (defined $_->{start} && defined $_->{end}) { - $urpm->{error}(_("problem reading hdlist file of medium \"%s\"", $_->{name})); + if ($options{synthesis}) { + #- synthesis take precedence over media, update options. + $options{media} || $options{update} || $options{parallel} and + $urpm->{fatal}(1, _("--synthesis cannot be used with --media, --update or --parallel")); + $urpm->parse_synthesis($options{synthesis}); + } else { + $urpm->read_config(%options); + if ($options{media}) { + $urpm->select_media(split ',', $options{media}); + foreach (grep { !$_->{modified} } @{$urpm->{media} || []}) { + #- this is only a local ignore that will not be saved. $_->{ignore} = 1; + } + } + $options{parallel} and unlink "$urpm->{cachedir}/partial/parallel.cz"; + foreach (grep { !$_->{ignore} && (!$options{update} || $_->{update}) } @{$urpm->{media} || []}) { + delete @{$_}{qw(start end)}; + if ($options{callback}) { + if (-s "$urpm->{statedir}/$_->{hdlist}" > 32) { + $urpm->{log}(_("examining hdlist file [%s]", "$urpm->{statedir}/$_->{hdlist}")); + eval { ($_->{start}, $_->{end}) = $urpm->parse_hdlist("$urpm->{statedir}/$_->{hdlist}", 0) }; + } + unless (defined $_->{start} && defined $_->{end}) { + $urpm->{error}(_("problem reading hdlist file of medium \"%s\"", $_->{name})); + $_->{ignore} = 1; + } else { + #- medium has been read correclty, now call the callback for each packages. + #- it is the responsability of callback to pack the header. + foreach ($_->{start} .. $_->{end}) { + $options{callback}->($urpm, $_, %options); + } + } } else { - #- medium has been read correclty, now call the callback for each packages. - #- it is the responsability of callback to pack the header. - foreach ($_->{start} .. $_->{end}) { - $options{callback}->($urpm, $_, %options); + if (-s "$urpm->{statedir}/synthesis.$_->{hdlist}" > 32) { + $urpm->{log}(_("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$_->{hdlist}")); + eval { ($_->{start}, $_->{end}) = $urpm->parse_synthesis("$urpm->{statedir}/synthesis.$_->{hdlist}") }; + } + unless (defined $_->{start} && defined $_->{end}) { + $urpm->{error}(_("problem reading synthesis file of medium \"%s\"", $_->{name})); + $_->{ignore} = 1; + } else { + $options{parallel} and system "cat '$urpm->{statedir}/synthesis.$_->{hdlist}' >> $urpm->{cachedir}/partial/parallel.cz"; } } - } else { - if (-s "$urpm->{statedir}/synthesis.$_->{hdlist}" > 32) { - $urpm->{log}(_("examining synthesis file [%s]", "$urpm->{statedir}/synthesis.$_->{hdlist}")); - eval { ($_->{start}, $_->{end}) = $urpm->parse_synthesis("$urpm->{statedir}/synthesis.$_->{hdlist}") }; + } + } + if ($options{bug}) { + #- and a dump of rpmdb itself as synthesis file. + my $db = URPM::DB::open($options{root}); + my $sig_handler = sub { undef $db; exit 3 }; + local $SIG{INT} = $sig_handler; + local $SIG{QUIT} = $sig_handler; + local *RPMDB; + open RPMDB, "| " . ($ENV{LD_LOADER} || '') . " gzip -9 >'$options{bug}/rpmdb.cz'"; + $db->traverse(sub{ + my ($p) = @_; + #- this is not right but may be enough. + my $files = join '@', grep { exists $urpm->{provides}{$_} } $p->files; + $p->pack_header; + $p->build_info(fileno *RPMDB, $files); + }); + close RPMDB; + } + if ($options{parallel}) { + my ($parallel_options, $parallel_handler); + #- handle parallel configuration, examine all module available that + #- will handle the parallel mode (configuration is /etc/urpmi/parallel.cfg). + local ($_, *PARALLEL); + open PARALLEL, "/etc/urpmi/parallel.cfg"; + while (<PARALLEL>) { + chomp; s/#.*$//; s/^\s*//; s/\s*$//; + /\s*([^:]*):(.*)/ or $urpm->{error}(_("unable to parse \"%s\" in file [%s]", $_, "/etc/urpmi/parallel.cfg")), next; + $1 eq $options{parallel} and $parallel_options = ($parallel_options && "\n") . $2; + } + close PARALLEL; + #- if a configuration options has been found, use it else fatal error. + if ($parallel_options) { + foreach my $dir (grep { -d $_ } map { "$_/urpm" } @INC) { + local *DIR; + opendir DIR, $dir; + while ($_ = readdir DIR) { + -f "$dir/$_" or next; + $urpm->{log}->(_("examining parallel handler in file [%s]", "$dir/$_")); + eval { require "$dir/$_"; $parallel_handler = $urpm->handle_parallel_options($parallel_options) }; + $parallel_handler and last; + } + closedir DIR; + $parallel_handler and last; } - unless (defined $_->{start} && defined $_->{end}) { - $urpm->{error}(_("problem reading synthesis file of medium \"%s\"", $_->{name})); - $_->{ignore} = 1; + } + if ($parallel_handler) { + if ($parallel_handler->{nodes}) { + $urpm->{log}->(_("found parallel handler for nodes: %s", join(', ', keys %{$parallel_handler->{nodes}}))); } + $urpm->{parallel_handler} = $parallel_handler; + } else { + $urpm->{fatal}(1, _("unable to use parallel option \"%s\"", $options{parallel})); } + } else { + #- parallel is exclusive against root options. + $urpm->{root} = $options{root}; } } @@ -1432,7 +1498,7 @@ sub relocate_depslist_provides { #- register local packages for being installed, keep track of source. sub register_rpms { my ($urpm, @files) = @_; - my ($start, $id, $error); + my ($start, $id, $error, %requested); #- examine each rpm and build the depslist for them using current #- depslist and provides environment. @@ -1447,8 +1513,9 @@ sub register_rpms { $urpm->{source}{$id} = $1 ? $_ : "./$_"; } $error and $urpm->{fatal}(1, _("error registering local packages")); + $start <= $id and @requested{($start .. $id)} = (1) x ($id-$start+1); - $start <= $id ? ($start, $id) : (); + %requested; } #- search packages registered by their name by storing their id into packages hash. @@ -1558,6 +1625,35 @@ sub search_packages { $result; } +#- do the resolution of dependencies. +sub resolve_dependencies { + my ($urpm, $state, $requested, %options) = @_; + + if ($urpm->{parallel_handler}) { + #- let each node determine what is requested, according to handler given. + $urpm->{parallel_handler}->parallel_resolve_dependencies("$urpm->{cachedir}/partial/parallel.cz", @_); + } else { + my $db; + + if ($options{rpmdb}) { + $db = new URPM; + $db->parse_synthesis($options{rpmdb}); + } else { + $db = URPM::DB::open($urpm->{root}); + } + + my $sig_handler = sub { undef $db; exit 3 }; + local $SIG{INT} = $sig_handler; + local $SIG{QUIT} = $sig_handler; + + require URPM::Resolve; + #- auto select package for upgrading the distribution. + $options{auto_select} and $urpm->request_packages_to_upgrade($db, $state, $requested, requested => undef); + + $urpm->resolve_requested($db, $state, $requested, %options); + } +} + #- get out of package that should not be upgraded. sub deselect_unwanted_packages { my ($urpm, $packages, %options) = @_; @@ -1598,11 +1694,8 @@ sub get_source_packages { #- examine each medium to search for packages. #- now get rpm file name in hdlist to match list file. - foreach my $medium (@{$urpm->{media} || []}) { - foreach ($medium->{start} .. $medium->{end}) { - my $pkg = $urpm->{depslist}[$_]; - $file2fullnames{($pkg->filename =~ /(.*)\.rpm$/ && $1) || $pkg->fullname}{$pkg->fullname} = undef; - } + foreach my $pkg (@{$urpm->{depslist} || []}) { + $file2fullnames{($pkg->filename =~ /(.*)\.rpm$/ && $1) || $pkg->fullname}{$pkg->fullname} = undef; } #- examine the local repository, which is trusted. @@ -1675,7 +1768,7 @@ sub download_source_packages { my (%sources, @distant_sources, %media, %removables); #- make sure everything is correct on input... - @{$urpm->{media}} == @$list or return; + @{$urpm->{media} || []} == @$list or return; #- examine if given medium is already inside a removable device. my $check_notfound = sub { @@ -1863,9 +1956,9 @@ sub install_logger { #- install packages according to each hashes (install or upgrade). sub install { - my ($urpm, $prefix, $remove, $install, $upgrade, %options) = @_; - my $db = URPM::DB::open($prefix, 1); #- open in read/write mode. - my $trans = $db->create_transaction($prefix); + my ($urpm, $remove, $install, $upgrade, %options) = @_; + my $db = URPM::DB::open($urpm->{root}, 1); #- open in read/write mode. + my $trans = $db->create_transaction($urpm->{root}); my @l; local *F; @@ -1911,4 +2004,10 @@ sub install { @l = $trans->run($urpm, %options); } +#- install all files to node as remembered according to resolving done. +sub parallel_install { + my ($urpm, $remove, $install, $upgrade, %options) = @_; + $urpm->{parallel_handler}->parallel_install(@_); +} + 1; @@ -24,13 +24,15 @@ import urpm _; #- default options. my $update = 0; -my $media = 0; +my $media = ''; +my $synthesis = ''; my $auto = 0; my $allow_medium_change = 0; my $auto_select = 0; my $force = 0; my $allow_nodeps = 0; my $allow_force = 0; +my $parallel = ''; my $sync = undef; my $X = 0; my $WID = 0; @@ -66,6 +68,7 @@ usage: ", $urpm::VERSION) . _(" --help - print this help message. ") . _(" --update - use only update media. ") . _(" --media - use only the media listed by comma. +") . _(" --synthesis - use the synthesis given instead of urpmi db. ") . _(" --auto - automatically select a package in choices. ") . _(" --auto-select - automatically select packages to upgrade the system. ") . _(" --fuzzy - impose fuzzy search (same as -y). @@ -76,6 +79,7 @@ usage: dependencies checking. ") . _(" --allow-force - allow asking user to install packages without dependencies checking and integrity. +") . _(" --parallel - distributed urpmi accross machines of alias. ") . _(" --wget - use wget to retrieve distant files. ") . _(" --curl - use curl to retrieve distant files. ") . _(" --proxy - use specified HTTP proxy, the port number is assumed @@ -107,6 +111,7 @@ while (defined($_ = shift @ARGV)) { /^--update$/ and do { $update = 1; next }; /^--media$/ and do { push @nextargv, \$media; next }; /^--mediums$/ and do { push @nextargv, \$media; next }; + /^--synthesis$/ and do { push @nextargv, \$synthesis; next }; /^--auto$/ and do { $auto = 1; next }; /^--allow-medium-change$/ and do { $allow_medium_change = 1; next }; /^--auto-select$/ and do { $auto_select = 1; next }; @@ -116,6 +121,7 @@ while (defined($_ = shift @ARGV)) { /^--force$/ and do { $force = 1; next }; /^--allow-nodeps$/ and do { $allow_nodeps = 1; next }; /^--allow-force$/ and do { $allow_force = 1; next }; + /^--parallel$/ and do { push @nextargv, \$parallel; next }; /^--wget$/ and do { $sync = sub { my $options = shift @_; if (ref $options) { $options->{prefer} = 'wget' } else { $options = { dir => $options, prefer => 'wget' } } @@ -266,33 +272,15 @@ $verbose or $urpm->{log} = sub {}; $urpm->configure(nocheck_access => $env || $uid > 0, media => $media, + synthesis => $synthesis, update => $update, + root => $root, + bug => $bug, + parallel => $parallel, ); -my ($start, $end) = $urpm->register_rpms(@files, @src_files); - -if ($bug) { - #- and a dump of rpmdb itself as synthesis file. - my $db = URPM::DB::open($root); - my $sig_handler = sub { undef $db; exit 3 }; - local $SIG{INT} = $sig_handler; - local $SIG{QUIT} = $sig_handler; - local *RPMDB; - open RPMDB, "| " . ($ENV{LD_LOADER} || '') . " gzip -9 >'$bug/rpmdb.cz'"; - $db->traverse(sub{ - my ($p) = @_; - #- this is not right but may be enough. - my $files = join '@', grep { exists $urpm->{provides}{$_} } $p->files; - $p->pack_header; - $p->build_info(fileno *RPMDB, $files); - }); - close RPMDB; -} - -#- select individual files. my $state = {}; -my %requested; -defined $start && defined $end and @requested{($start .. $end)} = (1) x ($end-$start+1); +my %requested = $urpm->register_rpms(@files, @src_files); #- search the packages according the selection given by the user, #- basesystem is added to the list so if it need to be upgraded, @@ -303,7 +291,7 @@ if (@names) { all => $all, use_provides => $use_provides, fuzzy => $fuzzy) - or $force or exit 1; + or $force or exit 1; } if (@src_names) { $urpm->search_packages(\%requested, [ @src_names ], @@ -311,7 +299,7 @@ if (@src_names) { use_provides => $use_provides, fuzzy => $fuzzy, src => 1) - or $force or exit 1; + or $force or exit 1; } #- filter to add in packages selected required packages. @@ -343,29 +331,13 @@ sub ask_choice { $choices->[$n - 1]; }; -#- open/close of database should be moved here, in order to allow testing -#- some bogus case and check for integrity. -{ - my $db; - - #- take care of specific environment. - if ($env) { - $db = new URPM; - $db->parse_synthesis("$env/rpmdb.cz"); - } else { - $db = URPM::DB::open($root); - } - - my $sig_handler = sub { undef $db; exit 3 }; - local $SIG{INT} = $sig_handler; - local $SIG{QUIT} = $sig_handler; - - require URPM::Resolve; - #- auto select package for upgrading the distribution. - $auto_select and $urpm->request_packages_to_upgrade($db, $state, \%requested, requested => undef); - - $urpm->resolve_requested($db, $state, \%requested, callback_choices => \&ask_choice); -} +#- do the resolution of dependencies between requested package (and auto selection if any). +#- handle parallel option if any. +$urpm->resolve_dependencies($state, \%requested, + rpmdb => $env && "$env/rpmdb.cz", + auto_select => $auto_select, + callback_choices => \&ask_choice, + ); if (%{$state->{ask_unselect} || {}}) { unless ($auto) { @@ -414,7 +386,7 @@ my $sum = 0; my @root_only; foreach my $pkg (sort { $a->name cmp $b->name } @{$urpm->{depslist}}[keys %{$state->{selected}}]) { - $ask_user ||= $pkg->flag_required || $auto_select; + $ask_user ||= $pkg->flag_required || $auto_select || $parallel; my $fullname = $pkg->fullname; if (!$env && $uid > 0 && $pkg->arch ne 'src') { @@ -507,55 +479,63 @@ if (%sources_install || %sources) { } } - message(_("installing %s\n", join(' ', values %sources_install, values %sources))); - log_it(scalar localtime, " ", join(' ', values %sources_install, values %sources), "\n"); #- check for local files. foreach (values %sources_install, values %sources) { m|^/| && ! -e $_ or next; message(_("Installation failed, some files are missing.\nYou may want to update your urpmi database")); exit 2; } - $urpm->{log}("starting installing packages"); - if ($uid > 0) { - system("rpm", "-i$rpm_opt", values %sources_install, values %sources, ($root ? ("--root", $root) : ())); - $? and message(_("Installation failed")), exit 1; - exit 0; + + if ($parallel) { + message(_("distributing %s\n", join(' ', values %sources_install, values %sources))); + #- no remove are handle here, automatically done by each distant node. + $urpm->{log}("starting distributed install"); + $urpm->parallel_install([ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources); } else { - if ($X && !$root) { - system("rpm", "-e", "--nodeps", keys %{$state->{ask_remove} || {}}, ($root ? ("--root", $root) : ())); - 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 - } + message(_("installing %s\n", join(' ', values %sources_install, values %sources))); + 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) : ())); + $? and message(_("Installation failed")), exit 1; + exit 0; } else { - my @l = $urpm->install($root, [ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources, - translate_message => 1); - 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($root, [ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources, - translate_message => 1, nodeps => 1); + if ($X && !$root) { + system("rpm", "-e", "--nodeps", keys %{$state->{ask_remove} || {}}, ($root ? ("--root", $root) : ())); + 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); 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($root, [ keys %{$state->{ask_remove} || {}} ], \%sources_install, \%sources, - translate_message => 1, nodeps => 1, force => 1); - @l and $urpm->fatal(2, _("Installation failed") . ":\n" . join("\n", map { "\t$_" } @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); + 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); + @l and $urpm->fatal(2, _("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); + } } } } @@ -1,14 +1,14 @@ %define group System/Configuration/Packaging Name: urpmi -Version: 3.9 -Release: 8mdk +Version: 4.0 +Release: 1mdk 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-6mdk perl-URPM >= 0.50-5mdk +PreReq: perl-Locale-gettext rpmtools >= 4.3-6mdk perl-URPM >= 0.70-1mdk BuildRequires: bzip2-devel gettext rpm-devel >= 4.0.3 BuildRoot: %{_tmppath}/%{name}-buildroot BuildArch: noarch @@ -34,6 +34,14 @@ gurpmi is a graphical front-end to urpmi #%description -n autoirpm #Auto install of rpm on demand +%package -n urpmi-parallel-ka-run +Summary: Parallel extensions to urpmi using ka-run +Requires: urpmi >= 4.0 ka-run >= 2.0-6mdk +Group: %{group} +%description -n urpmi-parallel-ka-run +urpmi-parallel-ka-run is an extensions module to urpmi for handling +distributed installation using ka-run tools. + %prep %setup -q -n %{name} @@ -63,6 +71,8 @@ EOF mkdir -p $RPM_BUILD_ROOT%{perl_vendorlib} install -m 644 urpm.pm $RPM_BUILD_ROOT%{perl_vendorlib}/urpm.pm +mkdir -p $RPM_BUILD_ROOT%{perl_vendorlib}/urpm +install -m 644 urpm.pm $RPM_BUILD_ROOT%{perl_vendorlib}/urpm/parallel_ka_run.pm mkdir -p $RPM_BUILD_ROOT%{_mandir}/man3 pod2man urpm.pm >$RPM_BUILD_ROOT%{_mandir}/man3/urpm.3 @@ -142,8 +152,20 @@ fi #%{_bindir}/_irpm #%doc README-autoirpm-icons autoirpm.README +%files -n urpmi-parallel-ka-run +%defattr(-,root,root) +%{perl_vendorlib}/urpm/parallel_ka_run.pm + %changelog +* Fri Aug 23 2002 François Pons <fpons@mandrakesoft.com> 4.0-1mdk +- added --parallel options for distributed urpmi. +- added urpmi module extensions support (only --parallel). +- added --synthesis options for urpmq/urpmi to use a specific + environment. +- use cache files even if no medium have been defined (for use + with --synthesis). + * Tue Aug 13 2002 François Pons <fpons@mandrakesoft.com> 3.9-8mdk - fixed development log still done for progression status, now removed. @@ -50,6 +50,7 @@ usage: ") . _(" -f - print version, release and arch with name. ") . "\n" . _(" --update - use only update media. ") . _(" --media - use only the media listed by comma. +") . _(" --synthesis - use the synthesis given instead of urpmi db. ") . _(" --auto-select - automatically select packages to upgrade the system. ") . _(" --fuzzy - impose fuzzy search (same as -y). ") . _(" --list - list available packages. @@ -79,7 +80,8 @@ for (@ARGV) { /^--update$/ and do { $query->{update} = 1; next }; /^--media$/ and do { push @nextargv, \$query->{media}; next }; /^--mediums$/ and do { push @nextargv, \$query->{media}; next }; - /^--auto-select$/ and do { $query->{auto_select} = 1; next }; + /^--synthesis$/ and do { push @nextargv, \$query->{synthesis}; next }; + /^--auto-select$/ and do { $query->{upgrade} = $query->{auto_select} = 1; next }; /^--fuzzy$/ and do { $query->{fuzzy} = 1; next }; /^--list$/ and do { $query->{list} = 1; next }; /^--src$/ and do { $query->{src} = 1; next }; @@ -137,10 +139,10 @@ $query->{verbose} or $urpm->{log} = sub {}; $urpm->configure(nocheck_access => 1, media => $query->{media}, + synthesis => $query->{synthesis}, update => $query->{update}, ); - my $state = {}; my %requested; @@ -148,10 +150,7 @@ my %requested; if ($query->{list}) { @{$state->{selected}}{0 .. $#{$urpm->{depslist}}} = (); } else { - my ($start, $end) = $urpm->register_rpms(@files); - - #- select individual files. - defined $start && defined $end and @requested{($start .. $end)} = (); + %requested = $urpm->register_rpms(@files); #- search the packages according the selection given by the user, #- basesystem is added to the list so if it need to be upgraded, all its dependency @@ -176,28 +175,13 @@ if ($query->{list}) { $state->{selected}{join '|', sort { $a <=> $b } map { $_ ? ($_->id) : () } @$choices} = 0; }; #- open/close of database should be moved here, in order to allow testing - #- some bogus case and check for integrity. + #- some bogus case and check for integrity. (note auto_select implies upgrade). if ($query->{auto_select} || $query->{upgrade}) { - my $db = URPM::DB::open($query->{root}); - my $sig_handler = sub { undef $db; exit 3 }; - local $SIG{INT} = $sig_handler; - local $SIG{QUIT} = $sig_handler; - - require URPM::Resolve; - #- auto select package for upgrading the distribution. - if ($query->{auto_select}) { - my (%to_remove, %keep_files); - - $urpm->request_packages_to_upgrade($db, $state, \%requested, requested => 0); - } - - #- filter to add in packages selected required packages. - if ($query->{upgrade}) { - $urpm->resolve_requested($db, $state, \%requested, callback_choices => $stop_on_choices); - #- dependancies are not asked, just clean selected part with added value (undef). - $query->{deps} or delete @{$state->{selected}}{grep { exists $state->{selected}{$_} && - ! defined $state->{selected}{$_}} keys %{$state->{selected}}}; - } + $urpm->resolve_dependencies($state, \%requested, + auto_select => $query->{auto_select}, + callback_choices => $stop_on_choices); + $query->{deps} or delete @{$state->{selected}}{grep { exists $state->{selected}{$_} && + ! defined $state->{selected}{$_}} keys %{$state->{selected}}}; } elsif ($query->{deps}) { #- only deps required. my $empty_db = new URPM; #- URPM has same methods as URPM::DB and empty URPM will be seen as empty URPM::DB. |