[OpenWrt-Devel] metadata: express conflicts in a single line

Message ID 1531416817-29017-1-git-send-email-dev@kresin.me
State Rejected
Delegated to: Mathias Kresin
Headers show
Series
  • [OpenWrt-Devel] metadata: express conflicts in a single line
Related show

Commit Message

Mathias Kresin July 12, 2018, 5:33 p.m.
Due to the use of dependencies to express conflicts, a package which
conflicts with multiple other packages (variants) is indented one level
for each conflict:

< > pkg-variant-a
< >   pkg-variant-b (conflicts pkg-variant-a)
< >     pkg-variant-c (conflicts pkg-variant-a && pkg-variant-b)

Express conflicts in a single line by using the logical AND operator to
fix the visual glitch.

Signed-off-by: Mathias Kresin <dev@kresin.me>
---
 scripts/package-metadata.pl | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Mathias Kresin July 14, 2018, 8:48 a.m. | #1
12.07.2018 19:33, Mathias Kresin:
> Due to the use of dependencies to express conflicts, a package which
> conflicts with multiple other packages (variants) is indented one level
> for each conflict:
> 
> < > pkg-variant-a
> < >   pkg-variant-b (conflicts pkg-variant-a)
> < >     pkg-variant-c (conflicts pkg-variant-a && pkg-variant-b)
> 
> Express conflicts in a single line by using the logical AND operator to
> fix the visual glitch.
> 
> Signed-off-by: Mathias Kresin <dev@kresin.me>
> ---
>   scripts/package-metadata.pl | 12 ++++++++++--
>   1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/package-metadata.pl b/scripts/package-metadata.pl
> index 53bb45a..3e5d8f7 100755
> --- a/scripts/package-metadata.pl
> +++ b/scripts/package-metadata.pl
> @@ -243,12 +243,20 @@ sub mconf_conflicts {
>   	my $pkgname = shift;
>   	my $depends = shift;
>   	my $res = "";
> +	my @conflics;
>   
>   	foreach my $depend (@$depends) {
>   		next unless $package{$depend};
> -		$res .= "\t\tdepends on m || (PACKAGE_$depend != y)\n";
> +		push @conflics, "PACKAGE_$depend != y";
>   	}
> -	return $res;
> +
> +	if (!@conflics) {
> +		return $res;
> +	}
> +
> +	$res = join(" && ",@conflics);
> +
> +	return "\t\tdepends on m || ($res)\n";
>   }
>   
>   sub print_package_config_category($) {
> 

Disregard this patch. I realised it's an ugly workaround which might not 
work in all cases. The script/conf code need to be extended to handle 
our use of "!= y" dependencies properly.

Mathias

Patch

diff --git a/scripts/package-metadata.pl b/scripts/package-metadata.pl
index 53bb45a..3e5d8f7 100755
--- a/scripts/package-metadata.pl
+++ b/scripts/package-metadata.pl
@@ -243,12 +243,20 @@  sub mconf_conflicts {
 	my $pkgname = shift;
 	my $depends = shift;
 	my $res = "";
+	my @conflics;
 
 	foreach my $depend (@$depends) {
 		next unless $package{$depend};
-		$res .= "\t\tdepends on m || (PACKAGE_$depend != y)\n";
+		push @conflics, "PACKAGE_$depend != y";
 	}
-	return $res;
+
+	if (!@conflics) {
+		return $res;
+	}
+
+	$res = join(" && ",@conflics);
+
+	return "\t\tdepends on m || ($res)\n";
 }
 
 sub print_package_config_category($) {