scripts/feeds: add support for installing targets
[openwrt/openwrt.git] / scripts / feeds
1 #!/usr/bin/perl
2 use Getopt::Std;
3 use FindBin;
4 use Cwd;
5 use lib "$FindBin::Bin";
6 use metadata;
7 use warnings;
8 use strict;
9 use Cwd 'abs_path';
10
11 chdir "$FindBin::Bin/..";
12 $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 chomp($mk); # trim trailing newline
18 $mk or $mk = "make"; # default to 'make'
19
20 # check version of make
21 my @mkver = split /\s+/, `$mk -v`, 4;
22 my $valid_mk = 1;
23 $mkver[0] =~ /^GNU/ or $valid_mk = 0;
24 $mkver[1] =~ /^Make/ or $valid_mk = 0;
25 $mkver[2] >= "3.81" or $valid_mk = 0;
26 $valid_mk or die "Unsupported version of make found: $mk\n";
27
28 my @feeds;
29 my %build_packages;
30 my %installed;
31 my %installed_targets;
32 my %feed_cache;
33
34 my $feed_package = {};
35 my $feed_src = {};
36 my $feed_target = {};
37
38 sub parse_config() {
39 my $line = 0;
40 my %name;
41
42 open FEEDS, "feeds.conf" or
43 open FEEDS, "feeds.conf.default" or
44 die "Unable to open feeds configuration";
45 while (<FEEDS>) {
46 chomp;
47 s/#.+$//;
48 next unless /\S/;
49 my @line = split /\s+/, $_, 3;
50 my @src;
51 $line++;
52
53 my $valid = 1;
54 $line[0] =~ /^src-\w+$/ or $valid = 0;
55 $line[1] =~ /^\w+$/ or $valid = 0;
56 @src = split /\s+/, $line[2];
57 $valid or die "Syntax error in feeds.conf, line: $line\n";
58
59 $name{$line[1]} and die "Duplicate feed name '$line[1]', line: $line\n";
60 $name{$line[1]} = 1;
61
62 push @feeds, [$line[0], $line[1], \@src];
63 }
64 close FEEDS;
65 }
66
67 sub update_location($$)
68 {
69 my $name = shift;
70 my $url = shift;
71 my $old_url;
72
73 -d "./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
74
75 if( open LOC, "< ./feeds/$name.tmp/location" )
76 {
77 chomp($old_url = readline LOC);
78 close LOC;
79 }
80
81 if( !$old_url || $old_url ne $url )
82 {
83 if( open LOC, "> ./feeds/$name.tmp/location" )
84 {
85 print LOC $url, "\n";
86 close LOC;
87 }
88 return $old_url ? 1 : 0;
89 }
90
91 return 0;
92 }
93
94 sub update_index($)
95 {
96 my $name = shift;
97
98 -d "./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
99 -d "./feeds/$name.tmp/info" or mkdir "./feeds/$name.tmp/info" or return 1;
100
101 system("$mk -s prepare-mk OPENWRT_BUILD= TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
102 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\"");
103 system("$mk -s -f include/scan.mk IS_TTY=1 SCAN_TARGET=\"targetinfo\" SCAN_DIR=\"feeds/$name\" SCAN_NAME=\"target\" SCAN_DEPS=\"profiles/*.mk $ENV{TOPDIR}/include/target.mk\" SCAN_DEPTH=5 SCAN_EXTRA=\"\" SCAN_MAKEOPTS=\"TARGET_BUILD=1\" TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
104 system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index");
105 system("ln -sf $name.tmp/.targetinfo ./feeds/$name.targetindex");
106
107 return 0;
108 }
109
110 my %update_method = (
111 'src-svn' => {
112 'init' => "svn checkout '%s' '%s'",
113 'update' => "svn update",
114 'controldir' => ".svn",
115 'revision' => "svn info | grep 'Revision' | cut -d ' ' -f 2 | tr -d '\n'"},
116 'src-cpy' => {
117 'init' => "cp -Rf '%s' '%s'",
118 'update' => "",
119 'revision' => "echo -n 'local'"},
120 'src-link' => {
121 'init' => "ln -s '%s' '%s'",
122 'update' => "",
123 'revision' => "echo -n 'local'"},
124 'src-git' => {
125 'init' => "git clone --depth 1 '%s' '%s'",
126 'init_branch' => "git clone --depth 1 --branch '%s' '%s' '%s'",
127 'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
128 'update' => "git pull --ff",
129 'controldir' => ".git",
130 'revision' => "git show --abbrev-commit HEAD | head -n 1 | cut -d ' ' -f 2 | tr -d '\n'"},
131 'src-gitsvn' => {
132 'init' => "git svn clone -r HEAD '%s' '%s'",
133 'update' => "git svn rebase",
134 'controldir' => ".git",
135 'revision' => "git show --abbrev-commit HEAD | head -n 1 | cut -d ' ' -f 2 | tr -d '\n'"},
136 'src-bzr' => {
137 'init' => "bzr checkout --lightweight '%s' '%s'",
138 'update' => "bzr update",
139 'controldir' => ".bzr"},
140 'src-hg' => {
141 'init' => "hg clone '%s' '%s'",
142 'update' => "hg pull --update",
143 'controldir' => ".hg"},
144 'src-darcs' => {
145 'init' => "darcs get '%s' '%s'",
146 'update' => "darcs pull -a",
147 'controldir' => "_darcs"},
148 );
149
150 # src-git: pull broken
151 # src-cpy: broken if `basename $src` != $name
152
153 sub update_feed_via($$$$) {
154 my $type = shift;
155 my $name = shift;
156 my $src = shift;
157 my $relocate = shift;
158
159 my $m = $update_method{$type};
160 my $localpath = "./feeds/$name";
161 my $safepath = $localpath;
162 $safepath =~ s/'/'\\''/;
163 my ($base_branch, $branch) = split(/;/, $src, 2);
164 my ($base_commit, $commit) = split(/\^/, $src, 2);
165
166 if( $relocate || !$m->{'update'} || !-d "$localpath/$m->{'controldir'}" ) {
167 system("rm -rf '$safepath'");
168 if ($m->{'init_branch'} and $branch) {
169 system(sprintf($m->{'init_branch'}, $branch, $base_branch, $safepath)) == 0 or return 1;
170 } elsif ($m->{'init_commit'} and $commit) {
171 system(sprintf($m->{'init_commit'}, $base_commit, $safepath, $safepath, $commit, $commit)) == 0 or return 1;
172 } else {
173 system(sprintf($m->{'init'}, $src, $safepath)) == 0 or return 1;
174 }
175 } elsif ($m->{'init_commit'} and $commit) {
176 # in case git hash has been provided don't update the feed
177 } else {
178 system("cd '$safepath'; $m->{'update'}") == 0 or return 1;
179 }
180
181 return 0;
182 }
183
184 sub get_targets($) {
185 my $file = shift;
186 my @target = parse_target_metadata($file);
187 my %target;
188 foreach my $target (@target) {
189 $target{$target->{id}} = $target;
190 }
191 return %target
192 }
193
194 sub get_feed($) {
195 my $feed = shift;
196
197 if (!defined($feed_cache{$feed})) {
198 my $file = "./feeds/$feed.index";
199
200 clear_packages();
201 -f $file or do {
202 print "Ignoring feed '$feed' - index missing\n";
203 return;
204 };
205 parse_package_metadata($file) or return;
206 my %target = get_targets("./feeds/$feed.targetindex");
207
208 $feed_cache{$feed} = [ { %package }, { %srcpackage }, { %target } ];
209 }
210
211 $feed_package = $feed_cache{$feed}->[0];
212 $feed_src = $feed_cache{$feed}->[1];
213 $feed_target = $feed_cache{$feed}->[2];
214 return $feed_cache{$feed}->[0];
215 }
216
217 sub get_installed() {
218 system("$mk -s prepare-tmpinfo OPENWRT_BUILD=");
219 clear_packages();
220 parse_package_metadata("./tmp/.packageinfo");
221 %installed = %package;
222 %installed_targets = get_targets("./tmp/.targetinfo");
223 }
224
225 sub search_feed {
226 my $feed = shift;
227 my @substr = @_;
228 my $display;
229
230 return unless @substr > 0;
231 get_feed($feed);
232 foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) {
233 my $pkg = $feed_package->{$name};
234 my $substr;
235 my $pkgmatch = 1;
236
237 next if $pkg->{vdepends};
238 foreach my $substr (@substr) {
239 my $match;
240 foreach my $key (qw(name title description src)) {
241 $pkg->{$key} and $substr and $pkg->{$key} =~ m/$substr/i and $match = 1;
242 }
243 $match or undef $pkgmatch;
244 };
245 $pkgmatch and do {
246 $display or do {
247 print "Search results in feed '$feed':\n";
248 $display = 1;
249 };
250 printf "\%-25s\t\%s\n", $pkg->{name}, $pkg->{title};
251 };
252 }
253
254 foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_target) {
255 my $target = $feed_target->{$name};
256 my $targetmatch = 1;
257
258 foreach my $substr (@substr) {
259 my $match;
260 foreach my $key (qw(id name description)) {
261 $target->{$key} and $substr and $target->{$key} =~ m/$substr/i and $match = 1;
262 }
263 $match or undef $targetmatch;
264 };
265 $targetmatch and do {
266 $display or do {
267 print "Search results in feed '$feed':\n";
268 $display = 1;
269 };
270 printf "TARGET: \%-17s\t\%s\n", $target->{id}, $target->{name};
271 };
272 }
273 return 0;
274 }
275
276 sub search {
277 my %opts;
278
279 getopt('r:', \%opts);
280 foreach my $feed (@feeds) {
281 search_feed($feed->[1], @ARGV) if (!defined($opts{r}) or $opts{r} eq $feed->[1]);
282 }
283 }
284
285 sub list_feed {
286 my $feed = shift;
287
288 get_feed($feed);
289 foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) {
290 my $pkg = $feed_package->{$name};
291 next if $pkg->{vdepends};
292 if($pkg->{name}) {
293 printf "\%-32s\t\%s\n", $pkg->{name}, $pkg->{title};
294 }
295 }
296
297 foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_target) {
298 my $target = $feed_target->{$name};
299 if($target->{name}) {
300 printf "TARGET: \%-24s\t\%s\n", $target->{id}, $target->{name};
301 }
302 }
303
304 return 0;
305 }
306
307 sub list {
308 my %opts;
309
310 getopts('r:d:nsh', \%opts);
311 if ($opts{h}) {
312 usage();
313 return 0;
314 }
315 if ($opts{n}) {
316 foreach my $feed (@feeds) {
317 printf "%s\n", $feed->[1];
318 }
319 return 0;
320 }
321 if ($opts{s}) {
322 foreach my $feed (@feeds) {
323 my $localpath = "./feeds/$feed->[1]";
324 my $m = $update_method{$feed->[0]};
325 my $revision;
326 if( !$m->{'revision'} ) {
327 $revision = "X";
328 }
329 elsif( $m->{'controldir'} && -d "$localpath/$m->{'controldir'}" ) {
330 $revision = `cd '$localpath'; $m->{'revision'}`;
331 }
332 else {
333 $revision = "local";
334 }
335 if ($opts{d}) {
336 printf "%s%s%s%s%s%s%s\n", $feed->[1], $opts{d}, $feed->[0], $opts{d}, $revision, $opts{d}, join(", ", @{$feed->[2]});
337 }
338 else {
339 printf "\%-8s \%-8s \%-8s \%s\n", $feed->[1], $feed->[0], $revision, join(", ", @{$feed->[2]});
340 }
341 }
342 return 0;
343 }
344 foreach my $feed (@feeds) {
345 list_feed($feed->[1], @ARGV) if (!defined($opts{r}) or $opts{r} eq $feed->[1]);
346 }
347 return 0;
348 }
349
350 sub do_install_package($$) {
351 my $feed = shift;
352 my $pkg = shift;
353 my $path = $pkg->{makefile};
354
355 if($path) {
356 $path =~ s/\/Makefile$//;
357
358 -d "./package/feeds" or mkdir "./package/feeds";
359 -d "./package/feeds/$feed->[1]" or mkdir "./package/feeds/$feed->[1]";
360 system("ln -sf ../../../$path ./package/feeds/$feed->[1]/");
361 } else {
362 warn "Package is not valid\n";
363 return 1;
364 }
365
366 return 0;
367 }
368
369 sub do_install_target($) {
370 my $target = shift;
371 my $path = $target->{makefile};
372
373 if ($path) {
374 $path =~ s/\/Makefile$//;
375 my $name = $path;
376 $name =~ s/.*\///;
377 my $dest = "./target/linux/$name";
378
379 -e $dest and do {
380 warn "Path $dest already exists";
381 return 1;
382 };
383
384 system("ln -sf ../../$path ./target/linux/");
385 } else {
386 warn "Package is not valid\n";
387 return 1;
388 }
389
390 return 0;
391 }
392
393 sub lookup_package($$) {
394 my $feed = shift;
395 my $package = shift;
396
397 foreach my $feed ($feed, @feeds) {
398 next unless $feed->[1];
399 next unless $feed_cache{$feed->[1]};
400 $feed_cache{$feed->[1]}->[0]->{$package} and return $feed;
401 }
402 return;
403 }
404
405 sub lookup_target($$) {
406 my $feed = shift;
407 my $target = shift;
408
409 foreach my $feed ($feed, @feeds) {
410 next unless $feed->[1];
411 next unless $feed_cache{$feed->[1]};
412 $feed_cache{$feed->[1]}->[2]->{$target} and return $feed;
413 }
414 return;
415 }
416
417 sub is_core_package($) {
418 my $package = shift;
419 foreach my $file ("tmp/info/.packageinfo-$package", glob("tmp/info/.packageinfo-*_$package")) {
420 next unless index($file, "tmp/info/.packageinfo-feeds_");
421 return 1 if -s $file;
422 }
423 return 0;
424 }
425
426 sub install_target {
427 my $feed = shift;
428 my $name = shift;
429
430 $feed = $feed_cache{$feed->[1]}->[2];
431 $feed or return 0;
432
433 my $target = $feed->{$name};
434 $target or return 0;
435
436 warn "Installing target '$name'\n";
437 return do_install_target($target);
438 }
439
440 sub install_package {
441 my $feed = shift;
442 my $name = shift;
443 my $force = shift;
444 my $ret = 0;
445
446 $feed = lookup_target($feed, $name);
447 $feed and do {
448 $installed_targets{$name} and return 0;
449 install_target($feed, $name);
450 return 0;
451 };
452
453 $feed = lookup_package($feed, $name);
454 $feed or do {
455 $installed{$name} and return 0;
456 # TODO: check if it's already installed within ./package directory
457 $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";
458 return 0;
459 };
460
461 # switch to the metadata for the selected feed
462 my $cur = get_feed($feed->[1]);
463
464 my $pkg = $cur->{$name} or return 1;
465 $pkg->{name} or do {
466 $installed{$name} and return 0;
467 # TODO: check if this is an alias package, maybe it's known by another name
468 warn "WARNING: Package '$name' is not available in feed $feed->[1].\n";
469 return 0;
470 };
471 my $src = $pkg->{src};
472 my $type = $feed->[0];
473 $src or $src = $name;
474
475 # If it's a core package and we don't want to override, just return
476 !$force and is_core_package($src) and return 0;
477
478 # previously installed packages set the runtime package
479 # newly installed packages set the source package to 1
480 $installed{$src} and $installed{$src} == 1 and return 0;
481
482 # we'll trigger the override only with the 3 conditions below:
483 # - override is allowed by command line (-f)
484 # - a package with the same src exists in the core packages list
485 # - the package previously installed is not from a feed
486 my $override = 1 if ($force and is_core_package($src) and !$installed{$name}->{feed});
487
488 # check previously installed packages
489 $installed{$name} and !$override and return 0;
490 $installed{$src} = 1;
491
492 defined($override) and $override == 1
493 and warn "Overriding package '$src'\n"
494 or warn "Installing package '$src'\n";
495
496 do_install_package($feed, $pkg) == 0 or do {
497 warn "failed.\n";
498 return 1;
499 };
500
501 # install all dependencies referenced from the source package
502 foreach my $vpkg (@{$feed_src->{$src}}) {
503 foreach my $dep (@{$vpkg->{depends}}, @{$vpkg->{builddepends}}, @{$vpkg->{"builddepends/host"}}) {
504 next if $dep =~ /@/;
505 $dep =~ s/^\+//;
506 $dep =~ s/^.+://;
507 $dep =~ s/\/.+$//;
508 next unless $dep;
509 install_package($feed, $dep, 0) == 0 or $ret = 1;
510 }
511 }
512
513 return $ret;
514 }
515
516 sub refresh_config {
517 my $default = shift;
518
519 # workaround for timestamp check
520 system("rm -f tmp/.packageinfo");
521
522 # refresh the config
523 if ($default) {
524 system("$mk oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null");
525 } else {
526 system("$mk defconfig Config.in >/dev/null 2>/dev/null");
527 }
528 }
529
530 sub install {
531 my $name;
532 my %opts;
533 my $feed;
534 my $ret = 0;
535
536 getopts('ap:d:fh', \%opts);
537
538 if ($opts{h}) {
539 usage();
540 return 0;
541 }
542
543 get_installed();
544
545 foreach my $f (@feeds) {
546 # fetch all feeds
547 get_feed($f->[1]);
548
549 # look up the preferred feed
550 $opts{p} and $f->[1] eq $opts{p} and $feed = $f;
551 }
552
553 if($opts{a}) {
554 foreach my $f (@feeds) {
555 if (!defined($opts{p}) or $opts{p} eq $f->[1]) {
556 printf "Installing all packages from feed %s.\n", $f->[1];
557 get_feed($f->[1]);
558 foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) {
559 my $p = $feed_package->{$name};
560 next if $p->{vdepends};
561 if( $p->{name} ) {
562 install_package($feed, $p->{name}, exists($opts{f})) == 0 or $ret = 1;
563 get_feed($f->[1]);
564 }
565 }
566 }
567 }
568 } else {
569 while ($name = shift @ARGV) {
570 install_package($feed, $name, exists($opts{f})) == 0 or $ret = 1;
571 }
572 }
573
574 # workaround for timestamp check
575
576 # set the defaults
577 if ($opts{d} and $opts{d} =~ /^[ymn]$/) {
578 refresh_config($opts{d});
579 }
580
581 return $ret;
582 }
583
584 sub uninstall {
585 my %opts;
586 my $name;
587 my $uninstall;
588
589 getopts('ah', \%opts);
590
591 if ($opts{h}) {
592 usage();
593 return 0;
594 }
595
596 if ($opts{a}) {
597 system("rm -rvf ./package/feeds");
598 $uninstall = 1;
599 } else {
600 if($#ARGV == -1) {
601 warn "WARNING: no package to uninstall\n";
602 return 0;
603 }
604 get_installed();
605 while ($name = shift @ARGV) {
606 my $pkg = $installed{$name};
607 $pkg or do {
608 warn "WARNING: $name not installed\n";
609 next;
610 };
611 $pkg->{src} and $name = $pkg->{src};
612 warn "Uninstalling package '$name'\n";
613 system("rm -f ./package/feeds/*/$name");
614 $uninstall = 1;
615 }
616 }
617 $uninstall and refresh_config();
618 return 0;
619 }
620
621 sub update_feed($$$$)
622 {
623 my $type=shift;
624 my $name=shift;
625 my $src=shift;
626 my $perform_update=shift;
627 my $force_relocate=update_location( $name, "@$src" );
628
629 if( $force_relocate ) {
630 warn "Source of feed $name has changed, replacing copy\n";
631 }
632 $update_method{$type} or do {
633 warn "Unknown type '$type' in feed $name\n";
634 return 1;
635 };
636 $perform_update and do {
637 my $failed = 1;
638 foreach my $feedsrc (@$src) {
639 warn "Updating feed '$name' from '$feedsrc' ...\n";
640 next unless update_feed_via($type, $name, $feedsrc, $force_relocate) == 0;
641 $failed = 0;
642 last;
643 }
644 $failed and do {
645 warn "failed.\n";
646 return 1;
647 };
648 };
649 warn "Create index file './feeds/$name.index' \n";
650 update_index($name) == 0 or do {
651 warn "failed.\n";
652 return 1;
653 };
654 return 0;
655 }
656
657 sub update {
658 my %opts;
659 my $feed_name;
660 my $perform_update=1;
661
662 $ENV{SCAN_COOKIE} = $$;
663 $ENV{OPENWRT_VERBOSE} = 's';
664
665 getopts('ahi', \%opts);
666
667 if ($opts{h}) {
668 usage();
669 return 0;
670 }
671
672 if ($opts{i}) {
673 # don't update from (remote) repository
674 # only re-create index information
675 $perform_update=0;
676 }
677
678 -d "feeds" or do {
679 mkdir "feeds" or die "Unable to create the feeds directory";
680 };
681
682 if ( ($#ARGV == -1) or $opts{a}) {
683 foreach my $feed (@feeds) {
684 my ($type, $name, $src) = @$feed;
685 next unless update_feed($type, $name, $src, $perform_update) == 1;
686 last;
687 }
688 } else {
689 while ($feed_name = shift @ARGV) {
690 foreach my $feed (@feeds) {
691 my ($type, $name, $src) = @$feed;
692 if($feed_name ne $name) {
693 next;
694 }
695 update_feed($type, $name, $src, $perform_update);
696 }
697 }
698 }
699
700 refresh_config();
701
702 return 0;
703 }
704
705 sub feed_config() {
706 foreach my $feed (@feeds) {
707 my $installed = (-f "feeds/$feed->[1].index");
708
709 printf "\tconfig FEED_%s\n", $feed->[1];
710 printf "\t\tbool \"Enable feed %s\"\n", $feed->[1];
711 printf "\t\tdepends on PER_FEED_REPO\n";
712 printf "\t\tdefault y\n" if $installed;
713 printf "\t\thelp\n";
714 printf "\t\t Enable the \\\"%s\\\" feed at %s.\n", $feed->[1], $feed->[2][0];
715 printf "\n";
716 }
717
718 return 0;
719 }
720
721 sub usage() {
722 print <<EOF;
723 Usage: $0 <command> [options]
724
725 Commands:
726 list [options]: List feeds, their content and revisions (if installed)
727 Options:
728 -n : List of feed names.
729 -s : List of feed names and their URL.
730 -r <feedname>: List packages of specified feed.
731 -d <delimiter>: Use specified delimiter to distinguish rows (default: spaces)
732
733 install [options] <package>: Install a package
734 Options:
735 -a : Install all packages from all feeds or from the specified feed using the -p option.
736 -p <feedname>: Prefer this feed when installing packages.
737 -d <y|m|n>: Set default for newly installed packages.
738 -f : Install will be forced even if the package exists in core OpenWrt (override)
739
740 search [options] <substring>: Search for a package
741 Options:
742 -r <feedname>: Only search in this feed
743
744 uninstall -a|<package>: Uninstall a package
745 Options:
746 -a : Uninstalls all packages.
747
748 update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf .
749 Options:
750 -a : Update all feeds listed within feeds.conf. Otherwise the specified feeds will be updated.
751 -i : Recreate the index only. No feed update from repository is performed.
752
753 clean: Remove downloaded/generated files.
754
755 EOF
756 exit(1);
757 }
758
759 my %commands = (
760 'list' => \&list,
761 'update' => \&update,
762 'install' => \&install,
763 'search' => \&search,
764 'uninstall' => \&uninstall,
765 'feed_config' => \&feed_config,
766 'clean' => sub {
767 system("rm -rf feeds");
768 }
769 );
770
771 my $arg = shift @ARGV;
772 $arg or usage();
773 parse_config;
774 foreach my $cmd (keys %commands) {
775 $arg eq $cmd and do {
776 exit(&{$commands{$cmd}}());
777 };
778 }
779 usage();