metadata: always resolve dependencies through provides list
Instead of adding virtual packages to the normal package list, keep a separate list for provides, make each package provide itself, and resolve all dependencies through this list. This allows to use PROVIDES to replace existing packages. Fixes FS#837. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
This commit is contained in:
parent
565de8b8a8
commit
47d6b05ad3
3 changed files with 35 additions and 46 deletions
|
@ -252,7 +252,6 @@ sub search_feed {
|
||||||
my $substr;
|
my $substr;
|
||||||
my $pkgmatch = 1;
|
my $pkgmatch = 1;
|
||||||
|
|
||||||
next if $pkg->{vdepends};
|
|
||||||
foreach my $substr (@substr) {
|
foreach my $substr (@substr) {
|
||||||
my $match;
|
my $match;
|
||||||
foreach my $key (qw(name title description src)) {
|
foreach my $key (qw(name title description src)) {
|
||||||
|
@ -306,7 +305,6 @@ sub list_feed {
|
||||||
get_feed($feed);
|
get_feed($feed);
|
||||||
foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) {
|
foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) {
|
||||||
my $pkg = $feed_package->{$name};
|
my $pkg = $feed_package->{$name};
|
||||||
next if $pkg->{vdepends};
|
|
||||||
if($pkg->{name}) {
|
if($pkg->{name}) {
|
||||||
printf "\%-32s\t\%s\n", $pkg->{name}, $pkg->{title};
|
printf "\%-32s\t\%s\n", $pkg->{name}, $pkg->{title};
|
||||||
}
|
}
|
||||||
|
@ -534,6 +532,7 @@ sub install_package {
|
||||||
@{$feed_src->{$src}{"builddepends/host"}},
|
@{$feed_src->{$src}{"builddepends/host"}},
|
||||||
map { @{$_->{depends}} } @{$feed_src->{$src}{packages}}
|
map { @{$_->{depends}} } @{$feed_src->{$src}{packages}}
|
||||||
) {
|
) {
|
||||||
|
# TODO: handle virtual packages and PROVIDES
|
||||||
next if $dep =~ /@/;
|
next if $dep =~ /@/;
|
||||||
$dep =~ s/^\+//;
|
$dep =~ s/^\+//;
|
||||||
$dep =~ s/^.+://;
|
$dep =~ s/^.+://;
|
||||||
|
@ -594,7 +593,6 @@ sub install {
|
||||||
get_feed($f->[1]);
|
get_feed($f->[1]);
|
||||||
foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) {
|
foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) {
|
||||||
my $p = $feed_package->{$name};
|
my $p = $feed_package->{$name};
|
||||||
next if $p->{vdepends};
|
|
||||||
if( $p->{name} ) {
|
if( $p->{name} ) {
|
||||||
install_package($feed, $p->{name}, exists($opts{f})) == 0 or $ret = 1;
|
install_package($feed, $p->{name}, exists($opts{f})) == 0 or $ret = 1;
|
||||||
get_feed($f->[1]);
|
get_feed($f->[1]);
|
||||||
|
|
|
@ -2,9 +2,10 @@ package metadata;
|
||||||
use base 'Exporter';
|
use base 'Exporter';
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
our @EXPORT = qw(%package %srcpackage %category %features %overrides clear_packages parse_package_metadata parse_target_metadata get_multiline @ignore %usernames %groupnames);
|
our @EXPORT = qw(%package %vpackage %srcpackage %category %features %overrides clear_packages parse_package_metadata parse_target_metadata get_multiline @ignore %usernames %groupnames);
|
||||||
|
|
||||||
our %package;
|
our %package;
|
||||||
|
our %vpackage;
|
||||||
our %srcpackage;
|
our %srcpackage;
|
||||||
our %category;
|
our %category;
|
||||||
our %features;
|
our %features;
|
||||||
|
@ -177,6 +178,7 @@ sub parse_target_metadata($) {
|
||||||
|
|
||||||
sub clear_packages() {
|
sub clear_packages() {
|
||||||
%package = ();
|
%package = ();
|
||||||
|
%vpackage = ();
|
||||||
%srcpackage = ();
|
%srcpackage = ();
|
||||||
%category = ();
|
%category = ();
|
||||||
%features = ();
|
%features = ();
|
||||||
|
@ -230,6 +232,9 @@ sub parse_package_metadata($) {
|
||||||
$pkg->{override} = $override;
|
$pkg->{override} = $override;
|
||||||
$package{$1} = $pkg;
|
$package{$1} = $pkg;
|
||||||
push @{$src->{packages}}, $pkg;
|
push @{$src->{packages}}, $pkg;
|
||||||
|
|
||||||
|
$vpackage{$1} or $vpackage{$1} = [];
|
||||||
|
unshift @{$vpackage{$1}}, $pkg;
|
||||||
};
|
};
|
||||||
/^Feature:\s*(.+?)\s*$/ and do {
|
/^Feature:\s*(.+?)\s*$/ and do {
|
||||||
undef $pkg;
|
undef $pkg;
|
||||||
|
@ -264,12 +269,8 @@ sub parse_package_metadata($) {
|
||||||
/^Provides: \s*(.+)\s*$/ and do {
|
/^Provides: \s*(.+)\s*$/ and do {
|
||||||
my @vpkg = split /\s+/, $1;
|
my @vpkg = split /\s+/, $1;
|
||||||
foreach my $vpkg (@vpkg) {
|
foreach my $vpkg (@vpkg) {
|
||||||
$package{$vpkg} or $package{$vpkg} = {
|
$vpackage{$vpkg} or $vpackage{$vpkg} = [];
|
||||||
name => $vpkg,
|
push @{$vpackage{$vpkg}}, $pkg;
|
||||||
vdepends => [],
|
|
||||||
src => $src,
|
|
||||||
};
|
|
||||||
push @{$package{$vpkg}->{vdepends}}, $pkg->{name};
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/^Menu-Depends: \s*(.+)\s*$/ and $pkg->{mdepends} = [ split /\s+/, $1 ];
|
/^Menu-Depends: \s*(.+)\s*$/ and $pkg->{mdepends} = [ split /\s+/, $1 ];
|
||||||
|
|
|
@ -101,14 +101,16 @@ my %dep_check;
|
||||||
sub __find_package_dep($$) {
|
sub __find_package_dep($$) {
|
||||||
my $pkg = shift;
|
my $pkg = shift;
|
||||||
my $name = shift;
|
my $name = shift;
|
||||||
my $deps = ($pkg->{vdepends} or $pkg->{depends});
|
my $deps = $pkg->{depends};
|
||||||
|
|
||||||
return 0 unless defined $deps;
|
return 0 unless defined $deps;
|
||||||
foreach my $dep (@{$deps}) {
|
foreach my $vpkg (@{$deps}) {
|
||||||
next if $dep_check{$dep};
|
foreach my $dep (@{$vpackage{$vpkg}}) {
|
||||||
$dep_check{$dep} = 1;
|
next if $dep_check{$dep->{name}};
|
||||||
return 1 if $dep eq $name;
|
$dep_check{$dep->{name}} = 1;
|
||||||
return 1 if ($package{$dep} and (__find_package_dep($package{$dep},$name) == 1));
|
return 1 if $dep->{name} eq $name;
|
||||||
|
return 1 if (__find_package_dep($dep, $name) == 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -156,7 +158,6 @@ sub mconf_depends {
|
||||||
my $m = "depends on";
|
my $m = "depends on";
|
||||||
my $flags = "";
|
my $flags = "";
|
||||||
$depend =~ s/^([@\+]+)// and $flags = $1;
|
$depend =~ s/^([@\+]+)// and $flags = $1;
|
||||||
my $vdep;
|
|
||||||
my $condition = $parent_condition;
|
my $condition = $parent_condition;
|
||||||
|
|
||||||
next if $condition eq $depend;
|
next if $condition eq $depend;
|
||||||
|
@ -173,23 +174,21 @@ sub mconf_depends {
|
||||||
}
|
}
|
||||||
$depend = $2;
|
$depend = $2;
|
||||||
}
|
}
|
||||||
next if $package{$depend} and $package{$depend}->{buildonly};
|
|
||||||
if ($flags =~ /\+/) {
|
if ($flags =~ /\+/) {
|
||||||
if ($vdep = $package{$depend}->{vdepends}) {
|
my $vdep = $vpackage{$depend};
|
||||||
|
if ($vdep) {
|
||||||
my @vdeps;
|
my @vdeps;
|
||||||
$depend = undef;
|
|
||||||
|
|
||||||
foreach my $v (@$vdep) {
|
foreach my $v (@$vdep) {
|
||||||
if ($package{$v} && $package{$v}->{variant_default}) {
|
next if $v->{buildonly};
|
||||||
$depend = $v;
|
if ($v->{variant_default}) {
|
||||||
|
unshift @vdeps, $v->{name};
|
||||||
} else {
|
} else {
|
||||||
push @vdeps, $v;
|
push @vdeps, $v->{name};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$depend) {
|
$depend = shift @vdeps;
|
||||||
$depend = shift @vdeps;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (@vdeps > 1) {
|
if (@vdeps > 1) {
|
||||||
$condition = ($condition ? "$condition && " : '') . '!('.join("||", map { "PACKAGE_".$_ } @vdeps).')';
|
$condition = ($condition ? "$condition && " : '') . '!('.join("||", map { "PACKAGE_".$_ } @vdeps).')';
|
||||||
|
@ -209,8 +208,9 @@ sub mconf_depends {
|
||||||
|
|
||||||
$flags =~ /@/ or $depend = "PACKAGE_$depend";
|
$flags =~ /@/ or $depend = "PACKAGE_$depend";
|
||||||
} else {
|
} else {
|
||||||
if ($vdep = $package{$depend}->{vdepends}) {
|
my $vdep = $vpackage{$depend};
|
||||||
$depend = join("||", map { "PACKAGE_".$_ } @$vdep);
|
if ($vdep) {
|
||||||
|
$depend = join("||", map { "PACKAGE_".$_->{name} } @$vdep);
|
||||||
} else {
|
} else {
|
||||||
$flags =~ /@/ or $depend = "PACKAGE_$depend";
|
$flags =~ /@/ or $depend = "PACKAGE_$depend";
|
||||||
}
|
}
|
||||||
|
@ -419,29 +419,21 @@ sub gen_package_mk() {
|
||||||
$dep = $2;
|
$dep = $2;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $pkg_dep = $package{$dep};
|
my $vpkg_dep = $vpackage{$dep};
|
||||||
unless (defined $pkg_dep) {
|
unless (defined $vpkg_dep) {
|
||||||
warn sprintf "WARNING: Makefile '%s' has a dependency on '%s', which does not exist\n",
|
warn sprintf "WARNING: Makefile '%s' has a dependency on '%s', which does not exist\n",
|
||||||
$src->{makefile}, $dep;
|
$src->{makefile}, $dep;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
unless ($pkg_dep->{vdepends}) {
|
# Filter out self-depends
|
||||||
next if $srcname eq $pkg_dep->{src}{name};
|
my @vdeps = grep { $srcname ne $_->{src}{name} } @{$vpkg_dep};
|
||||||
|
|
||||||
my $depstr = "\$(curdir)/$pkg_dep->{src}{path}/compile";
|
foreach my $vdep (@vdeps) {
|
||||||
my $depline = get_conditional_dep($condition, $depstr);
|
my $depstr = "\$(curdir)/$vdep->{src}{path}/compile";
|
||||||
if ($depline) {
|
if (@vdeps > 1) {
|
||||||
$deplines{''}{$depline}++;
|
$depstr = "\$(if \$(CONFIG_PACKAGE_$vdep->{name}),$depstr)";
|
||||||
}
|
}
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach my $vdep (@{$pkg_dep->{vdepends}}) {
|
|
||||||
my $pkg_vdep = $package{$vdep};
|
|
||||||
next if $srcname eq $pkg_vdep->{src}{name};
|
|
||||||
|
|
||||||
my $depstr = "\$(if \$(CONFIG_PACKAGE_$vdep),\$(curdir)/$pkg_vdep->{src}{path}/compile)";
|
|
||||||
my $depline = get_conditional_dep($condition, $depstr);
|
my $depline = get_conditional_dep($condition, $depstr);
|
||||||
if ($depline) {
|
if ($depline) {
|
||||||
$deplines{''}{$depline}++;
|
$deplines{''}{$depline}++;
|
||||||
|
@ -449,8 +441,6 @@ sub gen_package_mk() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next if defined $pkg->{vdepends};
|
|
||||||
|
|
||||||
my $config = '';
|
my $config = '';
|
||||||
$config = "\$(CONFIG_PACKAGE_$pkg->{name})" unless $pkg->{buildonly};
|
$config = "\$(CONFIG_PACKAGE_$pkg->{name})" unless $pkg->{buildonly};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue