metadata.pl: add support for forcing sorting of profiles

Used to mix device profiles (specified in the image makefile) with
regular target profiles.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
master
Felix Fietkau 9 years ago
parent 87550a0e87
commit 1189af85fd
  1. 2
      include/target.mk
  2. 4
      scripts/metadata.pl
  3. 7
      scripts/metadata.pm

@ -59,6 +59,7 @@ extra_packages = $(if $(filter wpad-mini wpad nas,$(1)),iwinfo)
define ProfileDefault define ProfileDefault
NAME:= NAME:=
PRIORITY:=
PACKAGES:= PACKAGES:=
endef endef
@ -70,6 +71,7 @@ define Profile
dumpinfo : $(call shexport,Profile/$(1)/Description) dumpinfo : $(call shexport,Profile/$(1)/Description)
DUMPINFO += \ DUMPINFO += \
echo "Target-Profile: $(1)"; \ echo "Target-Profile: $(1)"; \
$(if $(PRIORITY), echo "Target-Profile-Priority: $(PRIORITY)"; ) \
echo "Target-Profile-Name: $(NAME)"; \ echo "Target-Profile-Name: $(NAME)"; \
echo "Target-Profile-Packages: $(PACKAGES) $(call extra_packages,$(DEFAULT_PACKAGES) $(PACKAGES))"; \ echo "Target-Profile-Packages: $(PACKAGES) $(call extra_packages,$(DEFAULT_PACKAGES) $(PACKAGES))"; \
if [ -f ./config/profile-$(1) ]; then \ if [ -f ./config/profile-$(1) ]; then \

@ -282,6 +282,10 @@ EOF
foreach my $target (@target) { foreach my $target (@target) {
my $profiles = $target->{profiles}; my $profiles = $target->{profiles};
$target->{sort} and @$profiles = sort {
$a->{priority} <=> $b->{priority} or
$a->{name} cmp $b->{name};
} @$profiles;
foreach my $profile (@$profiles) { foreach my $profile (@$profiles) {
print <<EOF; print <<EOF;

@ -84,11 +84,16 @@ sub parse_target_metadata($) {
$profile = { $profile = {
id => $1, id => $1,
name => $1, name => $1,
priority => 999,
packages => [] packages => []
}; };
push @{$target->{profiles}}, $profile; 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-Packages:\s*(.*)\s*$/ and $profile->{packages} = [ split(/\s+/, $1) ];
/^Target-Profile-Description:\s*(.*)\s*/ and $profile->{desc} = get_multiline(*FILE); /^Target-Profile-Description:\s*(.*)\s*/ and $profile->{desc} = get_multiline(*FILE);
/^Target-Profile-Config:/ and $profile->{config} = get_multiline(*FILE, "\t"); /^Target-Profile-Config:/ and $profile->{config} = get_multiline(*FILE, "\t");

Loading…
Cancel
Save