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

Karl Palsson karlp at tweak.net.au
Wed Jun 5 06:17:34 EDT 2019


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


> 
> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP-digital-signature.html
Type: application/pgp-signature
Size: 1175 bytes
Desc: OpenPGP Digital Signature
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20190605/48c462c3/attachment.sig>
-------------- next part --------------
_______________________________________________
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