0033-scripts-metadata-always-resolve-dependencies-through-provides-list.patch 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. From: Matthias Schiffer <mschiffer@universe-factory.net>
  2. Date: Sat, 8 Jul 2017 01:35:35 +0200
  3. Subject: scripts: metadata: always resolve dependencies through provides list
  4. Instead of adding virtual packages to the normal package list, keep a
  5. separate list for provides, make each package provide itself, and resolve
  6. all dependencies through this list. This allows to use PROVIDES to replace
  7. existing packages.
  8. A side effect of the changes in the makefile dependency logic is that
  9. build dependencies are now always interpreted as source package names,
  10. instead of putting build and runtime dependencies into the same list.
  11. Fixes FS#837.
  12. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
  13. diff --git a/scripts/feeds b/scripts/feeds
  14. index 55c294ad0a4ec2f0419d12deddeda7324c349e04..a38eb454585f5dd27b707db23184b7df07ab2658 100755
  15. --- a/scripts/feeds
  16. +++ b/scripts/feeds
  17. @@ -252,7 +252,6 @@ sub search_feed {
  18. my $substr;
  19. my $pkgmatch = 1;
  20. - next if $pkg->{vdepends};
  21. foreach my $substr (@substr) {
  22. my $match;
  23. foreach my $key (qw(name title description src)) {
  24. @@ -306,7 +305,6 @@ sub list_feed {
  25. get_feed($feed);
  26. foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) {
  27. my $pkg = $feed_package->{$name};
  28. - next if $pkg->{vdepends};
  29. if($pkg->{name}) {
  30. printf "\%-32s\t\%s\n", $pkg->{name}, $pkg->{title};
  31. }
  32. @@ -588,7 +586,6 @@ sub install {
  33. get_feed($f->[1]);
  34. foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) {
  35. my $p = $feed_package->{$name};
  36. - next if $p->{vdepends};
  37. if( $p->{name} ) {
  38. install_package($feed, $p->{name}, exists($opts{f})) == 0 or $ret = 1;
  39. get_feed($f->[1]);
  40. diff --git a/scripts/metadata.pm b/scripts/metadata.pm
  41. index 8334f26d3179a0eb83aa1aa976778ff5828faf45..e7bdbab4568ddd7e10c10b2ca6a718380c7d6308 100644
  42. --- a/scripts/metadata.pm
  43. +++ b/scripts/metadata.pm
  44. @@ -2,9 +2,10 @@ package metadata;
  45. use base 'Exporter';
  46. use strict;
  47. use warnings;
  48. -our @EXPORT = qw(%package %srcpackage %category %subdir %preconfig %features %overrides clear_packages parse_package_metadata parse_target_metadata get_multiline @ignore);
  49. +our @EXPORT = qw(%package %vpackage %srcpackage %category %subdir %preconfig %features %overrides clear_packages parse_package_metadata parse_target_metadata get_multiline @ignore);
  50. our %package;
  51. +our %vpackage;
  52. our %preconfig;
  53. our %srcpackage;
  54. our %category;
  55. @@ -124,6 +125,7 @@ sub clear_packages() {
  56. %subdir = ();
  57. %preconfig = ();
  58. %package = ();
  59. + %vpackage = ();
  60. %srcpackage = ();
  61. %category = ();
  62. %features = ();
  63. @@ -179,6 +181,9 @@ sub parse_package_metadata($) {
  64. $pkg->{override} = $override;
  65. $package{$1} = $pkg;
  66. push @{$srcpackage{$src}}, $pkg;
  67. +
  68. + $vpackage{$1} or $vpackage{$1} = [];
  69. + unshift @{$vpackage{$1}}, $1;
  70. };
  71. /^Feature:\s*(.+?)\s*$/ and do {
  72. undef $pkg;
  73. @@ -210,14 +215,8 @@ sub parse_package_metadata($) {
  74. /^Provides: \s*(.+)\s*$/ and do {
  75. my @vpkg = split /\s+/, $1;
  76. foreach my $vpkg (@vpkg) {
  77. - $package{$vpkg} or $package{$vpkg} = {
  78. - name => $vpkg,
  79. - vdepends => [],
  80. - src => $src,
  81. - subdir => $subdir,
  82. - makefile => $makefile
  83. - };
  84. - push @{$package{$vpkg}->{vdepends}}, $pkg->{name};
  85. + $vpackage{$vpkg} or $vpackage{$vpkg} = [];
  86. + push @{$vpackage{$vpkg}}, $pkg->{name};
  87. }
  88. };
  89. /^Menu-Depends: \s*(.+)\s*$/ and $pkg->{mdepends} = [ split /\s+/, $1 ];
  90. diff --git a/scripts/package-metadata.pl b/scripts/package-metadata.pl
  91. index 2da32c770ef3333bfcc18922ede556f9734510c7..bd795bfe58d86c0e48205042192751fadf8a209b 100755
  92. --- a/scripts/package-metadata.pl
  93. +++ b/scripts/package-metadata.pl
  94. @@ -101,14 +101,16 @@ my %dep_check;
  95. sub __find_package_dep($$) {
  96. my $pkg = shift;
  97. my $name = shift;
  98. - my $deps = ($pkg->{vdepends} or $pkg->{depends});
  99. + my $deps = $pkg->{depends};
  100. return 0 unless defined $deps;
  101. - foreach my $dep (@{$deps}) {
  102. - next if $dep_check{$dep};
  103. - $dep_check{$dep} = 1;
  104. - return 1 if $dep eq $name;
  105. - return 1 if ($package{$dep} and (__find_package_dep($package{$dep},$name) == 1));
  106. + foreach my $vpkg (@{$deps}) {
  107. + foreach my $dep (@{$vpackage{$vpkg}}) {
  108. + next if $dep_check{$dep};
  109. + $dep_check{$dep} = 1;
  110. + return 1 if $dep eq $name;
  111. + return 1 if ($package{$dep} and (__find_package_dep($package{$dep},$name) == 1));
  112. + }
  113. }
  114. return 0;
  115. }
  116. @@ -173,9 +175,8 @@ sub mconf_depends {
  117. }
  118. $depend = $2;
  119. }
  120. - next if $package{$depend} and $package{$depend}->{buildonly};
  121. if ($flags =~ /\+/) {
  122. - if ($vdep = $package{$depend}->{vdepends}) {
  123. + if ($vdep = $vpackage{$depend}) {
  124. my @vdeps;
  125. $depend = undef;
  126. @@ -209,7 +210,7 @@ sub mconf_depends {
  127. $flags =~ /@/ or $depend = "PACKAGE_$depend";
  128. } else {
  129. - if ($vdep = $package{$depend}->{vdepends}) {
  130. + if ($vdep = $vpackage{$depend}) {
  131. $depend = join("||", map { "PACKAGE_".$_ } @$vdep);
  132. } else {
  133. $flags =~ /@/ or $depend = "PACKAGE_$depend";
  134. @@ -413,7 +414,6 @@ sub get_conditional_dep($$) {
  135. sub gen_package_mk() {
  136. my %conf;
  137. - my %dep;
  138. my %done;
  139. my $line;
  140. @@ -423,8 +423,6 @@ sub gen_package_mk() {
  141. my $pkg = $package{$name};
  142. my @srcdeps;
  143. - next if defined $pkg->{vdepends};
  144. -
  145. $config = "\$(CONFIG_PACKAGE_$name)";
  146. if ($config) {
  147. $pkg->{buildonly} and $config = "";
  148. @@ -445,16 +443,7 @@ sub gen_package_mk() {
  149. print "buildtypes-$pkg->{subdir}$pkg->{src} = ".join(' ', @{$pkg->{buildtypes}})."\n";
  150. }
  151. - foreach my $spkg (@{$srcpackage{$pkg->{src}}}) {
  152. - foreach my $dep (@{$spkg->{depends}}, @{$spkg->{builddepends}}) {
  153. - $dep =~ /@/ or do {
  154. - $dep =~ s/\+//g;
  155. - push @srcdeps, $dep;
  156. - };
  157. - }
  158. - }
  159. foreach my $type (@{$pkg->{buildtypes}}) {
  160. - my @extra_deps;
  161. my %deplines;
  162. next unless $pkg->{"builddepends/$type"};
  163. @@ -492,63 +481,70 @@ sub gen_package_mk() {
  164. }
  165. }
  166. - my $hasdeps = 0;
  167. my %deplines;
  168. - foreach my $deps (@srcdeps) {
  169. - my $idx;
  170. - my $condition;
  171. - my $prefix = "";
  172. - my $suffix = "";
  173. -
  174. - if ($deps =~ /^(.+):(.+)/) {
  175. - $condition = $1;
  176. - $deps = $2;
  177. - }
  178. - if ($deps =~ /^(.+)(\/.+)/) {
  179. - $deps = $1;
  180. - $suffix = $2;
  181. - }
  182. + foreach my $spkg (@{$srcpackage{$pkg->{src}}}) {
  183. + foreach my $bdep (@{$spkg->{builddepends}}) {
  184. + my $condition;
  185. + my $suffix = "";
  186. - my $pkg_dep = $package{$deps};
  187. - my @deps;
  188. + if ($bdep =~ /^(.+):(.+)/) {
  189. + $condition = $1;
  190. + $bdep = $2;
  191. + }
  192. + if ($bdep =~ /^(.+)(\/.+)/) {
  193. + $bdep = $1;
  194. + $suffix = $2;
  195. + }
  196. - if ($pkg_dep->{vdepends}) {
  197. - @deps = @{$pkg_dep->{vdepends}};
  198. - } else {
  199. - @deps = ($deps);
  200. + next unless $subdir{$bdep};
  201. + my $idx = $subdir{$bdep}.$bdep.$suffix;
  202. +
  203. + my $depline = get_conditional_dep($condition, "\$(curdir)/$idx/compile");
  204. + if ($depline) {
  205. + $deplines{$depline}++;
  206. + }
  207. }
  208. - foreach my $dep (@deps) {
  209. - $pkg_dep = $package{$deps};
  210. - if (defined $pkg_dep->{src}) {
  211. - ($pkg->{src} ne $pkg_dep->{src}.$suffix) and $idx = $pkg_dep->{subdir}.$pkg_dep->{src};
  212. - } elsif (defined($srcpackage{$dep})) {
  213. - $idx = $subdir{$dep}.$dep;
  214. + foreach my $dep (@{$spkg->{depends}}) {
  215. + my $condition;
  216. + my $suffix = "";
  217. +
  218. + next if $dep =~ /@/;
  219. + $dep =~ s/\+//g;
  220. +
  221. + if ($dep =~ /^(.+):(.+)/) {
  222. + $condition = $1;
  223. + $dep = $2;
  224. }
  225. - undef $idx if $idx eq 'base-files';
  226. - if ($idx) {
  227. - $idx .= $suffix;
  228. + if ($dep =~ /^(.+)(\/.+)/) {
  229. + $dep = $1;
  230. + $suffix = $2;
  231. + }
  232. +
  233. + next unless $vpackage{$dep};
  234. +
  235. + my @vdeps = @{$vpackage{$dep}};
  236. + foreach my $vdep (@vdeps) {
  237. + my $pkg_dep = $package{$vdep};
  238. - my $depline;
  239. + next unless $pkg_dep;
  240. next if $pkg->{src} eq $pkg_dep->{src}.$suffix;
  241. - next if $dep{$condition.":".$pkg->{src}."->".$idx};
  242. - next if $dep{$pkg->{src}."->($dep)".$idx} and $pkg_dep->{vdepends};
  243. - my $depstr;
  244. - if ($pkg_dep->{vdepends}) {
  245. - $depstr = "\$(if \$(CONFIG_PACKAGE_$dep),\$(curdir)/$idx/compile)";
  246. - $dep{$pkg->{src}."->($dep)".$idx} = 1;
  247. + my $idx = $pkg_dep->{subdir}.$pkg_dep->{src}.$suffix;
  248. + my $depstr;
  249. + if (@vdeps > 1) {
  250. + $depstr = "\$(if \$(CONFIG_PACKAGE_$vdep),\$(curdir)/$idx/compile)";
  251. } else {
  252. $depstr = "\$(curdir)/$idx/compile";
  253. - $dep{$pkg->{src}."->".$idx} = 1;
  254. }
  255. - $depline = get_conditional_dep($condition, $depstr);
  256. + my $depline = get_conditional_dep($condition, $depstr);
  257. if ($depline) {
  258. $deplines{$depline}++;
  259. }
  260. }
  261. }
  262. }
  263. +
  264. my $depline = join(" ", sort keys %deplines);
  265. if ($depline) {
  266. $line .= "\$(curdir)/".$pkg->{subdir}."$pkg->{src}/compile += $depline\n";
  267. @@ -573,7 +569,7 @@ ifndef DUMP_TARGET_DB
  268. ( \\
  269. $cmds \\
  270. ) > \$@
  271. -
  272. +
  273. ifneq (\$(IMAGEOPT)\$(CONFIG_IMAGEOPT),)
  274. package/preconfig: \$(TARGET_DIR)/etc/uci-defaults/$preconfig
  275. endif