[PATCH] scripts/feeds: add src-include method
=3D?UTF-8?q?Bj=3DC3=3DB8rn=3D20Mork?=3D
bjorn at mork.no
Wed Jun 5 07:51:24 EDT 2019
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=C3=B8rn Mork <bjorn at mork.no>
---
scripts/feeds | 34 ++++++++++++++++++++++++----------
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/scripts/feeds b/scripts/feeds
index 304ef6cbafd1..65072d673433 100755
--- a/scripts/feeds
+++ b/scripts/feeds
@@ -41,34 +41,48 @@ my $feed_src =3D {};
my $feed_target =3D {};
my $feed_vpackage =3D {};
=20
-sub parse_config() {
- my $line =3D 0;
- my %name;
+sub parse_file($$);
+
+sub parse_file($$) {
+ my ($fname, $name) =3D @_;
=20
- open FEEDS, "feeds.conf" or
- open FEEDS, "feeds.conf.default" or
- die "Unable to open feeds configuration";
+ my $line =3D 0;
+ open FEEDS, $fname or return undef;
while (<FEEDS>) {
chomp;
s/#.+$//;
+ $line++;
next unless /\S/;
my @line =3D split /\s+/, $_, 3;
my @src;
- $line++;
=20
my $valid =3D 1;
$line[0] =3D~ /^src-[\w-]+$/ or $valid =3D 0;
$line[1] =3D~ /^\w+$/ or $valid =3D 0;
@src =3D split /\s+/, ($line[2] or '');
@src =3D ('') if @src =3D=3D 0;
- $valid or die "Syntax error in feeds.conf, line: $line\n";
+ $valid or die "Syntax error in $fname, line: $line\n";
=20
- $name{$line[1]} and die "Duplicate feed name '$line[1]', line: $line\n";
- $name{$line[1]} =3D 1;
+ $name->{$line[1]} and die "Duplicate feed name '$line[1]', line: $line\n=
";
+ $name->{$line[1]} =3D 1;
+
+ if ($line[0] eq "include") {
+ parse_file($line[2], $name) or
+ die "Unable to open included file '$line[2]'";
+ next;
+ }
=20
push @feeds, [$line[0], $line[1], \@src];
}
close FEEDS;
+ 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";
}
=20
sub update_location($$)
--=20
2.11.0
--=-=-=
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
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