aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--URPM.pm119
-rw-r--r--URPM.xs41
-rw-r--r--perl-URPM.spec6
3 files changed, 108 insertions, 58 deletions
diff --git a/URPM.pm b/URPM.pm
index 5d712cf..2d6bb85 100644
--- a/URPM.pm
+++ b/URPM.pm
@@ -18,55 +18,6 @@ sub new {
}, $class;
}
-#- relocate depslist array id to use only the most recent packages,
-#- reorder info hashes to give only access to best packages.
-sub relocate_depslist {
- my ($urpm, %options) = @_;
- my $relocated_entries = 0;
-
- #- reset names hash now, will be filled after.
- $urpm->{names} = {};
-
- foreach (@{$urpm->{depslist} || []}) {
- #- remove access to info if arch is incompatible and only
- #- take into account compatible arch to examine.
- #- set names hash by prefering first better version,
- #- then better release, then better arch.
- if ($_->is_arch_compat) {
- my $p = $urpm->{names}{$_->name};
- if ($p) {
- if ($_->compare_pkg($p) > 0) {
- $urpm->{names}{$_->name} = $_;
- ++$relocated_entries;
- }
- } else {
- $urpm->{names}{$_->name} = $_;
- }
- } elsif ($_->arch ne 'src') {
- #- the package is removed, make it invisible (remove id).
- my $id = $_->set_id;
-
- #- the architecture is not compatible, this means the package is dropped.
- #- we have to remove its reference in provides.
- foreach ($_->provides) {
- delete $urpm->{provides}{$_}{$id};
- }
- }
- }
-
- #- relocate id used in depslist array, delete id if the package
- #- should NOT be used.
- #- if no entries have been relocated, we can safely avoid this computation.
- if ($relocated_entries) {
- foreach (@{$urpm->{depslist}}) {
- my $p = $urpm->{names}{$_->name} or next;
- $_->set_id($p->id);
- }
- }
-
- $relocated_entries;
-}
-
sub traverse {
my ($urpm, $callback) = @_;
@@ -127,3 +78,73 @@ sub traverse_tag {
$count;
}
+
+#- relocate depslist array id to use only the most recent packages,
+#- reorder info hashes to give only access to best packages.
+sub relocate_depslist {
+ my ($urpm, %options) = @_;
+ my $relocated_entries = 0;
+
+ #- reset names hash now, will be filled after.
+ $urpm->{names} = {};
+
+ foreach (@{$urpm->{depslist} || []}) {
+ #- remove access to info if arch is incompatible and only
+ #- take into account compatible arch to examine.
+ #- set names hash by prefering first better version,
+ #- then better release, then better arch.
+ if ($_->is_arch_compat) {
+ my $p = $urpm->{names}{$_->name};
+ if ($p) {
+ if ($_->compare_pkg($p) > 0) {
+ $urpm->{names}{$_->name} = $_;
+ ++$relocated_entries;
+ }
+ } else {
+ $urpm->{names}{$_->name} = $_;
+ }
+ } elsif ($_->arch ne 'src') {
+ #- the package is removed, make it invisible (remove id).
+ my $id = $_->set_id;
+
+ #- the architecture is not compatible, this means the package is dropped.
+ #- we have to remove its reference in provides.
+ foreach ($_->provides) {
+ delete $urpm->{provides}{$_}{$id};
+ }
+ }
+ }
+
+ #- relocate id used in depslist array, delete id if the package
+ #- should NOT be used.
+ #- if no entries have been relocated, we can safely avoid this computation.
+ if ($relocated_entries) {
+ foreach (@{$urpm->{depslist}}) {
+ my $p = $urpm->{names}{$_->name} or next;
+ $_->set_id($p->id);
+ }
+ }
+
+ $relocated_entries;
+}
+
+#- resolve requires using requested tag, keep resolution state to speed process.
+#- a requested package is marked to be installed, once done, a upgrade flag or
+#- installed flag is set according to needs of package.
+#- other required package will have required flag set along with upgrade flag or
+#- installed flag.
+#- base flag should always been installed or upgraded.
+#- the following options are recognized :
+#- check : check requires of installed packages.
+sub resolve_requires {
+ my ($urpm, $db, $state, %options);
+ my (@packages);
+
+ #- get package that need to be evaluated.
+ foreach (0 .. $#{$urpm->{depslist}}) {
+ my $pkg = $urpm->{depslist}[$_];
+ $pkg->flag_requested && !($pkg->flag_installed || $pkg->flag_upgrade) and push @packages, $_;
+ }
+ #TODO
+}
+
diff --git a/URPM.xs b/URPM.xs
index bbbebb9..fcaee43 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -677,6 +677,8 @@ Pkg_is_arch_compat(pkg)
} else {
RETVAL = 0;
}
+ OUTPUT:
+ RETVAL
void
Pkg_summary(pkg)
@@ -769,10 +771,12 @@ Pkg_compare_pkg(lpkg, rpkg)
int lepoch;
char *lversion;
char *lrelease;
+ char *larch;
char *leos;
int repoch;
char *rversion;
char *rrelease;
+ char *rarch;
char *reos;
CODE:
if (lpkg->info) {
@@ -785,14 +789,15 @@ Pkg_compare_pkg(lpkg, rpkg)
} else {
lepoch = 0;
}
- get_fullname_parts(lpkg, NULL, &lversion, &lrelease, &leos, NULL);
+ get_fullname_parts(lpkg, NULL, &lversion, &lrelease, &larch, &leos);
/* temporaly mark end of each substring */
lrelease[-1] = 0;
- leos[-1] = 0;
+ larch[-1] = 0;
} else if (lpkg->h) {
lepoch = get_int(lpkg->h, RPMTAG_EPOCH);
lversion = get_name(lpkg->h, RPMTAG_VERSION);
lrelease = get_name(lpkg->h, RPMTAG_RELEASE);
+ larch = headerIsEntry(lpkg->h, RPMTAG_SOURCEPACKAGE) ? "src" : get_name(lpkg->h, RPMTAG_ARCH);
} else croak("undefined package");
if (rpkg->info) {
char *s;
@@ -804,36 +809,56 @@ Pkg_compare_pkg(lpkg, rpkg)
} else {
repoch = 0;
}
- get_fullname_parts(rpkg, NULL, &rversion, &rrelease, &reos, NULL);
+ get_fullname_parts(rpkg, NULL, &rversion, &rrelease, &rarch, &reos);
/* temporaly mark end of each substring */
rrelease[-1] = 0;
- reos[-1] = 0;
+ rarch[-1] = 0;
} else if (rpkg->h) {
repoch = get_int(rpkg->h, RPMTAG_EPOCH);
rversion = get_name(rpkg->h, RPMTAG_VERSION);
rrelease = get_name(rpkg->h, RPMTAG_RELEASE);
+ rarch = headerIsEntry(rpkg->h, RPMTAG_SOURCEPACKAGE) ? "src" : get_name(rpkg->h, RPMTAG_ARCH);
} else {
/* restore info string modified */
if (lpkg->info) {
lrelease[-1] = '-';
- leos[-1] = '.';
+ larch[-1] = '.';
}
croak("undefined package");
}
compare = lepoch - repoch;
if (!compare) {
compare = rpmvercmp(lversion, rversion);
- if (!compare)
+ if (!compare) {
compare = rpmvercmp(lrelease, rrelease);
+ if (!compare) {
+ int lscore, rscore;
+
+ read_config_files();
+ lscore = rpmMachineScore(RPM_MACHTABLE_INSTARCH, larch);
+ rscore = rpmMachineScore(RPM_MACHTABLE_INSTARCH, rarch);
+ if (lscore == 0) {
+ if (rscore == 0)
+ compare = strcmp(larch, rarch);
+ else
+ compare = -1;
+ } else {
+ if (rscore == 0)
+ compare = 1;
+ else
+ compare = rscore - lscore; /* score are lower for better */
+ }
+ }
+ }
}
/* restore info string modified */
if (lpkg->info) {
lrelease[-1] = '-';
- leos[-1] = '.';
+ larch[-1] = '.';
}
if (rpkg->info) {
rrelease[-1] = '-';
- reos[-1] = '.';
+ rarch[-1] = '.';
}
RETVAL = compare;
OUTPUT:
diff --git a/perl-URPM.spec b/perl-URPM.spec
index 00bc8e5..34ea04a 100644
--- a/perl-URPM.spec
+++ b/perl-URPM.spec
@@ -1,7 +1,7 @@
%define name perl-URPM
%define real_name URPM
%define version 0.03
-%define release 1mdk
+%define release 2mdk
%{expand:%%define rpm_version %(rpm -q --queryformat '%{VERSION}-%{RELEASE}' rpm)}
@@ -48,6 +48,10 @@ rm -rf $RPM_BUILD_ROOT
%changelog
+* Thu Jun 6 2002 François Pons <fpons@mandrakesoft.com> 0.03-2mdk
+- fixed incomplete compare_pkg not taking into account score
+ of arch.
+
* Thu Jun 6 2002 François Pons <fpons@mandrakesoft.com> 0.03-1mdk
- added more flag method to URPM::Package
- avoid garbage output when reading hdlist archive.