aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorPaul Spooren <mail@aparcar.org>2021-09-17 12:00:40 -1000
committerPaul Spooren <mail@aparcar.org>2021-09-23 21:57:22 -1000
commit3128dfc18a5eaff145d17b8a3fe1131d10922384 (patch)
treef6f7d789819c120b9ee5dc316a6f5e1c6a45ee81 /scripts
parentb34aa6aff71374d5e4eb7ea2dda11cf6305d512b (diff)
downloadupstream-3128dfc18a5eaff145d17b8a3fe1131d10922384.tar.gz
upstream-3128dfc18a5eaff145d17b8a3fe1131d10922384.tar.bz2
upstream-3128dfc18a5eaff145d17b8a3fe1131d10922384.zip
scripts: package-metadata add pkgmanifestjson call
The new `pkgmanifestjson` call prints all package manifest of a feed in JSON format. This function can be used to print an overview of packages information used for downstream tooling. The script is entirely based on Petrs work on dependency visualisation. Signed-off-by: Paul Spooren <mail@aparcar.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/package-metadata.pl36
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/package-metadata.pl b/scripts/package-metadata.pl
index 02102be8f3..6288584d65 100755
--- a/scripts/package-metadata.pl
+++ b/scripts/package-metadata.pl
@@ -585,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;
@@ -594,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();
@@ -606,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