[OpenWrt-Devel] [PATCH V3 2/2] script/feeds: add a new command that allows generating a new feeds.conf

John Crispin john at phrozen.org
Wed Jun 5 06:30:57 EDT 2019


On 05/06/2019 12:17, Karl Palsson wrote:
> John Crispin <john at phrozen.org> wrote:
>> This can be used inside build setups for easy feeds.conf
>> generation.
>
> Could you give us an example of how this is actually easy, or
> what sort of functionality this is providing beyond "cat
> feeds.conf.default feeds.conf.extra > feeds.conf"
>
> It seems like a lot of perl for a narrow usecase.
>
> Sincerely,
> Karl Palsson

This was brought up as a missing feature by the prpl folks. I considered 
on how to best implement this and find that having proper tooling is 
much better than having to carry around an extra file that is cat. being 
able to build the feeds.conf dynamically like this just seems much 
cleaner to me and will allow downstream users, vendors, odms and 
integrators to have less need to patch their trees to death.

     John


>
>> Signed-off-by: John Crispin <john at phrozen.org>
>> ---
>>   scripts/feeds | 42 ++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 42 insertions(+)
>>
>> diff --git a/scripts/feeds b/scripts/feeds
>> index 304ef6cbaf..7cd4639ca6 100755
>> --- a/scripts/feeds
>> +++ b/scripts/feeds
>> @@ -7,6 +7,7 @@ use metadata;
>>   use warnings;
>>   use strict;
>>   use Cwd 'abs_path';
>> +use File::Copy;
>>   
>>   chdir "$FindBin::Bin/..";
>>   $ENV{TOPDIR} //= getcwd();
>> @@ -819,6 +820,42 @@ sub update {
>>   	return $failed;
>>   }
>>   
>> +sub setup {
>> +	my %opts;
>> +
>> +	getopts('bh', \%opts);
>> +
>> +	if ($opts{h}) {
>> +		usage();
>> +		return 0;
>> +	}
>> +
>> +	if ($opts{b}) {
>> +		copy("feeds.conf.default", "feeds.conf") or die "Copy failed: $!"
>> +	} else {
>> +		unlink "feeds.conf"
>> +	}
>> +
>> +	open(my $fd, ">>feeds.conf");
>> +	while (my $entry = shift @ARGV) {
>> +		my ($type, $name, $src) = split /,/, $entry;
>> +
>> +		$update_method{$type} or do {
>> +			warn "Unknown type '$type' in parameter $entry\n";
>> +			unlink "feeds.conf";
>> +			return 1;
>> +		};
>> +		if ($name =~ /\s/ || $src =~ /\s/) {
>> +			warn "Feed names or sources may not contain whitespace characters in parameter $entry\n";
>> +			unlink "feeds.conf";
>> +			return 1;
>> +		}
>> +		printf $fd "%s %s %s\n", $type, $name, $src;
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>>   sub feed_config() {
>>   	foreach my $feed (@feeds) {
>>   		my $installed = (-f "feeds/$feed->[1].index");
>> @@ -870,6 +907,10 @@ Commands:
>>   	    -i :           Recreate the index only. No feed update from repository is performed.
>>   	    -f :           Force updating feeds even if there are changed, uncommitted files.
>>   
>> +	setup [options] <type,name,link> <type,name,link> ...: generate feeds.conf
>> +	Options:
>> +	    -b :           Use feeds.conf.default as base for new feeds.conf.
>> +
>>   	clean:             Remove downloaded/generated files.
>>   
>>   EOF
>> @@ -883,6 +924,7 @@ my %commands = (
>>   	'search' => \&search,
>>   	'uninstall' => \&uninstall,
>>   	'feed_config' => \&feed_config,
>> +	'setup' => \&setup,
>>   	'clean' => sub {
>>   		system("rm -rf ./feeds ./package/feeds");
>>   	}
>> -- 
>> 2.20.1
>>
>>
>> _______________________________________________
>> openwrt-devel mailing list
>> openwrt-devel at lists.openwrt.org
>> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
>>
>> _______________________________________________
>> openwrt-devel mailing list
>> openwrt-devel at lists.openwrt.org
>> https://lists.openwrt.org/mailman/listinfo/openwrt-devel

_______________________________________________
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