Browse Source

fix dependency parsing, better handling of mutating virtual targets, added hint option to specify preferences

master
Michael van Elst 23 years ago committed by Ralf S. Engelschall
parent
commit
541ba0d99e
  1. 145
      openpkg-tool/openpkg-build.pl
  2. 4
      openpkg-tool/openpkg-tool.spec
  3. 7
      openpkg-tool/openpkg.1
  4. 6
      openpkg-tool/openpkg.pod

145
openpkg-tool/openpkg-build.pl

@ -31,10 +31,10 @@ $|=1; # autoflush
use strict;
use vars qw/
$opt_R $opt_r $opt_f $opt_u $opt_U $opt_a $opt_A
$opt_z $opt_Z $opt_P $opt_N $opt_E $opt_i $opt_D
$opt_p $opt_q $opt_s $opt_S $opt_X $opt_M $opt_L
$opt_W $opt_K $opt_e $opt_b $opt_B $opt_g/;
my $getopts = 'R:r:f:uUaAzZP:N:E:iD:p:qsSXMLWKebBg';
$opt_z $opt_Z $opt_P $opt_N $opt_E $opt_H $opt_i
$opt_D $opt_p $opt_q $opt_s $opt_S $opt_X $opt_M
$opt_L $opt_W $opt_K $opt_e $opt_b $opt_B $opt_g/;
my $getopts = 'R:r:f:uUaAzZP:N:EH:iD:p:qsSXMLWKebBg';
getopts($getopts);
##########################################################################
@ -112,7 +112,7 @@ if (open(FH, "< $ENV{'HOME'}/.openpkg/build")) {
close(FH);
}
die "openpkg:build:USAGE: $0 [-R rpm] [-r repository] [-f index.rdf] [-uUzZiqsSXMLWKebBg] [-P priv-cmd] [-N non-priv-cmd] [-p platform] [-Dwith ...] [-Ename ...] ( [-aA] | patternlist )\n"
die "openpkg:build:USAGE: $0 [-R rpm] [-r repository] [-f index.rdf] [-uUzZiqsSXMLWKebBg] [-P priv-cmd] [-N non-priv-cmd] [-p platform] [-Dwith ...] [-Ename ...] [-Hname ...] ( [-aA] | patternlist )\n"
unless $#ARGV >= 0 || ($#ARGV == -1 && ($opt_a || $opt_A));
##########################################################################
@ -410,15 +410,6 @@ sub depend_list ($) {
return $dl;
}
#
# compute list of package names from dependency list
#
sub depends2pkglist ($) {
my($t) = @_;
my(%d) = unique_map($t->{depends}, $t->{keeps});
return (keys %d);
}
#
# retrieve the local installed base
#
@ -432,20 +423,54 @@ sub get_installed () {
my(@l) = run("$RPM --provides -qa");
my($p);
my($nam,$val,%options);
my($vs,$rec,@provides);
my($name,$version,$release);
@provides = ();
foreach (@l) {
$p = parse_provides($_);
# is this an option ?
if (defined $p->{with}) {
$options{$p->{prefix}}->{$p->{with}} = $p->{version}
$options{$p->{prefix}}->{$p->{with}} = $p->{version};
push @provides, $p;
next;
}
# is this a virtual target ?
$vs = vs($p);
if ($vs eq '') {
push @provides,$p;
next;
}
push @{$map{$p->{name}}->{vs($p)}}, {
name => $p->{name},
version => (defined $p->{version} ? $p->{version} : '*'),
release => (defined $p->{release} ? $p->{release} : '*'),
$name = $p->{name};
$version = defined $p->{version} ? $p->{version} : '*';
$release = defined $p->{release} ? $p->{release} : '*';
push(@provides, {
name => $name,
version => $version,
release => $release
});
# create target record
$rec = {
name => $name,
version => $version,
release => $release,
PROXY => $p->{proxy}
};
foreach (@provides) {
push @{$map{$_->{name}}->{vs($_)}}, $rec;
}
@provides = ();
}
if (@provides) {
print "# ATTENTION: ",scalar(@provides)," froods found\n"
}
#
@ -472,6 +497,7 @@ sub get_revdep ($$) {
my($r) = $env->{'repository'};
my($pkg, %dep, %dlist, %rev);
my(@vers,$t);
my($d,$k,%d);
print "# computing reverse dependencies\n";
@ -496,8 +522,11 @@ sub get_revdep ($$) {
foreach (@vers) {
foreach $t (@{$r->{$pkg}->{$_}}) {
next unless $i->{$t->{name}};
next unless $t->{depends} || $t->{keeps};
foreach (depends2pkglist($t)) {
$d = target_depends($t, $env);
$k = target_keeps($t, $env);
next unless @$d || @$k;
%d = unique_map($d,$k);
foreach (keys %d) {
unless ($dep{$_}{$t->{name}}) {
$dep{$_}{$t->{name}} = 1;
push @{$dlist{$_}}, $t;
@ -1097,9 +1126,17 @@ sub chose_source ($$$$$) {
my($env, $name, $select, $vmap, $cond) = @_;
my(@vers,@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;
#
# filter out binary targets that are not usuable
#
@recs = map { $_->[1] } grep {
my($v,$t) = @$_;
is_source($t) ||
@ -1115,20 +1152,41 @@ sub chose_source ($$$$$) {
} @vers;
return unless @recs;
#
# limit list to exact matches if provided by -e
#
if (defined $select) {
@recs = grep {
vsn($_) =~ /^\Q$select\E/
} @recs;
}
#
# try to resolve ambiguity against installed targets
# and targets previously selected
#
if (scalar(@recs) > 1) {
@nrecs = grep {
$env->{built}->{$_->{name}} ||
$env->{installed}->{$_->{name}}
} @recs;
} @recs;
@recs = @nrecs if @nrecs;
}
#
# try to resolve ambiguity against hints
#
if ($env->{hint}) {
@nrecs = grep {
exists $env->{hint}->{$_->{name}}
} @recs;
@recs = @nrecs if @nrecs;
}
#
# try to resolve ambiguity against targets that match
# the exact name
#
if (scalar(@recs) > 1) {
@nrecs = grep {
$name eq $_->{name}
@ -1136,6 +1194,9 @@ sub chose_source ($$$$$) {
@recs = @nrecs if @nrecs;
}
#
# try to resolve ambiguity by preferring binaries
#
if (scalar(@recs) > 1 && !$env->{sourceonly}) {
@nrecs = grep {
defined $_->{'platform'}
@ -1143,6 +1204,9 @@ sub chose_source ($$$$$) {
@recs = @nrecs if @nrecs;
}
#
# if we still have non-unique targets, complain
#
if (scalar(@recs) > 1) {
%nam = map { $_->{name} => 1 } @recs;
if (scalar(keys %nam) > 1) {
@ -1156,10 +1220,16 @@ sub chose_source ($$$$$) {
}
}
#
# nothing left -> exit
#
if (scalar(@recs) == 0) {
return;
}
#
# chose last (= max version) in list of targets
#
$rec = $recs[-1];
print "# source for $name is ".vsn($rec)."\n";
@ -1215,10 +1285,10 @@ sub target_attribute ($$$) {
my($target, $env, $attr) = @_;
my($with) = $env->{with};
my($optreg) = $env->{config}->{optreg};
my($name) = $target->{name};
my(@out);
my($name,@out);
return unless $target;
$name = $target->{name};
my(%mywith) = %{$target->{OPTIONS}};
override_options(\%mywith, name_with($name, $with), $optreg);
@ -1293,10 +1363,10 @@ sub unique_map {
my(%out);
foreach (@_) {
foreach (@$_) {
$out{$_->{value}->{name}} = $_;
$out{$_->{name}} = $_;
}
}
return (%out);
return %out;
}
#
@ -1523,6 +1593,7 @@ sub dep2target ($$) {
if ($i && (@vers = get_versions($i, $cond))) {
foreach (@vers) {
$t = $i->{$_}->[0];
next unless $t &&
get_with($t);
if (target_suitable($t, $env->{with})) {
$tdef = $t;
@ -1538,7 +1609,8 @@ sub dep2target ($$) {
# use it if it exists
#
if ($b && (@vers = get_versions($b, $cond))) {
return ($b->{$vers[0]}->[0], 1);
$t = $b->{$vers[0]}->[0];
return ($t, 1);
}
#
@ -1550,7 +1622,7 @@ sub dep2target ($$) {
$t = chose_source($env, $name, undef, $r, $cond);
if ($t) {
if (!$tdef || (
$why = target_better($env, $t, $env->{installed}) &&
($why = target_better($env, $t, $env->{installed})) &&
$why ne 'new'
)) {
return ($t, 0);
@ -1600,6 +1672,10 @@ sub make_dep ($$$$$$$) {
# see if a target is already installed and requires a rebuild
#
if ($t = find_target($target->{name}, $env->{installed})) {
if (!exists $env->{repository}->{$target->{name}}) {
print "# excluding $target->{name} (no upgrade path)\n";
return;
}
if (exists $env->{exclude}->{$target->{name}}) {
print "# excluding $target->{name} (no upgrade allowed)\n";
return;
@ -1643,8 +1719,8 @@ sub make_dep ($$$$$$$) {
push(@{$env->{built}->{$target->{name}}->{vs($target)}}, $target);
$target->{LIMBO} = 1;
$d = target_depends(target_lookup($target, $env->{repository}), $env);
$k = target_keeps(target_lookup($target, $env->{repository}), $env);
$d = target_depends($target, $env);
$k = target_keeps($target, $env);
#
# recurse over dependencies
@ -1668,10 +1744,7 @@ sub make_dep ($$$$$$$) {
if ($t->{LIMBO}) {
print "# ATTENTION: ".vsn($t)." is in LIMBO\n";
}
}
# record which targets to keep in blist
if ($k{$_}) {
} elsif ($k{$_}) {
push @$blist,$t;
print "# $target->{name} installs ".vsn($t)." for $_\n";
} else {
@ -2210,7 +2283,7 @@ sub print_deps ($) {
#######################################################################
my($config,$url,$repository,$installed,$env,$list,$bonly,$clist);
my($pattern,%with,%exclude);
my($pattern,%with,%exclude,%hint);
if ($opt_a) {
$pattern = undef;
@ -2228,6 +2301,7 @@ if ($opt_A) {
: ()
} split(/\s+/, $opt_D);
%exclude = map { $_ => 1 } split(/\s+/, $opt_E);
%hint = map { $_ => 1 } split(/\s+/, $opt_H);
$config = get_config();
@ -2266,6 +2340,7 @@ $env = {
revdep => undef,
with => \%with,
exclude => \%exclude,
hint => \%hint,
upgrade => ($opt_a || $opt_U),
zero => ($opt_z || $opt_Z),
exact => $opt_e,

4
openpkg-tool/openpkg-tool.spec

@ -32,8 +32,8 @@ Packager: The OpenPKG Project
Distribution: OpenPKG [PLUS]
Group: Bootstrapping
License: GPL
Version: 20030624
Release: 20030624
Version: 20030625
Release: 20030625
# list of sources
Source0: openpkg.sh

7
openpkg-tool/openpkg.1

@ -129,7 +129,7 @@
.\" ========================================================================
.\"
.IX Title "OPENPKG 1"
.TH OPENPKG 1 "2003-06-20" "openpkg-tool" "OpenPKG Maintainance"
.TH OPENPKG 1 "2003-06-25" "openpkg-tool" "OpenPKG Maintainance"
.SH "NAME"
\&\fBopenpkg\fR \- \fBOpenPKG\fR maintainance utility
.SH "VERSION"
@ -174,6 +174,7 @@ openpkg-tool XX-VERSION-XX
[\fB\-p\fR \fIplatform\fR]
[\fB\-D\fR\fIvar\fR=\fIval\fR ...]
[\fB\-E\fR \fIname\fR ...]
[\fB\-H\fR \fIname\fR ...]
([\fB\-a\fR] [\fB\-A\fR] | \fIpatternlist\fR)
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
@ -399,6 +400,10 @@ then it applies only to the specified package. E.g. \fB\-D\fR\fIgcc::with_binuti
Ignore a package with the specified \fIname\fR. This can be used to avoid
upgrading to a broken package in the repository. There can be multiple
\&\fB\-E\fR options.
.IP "\fB\-H\fR \fIname\fR" 4
.IX Item "-H name"
Hint about packages that should be preferred when more than one fits
a requirement. There can be multiple \fB\-E\fR options.
.IP "\fB\-a\fR" 4
.IX Item "-a"
Select all installed packages. Do not specify a pattern list together

6
openpkg-tool/openpkg.pod

@ -73,6 +73,7 @@ B<build>
[B<-p> I<platform>]
[B<-D>I<var>=I<val> ...]
[B<-E> I<name> ...]
[B<-H> I<name> ...]
([B<-a>] [B<-A>] | I<patternlist>)
=head1 DESCRIPTION
@ -346,6 +347,11 @@ Ignore a package with the specified I<name>. This can be used to avoid
upgrading to a broken package in the repository. There can be multiple
B<-E> options.
=item B<-H> I<name>
Hint about packages that should be preferred when more than one fits
a requirement. There can be multiple B<-E> options.
=item B<-a>
Select all installed packages. Do not specify a pattern list together

Loading…
Cancel
Save