From patchwork Thu Nov 20 19:35:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francois Perrad X-Patchwork-Id: 412856 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id 1617D1400D5 for ; Fri, 21 Nov 2014 06:36:23 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 599B234352; Thu, 20 Nov 2014 19:36:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KMGWgQiEdWse; Thu, 20 Nov 2014 19:36:20 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 0A2603410D; Thu, 20 Nov 2014 19:36:20 +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 571F61BFA2B for ; Thu, 20 Nov 2014 19:36:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 4DD8792AE6 for ; Thu, 20 Nov 2014 19:36:19 +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 MaQqSXXutace for ; Thu, 20 Nov 2014 19:36:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by whitealder.osuosl.org (Postfix) with ESMTPS id CFB5B92AF7 for ; Thu, 20 Nov 2014 19:36:16 +0000 (UTC) Received: by mail-wi0-f180.google.com with SMTP id n3so6520042wiv.13 for ; Thu, 20 Nov 2014 11:36:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=us8/1q/AQwfE6Msvhn9R01Zm9EI1GtZCDjRJ0ScEsO0=; b=GV4C2pBFZtCBVhErnPqLAotXLHsc2NdjzqZ1e/V1+pbtFFlY2Mf/lFDKbw+GTRc/h5 glRZ7QFC9PdU+W6qAbLozxLf+f56BtWMAh4hcIhH4v0nkWSV6dquNmJizaFRsKj61cN5 gtocLbPbzRuCqdZCtHh+yDfntHusVmBhZEIYTBRgPmWOLbTbDKsXdg1/qlI2++s76rVq zjx96n2OZXtizG5PoWX25/CBG4DFanjrLRAC0Vu0hWNJD8U3vEDFr6zLkIInkhjlF4nw HFhgZt83GSjIifXL1NSpmo5sB36NlBhkm2DpTUtuTdVRmvTJgqOzPOnsC7qpDQh2iulg 7OiA== X-Received: by 10.194.158.193 with SMTP id ww1mr72449067wjb.65.1416512175477; Thu, 20 Nov 2014 11:36:15 -0800 (PST) Received: from localhost.localdomain (227.91.139.88.rev.sfr.net. [88.139.91.227]) by mx.google.com with ESMTPSA id mc10sm7974382wic.24.2014.11.20.11.36.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Nov 2014 11:36:14 -0800 (PST) From: Francois Perrad X-Google-Original-From: Francois Perrad To: buildroot@busybox.net Date: Thu, 20 Nov 2014 20:35:27 +0100 Message-Id: <1416512127-9789-1-git-send-email-francois.perrad@gadz.org> X-Mailer: git-send-email 2.1.0 Subject: [Buildroot] [PATCH] support/script/scancpan: generate hash file X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 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" retrieve md5&sha256 from metacpan.org, and store them in the hash file for each package. Signed-off-by: Francois Perrad --- support/scripts/scancpan | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) -- 2.1.0 diff --git a/support/scripts/scancpan b/support/scripts/scancpan index a049e2c..e929718 100755 --- a/support/scripts/scancpan +++ b/support/scripts/scancpan @@ -481,6 +481,7 @@ use Pod::Usage; use File::Basename; use Module::CoreList; use HTTP::Tiny; +use Safe; use MetaCPAN::API::Tiny; my ($help, $man, $quiet, $force, $recommend, $test, $host); @@ -505,9 +506,22 @@ 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; # name -> list of license files +my %checksum; # author -> list of checksum my $mcpan = MetaCPAN::API::Tiny->new(); my $ua = HTTP::Tiny->new(); +sub get_checksum { + my ($url) = @_; + my($path) = $url =~ m|^[^:/?#]+://[^/?#]*([^?#]*)|; + my($basename, $dirname) = fileparse( $path ); + unless ($checksum{$dirname}) { + my $response = $ua->get(qq{http://cpan.metacpan.org${dirname}CHECKSUMS}); + $checksum{$dirname} = $response->{content}; + } + my $chksum = Safe->new->reval($checksum{$dirname}); + return $chksum->{$basename}, $basename; +} + sub get_manifest { my ($author, $distname, $version) = @_; my $url = qq{http://api.metacpan.org/source/${author}/${distname}-${version}/MANIFEST}; @@ -608,6 +622,7 @@ while (my ($distname, $dist) = each %dist) { my $dirname = q{package/} . $fsname; my $cfgname = $dirname . q{/Config.in}; my $mkname = $dirname . q{/} . $fsname . q{.mk}; + my $hashname = $dirname . q{/} . $fsname . q{.hash}; my $brname = brname( $fsname ); mkdir $dirname unless -d $dirname; if ($need_target{$distname} && ($force || !-f $cfgname)) { @@ -675,6 +690,17 @@ while (my ($distname, $dist) = each %dist) { say {$fh} qq{\$(eval \$(host-perl-package))} if $need_host{$distname}; close $fh; } + if ($force || !-f $hashname) { + my($checksum, $filename) = get_checksum($dist->{download_url}); + my $md5 = $checksum->{md5}; + my $sha256 = $checksum->{sha256}; + say qq{write ${hashname}} unless $quiet; + open my $fh, q{>}, $hashname; + say {$fh} qq{# retrieved by scancpan from http://cpan.metacpan.org/}; + say {$fh} qq{md5 ${md5} ${filename}}; + say {$fh} qq{sha256 ${sha256} ${filename}}; + close $fh; + } } my %pkg;