aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--paku.lock1
-rwxr-xr-xsrc/bin/paku.in47
3 files changed, 42 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index e63f1bd..1063f9d 100644
--- a/Makefile
+++ b/Makefile
@@ -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 = \
diff --git a/paku.lock b/paku.lock
index 0843699..46afc78 100644
--- a/paku.lock
+++ b/paku.lock
@@ -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;