From patchwork Fri Jul 18 13:43:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francois Perrad X-Patchwork-Id: 371542 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ozlabs.org (Postfix) with ESMTP id E2468140139 for ; Fri, 18 Jul 2014 23:44:14 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id A0F6A86B3A; Fri, 18 Jul 2014 13:44:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 72p+4YunCe0v; Fri, 18 Jul 2014 13:44:12 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id DCD5F86241; Fri, 18 Jul 2014 13:44:11 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 5B2391BFA31 for ; Fri, 18 Jul 2014 13:44:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 5528C8B45C for ; Fri, 18 Jul 2014 13:44:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GnPIjfZmXAKW for ; Fri, 18 Jul 2014 13:44:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by whitealder.osuosl.org (Postfix) with ESMTPS id E08448B371 for ; Fri, 18 Jul 2014 13:44:06 +0000 (UTC) Received: by mail-wi0-f172.google.com with SMTP id n3so896516wiv.11 for ; Fri, 18 Jul 2014 06:44:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=qotPEPA73SpjCE6HVDArz1EBkWny6z0c5AsfpEF/vd8=; b=G7b+JEPUfAzxb/1Qk6iPkDifBqD8qRYWSnfQnLB6ESxk+8+cSQ11La/M+NCdBeyD4K t/xeWJUs5CUyItWu6n83M9KdHDcDWJ7NFQQQKpKD30Jq+OQXT3yPu0dLrJbYblTMNiRv qnGFN0Hyhj57gYJTaRP5vUv2vOXM76x16xhjr/TnU/YpoNsHm70pgz7I4u0/Ihtow61Q ygZysjPpms7SfvmfZ/Ntjxr9ddYj9BdSgx4FpKSE1MuEVO0lOaWQKWmliMQh3YqiXwk7 CejWbWY0gHru6zVKfu75vYDKVhYjvg83ZxcQyp1pbvR+wU1FP/EHiuMILlChZhyEZDLG MjJA== X-Received: by 10.180.14.162 with SMTP id q2mr3845797wic.29.1405691043815; Fri, 18 Jul 2014 06:44:03 -0700 (PDT) Received: from localhost.localdomain (158.193.82.79.rev.sfr.net. [79.82.193.158]) by mx.google.com with ESMTPSA id du6sm6922800wib.6.2014.07.18.06.44.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Jul 2014 06:44:03 -0700 (PDT) From: Francois Perrad X-Google-Original-From: Francois Perrad To: buildroot@busybox.net Date: Fri, 18 Jul 2014 15:43:36 +0200 Message-Id: <1405691019-10397-1-git-send-email-francois.perrad@gadz.org> X-Mailer: git-send-email 1.9.1 Subject: [Buildroot] [PATCH 1/4] support/scripts/scancpan: automatically populates LICENSE_FILES X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net from the MANIFEST Signed-off-by: Francois Perrad --- docs/manual/adding-packages-perl.txt | 3 --- support/scripts/scancpan | 30 +++++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/docs/manual/adding-packages-perl.txt b/docs/manual/adding-packages-perl.txt index d1a1616..9a3df4d 100644 --- a/docs/manual/adding-packages-perl.txt +++ b/docs/manual/adding-packages-perl.txt @@ -53,9 +53,6 @@ requested package, and also recursively for all dependencies specified by CPAN. You should still manually edit the result. In particular, the following things should be checked. -* The +PERL_FOO_BAR_LICENSE_FILES+ variable is not set, because metacpan - doesn't have this information. Also, the name of the license file(s) - varies between packages, and some don't even have a license file. * If the perl module links with a shared library that is provided by another (non-perl) package, this dependency is not added automatically. It has to be added manually to +PERL_FOO_BAR_DEPENDENCIES+. diff --git a/support/scripts/scancpan b/support/scripts/scancpan index d683f88..1280e75 100755 --- a/support/scripts/scancpan +++ b/support/scripts/scancpan @@ -503,17 +503,33 @@ 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 %license_files; # neam -> list of license files my $mcpan = MetaCPAN::API::Tiny->new(); my $ua = HTTP::Tiny->new(); -sub is_xs { +sub get_manifest { my ($author, $distname, $version) = @_; + my $url = qq{http://api.metacpan.org/source/${author}/${distname}-${version}/MANIFEST}; + my $response = $ua->get($url); + return $response->{content}; +} + +sub is_xs { + my ($manifest) = @_; # This heuristic determines if a module is a native extension, by searching # some file extension types in the MANIFEST of the distribution. # It was inspired by http://deps.cpantesters.org/static/purity.html - my $url = qq{http://api.metacpan.org/source/${author}/${distname}-${version}/MANIFEST}; - my $response = $ua->get($url); - return $response->{content} =~ m/\.(swg|xs|c|h|i)\n/; + return $manifest =~ m/\.(swg|xs|c|h|i)\n/; +} + +sub find_license_files { + my ($manifest) = @_; + my @license_files; + foreach (split /\n/, $manifest) { + next if m|/|; + push @license_files, $_ if m/(ARTISTIC|COPYING|COPYRIGHT|LICENSE)/i; + } + return \@license_files; } sub fetch { @@ -524,7 +540,9 @@ sub fetch { say qq{fetch ${name}} unless $quiet; my $result = $mcpan->release( distribution => $name ); $dist{$name} = $result; - $need_dlopen{$name} = is_xs( $result->{author}, $name, $result->{version} ); + my $manifest = get_manifest( $result->{author}, $name, $result->{version} ); + $need_dlopen{$name} = is_xs( $manifest ); + $license_files{$name} = find_license_files( $manifest ); my @deps_build = (); my @deps_runtime = (); my $mb; @@ -629,6 +647,7 @@ while (my ($distname, $dist) = each %dist) { $license =~ s|artistic_2|Artistic-2.0|; $license =~ s|openssl|OpenSSL|; $license =~ s|perl_5|Artistic or GPLv1+|; + my $license_files = join q{ }, @{$license_files{$distname}}; say qq{write ${mkname}} unless $quiet; open my $fh, q{>}, $mkname; say {$fh} qq{################################################################################}; @@ -643,6 +662,7 @@ while (my ($distname, $dist) = each %dist) { say {$fh} qq{${brname}_DEPENDENCIES = ${dependencies}} if $need_target{$distname}; say {$fh} qq{HOST_${brname}_DEPENDENCIES = ${host_dependencies}} if $need_host{$distname}; 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{}; say {$fh} qq{\$(eval \$(perl-package))} if $need_target{$distname}; say {$fh} qq{\$(eval \$(host-perl-package))} if $need_host{$distname};