scripts/feeds: add src-include method
The src-include method allows recursive inclusion of feeds.conf snippets. This can for example be used for adding static local feeds to feeds.conf.default without ever having to update the local feeds.conf: src-include defaults feeds.conf.default src-link custom /usr/local/src/lede/custom Signed-off-by: Bjørn Mork <bjorn@mork.no>
This commit is contained in:
parent
18e2053bec
commit
7a1b575ac4
|
@ -41,34 +41,49 @@ my $feed_src = {};
|
||||||
my $feed_target = {};
|
my $feed_target = {};
|
||||||
my $feed_vpackage = {};
|
my $feed_vpackage = {};
|
||||||
|
|
||||||
sub parse_config() {
|
sub parse_file($$);
|
||||||
my $line = 0;
|
|
||||||
my %name;
|
|
||||||
|
|
||||||
open FEEDS, "feeds.conf" or
|
sub parse_file($$) {
|
||||||
open FEEDS, "feeds.conf.default" or
|
my ($fname, $name) = @_;
|
||||||
die "Unable to open feeds configuration";
|
my $line = 0;
|
||||||
while (<FEEDS>) {
|
my $fh;
|
||||||
|
|
||||||
|
open $fh, $fname or return undef;
|
||||||
|
while (<$fh>) {
|
||||||
chomp;
|
chomp;
|
||||||
s/#.+$//;
|
s/#.+$//;
|
||||||
|
$line++;
|
||||||
next unless /\S/;
|
next unless /\S/;
|
||||||
my @line = split /\s+/, $_, 3;
|
my @line = split /\s+/, $_, 3;
|
||||||
my @src;
|
my @src;
|
||||||
$line++;
|
|
||||||
|
|
||||||
my $valid = 1;
|
my $valid = 1;
|
||||||
$line[0] =~ /^src-[\w-]+$/ or $valid = 0;
|
$line[0] =~ /^src-[\w-]+$/ or $valid = 0;
|
||||||
$line[1] =~ /^\w+$/ or $valid = 0;
|
$line[1] =~ /^\w+$/ or $valid = 0;
|
||||||
@src = split /\s+/, ($line[2] or '');
|
@src = split /\s+/, ($line[2] or '');
|
||||||
@src = ('') if @src == 0;
|
@src = ('') if @src == 0;
|
||||||
$valid or die "Syntax error in feeds.conf, line: $line\n";
|
$valid or die "Syntax error in $fname, line: $line\n";
|
||||||
|
|
||||||
$name{$line[1]} and die "Duplicate feed name '$line[1]', line: $line\n";
|
$name->{$line[1]} and die "Duplicate feed name '$line[1]' in '$fname' line: $line\n";
|
||||||
$name{$line[1]} = 1;
|
$name->{$line[1]} = 1;
|
||||||
|
|
||||||
|
if ($line[0] eq "src-include") {
|
||||||
|
parse_file($line[2], $name) or
|
||||||
|
die "Unable to open included file '$line[2]'";
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
push @feeds, [$line[0], $line[1], \@src];
|
push @feeds, [$line[0], $line[1], \@src];
|
||||||
}
|
}
|
||||||
close FEEDS;
|
close $fh;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub parse_config() {
|
||||||
|
my %name;
|
||||||
|
parse_file("feeds.conf", \%name) or
|
||||||
|
parse_file("feeds.conf.default", \%name) or
|
||||||
|
die "Unable to open feeds configuration";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub update_location($$)
|
sub update_location($$)
|
||||||
|
|
Loading…
Reference in New Issue