feeds 15.7 KB
Newer Older
1
2
3
4
5
6
7
8
#!/usr/bin/perl
use Getopt::Std;
use FindBin;
use Cwd;
use lib "$FindBin::Bin";
use metadata;
use warnings;
use strict;
9
use Cwd 'abs_path';
10
11
12

chdir "$FindBin::Bin/..";
$ENV{TOPDIR}=getcwd();
13
$ENV{GIT_CONFIG_PARAMETERS}="'core.autocrlf=false'";
14
$ENV{GREP_OPTIONS}="";
15

16
my $mk=`which gmake 2>/dev/null`;	# select the right 'make' program
17
18
19
chomp($mk);		# trim trailing newline
$mk or $mk = "make";	# default to 'make'

ralph's avatar
ralph committed
20
21
22
23
24
25
26
27
# check version of make
my @mkver = split /\s+/, `$mk -v`, 4;
my $valid_mk = 1;
$mkver[0] =~ /^GNU/ or $valid_mk = 0;
$mkver[1] =~ /^Make/ or $valid_mk = 0;
$mkver[2] >= "3.81" or $valid_mk = 0;
$valid_mk or die "Unsupported version of make found: $mk\n";

28
29
30
my @feeds;
my %build_packages;
my %installed;
31
32
33
34
my %feed_cache;

my $feed_package = {};
my $feed_src = {};
35
36
37
38
39

sub parse_config() {
	my $line = 0;
	my %name;

40
41
42
	open FEEDS, "feeds.conf" or
		open FEEDS, "feeds.conf.default" or
		die "Unable to open feeds configuration";
43
44
45
46
47
	while (<FEEDS>) {
		chomp;
		s/#.+$//;
		next unless /\S/;
		my @line = split /\s+/, $_, 3;
48
		my @src;
49
50
51
52
53
		$line++;

		my $valid = 1;
		$line[0] =~ /^src-\w+$/ or $valid = 0;
		$line[1] =~ /^\w+$/ or $valid = 0;
54
		@src = split /\s+/, $line[2];
nbd's avatar
nbd committed
55
		$valid or die "Syntax error in feeds.conf, line: $line\n";
56
57
58
59

		$name{$line[1]} and die "Duplicate feed name '$line[1]', line: $line\n";
		$name{$line[1]} = 1;

60
		push @feeds, [$line[0], $line[1], \@src];
61
62
63
64
	}
	close FEEDS;
}

65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
sub update_location($$)
{
	my $name = shift;
	my $url  = shift;
	my $old_url;

	-d "./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;

	if( open LOC, "< ./feeds/$name.tmp/location" )
	{
		chomp($old_url = readline LOC);
		close LOC;
	}

	if( !$old_url || $old_url ne $url )
	{
		if( open LOC, "> ./feeds/$name.tmp/location" )
		{
			print LOC $url, "\n";
			close LOC;
		}
		return $old_url ? 1 : 0;
	}

ralph's avatar
ralph committed
89
	return 0;
90
91
}

ralph's avatar
ralph committed
92
sub update_index($)
93
{
94
	my $name = shift;
ralph's avatar
ralph committed
95

96
97
98
	-d "./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
	-d "./feeds/$name.tmp/info" or mkdir "./feeds/$name.tmp/info" or return 1;

99
	system("$mk -s prepare-mk OPENWRT_BUILD= TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
mirko's avatar
mirko committed
100
	system("$mk -s -f include/scan.mk IS_TTY=1 SCAN_TARGET=\"packageinfo\" SCAN_DIR=\"feeds/$name\" SCAN_NAME=\"package\" SCAN_DEPS=\"$ENV{TOPDIR}/include/package*.mk\" SCAN_DEPTH=5 SCAN_EXTRA=\"\" TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
101
102
103
104
105
	system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index");

	return 0;
}

nbd's avatar
nbd committed
106
107
my %update_method = (
	'src-svn' => {
hcg's avatar
hcg committed
108
		'init'		=> "svn checkout '%s' '%s'",
nbd's avatar
nbd committed
109
		'update'	=> "svn update",
110
111
		'controldir'	=> ".svn",
		'revision'	=> "svn info | grep 'Revision' | cut -d ' ' -f 2 | tr -d '\n'"},
nbd's avatar
nbd committed
112
113
	'src-cpy' => {
		'init'		=> "cp -Rf '%s' '%s'",
114
115
		'update'	=> "",
		'revision'	=> "echo -n 'local'"},
nbd's avatar
nbd committed
116
117
	'src-link' => {
		'init'		=> "ln -s '%s' '%s'",
118
119
		'update'	=> "",
		'revision'	=> "echo -n 'local'"},
nbd's avatar
nbd committed
120
	'src-git' => {
121
122
		'init'          => "git clone --depth 1 '%s' '%s'",
		'init_branch'   => "git clone --depth 1 --branch '%s' '%s' '%s'",
123
		'init_commit'   => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
124
		'update'	=> "git pull --ff",
125
126
		'controldir'	=> ".git",
		'revision'	=> "git show --abbrev-commit HEAD | head -n 1 | cut -d ' ' -f 2 | tr -d '\n'"},
127
	'src-gitsvn' => {
128
129
130
131
		'init'	=> "git svn clone -r HEAD '%s' '%s'",
		'update'	=> "git svn rebase",
		'controldir'	=> ".git",
		'revision'	=> "git show --abbrev-commit HEAD | head -n 1 | cut -d ' ' -f 2 | tr -d '\n'"},
nbd's avatar
nbd committed
132
133
134
135
136
137
138
	'src-bzr' => {
		'init'		=> "bzr checkout --lightweight '%s' '%s'",
		'update'	=> "bzr update",
		'controldir'	=> ".bzr"},
	'src-hg' => {
		'init'		=> "hg clone '%s' '%s'",
		'update'	=> "hg pull --update",
139
140
141
142
143
		'controldir'	=> ".hg"},
	'src-darcs' => {
		'init'    => "darcs get '%s' '%s'",
		'update'  => "darcs pull -a",
		'controldir' => "_darcs"},
nbd's avatar
nbd committed
144
);
ralph's avatar
ralph committed
145

nbd's avatar
nbd committed
146
147
# src-git: pull broken
# src-cpy: broken if `basename $src` != $name
148

nbd's avatar
nbd committed
149
150
sub update_feed_via($$$$) {
	my $type = shift;
151
152
	my $name = shift;
	my $src = shift;
153
	my $relocate = shift;
nbd's avatar
nbd committed
154
155
156
157
158
	
	my $m = $update_method{$type};
	my $localpath = "./feeds/$name";
	my $safepath = $localpath;
	$safepath =~ s/'/'\\''/;
159
160
	my ($base_branch, $branch) = split(/;/, $src, 2);
	my ($base_commit, $commit) = split(/\^/, $src, 2);
nbd's avatar
nbd committed
161
162
163

	if( $relocate || !$m->{'update'} || !-d "$localpath/$m->{'controldir'}" ) {
		system("rm -rf '$safepath'");
164
		if ($m->{'init_branch'} and $branch) {
165
166
167
			system(sprintf($m->{'init_branch'}, $branch, $base_branch, $safepath)) == 0 or return 1;
		} elsif ($m->{'init_commit'} and $commit) {
			system(sprintf($m->{'init_commit'}, $base_commit, $safepath, $safepath, $commit, $commit)) == 0 or return 1;
168
169
170
		} else {
			system(sprintf($m->{'init'}, $src, $safepath)) == 0 or return 1;
		}
171
172
	} elsif ($m->{'init_commit'} and $commit) {
		# in case git hash has been provided don't update the feed
173
	} else {
nbd's avatar
nbd committed
174
		system("cd '$safepath'; $m->{'update'}") == 0 or return 1;
175
	}
nbd's avatar
nbd committed
176
	
ralph's avatar
ralph committed
177
	return 0;
178
179
}

180
181
182
sub get_feed($) {
	my $feed = shift;

183
184
	if (!defined($feed_cache{$feed})) {
		my $file = "./feeds/$feed.index";
185

186
187
188
189
190
191
192
193
194
195
196
197
		clear_packages();
		-f $file or do {
			print "Ignoring feed '$feed' - index missing\n";
			return;
		};
		parse_package_metadata($file) or return;
		$feed_cache{$feed} = [ { %package }, { %srcpackage } ];
	}

	$feed_package = $feed_cache{$feed}->[0];
	$feed_src = $feed_cache{$feed}->[1];
	return $feed_cache{$feed}->[0];
198
199
200
}

sub get_installed() {
201
	system("$mk -s prepare-tmpinfo OPENWRT_BUILD=");
202
203
204
205
206
207
208
209
210
	clear_packages();
	parse_package_metadata("./tmp/.packageinfo");
	%installed = %package;
}

sub search_feed {
	my $feed = shift;
	my @substr = @_;
	my $display;
211

212
213
	return unless @substr > 0;
	get_feed($feed);
214
215
	foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) {
		my $pkg = $feed_package->{$name};
216
217
218
		my $substr;
		my $pkgmatch = 1;

nbd's avatar
nbd committed
219
		next if $pkg->{vdepends};
220
221
		foreach my $substr (@substr) {
			my $match;
222
			foreach my $key (qw(name title description src)) {
nbd's avatar
nbd committed
223
				$pkg->{$key} and $substr and $pkg->{$key} =~ m/$substr/i and $match = 1;
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
			}
			$match or undef $pkgmatch;
		};
		$pkgmatch and do {
			$display or do {
				print "Search results in feed '$feed':\n";
				$display = 1;
			};
			printf "\%-25s\t\%s\n", $pkg->{name}, $pkg->{title};
		};
	}
	return 0;
}

sub search {
	my %opts;

	getopt('r:', \%opts);
	foreach my $feed (@feeds) {
		search_feed($feed->[1], @ARGV) if (!defined($opts{r}) or $opts{r} eq $feed->[1]);
	}
}

ralph's avatar
ralph committed
247
248
249
250
sub list_feed {
	my $feed = shift;

	get_feed($feed);
251
	foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) {
252
		my $pkg = $feed_package->{$name};
nbd's avatar
nbd committed
253
		next if $pkg->{vdepends};
ralph's avatar
ralph committed
254
255
256
257
258
259
260
261
262
263
264
		if($pkg->{name}) {
			printf "\%-32s\t\%s\n", $pkg->{name}, $pkg->{title};
		}
	}

	return 0;
}

sub list {
	my %opts;

265
	getopts('r:d:nsh', \%opts);
ralph's avatar
ralph committed
266
267
268
269
	if ($opts{h}) {
		usage();
		return 0;
	}
270
271
272
273
274
275
	if ($opts{n}) {
		foreach my $feed (@feeds) {
			printf "%s\n", $feed->[1];
		}
		return 0;
	}
ralph's avatar
ralph committed
276
277
	if ($opts{s}) {
		foreach my $feed (@feeds) {
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
			my $localpath = "./feeds/$feed->[1]";
			my $m = $update_method{$feed->[0]};
			my $revision;
			if( !$m->{'revision'} ) {
				$revision = "X";
			}
			elsif( $m->{'controldir'} && -d "$localpath/$m->{'controldir'}" ) {
				$revision = `cd '$localpath'; $m->{'revision'}`;
			}
			else {
				$revision = "local";
			}
			if ($opts{d}) {
				printf "%s%s%s%s%s%s%s\n", $feed->[1], $opts{d}, $feed->[0], $opts{d}, $revision, $opts{d}, join(", ", @{$feed->[2]});
			}
			else {
				printf "\%-8s \%-8s \%-8s \%s\n", $feed->[1], $feed->[0], $revision, join(", ", @{$feed->[2]});
			}
ralph's avatar
ralph committed
296
297
298
299
300
301
302
303
304
		}
		return 0;
	}
	foreach my $feed (@feeds) {
		list_feed($feed->[1], @ARGV) if (!defined($opts{r}) or $opts{r} eq $feed->[1]);
	}
	return 0;
}

305
sub install_generic() {
306
307
308
	my $feed = shift;
	my $pkg = shift;
	my $path = $pkg->{makefile};
309

310
311
	if($path) {
		$path =~ s/\/Makefile$//;
312

313
314
315
316
317
318
319
		-d "./package/feeds" or mkdir "./package/feeds";
		-d "./package/feeds/$feed->[1]" or mkdir "./package/feeds/$feed->[1]";
		system("ln -sf ../../../$path ./package/feeds/$feed->[1]/");
	} else {
		warn "Package is not valid\n";
		return 1;
	}
320

321
322
323
324
	return 0;
}

my %install_method = (
325
326
	'src-svn' => \&install_generic,
	'src-cpy' => \&install_generic,
327
328
	'src-link' => \&install_generic,
	'src-git' => \&install_generic,
329
	'src-gitsvn' => \&install_generic,
nbd's avatar
nbd committed
330
331
	'src-bzr' => \&install_generic,
	'src-hg' => \&install_generic,
332
	'src-darcs' => \&install_generic,
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
);

my %feed;

sub lookup_package($$) {
	my $feed = shift;
	my $package = shift;

	foreach my $feed ($feed, @feeds) {
		next unless $feed->[1];
		next unless $feed{$feed->[1]};
		$feed{$feed->[1]}->{$package} and return $feed;
	}
	return;
}

349
350
351
352
353
354
355
356
357
sub is_core_package($) {
	my $package = shift;
	foreach my $file ("tmp/info/.packageinfo-$package", glob("tmp/info/.packageinfo-*_$package")) {
		next unless index($file, "tmp/info/.packageinfo-feeds_");
		return 1 if -s $file;
	}
	return 0;
}

358
359
360
361
362
363
364
365
sub install_package {
	my $feed = shift;
	my $name = shift;
	my $ret = 0;

	$feed = lookup_package($feed, $name);
	$feed or do {
		$installed{$name} and return 0;
366
		# TODO: check if it's already installed within ./package directory
367
		$feed_src->{$name} or is_core_package($name) or warn "WARNING: No feed for package '$name' found, maybe it's already part of the standard packages?\n";
368
		return 0;
369
370
	};

371
372
373
	# switch to the metadata for the selected feed
	get_feed($feed->[1]);

374
	my $pkg = $feed{$feed->[1]}->{$name} or return 1;
375
376
	$pkg->{name} or do {
		$installed{$name} and return 0;
377
		# TODO: check if this is an alias package, maybe it's known by another name
378
		warn "WARNING: Package '$name' is not available in feed $feed->[1].\n";
379
		return 0;
380
	};
381
382
383
384
385
	my $src = $pkg->{src};
	my $type = $feed->[0];
	$src or $src = $name;

	# previously installed packages set the runtime package
blogic's avatar
blogic committed
386
387
	# newly installed packages set the source package
	$installed{$src} and return 0;
388
389

	# check previously installed packages
blogic's avatar
blogic committed
390
	$installed{$name} and return 0;
391
	$installed{$src} = 1;
blogic's avatar
blogic committed
392
	warn "Installing package '$src'\n";
393
394
395
396
397
398
399
400
401
402
403

	$install_method{$type} or do {
		warn "Unknown installation method: '$type'\n";
		return 1;
	};

	&{$install_method{$type}}($feed, $pkg) == 0 or do {
		warn "failed.\n";
		return 1;
	};

404
405
	# install all dependencies referenced from the source package
	foreach my $vpkg (@{$feed_src->{$src}}) {
406
		foreach my $dep (@{$vpkg->{depends}}, @{$vpkg->{builddepends}}, @{$vpkg->{"builddepends/host"}}) {
407
408
			next if $dep =~ /@/;
			$dep =~ s/^\+//;
409
			$dep =~ s/^.+://;
410
			$dep =~ s/\/.+$//;
411
			next unless $dep;
412
413
			install_package($feed, $dep) == 0 or $ret = 1;
		}
414
415
	}

416
417
418
419
420
421
422
423
424
	return $ret;
}

sub refresh_config {
	my $default = shift;

	# workaround for timestamp check
	system("rm -f tmp/.packageinfo");

425
	# refresh the config
ralph's avatar
ralph committed
426
	if ($default) {
427
		system("$mk oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null");
ralph's avatar
ralph committed
428
	} else {
429
		system("$mk defconfig Config.in >/dev/null 2>/dev/null");
ralph's avatar
ralph committed
430
	}
431
432
433
434
435
436
437
}

sub install {
	my $name;
	my %opts;
	my $feed;
	my $ret = 0;
438

blogic's avatar
blogic committed
439
	getopts('ap:d:h', \%opts);
ralph's avatar
ralph committed
440
441
442
443
444
445

	if ($opts{h}) {
		usage();
		return 0;
	}

446
447
448
449
450
451
452
453
454
455
	get_installed();

	foreach my $f (@feeds) {
		# index all feeds
		$feed{$f->[1]} = get_feed($f->[1]);

		# look up the preferred feed
		$opts{p} and $f->[1] eq $opts{p} and $feed = $f;
	}

456
457
458
459
460
	if($opts{a}) {
		foreach my $f (@feeds) {
			if (!defined($opts{p}) or $opts{p} eq $f->[1]) {
				printf "Installing all packages from feed %s.\n", $f->[1];
				get_feed($f->[1]);
461
				foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) {
462
					my $p = $feed_package->{$name};
nbd's avatar
nbd committed
463
					next if $p->{vdepends};
464
					if( $p->{name} ) {
blogic's avatar
blogic committed
465
						install_package($feed, $p->{name}) == 0 or $ret = 1;
466
						get_feed($f->[1]);
467
468
469
470
471
472
					}
				}
			}
		}
	} else {
		while ($name = shift @ARGV) {
blogic's avatar
blogic committed
473
			install_package($feed, $name) == 0 or $ret = 1;
474
		}
475
476
477
	}

	# workaround for timestamp check
478

479
480
481
482
483
484
485
486
487
	# set the defaults
	if ($opts{d} and $opts{d} =~ /^[ymn]$/) {
		refresh_config($opts{d});
	}

	return $ret;
}

sub uninstall {
ralph's avatar
ralph committed
488
	my %opts;
489
490
491
	my $name;
	my $uninstall;

ralph's avatar
ralph committed
492
493
494
495
496
497
498
499
500
	getopts('ah', \%opts);

	if ($opts{h}) {
		usage();
		return 0;
	}

	if ($opts{a}) {
		system("rm -rvf ./package/feeds");
501
502
		$uninstall = 1;
	} else {
ralph's avatar
ralph committed
503
504
505
506
		if($#ARGV == -1) {
			warn "WARNING: no package to uninstall\n";
			return 0;
		}
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
		get_installed();
		while ($name = shift @ARGV) {
			my $pkg = $installed{$name};
			$pkg or do {
				warn "WARNING: $name not installed\n";
				next;
			};
			$pkg->{src} and $name = $pkg->{src};
			warn "Uninstalling package '$name'\n";
			system("rm -f ./package/feeds/*/$name");
			$uninstall = 1;
		}
	}
	$uninstall and refresh_config();
	return 0;
}

ralph's avatar
ralph committed
524
525
526
527
528
529
sub update_feed($$$$)
{
	my $type=shift;
	my $name=shift;
	my $src=shift;
	my $perform_update=shift;
530
	my $force_relocate=update_location( $name, "@$src" );
ralph's avatar
ralph committed
531

532
533
534
	if( $force_relocate ) {
		warn "Source of feed $name has changed, replacing copy\n";
	}
ralph's avatar
ralph committed
535
536
537
538
539
	$update_method{$type} or do {
		warn "Unknown type '$type' in feed $name\n";
		return 1;
	};
	$perform_update and do {
540
541
542
		my $failed = 1;
		foreach my $feedsrc (@$src) {
			warn "Updating feed '$name' from '$feedsrc' ...\n";
nbd's avatar
nbd committed
543
			next unless update_feed_via($type, $name, $feedsrc, $force_relocate) == 0;
544
545
546
547
			$failed = 0;
			last;
		}
		$failed and do {
ralph's avatar
ralph committed
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
			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} = $$;
nbd's avatar
nbd committed
566
	$ENV{OPENWRT_VERBOSE} = 's';
ralph's avatar
ralph committed
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587

	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;
588
589
			next unless update_feed($type, $name, $src, $perform_update) == 1;
			last;
ralph's avatar
ralph committed
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
		}
	} 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;
}

608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
sub feed_config() {
	foreach my $feed (@feeds) {
		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\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 "\n";
	}

	return 0;
}

624
625
626
627
628
sub usage() {
	print <<EOF;
Usage: $0 <command> [options]

Commands:
629
	list [options]: List feeds, their content and revisions (if installed)
ralph's avatar
ralph committed
630
	Options:
631
	    -n :            List of feed names.
632
633
634
	    -s :            List of feed names and their URL.
	    -r <feedname>:  List packages of specified feed.
	    -d <delimiter>: Use specified delimiter to distinguish rows (default: spaces)
ralph's avatar
ralph committed
635

636
637
	install [options] <package>: Install a package
	Options:
ralph's avatar
ralph committed
638
639
640
	    -a :           Install all packages from all feeds or from the specified feed using the -p option.
	    -p <feedname>: Prefer this feed when installing packages.
	    -d <y|m|n>:    Set default for newly installed packages.
641
642
643
644
645
646

	search [options] <substring>: Search for a package
	Options:
	    -r <feedname>: Only search in this feed

	uninstall -a|<package>: Uninstall a package
ralph's avatar
ralph committed
647
	Options:
ralph's avatar
ralph committed
648
649
	    -a :           Uninstalls all packages.

ralph's avatar
ralph committed
650
651
	update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf .
	Options:
mb's avatar
mb committed
652
	    -a :           Update all feeds listed within feeds.conf. Otherwise the specified feeds will be updated.
ralph's avatar
ralph committed
653
	    -i :           Recreate the index only. No feed update from repository is performed.
654

ralph's avatar
ralph committed
655
	clean:             Remove downloaded/generated files.
656
657
658
659
660
661

EOF
	exit(1);
}

my %commands = (
ralph's avatar
ralph committed
662
	'list' => \&list,
ralph's avatar
ralph committed
663
	'update' => \&update,
664
665
666
	'install' => \&install,
	'search' => \&search,
	'uninstall' => \&uninstall,
667
	'feed_config' => \&feed_config,
668
669
670
671
672
673
674
675
676
677
678
679
680
681
	'clean' => sub {
		system("rm -rf feeds");
	}
);

my $arg = shift @ARGV;
$arg or usage();
parse_config;
foreach my $cmd (keys %commands) {
	$arg eq $cmd and do {
		exit(&{$commands{$cmd}}());
	};
}
usage();