From d4a585d02efb587e822d9ec4a9846098b6717ec9 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Thu, 23 Mar 2023 09:19:13 -0300 Subject: src/bin/paku.in: Allow dependency mapping to change in number --- paku.lock | 6 ++++-- src/bin/paku.in | 23 +++++++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/paku.lock b/paku.lock index 75537b2..73a8e32 100644 --- a/paku.lock +++ b/paku.lock @@ -6,8 +6,10 @@ ] }, "mappings": { - "guile": { - "guix": "guile-3.0" + "guix": { + "guile": [ + "guile-3.0" + ] } }, "namespace": "org.euandre", diff --git a/src/bin/paku.in b/src/bin/paku.in index a93ea82..a19b3e5 100755 --- a/src/bin/paku.in +++ b/src/bin/paku.in @@ -103,6 +103,18 @@ sub license_for($target, $id) { return $licenses->{$target}->{$id}; } +sub inputs_for($mappings, @inputs) { + my @out = (); + for (@inputs) { + if (!$mappings->{$_}) { + push @out, $_; + } else { + push @out, @{$mappings->{$_}}; + } + } + return @out; +} + sub emit_packages() { for (@ARGV) { my $fh; @@ -267,6 +279,7 @@ sub emit_guix() { EOF + my $mappings = $json->{mappings}{guix}; my @pkgs = (); for my $pkg (@{$json->{packages}}) { my $long = $pkg->{'long-description'}; @@ -294,17 +307,15 @@ sub emit_guix() { EOF print ' (list'; - for my $input (@{$pkg->{'native-inputs'}}) { - my $name = $json->{mappings}{$input}{guix} || $input; - print "\n $name"; + for (inputs_for $mappings, @{$pkg->{'native-inputs'}}) { + print "\n $_"; } print "))\n"; print " (inputs\n"; print ' (list'; - for my $input (@{$pkg->{inputs}}) { - my $name = $json->{mappings}{$input}{guix} || $input; - print "\n $name"; + for (inputs_for $mappings, @{$pkg->{inputs}}) { + print "\n $_"; } print "))\n"; -- cgit v1.2.3