metadata.pl: add support for forcing sorting of profiles
authorFelix Fietkau <nbd@nbd.name>
Tue, 10 May 2016 12:43:46 +0000 (14:43 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 11 May 2016 17:03:35 +0000 (19:03 +0200)
Used to mix device profiles (specified in the image makefile) with
regular target profiles.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
include/target.mk
scripts/metadata.pl
scripts/metadata.pm

index 817901f0b9cdff8124931279c251b2ebd4363404..f4342bdbb532d40ece8e8892c789c466aaa3daa1 100644 (file)
@@ -59,6 +59,7 @@ extra_packages = $(if $(filter wpad-mini wpad nas,$(1)),iwinfo)
 
 define ProfileDefault
   NAME:=
+  PRIORITY:=
   PACKAGES:=
 endef
 
@@ -70,6 +71,7 @@ define Profile
   dumpinfo : $(call shexport,Profile/$(1)/Description)
   DUMPINFO += \
        echo "Target-Profile: $(1)"; \
+       $(if $(PRIORITY), echo "Target-Profile-Priority: $(PRIORITY)"; ) \
        echo "Target-Profile-Name: $(NAME)"; \
        echo "Target-Profile-Packages: $(PACKAGES) $(call extra_packages,$(DEFAULT_PACKAGES) $(PACKAGES))"; \
        if [ -f ./config/profile-$(1) ]; then \
index 410fa9fe24fa2bb8852be9ecf08685b05c144d15..f5afb1e47b49a60d696afc42705d706e1f39c7c7 100755 (executable)
@@ -282,6 +282,10 @@ EOF
 
        foreach my $target (@target) {
                my $profiles = $target->{profiles};
+               $target->{sort} and @$profiles = sort {
+                       $a->{priority} <=> $b->{priority} or
+                       $a->{name} cmp $b->{name};
+               } @$profiles;
 
                foreach my $profile (@$profiles) {
                        print <<EOF;
index 1891c0a6ee88353dd7225707c8e0ba62a1efa360..3b756216a5ee7fac5ba31497f75ff5741d1d4998 100644 (file)
@@ -84,11 +84,16 @@ sub parse_target_metadata($) {
                        $profile = {
                                id => $1,
                                name => $1,
+                               priority => 999,
                                packages => []
                        };
                        push @{$target->{profiles}}, $profile;
                };
-               /^Target-Profile-Name:\s*(.+)\s*$/ and $profile->{name} = $1;
+               /^Target-Profile-Name:\s*(.+)\s*$/ and do {
+                       $target->{sort} = 1;
+                       $profile->{name} = $1;
+               };
+               /^Target-Profile-Priority:\s*(\d+)\s*$/ and $profile->{priority} = $1;
                /^Target-Profile-Packages:\s*(.*)\s*$/ and $profile->{packages} = [ split(/\s+/, $1) ];
                /^Target-Profile-Description:\s*(.*)\s*/ and $profile->{desc} = get_multiline(*FILE);
                /^Target-Profile-Config:/ and $profile->{config} = get_multiline(*FILE, "\t");