[From nobody Thu Jun 25 05:55:08 2020
Received: from sonic313-20.consmr.mail.gq1.yahoo.com ([98.137.65.83])
 by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux))
 id 1hJQOI-0005i2-DQ
 for openwrt-devel@lists.openwrt.org; Wed, 24 Apr 2019 22:29:24 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
 t=1556144956; bh=TyIEY9IxghZ+dWLVc323M8QlGsHqBrt1H0nMZoL4wi0=;
 h=From:To:Cc:Subject:Date:In-Reply-To:References:From:Subject;
 b=SCGCfcKnMIdEnq6+PtQdXkd4ljCnWD0i4QjdmZazbxZfqvPeuxA6vVRdZGRsdXCSewldgokbG5qVnWqRCHb53h8bMfQfG7ZdOa3PfaD7a+Jizx36+zHT9erkHTySPEvImgCHLWyqmF2F4RW4Nt1XA/cJEjRo69cwvUd219+TGEt2PSeqIFkehKdIm2PsH/dgChUcH07z+OPDgH+XKW5213QweMwhhYhJwtn2YDqyDAtU/RXg8aE0oqruOc72N0Yh5eNb0ty/yHMMFQaP3OYF7CxuIW3ZAd8oiocWPT98Qd6u4zaF2zB1iS83bJZ39vjEejM5ICuI0I1cTttjx1Flbg==
X-YMail-OSG: qhh5ExIVM1njt8JAt2Vt4qOoBUBP7ZZCErAmoGMJDuK7wI7eRNjcuTRyVoCEa48
 FqhNCMm6PDP.DRmJnwgAnLFPLb4YeIMh_LDTBZD_V6Yzvlv5X8sYzr8YXk7HgVjlB12pAPv7KnXh
 sVveWR50Acbb29mRT_Lxtz8E9rz2727LI92aXLY0aNsHz_BzyVor86GwhKlfheIpecbsCdVGuMwX
 HUCFrTk_SiwaRxaMxit0NgHIDQ_VskTeevzmJrcO0ctiEe7IHS3.e6AvNDAG5ISGvJxtbSppVgiz
 O7wt3vS98BEZTltHzreDACFLQRE.EDRfBaLETzs.FBLBP7Bq66NB_6RThTj2f.PL1HO505KK06KH
 FB.lGinfXbDJOgnuKywU90mDnvT2Dox_MzJKm.leMIOGkHC76jHqsMHWcm0DEPKDPQBE2Uc4KxL4
 1juwgFcnPlf9ycYGC44RB3pMAcyRS8AIRxHOo.FblzdwANDtirWa_wwJTtaesX4yoenMsSrZ.wCN
 SazjJnRbJiHvR8.zEn9EcE7r3tG9tiBsRxT73QoWJ166e0BO2FN.LabmmJRw7ALIHF6j795sKIeg
 Q3mNKK9TMOwDLkxRZR7kwKNu72I0mLnOoNu9tub74wLHgkseVY9B_360LKNsgqInISz53F2vEUW1
 qof5_Dh.i2VLl9IOKbSGUUd3obC54imkmNxFJp_1Al.B8mdPqfb8NcDrQJJk3Ma5jVnnI0GT_HKt
 KUc1M9sCfbtRirakLm9QDG0Sz9lpSX9sFZVU7UjnPfS8zUJUcy9gxWfZQYyHMpgoua1EQ8y9thY9
 uEEvI3vaMiWXdUo4ywGaaBo.3Hwff43ry94NEANTRdoxr3eRXv4iOJh.iqdmSaWykOCTaK7k_YMy
 Q6S_KNpQjFQ2i2yqu9BwTk_H2gw5i4Rpt6VxU1ffXFImpDtiHjyqnFIsX74cSEnZxu9JplFRCSsd
 dmW7sq_rNtAjUv8cOZNM2pwJb8YvuMwvGj6e93bote5w_s.dec.zMNIJDOjhOhqe_9UkKLWwfPU4
 06IN9LpQFRk_1xEck0j5Bj2hg2cmaGAEgRah_GOjjJNsHsawqGJ9XBORiGduGCUbfKLeYcptlyXv
 WWLP3S4hmBaLu
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic313.consmr.mail.gq1.yahoo.com with HTTP; Wed, 24 Apr 2019 22:29:16 +0000
Received: from 18.175.75.177.infopasa.com.br (EHLO gateway.troianet.com.br)
 ([177.75.175.18])
 by smtp419.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID
 bec5683d30fc2ea9b14b5fdbfe13a940; 
 Wed, 24 Apr 2019 22:29:11 +0000 (UTC)
From: Eneas U de Queiroz &lt;cote2004-github@yahoo.com&gt;
To: openwrt-devel@lists.openwrt.org
Cc: Eneas U de Queiroz &lt;cote2004-github@yahoo.com&gt;
Subject: [PATCH 1/1] build: add support to &amp;&amp; in DEPENDS
Date: Wed, 24 Apr 2019 19:28:23 -0300
Message-Id: &lt;20190424222823.20741-2-cote2004-github@yahoo.com&gt;
X-Mailer: git-send-email 2.21.0
In-Reply-To: &lt;20190424222823.20741-1-cote2004-github@yahoo.com&gt;
References: &lt;20190424222823.20741-1-cote2004-github@yahoo.com&gt;
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 
X-CRM114-CacheID: sfid-20190424_152922_517678_AF99FCBF 
X-CRM114-Status: UNSURE (   4.85  )
X-CRM114-Notice: Please train this message.
X-Spam-Score: -0.2 (/)
X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary:
 Content analysis details:   (-0.2 points)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
 no trust [98.137.65.83 listed in list.dnswl.org]
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (cote2004-github[at]yahoo.com)
 -0.0 SPF_PASS               SPF: sender matches SPF record
 -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature
 0.1 DKIM_SIGNED            Message has a DKIM or DK signature, not necessarily
 valid
 -0.1 DKIM_VALID_EF          Message has a valid DKIM or DK signature from
 envelope-from domain
 -0.1 DKIM_VALID_AU          Message has a valid DKIM or DK signature from
 author's domain

Adds support to &amp;&amp; operand in DEPENDS.  Also, fixes generation of ||
dependencies by scripts/package-metadata.pl.

The precedence order from higher to lower is &amp;&amp; then ||.  Use of
parentheses to change the order is not supported. As before, they are
silently ignored.  Use them for readability only.

Signed-off-by: Eneas U de Queiroz &lt;cote2004-github@yahoo.com&gt;

diff --git a/include/package-ipkg.mk b/include/package-ipkg.mk
index 9ca4879bfa..38252b95cd 100644
--- a/include/package-ipkg.mk
+++ b/include/package-ipkg.mk
@@ -35,7 +35,8 @@ PARENR :=)
 
 dep_split=$(subst :,$(space),$(1))
 dep_rem=$(subst !,,$(subst $(strip $(PARENL)),,$(subst $(strip $(PARENR)),,$(word 1,$(call dep_split,$(1))))))
-dep_confvar=$(strip $(foreach cond,$(subst ||, ,$(call dep_rem,$(1))),$(CONFIG_$(cond))))
+dep_and=dep_and_res:=$$(and $(subst $(space),$(comma),$(foreach cond,$(subst &amp;&amp;, ,$(1)),$$(CONFIG_$(cond)))))
+dep_confvar=$(strip $(foreach cond,$(subst ||, ,$(call dep_rem,$(1))),$(eval $(call dep_and,$(cond)))$(dep_and_res)))
 dep_pos=$(if $(call dep_confvar,$(1)),$(call dep_val,$(1)))
 dep_neg=$(if $(call dep_confvar,$(1)),,$(call dep_val,$(1)))
 dep_if=$(if $(findstring !,$(1)),$(call dep_neg,$(1)),$(call dep_pos,$(1)))
diff --git a/scripts/package-metadata.pl b/scripts/package-metadata.pl
index e0cdff1e81..76b09a56eb 100755
--- a/scripts/package-metadata.pl
+++ b/scripts/package-metadata.pl
@@ -358,14 +358,30 @@ sub gen_package_config() {
 	print_package_overrides();
 }
 
+sub and_condition($) {
+	my $condition = shift;
+	my @spl_and = split('\&amp;\&amp;', $condition);
+	if (@spl_and == 1) {
+		return &quot;\$(CONFIG_$spl_and[0])&quot;;
+	}
+	return &quot;\$(and &quot; . join (',', map(&quot;\$(CONFIG_$_)&quot;, @spl_and)) . &quot;)&quot;;
+}
+
+sub gen_condition ($) {
+	my $condition = shift;
+	# remove '!()', just as include/package-ipkg.mk does
+	$condition =~ s/[()!]//g;
+	return join(&quot;&quot;, map(and_condition($_), split('\|\|', $condition)));
+}
+
 sub get_conditional_dep($$) {
 	my $condition = shift;
 	my $depstr = shift;
 	if ($condition) {
 		if ($condition =~ /^!(.+)/) {
-			return &quot;\$(if \$(CONFIG_$1),,$depstr)&quot;;
+			return &quot;\$(if &quot; . gen_condition($1) . &quot;,,$depstr)&quot;;
 		} else {
-			return &quot;\$(if \$(CONFIG_$condition),$depstr)&quot;;
+			return &quot;\$(if &quot; . gen_condition($condition) . &quot;,$depstr)&quot;;
 		}
 	} else {
 		return $depstr;

]