scancpan: handle recommended dependencies as optional packages
PATCH v2 1/2 scancpan: handle recommended dependencies as optional packages
--- support/scripts/scancpan | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)
support/scripts/scancpan +22 -3
@@ -505,6 +505,7 @@ my %need_host; # name -> 1 if host package is needed my %need_dlopen; # name -> 1 if requires dynamic library my %deps_build; # name -> list of host dependencies my %deps_runtime; # name -> list of target dependencies +my %deps_optional; # name -> list of optional target dependencies my %license_files; # name -> list of license files my %checksum; # author -> list of checksum my $mcpan = MetaCPAN::API::Tiny->new();
@@ -563,6 +564,7 @@ sub fetch { $license_files{$name} = find_license_files( $manifest ); my %build = (); my %runtime = (); + my %optional = (); foreach my $dep (@{$result->{dependency}}) { my $modname = ${$dep}{module}; next if $modname eq q{perl};
@@ -574,10 +576,14 @@ sub fetch { # target perl have the same major version next if ${$dep}{phase} eq q{develop}; next if !$test && ${$dep}{phase} eq q{test}; - next if !$recommend && ${$dep}{relationship} ne q{requires}; my $distname = $mcpan->module( $modname )->{distribution}; if (${$dep}{phase} eq q{runtime}) { - $runtime{$distname} = 1; + if (${$dep}{relationship} eq q{requires}) { + $runtime{$distname} = 1; + } + else { + $optional{$distname} = 1 if $recommend; + } } else { # configure, build $build{$distname} = 1;
@@ -585,6 +591,7 @@ sub fetch { } $deps_build{$name} = [keys %build]; $deps_runtime{$name} = [keys %runtime]; + $deps_optional{$name} = [keys %optional]; foreach my $distname (@{$deps_build{$name}}) { fetch( $distname, 0, 1 ); }
@@ -592,6 +599,9 @@ sub fetch { fetch( $distname, $need_target, $need_host ); $need_dlopen{$name} ||= $need_dlopen{$distname}; } + foreach my $distname (@{$deps_optional{$name}}) { + fetch( $distname, $need_target, $need_host ); + } } return; }
@@ -683,6 +693,15 @@ while (my ($distname, $dist) = each %dist) { say {$fh} qq{${brname}_LICENSE = ${license}} if $license && $license ne q{unknown}; say {$fh} qq{${brname}_LICENSE_FILES = ${license_files}} if $license_files; say {$fh} qq{}; + foreach (sort @{$deps_optional{$distname}}) { + next if grep { $_ eq $distname; } @{$deps_runtime{$_}}; # avoid cyclic dependencies + my $opt_brname = brname( $_ ); + my $opt_fsname = fsname( $_ ); + say {$fh} qq{ifeq (\$(BR2_PACKAGE_PERL_${opt_brname}),y)}; + say {$fh} qq{${brname}_DEPENDENCIES += ${opt_fsname}}; + say {$fh} qq{endif}; + say {$fh} qq{}; + } say {$fh} qq{\$(eval \$(perl-package))} if $need_target{$distname}; say {$fh} qq{\$(eval \$(host-perl-package))} if $need_host{$distname}; close $fh;
@@ -800,7 +819,7 @@ in order to work with the right CoreList data. =head1 LICENSE -Copyright (C) 2013-2014 by Francois Perrad <[email protected]> +Copyright (C) 2013-2016 by Francois Perrad <[email protected]> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
Signature · 1 line
2.5.0
PATCH v2 2/2 scancpan: use recommend & test flags only at first level
--- support/scripts/scancpan | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
support/scripts/scancpan +6 -6
@@ -552,10 +552,10 @@ sub find_license_files { } sub fetch { - my ($name, $need_target, $need_host) = @_; + my ($name, $need_target, $need_host, $top) = @_; $need_target{$name} = $need_target if $need_target; $need_host{$name} = $need_host if $need_host; - unless ($dist{$name}) { + unless ($dist{$name} && !$top) { say qq{fetch ${name}} unless $quiet; my $result = $mcpan->release( distribution => $name ); $dist{$name} = $result;
@@ -570,19 +570,19 @@ sub fetch { next if $modname eq q{perl}; next if $modname =~ m|^Alien|; next if $modname =~ m|^Win32|; - next if !$test && $modname =~ m|^Test|; + next if !($test && $top) && $modname =~ m|^Test|; next if Module::CoreList::is_core( $modname, undef, $] ); # we could use the host Module::CoreList data, because host perl and # target perl have the same major version next if ${$dep}{phase} eq q{develop}; - next if !$test && ${$dep}{phase} eq q{test}; + next if !($test && $top) && ${$dep}{phase} eq q{test}; my $distname = $mcpan->module( $modname )->{distribution}; if (${$dep}{phase} eq q{runtime}) { if (${$dep}{relationship} eq q{requires}) { $runtime{$distname} = 1; } else { - $optional{$distname} = 1 if $recommend; + $optional{$distname} = 1 if $recommend && $top; } } else { # configure, build
@@ -608,7 +608,7 @@ sub fetch { foreach my $distname (@ARGV) { # Command-line's distributions - fetch( $distname, !!$target, !!$host ); + fetch( $distname, !!$target, !!$host, 1 ); } say scalar keys %dist, q{ packages fetched.} unless $quiet;
Signature · 1 line
2.5.0
PATCH v2 2/2 scancpan: use recommend & test flags only at first level
Fran?ois,
Quoted 1 line · Francois Perrad
Signed-off-by Francois Perrad <[email protected]>
Please add a commit log that explains *why*.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v2 2/2 scancpan: use recommend & test flags only at first level
In reply to Francois Perrad2016-01-21 21:44 GMT+01:00 Francois Perrad <[email protected]>:
Currently, these flags are recursively propagated. This behavior is not expected by users, because it can cause dependencies explosively.
Fran?ois
Quoted 57 lines
Signed-off-by Francois Perrad <[email protected]>--- support/scripts/scancpan | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)support/scripts/scancpan +6
-7@@ -552,10 +552,10 @@ sub find_license_files { } sub fetch { - my ($name, $need_target, $need_host) = @_; + my ($name, $need_target, $need_host, $top) = @_; $need_target{$name} = $need_target if $need_target; $need_host{$name} = $need_host if $need_host; - unless ($dist{$name}) { + unless ($dist{$name} && !$top) { say qq{fetch ${name}} unless $quiet; my $result = $mcpan->release( distribution => $name ); $dist{$name} = $result;@@ -570,19 +570,19 @@ sub fetch { next if $modname eq q{perl}; next if $modname =~ m|^Alien|; next if $modname =~ m|^Win32|; - next if !$test && $modname =~ m|^Test|; + next if !($test && $top) && $modname =~ m|^Test|; next if Module::CoreList::is_core( $modname, undef, $] ); # we could use the host Module::CoreList data, because host perl and # target perl have the same major version next if ${$dep}{phase} eq q{develop}; - next if !$test && ${$dep}{phase} eq q{test}; + next if !($test && $top) && ${$dep}{phase} eq q{test}; my $distname = $mcpan->module( $modname )->{distribution}; if (${$dep}{phase} eq q{runtime}) { if (${$dep}{relationship} eq q{requires}) { $runtime{$distname} = 1; } else { - $optional{$distname} = 1 if $recommend; + $optional{$distname} = 1 if $recommend && $top; } } else { # configure, build@@ -608,7 +608,7 @@ sub fetch { foreach my $distname (@ARGV) { # Command-line's distributions - fetch( $distname, !!$target, !!$host ); + fetch( $distname, !!$target, !!$host, 1 ); } say scalar keys %dist, q{ packages fetched.} unless $quiet; --2.5.0
PATCH v2 1/2 scancpan: handle recommended dependencies as optional packages
In reply to Francois PerradDear Francois Perrad,
Sorry for the slow answer.
Quoted 1 line · Francois Perrad
Signed-off-by Francois Perrad <[email protected]>
As usual, this patch would highly benefit from a more detailed commit log. I've already asked you this hundreds of times: whenever a patch is not just a simple version bump, it *MUST* have a commit log.
support/scripts/scancpan sub fetch { · line 586
Quoted 10 lines
support/scripts/scancpan +6
-2- next if !$recommend && ${$dep}{relationship} ne q{requires}; my $distname = $mcpan->module( $modname )->{distribution}; if (${$dep}{phase} eq q{runtime}) { - $runtime{$distname} = 1; + if (${$dep}{relationship} eq q{requires}) { + $runtime{$distname} = 1; + } + else { + $optional{$distname} = 1 if $recommend; + }
So, if I understand well, if -recommend was passed you used to handle "recommend" dependencies expressed on CPAN as "generate the Buildroot packages for them, but don't create any dependency on them".
And now, the idea is that if you pass -recommend, in additional to generating the Buildroot packages, it would also add some code in the Buildroot package to optionally depend on them. Is this correct ?
Unfortunately, it doesn't seem to work for me. I've tested with this patch applied, and then:
./output/host/usr/bin/perl ./support/scripts/scancpan -recommend IO-Stream
According to
https://metacpan.org/source/POWERMAN/IO-Stream-v2.0.2/META.yml,
IO-Stream has a "recommends" on Data::Alias. I can indeed see scancpan creating the perl-data-alias package, but perl-io-stream doesn't contain any optional dependency on it. Am I doing something wrong? Is there something missing in your script. Here is the generated perl-io-stream.mk:
PERL_IO_STREAM_VERSION = v2.0.2PERL_IO_STREAM_SOURCE = IO-Stream-$(PERL_IO_STREAM_VERSION).tar.gz PERL_IO_STREAM_SITE = $(BR2_CPAN_MIRROR)/authors/id/P/PO/POWERMAN PERL_IO_STREAM_DEPENDENCIES = host-perl-module-build-tiny perl-anyevent perl-ev PERL_IO_STREAM_LICENSE = MITPERL_IO_STREAM_LICENSE_FILES = LICENSE
$(eval $(perl-package))
support/scripts/scancpan while (my ($distname, $dist) = each %dist) { · line 703
Quoted 12 lines
support/scripts/scancpan +8
-0@@ -683,6 +693,15 @@ while (my ($distname, $dist) = each %dist) { say {$fh} qq{${brname}_LICENSE = ${license}} if $license && $license ne q{unknown}; say {$fh} qq{${brname}_LICENSE_FILES = ${license_files}} if $license_files; say {$fh} qq{}; + foreach (sort @{$deps_optional{$distname}}) { + next if grep { $_ eq $distname; } @{$deps_runtime{$_}}; # avoid cyclic dependencies + my $opt_brname = brname( $_ ); + my $opt_fsname = fsname( $_ ); + say {$fh} qq{ifeq (\$(BR2_PACKAGE_PERL_${opt_brname}),y)}; + say {$fh} qq{${brname}_DEPENDENCIES += ${opt_fsname}}; + say {$fh} qq{endif}; + say {$fh} qq{};
So in Perl, dependencies are not runtime dependencies, but really build time dependencies ?
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v2 1/2 scancpan: handle recommended dependencies as optional packages
2016-03-05 16:41 GMT+01:00 Thomas Petazzoni
<[email protected]>:
Quoted 26 lines
Dear Francois Perrad,
Sorry for the slow answer.
Quoted 1 line · Francois Perrad
Signed-off-by Francois Perrad <[email protected]>As usual, this patch would highly benefit from a more detailed commit log. I've already asked you this hundreds of times: whenever a patch is not just a simple version bump, it *MUST* have a commit log.
support/scripts/scancpan sub fetch { · line 586
Quoted 10 lines
support/scripts/scancpan +6
-2- next if !$recommend && ${$dep}{relationship} ne q{requires}; my $distname = $mcpan->module( $modname )->{distribution}; if (${$dep}{phase} eq q{runtime}) { - $runtime{$distname} = 1; + if (${$dep}{relationship} eq q{requires}) { + $runtime{$distname} = 1; + } + else { + $optional{$distname} = 1 if $recommend; + }So, if I understand well, if -recommend was passed you used to handle "recommend" dependencies expressed on CPAN as "generate the Buildroot packages for them, but don't create any dependency on them".
Quoted 9 lines
And now, the idea is that if you pass -recommend, in additional to generating the Buildroot packages, it would also add some code in the Buildroot package to optionally depend on them. Is this correct ?
Unfortunately, it doesn't seem to work for me. I've tested with this patch applied, and then:
./output/host/usr/bin/perl ./support/scripts/scancpan -recommend IO-Stream
Works for me. Try with the flag -f in order to override existing files.
Fran?ois
Quoted 45 lines
According to
https://metacpan.org/source/POWERMAN/IO-Stream-v2.0.2/META.yml,
IO-Stream has a "recommends" onData::Alias. I can indeed see scancpan creating the perl-data-alias package, but perl-io-stream doesn't contain any optional dependency on it. Am I doing something wrong? Is there something missing in your script. Here is the generated perl-io-stream.mk:
PERL_IO_STREAM_VERSION= v2.0.2PERL_IO_STREAM_SOURCE= IO-Stream-$(PERL_IO_STREAM_VERSION).tar.gzPERL_IO_STREAM_SITE= $(BR2_CPAN_MIRROR)/authors/id/P/PO/POWERMANPERL_IO_STREAM_DEPENDENCIES= host-perl-module-build-tiny perl-anyevent perl-evPERL_IO_STREAM_LICENSE= MITPERL_IO_STREAM_LICENSE_FILES= LICENSE$(eval $(perl-package))
support/scripts/scancpan while (my ($distname, $dist) = each %dist) { · line 703
Quoted 12 lines
support/scripts/scancpan +8
-0@@ -683,6 +693,15 @@ while (my ($distname, $dist) = each %dist) { say {$fh} qq{${brname}_LICENSE = ${license}} if $license && $license ne q{unknown}; say {$fh} qq{${brname}_LICENSE_FILES = ${license_files}} if $license_files; say {$fh} qq{}; + foreach (sort @{$deps_optional{$distname}}) { + next if grep { $_ eq $distname; } @{$deps_runtime{$_}}; # avoid cyclic dependencies + my $opt_brname = brname( $_ ); + my $opt_fsname = fsname( $_ ); + say {$fh} qq{ifeq (\$(BR2_PACKAGE_PERL_${opt_brname}),y)}; + say {$fh} qq{${brname}_DEPENDENCIES += ${opt_fsname}}; + say {$fh} qq{endif}; + say {$fh} qq{};So in Perl, dependencies are not runtime dependencies, but really build time dependencies ?
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
PATCH v2 1/2 scancpan: handle recommended dependencies as optional packages
Hello,
Quoted 4 lines · Fran?ois Perrad
Quoted 2 lines
./output/host/usr/bin/perl ./support/scripts/scancpan -recommend IO-Stream
Works for me. Try with the flag -f in order to override existing files.
Ok, I'll retry. Can you send an updated version that takes into account my other comments?
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH v2 1/2 scancpan: handle recommended dependencies as optional packages
In reply to Francois PerradCurrently, without the flag -recommend, scancpan takes as dependency only one which has the relationship "requires"; this mode works fine. And, with the flag -recommend, scancpan takes all ones (ie. with relationship "requires" or "recommends") in the same way; this mode never works fine, because it is too simplistic.
With this commit, the "not required" dependencies are handled as optional BR package or skipped if a cyclic dependency is detected.
Fran?ois
2016-01-21 21:44 GMT+01:00 Francois Perrad <[email protected]>:
Quoted 88 lines
Signed-off-by Francois Perrad <[email protected]>--- support/scripts/scancpan | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-)support/scripts/scancpan +22
-4@@ -505,6 +505,7 @@ my %need_host; # name -> 1 if host package is needed my %need_dlopen; # name -> 1 if requires dynamic library my %deps_build; # name -> list of host dependencies my %deps_runtime; # name -> list of target dependencies +my %deps_optional; # name -> list of optional target dependencies my %license_files; # name -> list of license files my %checksum; # author -> list of checksum my $mcpan = MetaCPAN::API::Tiny->new();@@ -563,6 +564,7 @@ sub fetch { $license_files{$name} = find_license_files( $manifest ); my %build = (); my %runtime = (); + my %optional = (); foreach my $dep (@{$result->{dependency}}) { my $modname = ${$dep}{module}; next if $modname eq q{perl};@@ -574,10 +576,14 @@ sub fetch { # target perl have the same major version next if ${$dep}{phase} eq q{develop}; next if !$test && ${$dep}{phase} eq q{test}; - next if !$recommend && ${$dep}{relationship} ne q{requires}; my $distname = $mcpan->module( $modname )->{distribution}; if (${$dep}{phase} eq q{runtime}) { - $runtime{$distname} = 1; + if (${$dep}{relationship} eq q{requires}) { + $runtime{$distname} = 1; + } + else { + $optional{$distname} = 1 if $recommend; + } } else { # configure, build $build{$distname} = 1;@@ -585,6 +591,7 @@ sub fetch { } $deps_build{$name} = [keys %build]; $deps_runtime{$name} = [keys %runtime]; + $deps_optional{$name} = [keys %optional]; foreach my $distname (@{$deps_build{$name}}) { fetch( $distname, 0, 1 ); }@@ -592,6 +599,9 @@ sub fetch { fetch( $distname, $need_target, $need_host ); $need_dlopen{$name} ||= $need_dlopen{$distname}; } + foreach my $distname (@{$deps_optional{$name}}) { + fetch( $distname, $need_target, $need_host ); + } } return; }@@ -683,6 +693,15 @@ while (my ($distname, $dist) = each %dist) { say {$fh} qq{${brname}_LICENSE = ${license}} if $license && $license ne q{unknown}; say {$fh} qq{${brname}_LICENSE_FILES = ${license_files}} if $license_files; say {$fh} qq{}; + foreach (sort @{$deps_optional{$distname}}) { + next if grep { $_ eq $distname; } @{$deps_runtime{$_}}; # avoid cyclic dependencies + my $opt_brname = brname( $_ ); + my $opt_fsname = fsname( $_ ); + say {$fh} qq{ifeq (\$(BR2_PACKAGE_PERL_${opt_brname}),y)}; + say {$fh} qq{${brname}_DEPENDENCIES += ${opt_fsname}}; + say {$fh} qq{endif}; + say {$fh} qq{}; + } say {$fh} qq{\$(eval \$(perl-package))} if $need_target{$distname}; say {$fh} qq{\$(eval \$(host-perl-package))} if $need_host{$distname}; close $fh;@@ -800,7 +819,7 @@ in order to work with the right CoreList data. =head1 LICENSE -Copyright (C) 2013-2014 by Francois Perrad <[email protected]> +Copyright (C) 2013-2016 by Francois Perrad <[email protected]> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by --2.5.0