A little late into this discussion, but something like the attached
patch would suite my personal usage patterns much better.  I don't
really need to update or change my local additions to feeds.conf at all.
I just want to add them to the defaults for whatever version I am
currently building.

Another alternative would be to make scripts/feeds look for an optional
feeds.conf.local when falling back to feeds.conf.default.  That would
also work for me.

But this might be on my wishlist only...


Bjørn

>From b43bdbbcc71ad881ac753b342f2ae400410e9257 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= <[email protected]>
Date: Wed, 5 Jun 2019 13:51:24 +0200
Subject: [PATCH] scripts/feeds: add src-include method
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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 <[email protected]>
---
 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 = {};
 my $feed_target = {};
 my $feed_vpackage = {};
 
-sub parse_config() {
-	my $line = 0;
-	my %name;
+sub parse_file($$);
+
+sub parse_file($$) {
+	my ($fname, $name) = @_;
 
-	open FEEDS, "feeds.conf" or
-		open FEEDS, "feeds.conf.default" or
-		die "Unable to open feeds configuration";
+	my $line = 0;
+	open FEEDS, $fname or return undef;
 	while (<FEEDS>) {
 		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]', line: $line\n";
+		$name->{$line[1]} = 1;
+
+		if ($line[0] eq "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;
+	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($$)
-- 
2.11.0

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to