+my %update_method = (
+ 'src-svn' => \&update_svn,
+ 'src-cpy' => \&update_cpy,
+ 'src-link' => \&update_link,
+ 'src-git' => \&update_git
+);
+
+sub update_feed($$$$)
+{
+ my $type=shift;
+ my $name=shift;
+ my $src=shift;
+ my $perform_update=shift;
+
+ $update_method{$type} or do {
+ warn "Unknown type '$type' in feed $name\n";
+ return 1;
+ };
+ $perform_update and do {
+ warn "Updating feed '$name' from '$src' ...\n";
+ &{$update_method{$type}}($name, $src) == 0 or do {
+ warn "failed.\n";
+ return 1;
+ };
+ };
+ warn "Create index file './feeds/$name.index' \n";
+ update_index($name) == 0 or do {
+ warn "failed.\n";
+ return 1;
+ };
+ return 0;
+}
+
+sub update {
+ my %opts;
+ my $feed_name;
+ my $perform_update=1;
+
+ $ENV{SCAN_COOKIE} = $$;
+ $ENV{KBUILD_VERBOSE} = 99;
+
+ getopts('ahi', \%opts);
+
+ if ($opts{h}) {
+ usage();
+ return 0;
+ }
+
+ if ($opts{i}) {
+ # don't update from (remote) repository
+ # only re-create index information
+ $perform_update=0;
+ }
+
+ -d "feeds" or do {
+ mkdir "feeds" or die "Unable to create the feeds directory";
+ };
+
+ if ( ($#ARGV == -1) or $opts{a}) {
+ foreach my $feed (@feeds) {
+ my ($type, $name, $src) = @$feed;
+ update_feed($type, $name, $src, $perform_update);
+ }
+ } else {
+ while ($feed_name = shift @ARGV) {
+ foreach my $feed (@feeds) {
+ my ($type, $name, $src) = @$feed;
+ if($feed_name ne $name) {
+ next;
+ }
+ update_feed($type, $name, $src, $perform_update);
+ }
+ }
+ }
+
+ refresh_config();
+
+ return 0;
+}
+