From patchwork Mon Jan 8 14:52:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Schiffer X-Patchwork-Id: 856839 X-Patchwork-Delegate: mschiffer@universe-factory.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BGYI34J+"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zFdkm1GzBz9ryT for ; Tue, 9 Jan 2018 02:01:04 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=syQpQcNN5H2gPngn22gci+HKcnZRSXsMewmPgiq2p3I=; b=BGYI34J+0vTD61gdYv7TwipV7V BGQqFa8CzuH1btR81kewB9Sj9eeA1UOagBEIA2KgybRm7bZBToYXtwbRdbFKtvdqSbMwStmHJyvq4 u1ZAlSWckqQPFz2ZBpttak3ki2PR8B2lcALD9bpPJeiN+9f79d4q/o18r8t4ofvPxchqDfP6pe4P8 eRv3mFs+riGyX31Br0J6YyViiHJRdiiLLq00QwbZCQR2X5Sanidtj8hr1gUgVzN0/ZX6VQud20Qsz bg5r991lHOSsdLtxIKnwXqwBTuQuSHikHgfj1RJ4aA3ZuBSP/zqEk36CFQGv/bld9M+XJ2haEU25r QGvrztcg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eYYux-0003xQ-4I; Mon, 08 Jan 2018 15:00:51 +0000 Received: from orthanc.universe-factory.net ([2001:19f0:6c01:100::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eYYtX-0002l6-Jb for lede-dev@lists.infradead.org; Mon, 08 Jan 2018 14:59:38 +0000 Received: from avalon.lan (unknown [IPv6:2001:19f0:6c01:100::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by orthanc.universe-factory.net (Postfix) with ESMTPSA id A89712046D; Mon, 8 Jan 2018 15:52:46 +0100 (CET) From: Matthias Schiffer To: lede-dev@lists.infradead.org, openwrt-devel@lists.openwrt.org, jo@mein.io, nbd@nbd.name Date: Mon, 8 Jan 2018 15:52:19 +0100 Message-Id: <6ac2562ff76fa02627200e0ac74548b666b98156.1515421834.git.mschiffer@universe-factory.net> X-Mailer: git-send-email 2.15.1 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180108_065924_919797_7E5F0D7E X-CRM114-Status: GOOD ( 10.91 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Subject: [LEDE-DEV] [PATCH 06/15] metadata: change pkg->{src} field to hold a reference X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org We often want to access fields of a source packages through pkg->{src}. Allow accessing them directly instead of resolving the source hash through srcpackages. Signed-off-by: Matthias Schiffer --- scripts/feeds | 4 ++-- scripts/metadata.pm | 51 ++++++++++++++++++++++----------------------- scripts/package-metadata.pl | 14 ++++++------- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/scripts/feeds b/scripts/feeds index 31481edcb1..b531fbac62 100755 --- a/scripts/feeds +++ b/scripts/feeds @@ -494,7 +494,7 @@ sub install_package { warn "WARNING: Package '$name' is not available in feed $feed->[1].\n"; return 0; }; - my $src = $pkg->{src}; + my $src = $pkg->{src}->{name}; my $type = $feed->[0]; $src or $src = $name; @@ -663,7 +663,7 @@ sub uninstall { warn "WARNING: $name not installed\n"; next; }; - $pkg->{src} and $name = $pkg->{src}; + $pkg->{src} and $name = $pkg->{src}->{name}; warn "Uninstalling package '$name'\n"; system("rm -f ./package/feeds/*/$name"); $uninstall = 1; diff --git a/scripts/metadata.pm b/scripts/metadata.pm index 404309dc4e..0577390eda 100644 --- a/scripts/metadata.pm +++ b/scripts/metadata.pm @@ -193,9 +193,7 @@ sub parse_package_metadata($) { my $file = shift; my $pkg; my $feature; - my $makefile; my $preconfig; - my $subdir; my $src; my $override; my %ignore = map { $_ => 1 } @ignore; @@ -206,41 +204,42 @@ sub parse_package_metadata($) { }; while () { chomp; - /^Source-Makefile: \s*((.+\/)([^\/]+)\/Makefile)\s*$/ and do { - $makefile = $1; - $subdir = $2; - $src = $3; - $subdir =~ s/^package\///; - $subdir{$src} = $subdir; - $srcpackage{$src} = { - makefile => $makefile, + /^Source-Makefile: \s*(package\/((?:.+\/)?)([^\/]+)\/Makefile)\s*$/ and do { + $subdir{$3} = $2; + + $src = { + makefile => $1, + subdir => $2, + name => $3, + ignore => $ignore{$3}, packages => [], buildtypes => [], builddepends => [], }; + $srcpackage{$3} = $src; $override = ""; undef $pkg; }; /^Override: \s*(.+?)\s*$/ and do { $override = $1; - $overrides{$src} = 1; + $overrides{$src->{name}} = 1; }; next unless $src; /^Package:\s*(.+?)\s*$/ and do { undef $feature; $pkg = {}; - $pkg->{ignore} = $ignore{$src}; + $pkg->{ignore} = $src->{ignore}; $pkg->{src} = $src; - $pkg->{makefile} = $makefile; + $pkg->{makefile} = $src->{makefile}; $pkg->{name} = $1; $pkg->{title} = ""; $pkg->{depends} = []; $pkg->{mdepends} = []; - $pkg->{subdir} = $subdir; + $pkg->{subdir} = $src->{subdir}; $pkg->{tristate} = 1; $pkg->{override} = $override; $package{$1} = $pkg; - push @{$srcpackage{$src}->{packages}}, $pkg; + push @{$src->{packages}}, $pkg; }; /^Feature:\s*(.+?)\s*$/ and do { undef $pkg; @@ -251,7 +250,7 @@ sub parse_package_metadata($) { $feature and do { /^Target-Name:\s*(.+?)\s*$/ and do { $features{$1} or $features{$1} = []; - push @{$features{$1}}, $feature unless $ignore{$src}; + push @{$features{$1}}, $feature unless $src->{ignore}; }; /^Target-Title:\s*(.+?)\s*$/ and $feature->{target_title} = $1; /^Feature-Priority:\s*(\d+)\s*$/ and $feature->{priority} = $1; @@ -259,9 +258,9 @@ sub parse_package_metadata($) { /^Feature-Description:/ and $feature->{description} = get_multiline(\*FILE, "\t\t\t"); next; }; - /^Build-Depends: \s*(.+)\s*$/ and $srcpackage{$src}->{builddepends} = [ split /\s+/, $1 ]; - /^Build-Depends\/(\w+): \s*(.+)\s*$/ and $srcpackage{$src}->{"builddepends/$1"} = [ split /\s+/, $2 ]; - /^Build-Types:\s*(.+)\s*$/ and $srcpackage{$src}->{buildtypes} = [ split /\s+/, $1 ]; + /^Build-Depends: \s*(.+)\s*$/ and $src->{builddepends} = [ split /\s+/, $1 ]; + /^Build-Depends\/(\w+): \s*(.+)\s*$/ and $src->{"builddepends/$1"} = [ split /\s+/, $2 ]; + /^Build-Types:\s*(.+)\s*$/ and $src->{buildtypes} = [ split /\s+/, $1 ]; next unless $pkg; /^Version: \s*(.+)\s*$/ and $pkg->{version} = $1; /^Title: \s*(.+)\s*$/ and $pkg->{title} = $1; @@ -279,8 +278,8 @@ sub parse_package_metadata($) { name => $vpkg, vdepends => [], src => $src, - subdir => $subdir, - makefile => $makefile + subdir => $src->{subdir}, + makefile => $src->{makefile}, }; push @{$package{$vpkg}->{vdepends}}, $pkg->{name}; } @@ -296,8 +295,8 @@ sub parse_package_metadata($) { /^Category: \s*(.+)\s*$/ and do { $pkg->{category} = $1; defined $category{$1} or $category{$1} = {}; - defined $category{$1}->{$src} or $category{$1}->{$src} = []; - push @{$category{$1}->{$src}}, $pkg; + defined $category{$1}->{$src->{name}} or $category{$1}->{$src->{name}} = []; + push @{$category{$1}->{$src->{name}}}, $pkg; }; /^Description: \s*(.*)\s*$/ and $pkg->{description} = "\t\t $1\n". get_multiline(*FILE, "\t\t "); /^Type: \s*(.+)\s*$/ and do { @@ -318,7 +317,7 @@ sub parse_package_metadata($) { $preconfig = { id => $1 }; - $preconfig{$pkgname}->{$1} = $preconfig unless $ignore{$src}; + $preconfig{$pkgname}->{$1} = $preconfig unless $src->{ignore}; } }; /^Preconfig-Type:\s*(.*?)\s*$/ and $preconfig->{type} = $1; @@ -329,9 +328,9 @@ sub parse_package_metadata($) { for my $ugspec (@ugspecs) { my @ugspec = split /:/, $ugspec, 2; - parse_package_metadata_usergroup($makefile, "user", \%usernames, \%userids, $ugspec[0]) or return 0; + parse_package_metadata_usergroup($src->{makefile}, "user", \%usernames, \%userids, $ugspec[0]) or return 0; if (@ugspec > 1) { - parse_package_metadata_usergroup($makefile, "group", \%groupnames, \%groupids, $ugspec[1]) or return 0; + parse_package_metadata_usergroup($src->{makefile}, "group", \%groupnames, \%groupids, $ugspec[1]) or return 0; } } }; diff --git a/scripts/package-metadata.pl b/scripts/package-metadata.pl index 077956e6a1..2369c37e2b 100755 --- a/scripts/package-metadata.pl +++ b/scripts/package-metadata.pl @@ -484,12 +484,12 @@ sub gen_package_mk() { my $idx = ""; my $pkg_dep = $package{$dep}; if (defined($pkg_dep) && defined($pkg_dep->{src})) { - unless (!$deptype || grep { $_ eq $deptype } @{$srcpackage{$pkg_dep->{src}}->{buildtypes}}) { + unless (!$deptype || grep { $_ eq $deptype } @{$pkg_dep->{src}->{buildtypes}}) { warn sprintf "WARNING: Makefile '%s' has a %s build dependency on '%s/%s' but '%s' does not implement a '%s' build type\n", - $src->{makefile}, $type, $pkg_dep->{src}, $deptype, $pkg_dep->{makefile}, $deptype; + $src->{makefile}, $type, $pkg_dep->{src}->{name}, $deptype, $pkg_dep->{makefile}, $deptype; next; } - $idx = $pkg_dep->{subdir}.$pkg_dep->{src}; + $idx = $pkg_dep->{subdir}.$pkg_dep->{src}->{name}; } elsif (defined($srcpackage{$dep})) { $idx = $subdir{$dep}.$dep; } else { @@ -538,12 +538,12 @@ sub gen_package_mk() { foreach my $dep (@deps) { $pkg_dep = $package{$deps}; if (defined $pkg_dep->{src}) { - unless (!$deptype || grep { $_ eq $deptype } @{$srcpackage{$pkg_dep->{src}}->{buildtypes}}) { + unless (!$deptype || grep { $_ eq $deptype } @{$pkg_dep->{src}->{buildtypes}}) { warn sprintf "WARNING: Makefile '%s' has a build dependency on '%s/%s' but '%s' does not implement a '%s' build type\n", - $src->{makefile}, $pkg_dep->{src}, $deptype, $pkg_dep->{makefile}, $deptype; + $src->{makefile}, $pkg_dep->{src}->{name}, $deptype, $pkg_dep->{makefile}, $deptype; next; } - $idx = $pkg_dep->{subdir}.$pkg_dep->{src}; + $idx = $pkg_dep->{subdir}.$pkg_dep->{src}->{name}; } elsif (defined($srcpackage{$dep})) { $idx = $subdir{$dep}.$dep; } @@ -552,7 +552,7 @@ sub gen_package_mk() { $idx .= $suffix; my $depline; - next if $srcname eq $pkg_dep->{src}.$suffix; + next if $srcname eq $pkg_dep->{src}->{name}.$suffix; next if $dep{$condition.":".$srcname."->".$idx}; next if $dep{$srcname."->($dep)".$idx} and $pkg_dep->{vdepends}; my $depstr;