return 0;
}
-sub install_generic() {
+sub do_install_package($$) {
my $feed = shift;
my $pkg = shift;
my $path = $pkg->{makefile};
return 0;
}
-my %install_method = (
- 'src-svn' => \&install_generic,
- 'src-cpy' => \&install_generic,
- 'src-link' => \&install_generic,
- 'src-git' => \&install_generic,
- 'src-gitsvn' => \&install_generic,
- 'src-bzr' => \&install_generic,
- 'src-hg' => \&install_generic,
- 'src-darcs' => \&install_generic,
-);
+sub do_install_target($) {
+ my $target = shift;
+ my $path = $target->{makefile};
+
+ if ($path) {
+ $path =~ s/\/Makefile$//;
+ my $name = $path;
+ $name =~ s/.*\///;
+ my $dest = "./target/linux/$name";
-my %feed;
+ -e $dest and do {
+ warn "Path $dest already exists";
+ return 1;
+ };
+
+ system("ln -sf ../../$path ./target/linux/");
+ } else {
+ warn "Package is not valid\n";
+ return 1;
+ }
+
+ return 0;
+}
sub lookup_package($$) {
my $feed = shift;
foreach my $feed ($feed, @feeds) {
next unless $feed->[1];
- next unless $feed{$feed->[1]};
- $feed{$feed->[1]}->{$package} and return $feed;
+ next unless $feed_cache{$feed->[1]};
+ $feed_cache{$feed->[1]}->[0]->{$package} and return $feed;
+ }
+ return;
+}
+
+sub lookup_target($$) {
+ my $feed = shift;
+ my $target = shift;
+
+ foreach my $feed ($feed, @feeds) {
+ next unless $feed->[1];
+ next unless $feed_cache{$feed->[1]};
+ $feed_cache{$feed->[1]}->[2]->{$target} and return $feed;
}
return;
}
return 0;
}
+sub install_target {
+ my $feed = shift;
+ my $name = shift;
+
+ $feed = $feed_cache{$feed->[1]}->[2];
+ $feed or return 0;
+
+ my $target = $feed->{$name};
+ $target or return 0;
+
+ warn "Installing target '$name'\n";
+ return do_install_target($target);
+}
+
sub install_package {
my $feed = shift;
my $name = shift;
my $force = shift;
my $ret = 0;
+ $feed = lookup_target($feed, $name);
+ $feed and do {
+ $installed_targets{$name} and return 0;
+ install_target($feed, $name);
+ return 0;
+ };
+
$feed = lookup_package($feed, $name);
$feed or do {
$installed{$name} and return 0;
};
# switch to the metadata for the selected feed
- get_feed($feed->[1]);
+ my $cur = get_feed($feed->[1]);
- my $pkg = $feed{$feed->[1]}->{$name} or return 1;
+ my $pkg = $cur->{$name} or return 1;
$pkg->{name} or do {
$installed{$name} and return 0;
# TODO: check if this is an alias package, maybe it's known by another name
and warn "Overriding package '$src'\n"
or warn "Installing package '$src'\n";
- $install_method{$type} or do {
- warn "Unknown installation method: '$type'\n";
- return 1;
- };
-
- &{$install_method{$type}}($feed, $pkg) == 0 or do {
+ do_install_package($feed, $pkg) == 0 or do {
warn "failed.\n";
return 1;
};
get_installed();
foreach my $f (@feeds) {
- # index all feeds
- $feed{$f->[1]} = get_feed($f->[1]);
+ # fetch all feeds
+ get_feed($f->[1]);
# look up the preferred feed
$opts{p} and $f->[1] eq $opts{p} and $feed = $f;