[OpenWrt-Devel] [PATCH 2/3] build: Introduce Target-Profile-AltNames

Paul Spooren mail at aparcar.org
Wed Apr 1 02:17:48 EDT 2020


Currently the alternative consumer names for devices are stored in the
description only or as a joint string in `Target-Profile-Name`. This
adds a new variable called `Target-Profile-AltNames` to store the
alternateive names as a quoted list: "<ALT0>" "<ALT1>" "<ALT2>"

Signed-off-by: Paul Spooren <mail at aparcar.org>
---
 include/image.mk           | 1 +
 scripts/metadata.pm        | 2 ++
 scripts/target-metadata.pl | 3 +++
 3 files changed, 6 insertions(+)

diff --git a/include/image.mk b/include/image.mk
index 6204e8ab61..c4015da809 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -632,6 +632,7 @@ endef
 define Device/DumpInfo
 Target-Profile: DEVICE_$(1)
 Target-Profile-Name: $(DEVICE_DISPLAY)
+Target-Profile-AltNames: $(if $(strip $(DEVICE_ALT0_TITLE)),"$(DEVICE_ALT0_TITLE)")$(if $(strip $(DEVICE_ALT1_TITLE)), "$(DEVICE_ALT1_TITLE)")$(if $(strip $(DEVICE_ALT2_TITLE)), "$(DEVICE_ALT2_TITLE)")
 Target-Profile-Packages: $(DEVICE_PACKAGES)
 Target-Profile-hasImageMetadata: $(if $(foreach image,$(IMAGES),$(findstring append-metadata,$(IMAGE/$(image)))),1,0)
 Target-Profile-SupportedDevices: $(SUPPORTED_DEVICES)
diff --git a/scripts/metadata.pm b/scripts/metadata.pm
index 1826a040a1..1967adf8d6 100644
--- a/scripts/metadata.pm
+++ b/scripts/metadata.pm
@@ -140,6 +140,7 @@ sub parse_target_metadata($) {
 			$profile = {
 				id => $1,
 				name => $1,
+				altnames => [],
 				has_image_metadata => 0,
 				supported_devices => [],
 				priority => 999,
@@ -150,6 +151,7 @@ sub parse_target_metadata($) {
 			push @{$target->{profiles}}, $profile;
 		};
 		/^Target-Profile-Name:\s*(.+)\s*$/ and $profile->{name} = $1;
+		/^Target-Profile-AltNames:\s*(.+)\s*$/ and $profile->{altnames} = [ split(/\s+/, $1) ];
 		/^Target-Profile-hasImageMetadata:\s*(\d+)\s*$/ and $profile->{has_image_metadata} = $1;
 		/^Target-Profile-SupportedDevices:\s*(.+)\s*$/ and $profile->{supported_devices} = [ split(/\s+/, $1) ];
 		/^Target-Profile-Priority:\s*(\d+)\s*$/ and do {
diff --git a/scripts/target-metadata.pl b/scripts/target-metadata.pl
index fd8f4096a7..38a1f25e1a 100755
--- a/scripts/target-metadata.pl
+++ b/scripts/target-metadata.pl
@@ -435,6 +435,9 @@ sub gen_profile_mk() {
 				print $profile->{id}.'_SUPPORTED_DEVICES:='.join(' ', @{$profile->{supported_devices}})."\n";
 			}
 			print $profile->{id}.'_PACKAGES:='.join(' ', @{$profile->{packages}})."\n";
+			if (defined($profile->{altnames}) and @{$profile->{altnames}} > 0) {
+				print $profile->{id}.'_ALT_NAMES:='.join(' ', @{$profile->{altnames}})."\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