From 6ac20cd3f258cdd235eb2f07c6e8170e6d57683e Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Thu, 23 Mar 2023 09:26:59 -0300 Subject: src/bin/paku.in: Enable license mapping to be extended or overriden from paku.lock --- paku.lock | 8 +++++--- src/bin/paku.in | 16 +++++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/paku.lock b/paku.lock index 73a8e32..82231fd 100644 --- a/paku.lock +++ b/paku.lock @@ -7,9 +7,11 @@ }, "mappings": { "guix": { - "guile": [ - "guile-3.0" - ] + "packages": { + "guile": [ + "guile-3.0" + ] + } } }, "namespace": "org.euandre", diff --git a/src/bin/paku.in b/src/bin/paku.in index a19b3e5..d1d7939 100755 --- a/src/bin/paku.in +++ b/src/bin/paku.in @@ -99,8 +99,8 @@ my $licenses = { 'AGPL-3.0-or-later' => 'agpl3Plus', }, }; -sub license_for($target, $id) { - return $licenses->{$target}->{$id}; +sub license_for($target, $mappings, $id) { + return $mappings->{$id} || $licenses->{$target}->{$id} || $id; } sub inputs_for($mappings, @inputs) { @@ -195,10 +195,11 @@ sub emit_nix() { self: super: { $ns = rec { EOF + my $license_mapping = $json->{mappings}{nix}{licenses}; for my $pkg (@{$json->{packages}}) { my $long = $pkg->{'long-description'}; $long =~ s/^(.)/ $1/gm; - my $license = license_for 'nix', $pkg->{license}; + my $license = license_for 'nix', $license_mapping, $pkg->{license}; my $suffix = $pkg->{label} eq 'latest' ? '' : "-$pkg->{label}"; print <<~EOF; @@ -279,13 +280,14 @@ sub emit_guix() { EOF - my $mappings = $json->{mappings}{guix}; + my $pkg_mapping = $json->{mappings}{guix}{packages}; + my $license_mapping = $json->{mappings}{guix}{licenses}; my @pkgs = (); for my $pkg (@{$json->{packages}}) { my $long = $pkg->{'long-description'}; $long =~ s/^(.)/ $1/gm; my $ver = $pkg->{version} =~ s/^v//r; - my $license = license_for 'guix', $pkg->{license}; + my $license = license_for 'guix', $license_mapping, $pkg->{license}; my $name = $pkg->{name} . ( $pkg->{label} eq 'latest' ? '' : "-$pkg->{label}" @@ -307,14 +309,14 @@ sub emit_guix() { EOF print ' (list'; - for (inputs_for $mappings, @{$pkg->{'native-inputs'}}) { + for (inputs_for $pkg_mapping, @{$pkg->{'native-inputs'}}) { print "\n $_"; } print "))\n"; print " (inputs\n"; print ' (list'; - for (inputs_for $mappings, @{$pkg->{inputs}}) { + for (inputs_for $pkg_mapping, @{$pkg->{inputs}}) { print "\n $_"; } print "))\n"; -- cgit v1.2.3