backport: scripts/feeds: add a new command that allows generating a new feeds.conf
This can be used inside build setups for easy feeds.conf generation. Signed-off-by: John Crispin <john@phrozen.org> (cherry picked from commit f039f68dcbf26b424028f39f9dd80cd4c89ea9be)
This commit is contained in:
parent
3fcc07ff55
commit
2eacc18b31
@ -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] <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
|
||||
@ -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");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user