diff options
author | EuAndreh <eu@euandre.org> | 2023-03-24 15:47:47 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2023-03-24 16:01:26 -0300 |
commit | 785aa336c75ab757b0caa9d3d27925ad3e2823da (patch) | |
tree | 9bffe49e5ce0154497995b4fe2a59ccfd9cd9b8b | |
parent | src/bin/paku.in: Emit Makefile for generating $NAME.key for Guix channel (diff) | |
download | package-repository-785aa336c75ab757b0caa9d3d27925ad3e2823da.tar.gz package-repository-785aa336c75ab757b0caa9d3d27925ad3e2823da.tar.xz |
src/bin/paku.in: Move "datadir" to paku.lock
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | paku.lock | 1 | ||||
-rwxr-xr-x | src/bin/paku.in | 47 |
3 files changed, 42 insertions, 12 deletions
@@ -98,9 +98,11 @@ public: public/debian public/paku.html upload: public rsync -avzP --delete public/ euandre.org:/srv/www/s/package-repository/ -clean: + +clean: src/bin/paku + rm -rf "`paku -C datadir`" rm -rf \ - $(derived-assets) result* *.mk .paku/ public/ \ + $(derived-assets) result* *.mk public/ local-files = \ @@ -1,4 +1,5 @@ { + "datadir": ".paku", "guix": { "module-use": [ "guile", diff --git a/src/bin/paku.in b/src/bin/paku.in index 4d92d9b..79cf703 100755 --- a/src/bin/paku.in +++ b/src/bin/paku.in @@ -4,6 +4,7 @@ use v5.34; use warnings; use feature 'signatures'; no warnings ('experimental::signatures'); +use Scalar::Util qw(looks_like_number); use Getopt::Std (); use JSON (); use File::Basename (); @@ -13,7 +14,8 @@ use Digest::SHA (); sub usage($fh) { print $fh <<~'EOF' Usage: - paku [-d DIR] [-f FILE] ACTION + paku [-f FILE] ACTION + paku [-f FILE] -C CONFIG_PATH paku -h EOF } @@ -23,8 +25,8 @@ sub help($fh) { Options: - -d DIR use DIR for intermediary data (default: .paku/) -f FILE use data from FILE (default: paku.lock) + -C CONFIG get the final value of CONFIG_PATH -h, --help show this message ACTION what to emit, one of: @@ -46,11 +48,15 @@ sub help($fh) { $ guix build -f packages.scm - Emit Debian build recipes from "debian.json", using - ".debtmp/" as the temporary directory, and execute them - as is: + Emit Debian build recipes from "debian.json", and execute + them as is: - $ paku -d .debtemp/ -f debian.json debian | make -f- + $ paku -f debian.json debian | make -f- + + + Find out what is the final value of "datadir": + + $ paku -C 'datadir' EOF } @@ -65,7 +71,7 @@ for (@ARGV) { } my %opts; -if (!Getopt::Std::getopts('d:f:h', \%opts)) { +if (!Getopt::Std::getopts('f:C:h', \%opts)) { usage *STDERR; exit 2; } @@ -77,11 +83,8 @@ if ($opts{h}) { } -my $dir = $opts{d} || '.paku'; my $fname = $opts{f} || 'paku.lock'; -my $action = $ARGV[0] or die "Missing ACTION"; -shift; sub load_json() { my $json_str = do { @@ -92,6 +95,27 @@ sub load_json() { return JSON::decode_json($json_str); } + + +sub get_in($j, @l) { + my ($head, @tail) = @l; + if (!defined $head) { + return ref $j ? + JSON::encode_json $j : + $j; + } elsif (looks_like_number($head)) { + return get_in($j->[$head], @tail); + } else { + return get_in($j->{$head}, @tail); + } +} + +if ($opts{C}) { + say get_in(load_json(), split(/\./, $opts{C})); + exit; +} + + my $licenses = { guix => { 'AGPL-3.0-or-later' => 'agpl3+', @@ -358,6 +382,7 @@ sub emit_guix_channel_key() { sub emit_debian() { my $json = load_json(); + my $dir = $json->{datadir}; my @debs = ("debs = \\\n"); my @targets = (); @@ -760,5 +785,7 @@ my %actions = ( html => \&emit_html, ); +my $action = $ARGV[0] or die "Missing ACTION"; +shift; my $fn = $actions{$action} or die "Unknown ACTION: \"$action\""; &$fn; |