John Crispin <[email protected]> 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 <[email protected]>
> ---
>  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
> [email protected]
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Attachment: OpenPGP-digital-signature.html
Description: OpenPGP Digital Signature

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

Reply via email to