[OpenWrt-Devel] [PATCH v2 1/3] scripts: target-metadata don't add PROFILES twice

Paul Spooren mail at aparcar.org
Tue Apr 14 20:49:54 EDT 2020


Since 4ee3cf2b5a profiles with alternative vendor names may appear
multiple times in `tmp/.targetinfo` or `.targetinfo` (for
ImageBuilders).

The `target-metadata.pl` script adds these profiles then twice to
`PROFILE_NAMES` and the ImageBuilder show the profile twices when
running `make info`.

This patch uses Perls `uniq` function to add the profiles only once to
`.profiles.mk`.

Signed-off-by: Paul Spooren <mail at aparcar.org>
---
v2:
  * Instead of importing the entire MoreUtils library only copy the
    `uniq` function.

 scripts/target-metadata.pl | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/scripts/target-metadata.pl b/scripts/target-metadata.pl
index ee0ab5a718..4142b51162 100755
--- a/scripts/target-metadata.pl
+++ b/scripts/target-metadata.pl
@@ -5,6 +5,15 @@ use strict;
 use metadata;
 use Getopt::Long;
 
+# uniq function from
+# https://metacpan.org/source/REHSACK/List-MoreUtils-0.428/lib/List/MoreUtils/PP.pm
+sub uniq (@) {
+	my %seen = ();
+	my $k;
+	my $seen_undef;
+	grep { defined $_ ? not $seen{$k = $_}++ : not $seen_undef++ } @_;
+}
+
 sub target_config_features(@) {
 	my $ret;
 
@@ -426,7 +435,7 @@ sub gen_profile_mk() {
 	my @targets = parse_target_metadata($file);
 	foreach my $cur (@targets) {
 		next unless $cur->{id} eq $target;
-		print "PROFILE_NAMES = ".join(" ", map { $_->{id} } @{$cur->{profiles}})."\n";
+		print "PROFILE_NAMES = ".join(" ", uniq map { $_->{id} } @{$cur->{profiles}})."\n";
 		foreach my $profile (@{$cur->{profiles}}) {
 			print $profile->{id}.'_NAME:='.$profile->{name}."\n";
 			print $profile->{id}.'_HAS_IMAGE_METADATA:='.$profile->{has_image_metadata}."\n";
-- 
2.25.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list