scripts: Add Buildbot dump-target-info.pl script
[openwrt/staging/stintel.git] / scripts / feeds
index b29e1d5c353d23c8f0afc81fb0f1ec37e1f2a521..69ab60278a1a12bc5446cf5245c9f8cdac09d349 100755 (executable)
@@ -41,34 +41,56 @@ my $feed_src = {};
 my $feed_target = {};
 my $feed_vpackage = {};
 
-sub parse_config() {
+sub parse_file($$);
+
+sub parse_file($$) {
+       my ($fname, $existing) = @_;
        my $line = 0;
-       my %name;
+       my $fh;
 
-       open FEEDS, "feeds.conf" or
-               open FEEDS, "feeds.conf.default" or
-               die "Unable to open feeds configuration";
-       while (<FEEDS>) {
+       open $fh, $fname or return undef;
+       while (<$fh>) {
                chomp;
                s/#.+$//;
-               next unless /\S/;
-               my @line = split /\s+/, $_, 3;
-               my @src;
                $line++;
+               next unless /\S/;
 
-               my $valid = 1;
-               $line[0] =~ /^src-[\w-]+$/ or $valid = 0;
-               $line[1] =~ /^\w+$/ or $valid = 0;
-               @src = split /\s+/, ($line[2] or '');
-               @src = ('') if @src == 0;
-               $valid or die "Syntax error in feeds.conf, line: $line\n";
+               my ($type, $flags, $name, $urls) = m!^src-([\w\-]+)((?:\s+--\w+(?:=\S+)?)*)\s+(\w+)(?:\s+(\S.*))?$!;
+               unless ($type && $name) {
+                       die "Syntax error in $fname, line $line\n";
+               }
+
+               if ($existing->{$name}++) {
+                       die "Duplicate feed name '$name' in '$fname' line: $line\n";
+               }
 
-               $name{$line[1]} and die "Duplicate feed name '$line[1]', line: $line\n";
-               $name{$line[1]} = 1;
+               my @src = defined($urls) ? split /\s+/, $urls : ();
+               push @src, '' if @src == 0;
 
-               push @feeds, [$line[0], $line[1], \@src];
+               my %flags;
+               if (defined $flags) {
+                       while ($flags =~ m!\s+--(\w+)(?:=(\S+))?!g) {
+                               $flags{$1} = defined($2) ? $2 : 1;
+                       }
+               }
+
+               if ($type eq "include") {
+                       parse_file($urls, $existing) or
+                           die "Unable to open included file '$urls'";
+                       next;
+               }
+
+               push @feeds, ["src-$type", $name, \@src, \%flags];
        }
-       close FEEDS;
+       close $fh;
+       return 1;
+}
+
+sub parse_config() {
+       my %name;
+       parse_file("feeds.conf", \%name) or
+           parse_file("feeds.conf.default", \%name)  or
+           die "Unable to open feeds configuration";
 }
 
 sub update_location($$)
@@ -506,6 +528,11 @@ sub install_src {
        get_feed($feed->[1]);
        my $src = $feed_src->{$name} or return 1;
 
+       # enable force flag if feed src line was declared with --force
+       if (exists($feed->[3]{force})) {
+               $force = 1;
+       }
+
        # If it's a core package and we don't want to override, just return
        my $override = 0;
        if (is_core_src($name)) {
@@ -824,11 +851,12 @@ sub feed_config() {
                my $installed = (-f "feeds/$feed->[1].index");
 
                printf "\tconfig FEED_%s\n", $feed->[1];
-               printf "\t\tbool \"Enable feed %s\"\n", $feed->[1];
+               printf "\t\ttristate \"Enable feed %s\"\n", $feed->[1];
                printf "\t\tdepends on PER_FEED_REPO\n";
                printf "\t\tdefault y\n" if $installed;
                printf "\t\thelp\n";
-               printf "\t\t Enable the \\\"%s\\\" feed at %s.\n", $feed->[1], $feed->[2][0];
+               printf "\t\t Enable the \\\"%s\\\" feed in opkg distfeeds.conf.\n", $feed->[1];
+               printf "\t\t Say M to add the feed commented out.\n";
                printf "\n";
        }