OpenPKG CVS Repository
http://cvs.openpkg.org/
____________________________________________________________________________
Server: cvs.openpkg.org Name: Michael van Elst
Root: /v/openpkg/cvs Email: [EMAIL PROTECTED]
Module: openpkg-tools Date: 24-Mar-2005 01:12:37
Branch: HEAD Handle: 2005032400123700
Modified files:
openpkg-tools/cmd build.pl
Log:
A relmap is a two dimensional hash that maps requirement names
and requirement values to a list of targets. For normal package
requirements the name is a package name and the value is a package
version-revision. For option requirements the name is package::option
and the value is the (default) value of the option.
get_versions fetched and sorted all values that matched a condition.
For normal package requirements the result is a sorted list of
package versions with the newest version last. This can be used to
pick a 'best' package.
For option requirements the result is useless because most packages
will provide the same defaults and sorting over option values is
meaningless to find a 'best' package.
This change removes get_versions, the get_targets function now
does the low level sorting itself and does the sorting by
target version-revision.
All places where the version list was evaluated were changed to
handle target lists instead. The only tricky part is the
selection of binary packages where the target lists have to
be processed twice because binary packages must already fulfill
conditions whereas source packages must only support the
required options (the condition will be fulfilled by the
compiled package later).
Summary:
Revision Changes Path
1.11 +57 -66 openpkg-tools/cmd/build.pl
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: openpkg-tools/cmd/build.pl
============================================================================
$ cvs diff -u -r1.10 -r1.11 build.pl
--- openpkg-tools/cmd/build.pl 26 Jan 2005 14:03:52 -0000 1.10
+++ openpkg-tools/cmd/build.pl 24 Mar 2005 00:12:37 -0000 1.11
@@ -530,7 +530,7 @@
my($i) = $env->{'installed'};
my($r) = $env->{'repository'};
my($pkg, %dep, %dlist, %rev);
- my(@vers,$t,$t1,$t2,$with,$name,$vmap);
+ my(@targ,$t,$t1,$t2,$with,$name,$vmap);
my($d,$k,%d,$old,%name,%pkg);
print "# computing reverse dependencies\n";
@@ -549,34 +549,32 @@
# dep{a}{b} is true if b depends directly on a
# dlist{a} is list of packages that depend on a
#
- @vers = get_versions($i->{$pkg}, sub { 1; });
- foreach (@vers) {
- foreach $t (@{$i->{$pkg}->{$_}}) {
- $with = get_with($t);
- $d = target_attribute($t, $env, 'depends', $with);
- $k = target_attribute($t, $env, 'keeps', $with);
- next unless @$d || @$k;
- %d = unique_map($d,$k);
- # resolve package
- unless (exists $pkg{$pkg}) {
- ($t2,$old) = dep2target({ name => $pkg }, $env, 1);
- $t2 = undef if $old;
- $pkg{$pkg} = $t2;
+ @targ = get_targets($i->{$pkg}, sub { 1; });
+ foreach $t (@targ) {
+ $with = get_with($t);
+ $d = target_attribute($t, $env, 'depends', $with);
+ $k = target_attribute($t, $env, 'keeps', $with);
+ next unless @$d || @$k;
+ %d = unique_map($d,$k);
+ # resolve package
+ unless (exists $pkg{$pkg}) {
+ ($t2,$old) = dep2target({ name => $pkg }, $env, 1);
+ $t2 = undef if $old;
+ $pkg{$pkg} = $t2;
+ }
+ $t2 = $pkg{$pkg};
+ next unless $t2;
+ foreach (keys %d) {
+ next if $_ eq 'OpenPKG';
+ # resolve target
+ unless (exists $name{$_}) {
+ ($t1,$old) = dep2target($d{$_}, $env, 0);
+ $name{$_} = $t1 ? $t1->{name} : $_;
}
- $t2 = $pkg{$pkg};
- next unless $t2;
- foreach (keys %d) {
- next if $_ eq 'OpenPKG';
- # resolve target
- unless (exists $name{$_}) {
- ($t1,$old) = dep2target($d{$_}, $env, 0);
- $name{$_} = $t1 ? $t1->{name} : $_;
- }
- $name = $name{$_};
- unless ($dep{$name}{$t->{name}}) {
- $dep{$name}{$t->{name}} = 1;
- push @{$dlist{$name}}, $t2;
- }
+ $name = $name{$_};
+ unless ($dep{$name}{$t->{name}}) {
+ $dep{$name}{$t->{name}} = 1;
+ push @{$dlist{$name}}, $t2;
}
}
}
@@ -1142,24 +1140,20 @@
############################################################################
#
-# grep all versions of a name that
-# satisfy a condition
-#
-sub get_versions ($$) {
- my($relmap, $cond) = @_;
- return grep { $cond->($_); }
- sort { vcmp($a,$b); } keys %$relmap;
-}
-
-#
# fetch targets of a name that
-# satisfies a condition
+# satisfy a condition
+# sort by target version
#
sub get_targets ($$) {
my($relmap, $cond) = @_;
- return map {
- @{$relmap->{$_}}
- } get_versions($relmap, $cond);
+ return
+ sort {
+ vcmp(vs($a),vs($b));
+ } map {
+ @{$relmap->{$_}}
+ } grep {
+ $cond->($_);
+ } keys %$relmap;
}
#
@@ -1175,32 +1169,31 @@
#
sub chose_source ($$$$$) {
my($env, $name, $select, $vmap, $cond) = @_;
- my(@vers,@recs,@nrecs,$rec,%nam);
+ my(@targ,@recs,@nrecs,$rec,%nam);
#
# resolve name into a list of versions
# for virtual targets this resolves to a list
# of real targets that provide the virtual target
#
- @vers = get_versions($vmap, sub { 1; });
- return unless @vers;
+ @targ = get_targets($vmap, sub { 1; });
+ return unless @targ;
#
- # filter out binary targets that are not usuable
+ # find usuable binary targets
+ # add all source targets
#
- @recs = map { $_->[1] } grep {
- my($v,$t) = @$_;
- is_source($t) ||
- ( !$env->{sourceonly} &&
- $t->{'platform'} eq $env->{config}->{platform} &&
- $t->{'prefix'} eq $env->{config}->{prefix} &&
- $cond->($v)
- )
- } map {
- my($v) = $_;
- my($l) = $vmap->{$_};
- map { [ $v, $_ ] } @$l;
- } @vers;
+ @recs = (
+ ( grep {
+ !$env->{sourceonly} &&
+ !is_source($_) &&
+ $_->{'platform'} eq $env->{config}->{platform} &&
+ $_->{'prefix'} eq $env->{config}->{prefix}
+ } get_targets($vmap, $cond) ),
+ ( grep {
+ is_source($_)
+ } @targ )
+ );
return unless @recs;
#
@@ -1627,7 +1620,7 @@
#
sub dep2target ($$$) {
my($dep, $env, $source) = @_;
- my($name,$op,@vers);
+ my($name,$op,@targ);
my($i,$r,$b,$cond,$version);
my($t,$tdef,$why);
@@ -1661,10 +1654,8 @@
# search installed target that matches requirement
# use it if we are not upgrading (no -U and no -z/-Z)
#
- if ($i && (@vers = get_versions($i, $cond))) {
- foreach (@vers) {
- $t = $i->{$_}->[0];
- next unless $t;
+ if ($i && (@targ = get_targets($i, $cond))) {
+ foreach $t (@targ) {
get_with($t);
if (target_suitable($t, $env->{with}, 0)) {
$tdef = $t;
@@ -1679,8 +1670,8 @@
# search target in current build list that matches requirement
# use it if it exists
#
- if ($b && (@vers = get_versions($b, $cond))) {
- $t = $b->{$vers[0]}->[0];
+ if ($b && (@targ = get_targets($b, $cond))) {
+ $t = $targ[0];
return ($t, 1);
}
@@ .
______________________________________________________________________
The OpenPKG Project www.openpkg.org
CVS Repository Commit List [email protected]