scripts/download.pl: fix downloads with wget
[openwrt/staging/stintel.git] / scripts / package-metadata.pl
index 5abc1bdef3f70e1c4cbe3f97ecfd6ea925ad88ed..6288584d65f58890bcdfa3f5d359c42672712ee6 100755 (executable)
@@ -532,21 +532,6 @@ sub gen_package_auxiliary() {
                if ($pkg->{name} && $pkg->{repository}) {
                        print "Package/$name/subdir = $pkg->{repository}\n";
                }
-               if ($pkg->{name} && defined($pkg->{abiversion}) && length($pkg->{abiversion})) {
-                       my $abiv;
-
-                       if ($pkg->{abiversion} =~ m!^(\d{4})-(\d{2})-(\d{2})-[0-9a-f]{7,40}$!) {
-                               print STDERR "WARNING: Reducing ABI version '$pkg->{abiversion}' of package '$name' to '$1$2$3'\n";
-                               $abiv = "$1$2$3";
-                       }
-                       else {
-                               $abiv = $pkg->{abiversion};
-                       }
-
-                       foreach my $n (@{$pkg->{provides}}) {
-                               print "Package/$n/abiversion = $abiv\n";
-                       }
-               }
                my %depends;
                foreach my $dep (@{$pkg->{depends} || []}) {
                        if ($dep =~ m!^\+?(?:[^:]+:)?([^@]+)$!) {
@@ -600,6 +585,40 @@ sub gen_usergroup_list() {
        }
 }
 
+sub gen_package_manifest_json() {
+       my $json;
+       parse_package_metadata($ARGV[0]) or exit 1;
+       foreach my $name (sort {uc($a) cmp uc($b)} keys %package) {
+               my %depends;
+               my $pkg = $package{$name};
+               foreach my $dep (@{$pkg->{depends} || []}) {
+                       if ($dep =~ m!^\+?(?:[^:]+:)?([^@]+)$!) {
+                               $depends{$1}++;
+                       }
+               }
+               my @depends = sort keys %depends;
+               my $pkg_deps = join ' ', map { qq/"$_",/ } @depends;
+               $pkg_deps =~ s/\,$//;
+
+               my $pkg_maintainer = join ' ', map { qq/"$_",/ } @{$pkg->{maintainer} || []};
+               $pkg_maintainer =~ s/\,$//;
+
+               $json = <<"END_JSON";
+${json}{
+"name":"$name",
+"version":"$pkg->{version}",
+"category":"$pkg->{category}",
+"license":"$pkg->{license}",
+"maintainer": [$pkg_maintainer],
+"depends":[$pkg_deps]},
+END_JSON
+       }
+
+       $json =~ s/[\n\r]//g;
+       $json =~ s/\,$//;
+       print "[$json]";
+}
+
 sub parse_command() {
        GetOptions("ignore=s", \@ignore);
        my $cmd = shift @ARGV;
@@ -609,6 +628,7 @@ sub parse_command() {
                /^kconfig/ and return gen_kconfig_overrides();
                /^source$/ and return gen_package_source();
                /^pkgaux$/ and return gen_package_auxiliary();
+               /^pkgmanifestjson$/ and return gen_package_manifest_json();
                /^license$/ and return gen_package_license(0);
                /^licensefull$/ and return gen_package_license(1);
                /^usergroup$/ and return gen_usergroup_list();
@@ -621,6 +641,7 @@ Available Commands:
        $0 kconfig [file] [config] [patchver]   Kernel config overrides
        $0 source [file]                        Package source file information
        $0 pkgaux [file]                        Package auxiliary variables in makefile format
+       $0 pkgmanifestjson [file]               Package manifests in JSON format
        $0 license [file]                       Package license information
        $0 licensefull [file]                   Package license information (full list)
        $0 usergroup [file]                     Package usergroup allocation list