diff --git a/scripts/feeds b/scripts/feeds index 959995c7af..d49a402880 100755 --- a/scripts/feeds +++ b/scripts/feeds @@ -880,6 +880,47 @@ sub update { return $failed; } +sub setup { + my %opts; + + getopts('bh', \%opts); + + if ($opts{h}) { + usage(); + return 0; + } + + if (-e "feeds.conf") { + warn "The file feeds.conf already exists.\n"; + return 1; + } + + open(my $fd, ">>feeds.conf"); + + if ($opts{b}) { + printf $fd "src-include defaults feeds.conf.default\n"; + } + + 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-]/) { + warn "Feed names or sources may not contain whitespace or - 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"); @@ -933,6 +974,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] ...: generate feeds.conf + Options: + -b : Use feeds.conf.default as base for new feeds.conf. + clean: Remove downloaded/generated files. EOF @@ -946,6 +991,7 @@ my %commands = ( 'search' => \&search, 'uninstall' => \&uninstall, 'feed_config' => \&feed_config, + 'setup' => \&setup, 'clean' => sub { system("rm -rf ./feeds ./package/feeds ./target/linux/feeds"); }