From 98abfd8a4d784ede07c3d7f9aa1048006f4a206e Mon Sep 17 00:00:00 2001 From: Francois Pons Date: Fri, 16 Nov 2001 14:04:07 +0000 Subject: added /etc/urpmi/inst.list support. --- urpm.pm | 80 +++++++++++++++++++++++++++++------------------ urpmi | 104 ++++++++++++++++++++++++++++++++++++++++--------------------- urpmi.spec | 21 +++++++++++-- urpmq | 8 ++--- 4 files changed, 141 insertions(+), 72 deletions(-) diff --git a/urpm.pm b/urpm.pm index 912df127..9d139334 100644 --- a/urpm.pm +++ b/urpm.pm @@ -1287,7 +1287,6 @@ sub filter_packages_to_upgrade { #- parse synthesis file to retrieve information stored inside. sub parse_synthesis { my ($urpm, $synthesis) = @_; - local (*F, $_); my ($error, $last_name, @founds, %info); @@ -1337,6 +1336,7 @@ sub parse_synthesis { } $update_info->(); close F or $urpm->{error}(_("unable to parse correctly [%s]", $synthesis)), return; + $urpm->{log}(_("read synthesis file [%s]", $synthesis)); @founds; } @@ -1572,7 +1572,6 @@ sub filter_minimal_packages_to_upgrade { sub deselect_unwanted_packages { my ($urpm, $packages, %options) = @_; - my %skip; local ($_, *F); open F, $urpm->{skiplist}; while () { @@ -1593,14 +1592,14 @@ sub deselect_unwanted_packages { #- have a null list. sub get_source_packages { my ($urpm, $packages) = @_; - my ($error, @local_to_removes, @local_sources, @list, %fullname2id, %file2fullnames); + my ($error, %local_sources, @list, @local_to_removes, %fullname2id, %file2fullnames); local (*D, *F, $_); #- build association hash to retrieve id and examine all list files. foreach (keys %$packages) { my $p = $urpm->{params}{depslist}[$_]; if ($p->{source}) { - push @local_sources, $p->{source}; + $local_sources{$_} = $p->{source}; } else { $fullname2id{"$p->{name}-$p->{version}-$p->{release}.$p->{arch}"} = $_; } @@ -1647,8 +1646,8 @@ sub get_source_packages { next; } elsif (keys(%{$file2fullnames{$1} || {}}) == 1) { my ($fullname) = keys(%{$file2fullnames{$1} || {}}); - if (defined delete $fullname2id{$fullname}) { - push @local_sources, "$urpm->{cachedir}/rpms/$1.rpm"; + if (my $id = defined delete $fullname2id{$fullname}) { + $local_sources{$id} = "$urpm->{cachedir}/rpms/$1.rpm"; } else { push @local_to_removes, "$urpm->{cachedir}/rpms/$1.rpm"; } @@ -1662,7 +1661,7 @@ sub get_source_packages { closedir D; foreach my $medium (@{$urpm->{media} || []}) { - my @sources; + my %sources; if (-r "$urpm->{statedir}/$medium->{list}" && !$medium->{ignore}) { open F, "$urpm->{statedir}/$medium->{list}"; @@ -1673,7 +1672,8 @@ sub get_source_packages { next; } elsif (keys(%{$file2fullnames{$2} || {}}) == 1) { my ($fullname) = keys(%{$file2fullnames{$2} || {}}); - defined delete $fullname2id{$fullname} and push @sources, "$1/$2.rpm"; + my $id = delete $fullname2id{$fullname}; + defined $id and $sources{$id} = "$1/$2.rpm"; } } else { chomp; @@ -1684,7 +1684,7 @@ sub get_source_packages { } close F; } - push @list, \@sources; + push @list, \%sources; } #- examine package list to see if a package has not been found. @@ -1693,7 +1693,7 @@ sub get_source_packages { $urpm->{error}(_("package %s is not found.", $_)); } - $error ? () : ( \@local_sources, \@list, \@local_to_removes ); + $error ? () : ( \%local_sources, \@list, \@local_to_removes ); } #- upload package that may need to be uploaded. @@ -1704,7 +1704,7 @@ sub get_source_packages { #- return a list of package ready for rpm. sub upload_source_packages { my ($urpm, $local_sources, $list, $force_local, $ask_for_medium) = @_; - my (@sources, @distant_sources, %media, %removables); + my (%sources, @distant_sources, %media, %removables); #- make sure everything is correct on input... @{$urpm->{media}} == @$list or return; @@ -1719,12 +1719,12 @@ sub upload_source_packages { my $count_not_found = sub { my $not_found; if (-e $dir) { - foreach (@{$list->[$id]}) { + foreach (values %{$list->[$id]}) { /^(removable_?[^_:]*|file):\/(.*\/([^\/]*))/ or next; -r $2 or ++$not_found; } } else { - $not_found = @{$list->[$id]}; + $not_found = values %{$list->[$id]}; } return $not_found; }; @@ -1742,14 +1742,14 @@ sub upload_source_packages { } if (-e $dir) { my @removable_sources; - foreach (@{$list->[$id]}) { - /^(removable_?[^_:]*|file):\/(.*\/([^\/]*))/ or next; + while (my ($i, $url) = each %{$list->[$id]}) { + $url =~ /^(removable_?[^_:]*|file):\/(.*\/([^\/]*))/ or next; -r $2 or $urpm->{error}(_("unable to read rpm file [%s] from medium \"%s\"", $2, $medium->{name})); if ($copy) { push @removable_sources, $2; - push @sources, "$urpm->{cachedir}/rpms/$3"; + $sources{$i} = "$urpm->{cachedir}/rpms/$3"; } else { - push @sources, $2; + $sources{$i} = $2; } } if (@removable_sources) { @@ -1764,7 +1764,7 @@ sub upload_source_packages { } }; foreach (0..$#$list) { - @{$list->[$_]} or next; + values %{$list->[$_]} or next; my $medium = $urpm->{media}[$_]; #- examine non removable device but that may be mounted. if ($medium->{removable}) { @@ -1779,7 +1779,7 @@ sub upload_source_packages { #- if more than one media use this device, we have to sort #- needed package to copy first the needed rpms files. if (@{$removables{$device}} > 1) { - my @sorted_media = sort { @{$list->[$a]} <=> @{$list->[$b]} } @{$removables{$device}}; + my @sorted_media = sort { values %{$list->[$a]} <=> values %{$list->[$b]} } @{$removables{$device}}; #- mount all except the biggest one. foreach (@sorted_media[0 .. $#sorted_media-1]) { @@ -1798,19 +1798,19 @@ sub upload_source_packages { #- we are using wget for that with an input from its stdin. foreach (0..$#$list) { exists $media{$_} and next; - @{$list->[$_]} or next; - foreach (@{$list->[$_]}) { - if (/^(removable_?[^_:]*|file):\/(.*)/) { - push @sources, $2; - } elsif (/^([^:]*):\/(.*\/([^\/]*))/) { + values %{$list->[$_]} or next; + while (my ($i, $url) = each %{$list->[$_]}) { + if ($url =~ /^(removable_?[^_:]*|file):\/(.*)/) { + $sources{$i} = $2; + } elsif ($url =~ /^([^:]*):\/(.*\/([^\/]*))/) { if ($force_local) { - push @distant_sources, $_; - push @sources, "$urpm->{cachedir}/rpms/$3"; + push @distant_sources, $url; + $sources{$i} = "$urpm->{cachedir}/rpms/$3"; } else { - push @sources, $_; + $sources{$i} = $url; } } else { - $urpm->{error}(_("malformed input: [%s]", $_)); + $urpm->{error}(_("malformed input: [%s]", $url)); } } } @@ -1820,8 +1820,28 @@ sub upload_source_packages { $? == 0 or $urpm->{error}(_("wget of [%s] failed", "/$_")); } - #- return the list of rpm file that have to be installed, they are all local now. - @$local_sources, @sources; + #- return the hash of rpm file that have to be installed, they are all local now. + %$local_sources, %sources; +} + +#- extract package that should be installed instead of upgraded, +#- sources is a hash of id -> source rpm filename. +sub extract_packages_to_install { + my ($urpm, $sources) = @_; + + my %inst; + local ($_, *F); + open F, $urpm->{instlist}; + while () { + chomp; s/#.*$//; s/^\s*//; s/\s*$//; + foreach (@{$urpm->{params}{provides}{$_} || []}) { + my $pkg = $urpm->{params}{info}{$_} or next; + exists $sources->{$pkg->{id}} and $inst{$pkg->{id}} = delete $sources->{$pkg->{id}}; + } + } + close F; + + \%inst; } sub select_packages_to_upgrade { diff --git a/urpmi b/urpmi index 7b0c3b3c..562651fc 100755 --- a/urpmi +++ b/urpmi @@ -33,7 +33,7 @@ my $WID = 0; my $all = 0; my $complete = 0; my $minimal = 1; -my $rpm_opt = "-Uvh"; +my $rpm_opt = "vh"; my $use_provides = 0; my $verbose = 0; @@ -92,7 +92,7 @@ for (@ARGV) { /c/ and do { $complete = 1; next }; /m/ and do { $minimal = 1; next }; /M/ and do { next }; #- nop - /q/ and do { $rpm_opt = "-U"; next }; + /q/ and do { $rpm_opt = ""; next }; /p/ and do { $use_provides = 1; next }; /v/ and do { $verbose = 1; next }; die _("urpmi: unknown option \"-%s\", check usage with --help\n", $1); } next }; @@ -272,7 +272,7 @@ foreach (@$local_to_removes) { unlink $_; } -my @sources = $urpm->upload_source_packages($local_sources, $list, ($X ? '' : 'force_local'), +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..."); @@ -288,47 +288,79 @@ my @sources = $urpm->upload_source_packages($local_sources, $list, ($X ? '' : 'f } }); -install(@sources); -@sources or message_auto(_("everything already installed")); - -#- this help flushing correctly by closing this file before (piped on tee). -#- but killing them is generally better. -fork() or do { sleep 1; kill 15, $pid_err, $pid_out }; -close STDERR; -close STDOUT; - -sub install { - my @l = grep { $_ !~ /\.src.\.rpm/ } @_; - @l or return; - +#- 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(' ', @l)); log_it(scalar localtime, " @_\n"); $urpm->{log}("starting installing packages"); - system($X ? ("grpmi", $WID ? ("--WID=$WID") : ()) : ("rpm", $rpm_opt), @l); - if ($?) { - message(_("Installation failed")); - $X and exit(($? >> 8) + 32); #- grpmi handles --nodeps and --force by itself, forward grpmi error + 32 - - m|^/| && !-e $_ and exit 2 foreach @l; #- missing local file - - $noexpr = _("Nn"); - $yesexpr = _("Yy"); - print SAVEOUT _("Try installation without checking dependencies? (y/N) "); - $auto and exit 1; #- if auto has been set, avoid asking user. - $force or =~ /[$yesexpr]/ or exit 1; - $urpm->{log}("starting installing packages without deps"); - system("rpm", $rpm_opt, "--nodeps", @l); - + if ($X) { + system("grpmi", $WID ? ("--WID=$WID") : (), map { ("-noupgrade", $_) } @rpms_install, @rpms_upgrade); if ($?) { - message(_("Installation failed")); - print SAVEOUT _("Try installation even more strongly (--force)? (y/N) "); - $force or =~ /[$yesexpr]/ or exit 1; - $urpm->{log}("starting force installing packages without deps"); - system("rpm", $rpm_opt, "--nodeps", "--force", @l); + message(_("Installation failed")); #- grpmi handles --nodeps and --force by itself, + exit(($? >> 8) + 32); #- forward grpmi error + 32 + } + } else { + if (@rpms_install) { + system("rpm", "-i$rpm_opt", @rpms_install); + if (@$_) { + message(_("Installation failed")); + + m|^/| && !-e $_ and exit 2 foreach @l; #- missing local file + + $noexpr = _("Nn"); + $yesexpr = _("Yy"); + print SAVEOUT _("Try installation without checking dependencies? (y/N) "); + $auto and exit 1; #- if auto has been set, avoid asking user. + $force or =~ /[$yesexpr]/ or exit 1; + $urpm->{log}("starting installing packages without deps"); + system("rpm", "-i$rpm_opt", "--nodeps", @rpms_install); + + if ($?) { + message(_("Installation failed")); + print SAVEOUT _("Try installation even more strongly (--force)? (y/N) "); + $force or =~ /[$yesexpr]/ or exit 1; + $urpm->{log}("starting force installing packages without deps"); + system("rpm", "-i$rpm_opt", "--nodeps", "--force", @rpms_install); + } + } + } + if (@rpms_upgrade) { + system("rpm", "-U$rpm_opt", @rpms_upgrade); + if ($?) { + message(_("Installation failed")); + + m|^/| && !-e $_ and exit 2 foreach @l; #- missing local file + + $noexpr = _("Nn"); + $yesexpr = _("Yy"); + print SAVEOUT _("Try installation without checking dependencies? (y/N) "); + $auto and exit 1; #- if auto has been set, avoid asking user. + $force or =~ /[$yesexpr]/ or exit 1; + $urpm->{log}("starting installing packages without deps"); + system("rpm", "-U$rpm_opt", "--nodeps", @rpms_upgrade); + + if ($?) { + message(_("Installation failed")); + print SAVEOUT _("Try installation even more strongly (--force)? (y/N) "); + $force or =~ /[$yesexpr]/ or exit 1; + $urpm->{log}("starting force installing packages without deps"); + system("rpm", "-U$rpm_opt", "--nodeps", "--force", @rpms_upgrade); + } + } } } +} else { + message_auto(_("everything already installed")); } +#- this help flushing correctly by closing this file before (piped on tee). +#- but killing them is generally better. +fork() or do { sleep 1; kill 15, $pid_err, $pid_out }; +close STDERR; +close STDOUT; + sub toMb { my $nb = $_[0] / 1024 / 1024; int $nb + 0.5; diff --git a/urpmi.spec b/urpmi.spec index c98472a0..a8cd940f 100644 --- a/urpmi.spec +++ b/urpmi.spec @@ -2,13 +2,13 @@ Name: urpmi Version: 2.0 -Release: 4mdk +Release: 5mdk License: GPL Source0: %{name}.tar.bz2 Source1: %{name}.logrotate Summary: User mode rpm install Requires: eject, wget -PreReq: perl-gettext, rpmtools >= 3.1 +PreReq: perl-gettext, rpmtools >= 3.1-5mdk BuildRequires: libbzip2-devel rpm-devel BuildRoot: %{_tmppath}/%{name}-buildroot @@ -45,6 +45,19 @@ do install -d $RPM_BUILD_ROOT/var/cache/urpmi/$dir done install -m 644 autoirpm.deny $RPM_BUILD_ROOT/etc/urpmi +cat <$RPM_BUILD_ROOT/etc/urpmi/inst.list +kernel +kernel-smp +kernel-secure +kernel-enterprise +kernel-linus2.2 +kernel-linus2.4 +kernel22 +kernel22-secure +kernel22-smp +hackkernel +EOF + mkdir -p $RPM_BUILD_ROOT%{perl_sitearch} install -m 644 urpm.pm $RPM_BUILD_ROOT%{perl_sitearch} @@ -83,6 +96,7 @@ rm -f /var/lib/urpmi/depslist %dir /var/cache/urpmi/headers %dir /var/cache/urpmi/rpms %config(noreplace) /etc/urpmi/skip.list +%config(noreplace) /etc/urpmi/inst.list %config(noreplace) %{_sysconfdir}/logrotate.d/%{name} %{_bindir}/urpmi_rpm-find-leaves %{_bindir}/urpmf @@ -112,6 +126,9 @@ rm -f /var/lib/urpmi/depslist %changelog +* Fri Nov 16 2001 François Pons 2.0-5mdk +- added /etc/urpmi/inst.list support. + * Thu Nov 15 2001 François Pons 2.0-4mdk - first stable support for updating synthesis file. diff --git a/urpmq b/urpmq index bcc7782d..63a66c13 100755 --- a/urpmq +++ b/urpmq @@ -154,12 +154,12 @@ if ($query->{headers} || $query->{sources}) { if ($query->{headers}) { #- now examine source package to build headers list to extract. - @$local_sources and system 'rpm2header', @$local_sources; + values %$local_sources and system 'rpm2header', values %$local_sources; foreach (0..$#{$urpm->{media} || []}) { my @headers = (grep { my $file = "$urpm->{cachedir}/headers/$_"; -s $file and system 'cat', $file; ! -s $file } - map { /(.*)\/([^\/]*)-([^-]*)-([^-]*)\.([^\.]*)\.rpm/ and "$2-$3-$4.$5" } @{$list->[$_]}); + map { /(.*)\/([^\/]*)-([^-]*)-([^-]*)\.([^\.]*)\.rpm/ and "$2-$3-$4.$5" } values %{$list->[$_]}); @headers > 0 or next; require packdrake; @@ -167,9 +167,9 @@ if ($query->{headers} || $query->{sources}) { $packer->extract_archive(undef, @headers); } } else { - print join "\n", @$local_sources; @$local_sources and print "\n"; + print join "\n", values %$local_sources; values %$local_sources and print "\n"; foreach (0..$#{$urpm->{media} || []}) { - print join "\n", @{$list->[$_]}; @{$list->[$_]} and print "\n"; + print join "\n", values %{$list->[$_]}; values %{$list->[$_]} and print "\n"; } } exit 0; -- cgit v1.2.1