metadata: remove redundant fields from package hash
[openwrt/openwrt.git] / scripts / feeds
index 3016eac92d087b0f6b30e56dfde152427b812832..4595c824a4b7c4836fdb1b67472dc476101e3d45 100755 (executable)
@@ -9,7 +9,8 @@ use strict;
 use Cwd 'abs_path';
 
 chdir "$FindBin::Bin/..";
-$ENV{TOPDIR}=getcwd();
+$ENV{TOPDIR} //= getcwd();
+chdir $ENV{TOPDIR};
 $ENV{GIT_CONFIG_PARAMETERS}="'core.autocrlf=false'";
 $ENV{GREP_OPTIONS}="";
 
@@ -372,10 +373,14 @@ sub list {
        return 0;
 }
 
+# TODO: do_install_package etc. should deal with source packages rather
+# than binary packages
 sub do_install_package($$) {
        my $feed = shift;
        my $pkg = shift;
-       my $path = $pkg->{makefile};
+
+       my $path;
+       $pkg->{src} and $path = $pkg->{src}{makefile};
 
        if($path) {
                $path =~ s/\/Makefile$//;
@@ -493,7 +498,7 @@ sub install_package {
                warn "WARNING: Package '$name' is not available in feed $feed->[1].\n";
                return 0;
        };
-       my $src = $pkg->{src};
+       my $src = $pkg->{src}{name};
        my $type = $feed->[0];
        $src or $src = $name;
 
@@ -524,15 +529,17 @@ sub install_package {
        };
 
        # install all dependencies referenced from the source package
-       foreach my $vpkg (@{$feed_src->{$src}}) {
-               foreach my $dep (@{$vpkg->{depends}}, @{$vpkg->{builddepends}}, @{$vpkg->{"builddepends/host"}}) {
-                       next if $dep =~ /@/;
-                       $dep =~ s/^\+//;
-                       $dep =~ s/^.+://;
-                       $dep =~ s/\/.+$//;
-                       next unless $dep;
-                       install_package($feed, $dep, 0) == 0 or $ret = 1;
-               }
+       foreach my $dep (
+               @{$feed_src->{$src}{builddepends}},
+               @{$feed_src->{$src}{"builddepends/host"}},
+               map { @{$_->{depends}} } @{$feed_src->{$src}{packages}}
+       ) {
+               next if $dep =~ /@/;
+               $dep =~ s/^\+//;
+               $dep =~ s/^.+://;
+               $dep =~ s/\/.+$//;
+               next unless $dep;
+               install_package($feed, $dep, 0) == 0 or $ret = 1;
        }
 
        return $ret;
@@ -660,7 +667,7 @@ sub uninstall {
                                warn "WARNING: $name not installed\n";
                                next;
                        };
-                       $pkg->{src} and $name = $pkg->{src};
+                       $pkg->{src} and $name = $pkg->{src}{name};
                        warn "Uninstalling package '$name'\n";
                        system("rm -f ./package/feeds/*/$name");
                        $uninstall = 1;