summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2018-01-08 12:17:30 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2018-01-13 19:54:44 +0100
commit47d6b05ad328e80e4ee05e48aa95462f3518c014 (patch)
treec1caa85b174473b25be2f5889cf4857529f13caf /scripts
parent565de8b8a8b3532d07abba7a083763ac31ca28ee (diff)
downloadmtk-20170518-47d6b05ad328e80e4ee05e48aa95462f3518c014.zip
mtk-20170518-47d6b05ad328e80e4ee05e48aa95462f3518c014.tar.gz
mtk-20170518-47d6b05ad328e80e4ee05e48aa95462f3518c014.tar.bz2
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>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/feeds4
-rw-r--r--scripts/metadata.pm15
-rwxr-xr-xscripts/package-metadata.pl62
3 files changed, 35 insertions, 46 deletions
diff --git a/scripts/feeds b/scripts/feeds
index 4595c82..f5d764a 100755
--- a/scripts/feeds
+++ b/scripts/feeds
@@ -252,7 +252,6 @@ sub search_feed {
my $substr;
my $pkgmatch = 1;
- next if $pkg->{vdepends};
foreach my $substr (@substr) {
my $match;
foreach my $key (qw(name title description src)) {
@@ -306,7 +305,6 @@ sub list_feed {
get_feed($feed);
foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) {
my $pkg = $feed_package->{$name};
- next if $pkg->{vdepends};
if($pkg->{name}) {
printf "\%-32s\t\%s\n", $pkg->{name}, $pkg->{title};
}
@@ -534,6 +532,7 @@ sub install_package {
@{$feed_src->{$src}{"builddepends/host"}},
map { @{$_->{depends}} } @{$feed_src->{$src}{packages}}
) {
+ # TODO: handle virtual packages and PROVIDES
next if $dep =~ /@/;
$dep =~ s/^\+//;
$dep =~ s/^.+://;
@@ -594,7 +593,6 @@ sub install {
get_feed($f->[1]);
foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) {
my $p = $feed_package->{$name};
- next if $p->{vdepends};
if( $p->{name} ) {
install_package($feed, $p->{name}, exists($opts{f})) == 0 or $ret = 1;
get_feed($f->[1]);
diff --git a/scripts/metadata.pm b/scripts/metadata.pm
index 5d829eb..7c82cec 100644
--- a/scripts/metadata.pm
+++ b/scripts/metadata.pm
@@ -2,9 +2,10 @@ package metadata;
use base 'Exporter';
use strict;
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 %vpackage;
our %srcpackage;
our %category;
our %features;
@@ -177,6 +178,7 @@ sub parse_target_metadata($) {
sub clear_packages() {
%package = ();
+ %vpackage = ();
%srcpackage = ();
%category = ();
%features = ();
@@ -230,6 +232,9 @@ sub parse_package_metadata($) {
$pkg->{override} = $override;
$package{$1} = $pkg;
push @{$src->{packages}}, $pkg;
+
+ $vpackage{$1} or $vpackage{$1} = [];
+ unshift @{$vpackage{$1}}, $pkg;
};
/^Feature:\s*(.+?)\s*$/ and do {
undef $pkg;
@@ -264,12 +269,8 @@ sub parse_package_metadata($) {
/^Provides: \s*(.+)\s*$/ and do {
my @vpkg = split /\s+/, $1;
foreach my $vpkg (@vpkg) {
- $package{$vpkg} or $package{$vpkg} = {
- name => $vpkg,
- vdepends => [],
- src => $src,
- };
- push @{$package{$vpkg}->{vdepends}}, $pkg->{name};
+ $vpackage{$vpkg} or $vpackage{$vpkg} = [];
+ push @{$vpackage{$vpkg}}, $pkg;
}
};
/^Menu-Depends: \s*(.+)\s*$/ and $pkg->{mdepends} = [ split /\s+/, $1 ];
diff --git a/scripts/package-metadata.pl b/scripts/package-metadata.pl
index c8ae27a..2dc29ea 100755
--- a/scripts/package-metadata.pl
+++ b/scripts/package-metadata.pl
@@ -101,14 +101,16 @@ my %dep_check;
sub __find_package_dep($$) {
my $pkg = shift;
my $name = shift;
- my $deps = ($pkg->{vdepends} or $pkg->{depends});
+ my $deps = $pkg->{depends};
return 0 unless defined $deps;
- foreach my $dep (@{$deps}) {
- next if $dep_check{$dep};
- $dep_check{$dep} = 1;
- return 1 if $dep eq $name;
- return 1 if ($package{$dep} and (__find_package_dep($package{$dep},$name) == 1));
+ foreach my $vpkg (@{$deps}) {
+ foreach my $dep (@{$vpackage{$vpkg}}) {
+ next if $dep_check{$dep->{name}};
+ $dep_check{$dep->{name}} = 1;
+ return 1 if $dep->{name} eq $name;
+ return 1 if (__find_package_dep($dep, $name) == 1);
+ }
}
return 0;
}
@@ -156,7 +158,6 @@ sub mconf_depends {
my $m = "depends on";
my $flags = "";
$depend =~ s/^([@\+]+)// and $flags = $1;
- my $vdep;
my $condition = $parent_condition;
next if $condition eq $depend;
@@ -173,23 +174,21 @@ sub mconf_depends {
}
$depend = $2;
}
- next if $package{$depend} and $package{$depend}->{buildonly};
if ($flags =~ /\+/) {
- if ($vdep = $package{$depend}->{vdepends}) {
+ my $vdep = $vpackage{$depend};
+ if ($vdep) {
my @vdeps;
- $depend = undef;
foreach my $v (@$vdep) {
- if ($package{$v} && $package{$v}->{variant_default}) {
- $depend = $v;
+ next if $v->{buildonly};
+ if ($v->{variant_default}) {
+ unshift @vdeps, $v->{name};
} else {
- push @vdeps, $v;
+ push @vdeps, $v->{name};
}
}
- if (!$depend) {
- $depend = shift @vdeps;
- }
+ $depend = shift @vdeps;
if (@vdeps > 1) {
$condition = ($condition ? "$condition && " : '') . '!('.join("||", map { "PACKAGE_".$_ } @vdeps).')';
@@ -209,8 +208,9 @@ sub mconf_depends {
$flags =~ /@/ or $depend = "PACKAGE_$depend";
} else {
- if ($vdep = $package{$depend}->{vdepends}) {
- $depend = join("||", map { "PACKAGE_".$_ } @$vdep);
+ my $vdep = $vpackage{$depend};
+ if ($vdep) {
+ $depend = join("||", map { "PACKAGE_".$_->{name} } @$vdep);
} else {
$flags =~ /@/ or $depend = "PACKAGE_$depend";
}
@@ -419,29 +419,21 @@ sub gen_package_mk() {
$dep = $2;
}
- my $pkg_dep = $package{$dep};
- unless (defined $pkg_dep) {
+ my $vpkg_dep = $vpackage{$dep};
+ unless (defined $vpkg_dep) {
warn sprintf "WARNING: Makefile '%s' has a dependency on '%s', which does not exist\n",
$src->{makefile}, $dep;
next;
}
- unless ($pkg_dep->{vdepends}) {
- next if $srcname eq $pkg_dep->{src}{name};
+ # Filter out self-depends
+ my @vdeps = grep { $srcname ne $_->{src}{name} } @{$vpkg_dep};
- my $depstr = "\$(curdir)/$pkg_dep->{src}{path}/compile";
- my $depline = get_conditional_dep($condition, $depstr);
- if ($depline) {
- $deplines{''}{$depline}++;
+ foreach my $vdep (@vdeps) {
+ my $depstr = "\$(curdir)/$vdep->{src}{path}/compile";
+ if (@vdeps > 1) {
+ $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);
if ($depline) {
$deplines{''}{$depline}++;
@@ -449,8 +441,6 @@ sub gen_package_mk() {
}
}
- next if defined $pkg->{vdepends};
-
my $config = '';
$config = "\$(CONFIG_PACKAGE_$pkg->{name})" unless $pkg->{buildonly};