diff options
-rw-r--r-- | urpm.pm | 56 | ||||
-rwxr-xr-x | urpmi | 350 | ||||
-rwxr-xr-x | urpmi.addmedia | 6 | ||||
-rw-r--r-- | urpmi.spec | 11 | ||||
-rwxr-xr-x | urpmi.update | 8 |
5 files changed, 239 insertions, 192 deletions
@@ -1027,15 +1027,33 @@ sub find_mntpoints { #- read /etc/fstab and check for existing mount point. open F, "/etc/fstab"; while (<F>) { - my ($device, $mntpoint) = /^\s*(\S+)\s+(\/\S+)/ or next; + my ($device, $mntpoint, $fstype, $options) = /^\s*(\S+)\s+(\/\S+)\s+(\S+)\s+(\S+)/ or next; $mntpoint =~ s,/+,/,g; $mntpoint =~ s,/$,,; - $fstab{$mntpoint} = $mode eq 'device' ? ($device eq $mntpoint ? m|dev=(/[^,\s]*)| && $1 : $device) : 0; + $fstab{$mntpoint} = 0; + if ($mode eq 'device') { + if ($fstype eq 'supermount') { + $options =~ /^.*dev=([^,]+),*$/ and $fstab{$mntpoint} = $1; + } elsif ($device eq 'none') { + next; + } else { + $fstab{$mntpoint} = $device; + } + } } open F, "/etc/mtab"; while (<F>) { - my ($device, $mntpoint) = /^\s*(\S+)\s+(\/\S+)/ or next; + my ($device, $mntpoint, $fstype, $options) = /^\s*(\S+)\s+(\/\S+)\s+(\S+)\s+(\S+)/ or next; $mntpoint =~ s,/+,/,g; $mntpoint =~ s,/$,,; - $fstab{$mntpoint} = $mode eq 'device' ? $device : 1; + $fstab{$mntpoint} = 1; + if ($mode eq 'device') { + if ($fstype eq 'supermount') { + $options =~ /^.*dev=([^,]+),*$/ and $fstab{$mntpoint} = $1; + } elsif ($device eq 'none') { + next; + } else { + $fstab{$mntpoint} = $device; + } + } } close F; @@ -1495,9 +1513,9 @@ sub filter_packages_to_upgrade { $v and eval(rpmtools::version_compare($_[0]{version}, $v) . $o . 0) || return; $r && rpmtools::version_compare($_[0]{version}, $v) == 0 and eval(rpmtools::version_compare($_[0]{release}, $r) . $o . 0) || return; - $provides{$n} = "$_[0]{name}-$_[0]{version}-$_[0]{release}"; + $provides{$_} = "$_[0]{name}-$_[0]{version}-$_[0]{release}"; }); - unless (exists $provides{$n}) { + unless (exists $provides{$_}) { foreach my $fullname (keys %{$urpm->{params}{provides}{$n} || {}}) { exists $conflicts{$fullname} and next; my $p = $urpm->{params}{info}{$fullname}; @@ -1506,10 +1524,10 @@ sub filter_packages_to_upgrade { $r && rpmtools::version_compare($p->{version}, $v) == 0 and eval(rpmtools::version_compare($p->{release}, $r) . $o . 0) || next; #- this is incomplete, exact provides is not kept. - $provides{$n} = undef; + $provides{$_} = undef; } } - unless (exists $provides{$n}) { + unless (exists $provides{$_}) { rpmtools::db_traverse_tag($db, 'whatrequires', [ $1 ], [ qw(name version release sense requires) ], sub{ @@ -1528,17 +1546,17 @@ sub filter_packages_to_upgrade { $provides{$pkg->{name}} = undef; #"$pkg->{name}-$pkg->{version}-$pkg->{release}"; foreach (@{$pkg->{requires} || []}) { if (my ($n, $o, $v, $r) = /^([^\s\[]*)(?:\[\*\])?(?:\s+|\[)?([^\s\]]*)\s*([^\s\-\]]*)-?([^\s\]]*)/) { - exists $provides{$n} || exists $selected{$n} and next; + exists $provides{$_} || exists $selected{$_} and next; #- if the provides is not found, it will be resolved at next step, else #- it will be resolved by searching the rpm database. - $provides{$n} ||= undef; + $provides{$_} ||= undef; my $check_pkg = sub { $options{keep_alldeps} and return; $o and $n eq $_[0]{name} || return; $v and eval(rpmtools::version_compare($_[0]{version}, $v) . $o . 0) || return; $r && rpmtools::version_compare($_[0]{version}, $v) == 0 and eval(rpmtools::version_compare($_[0]{release}, $r) . $o . 0) || return; - $provides{$n} = "$_[0]{name}-$_[0]{version}-$_[0]{release}"; + $provides{$_} = "$_[0]{name}-$_[0]{version}-$_[0]{release}"; }; rpmtools::db_traverse_tag($db, $n =~ m|^/| ? 'path' : 'whatprovides', [ $n ], [ qw (name version release) ], $check_pkg); @@ -1562,7 +1580,7 @@ sub filter_packages_to_upgrade { [ qw (name version release) ], $check_pkg); foreach my $fullname (keys %{$urpm->{params}{provides}{$n} || {}}) { my $pkg = $urpm->{params}{info}{$fullname}; - $o and $n eq $_[0]{name} || next; + $o and $n eq $pkg->{name} || next; $v and eval(rpmtools::version_compare($pkg->{version}, $v) . $o . 0) || next; $r && rpmtools::version_compare($pkg->{version}, $v) == 0 and eval(rpmtools::version_compare($pkg->{release}, $r) . $o . 0) || next; @@ -1578,10 +1596,16 @@ sub filter_packages_to_upgrade { $selected{$_} = undef; my (%pre_choices, @pre_choices, @choices, @upgradable_choices, %choices_id); - foreach my $fullname (keys %{$urpm->{params}{provides}{$_} || {}}) { - exists $conflicts{$fullname} and next; - my $pkg = $urpm->{params}{info}{$fullname}; - push @{$pre_choices{$pkg->{name}}}, $pkg; + if (my ($n, $o, $v, $r) = /^([^\s\[]*)(?:\[\*\])?(?:\s+|\[)?([^\s\]]*)\s*([^\s\-\]]*)-?([^\s\]]*)/) { + foreach my $fullname (keys %{$urpm->{params}{provides}{$n} || {}}) { + exists $conflicts{$fullname} and next; + my $pkg = $urpm->{params}{info}{$fullname}; + $o and $n eq $pkg->{name} || next; + $v and eval(rpmtools::version_compare($pkg->{version}, $v) . $o . 0) || next; + $r && rpmtools::version_compare($pkg->{version}, $v) == 0 and + eval(rpmtools::version_compare($pkg->{release}, $r) . $o . 0) || next; + push @{$pre_choices{$pkg->{name}}}, $pkg; + } } foreach (values %pre_choices) { #- there is at least one element in each list of values. @@ -40,11 +40,14 @@ my $verbose = 0; my $uid; my @files; +my @src_files; +my @rpms_install; +my @rpms_upgrade; my @names; -#$ENV{PATH} = "/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"; -#delete @ENV{qw(ENV BASH_ENV IFS CDPATH)}; -#($<, $uid) = ($>, $<); +$ENV{PATH} = "/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"; +delete @ENV{qw(ENV BASH_ENV IFS CDPATH)}; +($<, $uid) = ($>, $<); sub usage { print STDERR _("urpmi version %s @@ -68,7 +71,7 @@ usage: ") . _(" -p - allow search in provides to find package. ") . _(" -q - quiet mode. ") . _(" -v - verbose mode. -") . "\n" . _(" names or rpm files (only for root) given on command line are installed. +") . "\n" . _(" names or rpm files given on command line are installed. ", $urpm::VERSION); exit(0); } @@ -104,195 +107,205 @@ for (@ARGV) { /v/ and do { $verbose = 1; next }; die _("urpmi: unknown option \"-%s\", check usage with --help\n", $1); } next }; @nextargv and do { my $r = shift @nextargv; $r and $$r = $_; next }; - #- only superuser by default can install packages, - #- TODO check for source package, to download but not to install ? - $uid == 0 or $urpm->fatal(1, _("Only superuser is allowed to install packages")); - /\.rpm$/ and do { push @files, untaint($_); next }; + if (/\.rpm$/) { + if (/\.src\.rpm$/) { + push @src_files, $_; + } + push @files, untaint($_); + next; + } push @names, $_; } -#- log only at this point in case of query usage. -log_it(scalar localtime, " urpmi called with @ARGV\n"); - -my ($pid_out, $pid_err); +#- params contains informations to parse installed system. +my $urpm = new urpm; -open SAVEOUT, ">&STDOUT"; select SAVEOUT; $| = 1; -open SAVEERR, ">&STDERR"; select SAVEERR; $| = 1; -unless ($pid_out = open STDOUT, "|-") { - open F, ">>/var/log/urpmi.log"; select F; $| = 1; - select SAVEOUT; $| = 1; - $/ = \1; - while (<STDIN>) { - print SAVEOUT $_; - print F $_; +if ($uid) { + #- only src files are installable using urpmi. + @src_files or $urpm->{fatal}(1, _("Only superuser is allowed to install packages")); + + #- allow installation. + @rpms_install = @src_files; +} else { + #- log only at this point in case of query usage. + log_it(scalar localtime, " urpmi called with @ARGV\n"); + + my ($pid_out, $pid_err); + + open SAVEOUT, ">&STDOUT"; select SAVEOUT; $| = 1; + open SAVEERR, ">&STDERR"; select SAVEERR; $| = 1; + unless ($pid_out = open STDOUT, "|-") { + open F, ">>/var/log/urpmi.log"; select F; $| = 1; + select SAVEOUT; $| = 1; + $/ = \1; + while (<STDIN>) { + print SAVEOUT $_; + print F $_; + } + close F; + exit 0; } - close F; - exit 0; -} -unless ($pid_err = open STDERR, "|-") { - open F, ">>/var/log/urpmi.log"; select F; $| = 1; - select SAVEERR; $| = 1; - $/ = \1; - while (<STDIN>) { - print SAVEERR $_; - print F $_; + unless ($pid_err = open STDERR, "|-") { + open F, ">>/var/log/urpmi.log"; select F; $| = 1; + select SAVEERR; $| = 1; + $/ = \1; + while (<STDIN>) { + print SAVEERR $_; + print F $_; + } + close F; + exit 0; } - close F; - exit 0; -} -select STDERR; $| = 1; # make unbuffered -select STDOUT; $| = 1; # make unbuffered + select STDERR; $| = 1; # make unbuffered + select STDOUT; $| = 1; # make unbuffered -#- params contains informations to parse installed system. -my $urpm = new urpm; + #- use specific sync routine. + $sync and $urpm->{sync} = $sync; -#- use specific sync routine. -$sync and $urpm->{sync} = $sync; + #- remove verbose if not asked. + $verbose or $urpm->{log} = sub {}; -#- remove verbose if not asked. -$verbose or $urpm->{log} = sub {}; - -$urpm->read_config; -if ($media) { - $urpm->select_media(split ',', $media); - foreach (grep { !$_->{modified} } @{$urpm->{media} || []}) { - #- this is only a local ignore that will not be saved. - $_->{ignore} = 1; + $urpm->read_config; + if ($media) { + $urpm->select_media(split ',', $media); + foreach (grep { !$_->{modified} } @{$urpm->{media} || []}) { + #- this is only a local ignore that will not be saved. + $_->{ignore} = 1; + } + } + foreach (grep { !$_->{ignore} && (!$update || $_->{update}) } @{$urpm->{media} || []}) { + $urpm->parse_synthesis($_); } -} -foreach (grep { !$_->{ignore} && (!$update || $_->{update}) } @{$urpm->{media} || []}) { - $urpm->parse_synthesis($_); -} - -if (@files) { - $uid == 0 or $urpm->fatal(1, _("Only superuser is allowed to install local packages")); - #- sanity check of pathname. - m|^/| or $_ = "./$_" foreach @files; + if (@files) { + #- sanity check of pathname. + m|^/| or $_ = "./$_" foreach @files; - #- build closure with local package and return list of names. - push @names, $urpm->register_local_packages(@files); -} + #- build closure with local package and return list of names. + push @names, $urpm->register_local_packages(@files); + } -#- relocate depslist. -$urpm->relocate_depslist_provides(); - - -#- 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 will be updated too. -#- make sure basesystem exists before. -my %packages; -$urpm->search_packages(\%packages, [ @names], - all => $all, - use_provides => $use_provides) or $force or exit 1; - -#- filter to add in packages selected required packages. -my $ask_choice = sub { - my ($urpm, $from_id, @choices_id) = @_; - my $n = 1; #- default value. - my ($from, @l) = map { my $info = $urpm->{params}{depslist}[$_]; - "$info->{name}-$info->{version}-$info->{release}" } ($from_id, @choices_id); - - if (@l > 1 && !$auto) { - my $msg = (defined $from_id ? - _("One of the following packages is needed to install %s:", $from) : - _("One of the following packages is needed:")); - if ($X) { - `gchooser "$msg" @l`; - $n = $? >> 8 || die; - } else { - print SAVEOUT "$msg\n"; - my $i = 0; foreach (@l) { print SAVEOUT " ", ++$i, "- $_\n"; } - while (1) { - printf SAVEOUT _("What is your choice? (1-%d) ", $i); - $n = <STDIN>; - 1 <= $n && $n <= $i and last; - print SAVEOUT _("Sorry, bad choice, try again\n"); + #- relocate depslist. + $urpm->relocate_depslist_provides(); + + + #- 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 will be updated too. + #- make sure basesystem exists before. + my %packages; + $urpm->search_packages(\%packages, [ @names], + all => $all, + use_provides => $use_provides) or $force or exit 1; + + #- filter to add in packages selected required packages. + my $ask_choice = sub { + my ($urpm, $from_id, @choices_id) = @_; + my $n = 1; #- default value. + my ($from, @l) = map { my $info = $urpm->{params}{depslist}[$_]; + "$info->{name}-$info->{version}-$info->{release}" } ($from_id, @choices_id); + + if (@l > 1 && !$auto) { + my $msg = (defined $from_id ? + _("One of the following packages is needed to install %s:", $from) : + _("One of the following packages is needed:")); + if ($X) { + `gchooser "$msg" @l`; + $n = $? >> 8 || die; + } else { + print SAVEOUT "$msg\n"; + my $i = 0; foreach (@l) { print SAVEOUT " ", ++$i, "- $_\n"; } + while (1) { + printf SAVEOUT _("What is your choice? (1-%d) ", $i); + $n = <STDIN>; + 1 <= $n && $n <= $i and last; + print SAVEOUT _("Sorry, bad choice, try again\n"); + } } } - } - $choices_id[$n - 1]; -}; + $choices_id[$n - 1]; + }; -#- auto select package for upgrading the distribution. -if ($auto_select) { - my (%to_remove, %keep_files); + #- auto select package for upgrading the distribution. + if ($auto_select) { + my (%to_remove, %keep_files); - $urpm->select_packages_to_upgrade('', \%packages, \%to_remove, \%keep_files, use_parsehdlist => $complete); + $urpm->select_packages_to_upgrade('', \%packages, \%to_remove, \%keep_files, use_parsehdlist => $complete); - if (keys(%to_remove) > 0) { - print STDERR "some packages have to be removed for being upgraded, this is not supported yet\n"; + if (keys(%to_remove) > 0) { + print STDERR "some packages have to be removed for being upgraded, this is not supported yet\n"; + } } -} -$urpm->filter_packages_to_upgrade(\%packages, $ask_choice); + $urpm->filter_packages_to_upgrade(\%packages, $ask_choice); -#- get out of package that should not be upgraded. -$urpm->deselect_unwanted_packages(\%packages); + #- get out of package that should not be upgraded. + $urpm->deselect_unwanted_packages(\%packages); -#- package to install as a array of strings. -my @to_install; + #- package to install as a array of strings. + my @to_install; -#- check if there is at least one package to install that -#- has not been given by the user. -my $ask_user = $auto_select && scalar(keys %packages); -my $sum = 0; -foreach (keys %packages) { - defined $packages{$_} and $ask_user = 1; - my $info = $urpm->{params}{depslist}[$_]; - $sum += $info->{size}; - push @to_install, "$info->{name}-$info->{version}-$info->{release}"; -} -if (!$auto) { - if ($ask_user) { - my $msg = _("To satisfy dependencies, the following packages are going to be installed (%d MB)", toMb($sum)); - my $msg2 = _("Is it OK?"); - if ($X) { - my $p = join "\n", @to_install; - my $ok = _("Ok"); - my $cancel = _("Cancel"); - `gmessage -default $ok -buttons "$ok:0,$cancel:2" "$msg:\n$p\n\n$msg2"`; - $? and exit 0; - } else { - $noexpr = _("Nn"); - $yesexpr = _("Yy"); - print SAVEOUT "$msg:\n@to_install\n$msg2" . _(" (Y/n) "); - <STDIN> =~ /[$noexpr]/ and exit 0; + #- check if there is at least one package to install that + #- has not been given by the user. + my $ask_user = $auto_select && scalar(keys %packages); + my $sum = 0; + foreach (keys %packages) { + defined $packages{$_} and $ask_user = 1; + my $info = $urpm->{params}{depslist}[$_]; + $sum += $info->{size}; + push @to_install, "$info->{name}-$info->{version}-$info->{release}"; + } + if (!$auto) { + if ($ask_user) { + my $msg = _("To satisfy dependencies, the following packages are going to be installed (%d MB)", toMb($sum)); + my $msg2 = _("Is it OK?"); + if ($X) { + my $p = join "\n", @to_install; + my $ok = _("Ok"); + my $cancel = _("Cancel"); + `gmessage -default $ok -buttons "$ok:0,$cancel:2" "$msg:\n$p\n\n$msg2"`; + $? and exit 0; + } else { + $noexpr = _("Nn"); + $yesexpr = _("Yy"); + print SAVEOUT "$msg:\n@to_install\n$msg2" . _(" (Y/n) "); + <STDIN> =~ /[$noexpr]/ and exit 0; + } } } -} -my ($local_sources, $list, $local_to_removes) = $urpm->get_source_packages(\%packages); -unless ($local_sources || $list) { - $urpm->{fatal}(3, _("unable to get source packages, aborting")); -} -#- clean cache with file that are not necessary with this transaction. -#- TODO check not another urpmi is doing the same... -foreach (@$local_to_removes) { - unlink $_; + my ($local_sources, $list, $local_to_removes) = $urpm->get_source_packages(\%packages); + unless ($local_sources || $list) { + $urpm->{fatal}(3, _("unable to get source packages, aborting")); + } + #- clean cache with file that are not necessary with this transaction. + #- TODO check not another urpmi is doing the same... + foreach (@$local_to_removes) { + unlink $_; + } + + my %sources = $urpm->upload_source_packages($local_sources, $list, ($X ? '' : 'force_local'), + (!$auto || $allow_medium_change) && sub { + my $msg = _("Please insert the medium named \"%s\" on device [%s]", @_); + my $msg2 = _("Press Enter when it's done..."); + if ($X) { + my $ok = _("Ok"); + my $cancel = _("Cancel"); + $msg =~ s/"/\\"/g; + `gmessage -default $ok -buttons "$ok:0,$cancel:2" "$msg"`; + !$?; + } else { + print SAVEOUT "$msg\n$msg2 "; + <STDIN>; 1; + } + }); + + #- install package. + @rpms_install = grep { $_ !~ /\.src.\.rpm/ } values %{$urpm->extract_packages_to_install(\%sources) || {}}; + @rpms_upgrade = grep { $_ !~ /\.src.\.rpm/ } values %sources; } -my %sources = $urpm->upload_source_packages($local_sources, $list, ($X ? '' : 'force_local'), - (!$auto || $allow_medium_change) && sub { - my $msg = _("Please insert the medium named \"%s\" on device [%s]", @_); - my $msg2 = _("Press Enter when it's done..."); - if ($X) { - my $ok = _("Ok"); - my $cancel = _("Cancel"); - $msg =~ s/"/\\"/g; - `gmessage -default $ok -buttons "$ok:0,$cancel:2" "$msg"`; - !$?; - } else { - print SAVEOUT "$msg\n$msg2 "; - <STDIN>; 1; - } - }); - -#- install package. -my @rpms_install = grep { $_ !~ /\.src.\.rpm/ } values %{$urpm->extract_packages_to_install(\%sources) || {}}; -my @rpms_upgrade = grep { $_ !~ /\.src.\.rpm/ } values %sources; if (@rpms_install || @rpms_upgrade) { printf SAVEOUT _("installing %s\n", join(' ', @rpms_install, @rpms_upgrade)); log_it(scalar localtime, " @_\n"); @@ -380,9 +393,12 @@ sub message { $X ? `gmessage -default Ok -buttons Ok "$_[0]"` : print SAVEOUT "$ sub message_auto { $auto ? print SAVEOUT "$_[0]\n" : message($_[0]); } sub log_it { - local *LOG; - open LOG, ">>/var/log/urpmi.log" or die "can't output to log file\n"; - print LOG @_; + #- if invoked as a simple user, nothing should be logged. + if ($uid == 0) { + local *LOG; + open LOG, ">>/var/log/urpmi.log" or die "can't output to log file\n"; + print LOG @_; + } } sub untaint { diff --git a/urpmi.addmedia b/urpmi.addmedia index be398787..ead4b13a 100755 --- a/urpmi.addmedia +++ b/urpmi.addmedia @@ -46,13 +46,12 @@ and [options] are from $options{force} = 0; $options{noclean} = 1; - $options{sync} = undef; while ($_ = shift @_) { /^--?c/ and $options{noclean} = 0, next; /^--?h/ and $options{probe_with_hdlist} = 1, next; /^--?f/ and ++$options{force}, next; - /^--wget/ and $options{sync} = \&urpm::sync_wget, next; - /^--curl/ and $options{sync} = \&urpm::sync_curl, next; + /^--wget/ and $urpm->{sync} = \&urpm::sync_wget, next; + /^--curl/ and $urpm->{sync} = \&urpm::sync_curl, next; /^--distrib$/ and $options{distrib} = 1, next; /^--update$/ and $options{update} = 1, next; /^-/ and die $usage . _("\nunknown options '%s'\n", $_); @@ -64,7 +63,6 @@ and [options] are from my ($type) = $url =~ m,^([^:]*)://, or die $usage; my $urpm = new urpm; - $options{sync} and $urpm->{sync} = $options{sync}; $urpm->read_config; @@ -2,7 +2,7 @@ Name: urpmi Version: 3.2 -Release: 3mdk +Release: 4mdk License: GPL Source0: %{name}.tar.bz2 Source1: %{name}.logrotate @@ -144,6 +144,15 @@ fi %changelog +* Mon Jan 28 2002 François Pons <fpons@mandrakesoft.com> 3.2-4mdk +- integrated patch for supermount from Andrej Borsenkow. +- fixed --wget (or --curl) not used in urpmi.update. +- try to manage .src.rpm file in a usable way. +- fixed requires resolution on multiple requires with + sense and without sense informations on the same + package (menu bug). +- fixed typo in po/fr.po (multiple -f for help page). + * Wed Jan 23 2002 François Pons <fpons@mandrakesoft.com> 3.2-3mdk - fixed possible conflicts management error. - fixed --mediums for upload of same package in different media. diff --git a/urpmi.update b/urpmi.update index ed75724b..eb36afac 100755 --- a/urpmi.update +++ b/urpmi.update @@ -26,17 +26,17 @@ import urpm _; sub main { my (@toupdates, %options); + my $urpm = new urpm; $options{force} = 0; $options{noclean} = 1; - $options{sync} = undef; foreach (@_) { /^--?a/ and $options{all} = 1, next; /^--?c/ and $options{noclean} = 0, next; /^--?d/ and $options{depslist} = 1, next; /^--?f/ and ++$options{force}, next; - /^--wget/ and $options{sync} = \&urpm::sync_wget, next; - /^--curl/ and $options{sync} = \&urpm::sync_curl, next; + /^--wget/ and $urpm->{sync} = \&urpm::sync_wget, next; + /^--curl/ and $urpm->{sync} = \&urpm::sync_curl, next; /^--?noa/ and next; #- default, keeped for compability. /^-/ and die _("usage: urpmi.update [options] <name> ... where <name> is a medium name to update. @@ -50,7 +50,7 @@ where <name> is a medium name to update. push @toupdates, $_; } - my $urpm = new urpm; $urpm->read_config; + $urpm->read_config; my @entries = map { $_->{name} } @{$urpm->{media}}; if ($options{all}) { |