diff options
author | Bjørn Mork <bjorn@mork.no> | 2019-06-05 14:19:11 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-09-04 13:22:34 +0200 |
commit | 1e887ddc8d805a76b59687bea9f520ccb0557223 (patch) | |
tree | 1a0d3155a7a7303363f843451739d56f10d3bac0 /scripts/feeds | |
parent | 5a41c027e19cf8f82f38f6a3a1db83b3a4c208e3 (diff) | |
download | upstream-1e887ddc8d805a76b59687bea9f520ccb0557223.tar.gz upstream-1e887ddc8d805a76b59687bea9f520ccb0557223.tar.bz2 upstream-1e887ddc8d805a76b59687bea9f520ccb0557223.zip |
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>
(cherry picked from commit 7a1b575ac4ede2778bb21cfafa7a1152d9d2555f)
Diffstat (limited to 'scripts/feeds')
-rwxr-xr-x | scripts/feeds | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/scripts/feeds b/scripts/feeds index 304ef6cbaf..a4dfd9e260 100755 --- a/scripts/feeds +++ b/scripts/feeds @@ -41,34 +41,49 @@ my $feed_src = {}; my $feed_target = {}; my $feed_vpackage = {}; -sub parse_config() { +sub parse_file($$); + +sub parse_file($$) { + my ($fname, $name) = @_; my $line = 0; - my %name; + my $fh; - open FEEDS, "feeds.conf" or - open FEEDS, "feeds.conf.default" or - die "Unable to open feeds configuration"; - while (<FEEDS>) { + open $fh, $fname or return undef; + while (<$fh>) { chomp; s/#.+$//; + $line++; next unless /\S/; my @line = split /\s+/, $_, 3; my @src; - $line++; my $valid = 1; $line[0] =~ /^src-[\w-]+$/ or $valid = 0; $line[1] =~ /^\w+$/ or $valid = 0; @src = split /\s+/, ($line[2] or ''); @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]} = 1; + $name->{$line[1]} and die "Duplicate feed name '$line[1]' in '$fname' line: $line\n"; + $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]; } - 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($$) |