aboutsummaryrefslogtreecommitdiffstats
path: root/rpmtools.pm
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2000-09-03 17:03:33 +0000
committerFrancois Pons <fpons@mandriva.com>2000-09-03 17:03:33 +0000
commit6b947817a5c48e175a43f95ab6d59cfec58f4e67 (patch)
treebc3eff5bb42e0ad9839daf5719db55cb196b99d8 /rpmtools.pm
parent75d42db69052672a2e8ce38303577e826ff380f7 (diff)
downloadrpmtools-6b947817a5c48e175a43f95ab6d59cfec58f4e67.tar
rpmtools-6b947817a5c48e175a43f95ab6d59cfec58f4e67.tar.gz
rpmtools-6b947817a5c48e175a43f95ab6d59cfec58f4e67.tar.bz2
rpmtools-6b947817a5c48e175a43f95ab6d59cfec58f4e67.tar.xz
rpmtools-6b947817a5c48e175a43f95ab6d59cfec58f4e67.zip
*** empty log message ***
Diffstat (limited to 'rpmtools.pm')
-rw-r--r--rpmtools.pm50
1 files changed, 47 insertions, 3 deletions
diff --git a/rpmtools.pm b/rpmtools.pm
index 85a6e12..6ccb303 100644
--- a/rpmtools.pm
+++ b/rpmtools.pm
@@ -53,10 +53,18 @@ sub compute_depslist {
my @info = grep { ! exists $_->{id} } values %{$params->{info}};
#- speed up the search by giving a provide from all packages.
+ #- and remove all dobles for each one !
foreach (@info) {
push @{$params->{provides}{$_->{name}} ||= []}, $_->{name};
}
+ #- remove all dobles for each provides.
+ foreach (keys %{$params->{provides}}) {
+ $params->{provides}{$_} or next;
+ my %provides; @provides{@{$params->{provides}{$_}}} = ();
+ $params->{provides}{$_} = [ keys %provides ];
+ }
+
#- search for entries in provides, if such entries are found,
#- another pass has to be done. TODO.
@@ -231,13 +239,49 @@ sub read_depslist {
1;
}
+#- relocate depslist array to use only the most recent packages,
+#- reorder info hashes too in the same manner.
+sub relocate_depslist {
+ my ($params) = @_;
+ my $relocated_entries = 0;
+
+ foreach (@{$params->{depslist} || []}) {
+ if ($params->{info}{$_->{name}} != $_) {
+ #- at this point, it is sure there is a package that
+ #- is multiply defined and this should be fixed.
+ #- first correct info hash, then a second pass on depslist
+ #- is required to relocate its entries.
+ my $cmp_version = compare_version($_->{version}, $params->{info}{$_->{name}});
+ if ($cmp_version > 0 || $cmp_version == 0 &&
+ compare_version($_->{release}, $params->{info}{$_->{name}}) > 0) {
+ $params->{info}{$_->{name}} = $_;
+ ++$relocated_entries;
+ }
+ }
+ }
+
+ if ($relocated_entries) {
+ my $n = scalar(@{$params->{depslist}}) - 1;
+ for (0..$n) {
+ my $pkg = $params->{depslist}[$_];
+ $params->{depslist}[$_] = $params->{info}{$pkg->{name}};
+ }
+ }
+
+ $relocated_entries;
+}
+
#- write depslist.ordered file according to info in params.
sub write_depslist {
my ($params, $FILE, $min, $max) = @_;
- foreach (grep { (! defined $min || $_->{id} >= $min) && (! defined $max || $_->{id} <= $max) }
- sort { $a->{id} <=> $b->{id} } values %{$params->{info}}) {
- printf $FILE "%s-%s-%s %s %s\n", $_->{name}, $_->{version}, $_->{release}, $_->{size}, $_->{deps};
+ $min > 0 or $min = 0;
+ defined $max && $max < scalar(@{$params->{depslist} || []}) or $max = scalar(@{$params->{depslist} || []}) - 1;
+ $max >= $min or return;
+
+ for ($min..$max) {
+ my $pkg = $params->{depslist}[$_];
+ printf $FILE "%s-%s-%s %s %s\n", $pkg->{name}, $pkg->{version}, $pkg->{release}, $pkg->{size}, $pkg->{deps};
}
1;
}