aboutsummaryrefslogtreecommitdiff
path: root/src/bin/paku
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-03-21 16:15:56 -0300
committerEuAndreh <eu@euandre.org>2023-03-21 16:16:49 -0300
commit18a81df9d5a61bc19f3975c994bc134f0cbd9a82 (patch)
tree2ddc021d5011b4faffc73b5fac7bf03cdce42d80 /src/bin/paku
parentsrc/bin/paku: First-ish version of HTML output (diff)
downloadpackage-repository-18a81df9d5a61bc19f3975c994bc134f0cbd9a82.tar.gz
package-repository-18a81df9d5a61bc19f3975c994bc134f0cbd9a82.tar.xz
src/bin/paku: Use "label" field from paku.lock
Diffstat (limited to 'src/bin/paku')
-rwxr-xr-xsrc/bin/paku45
1 files changed, 12 insertions, 33 deletions
diff --git a/src/bin/paku b/src/bin/paku
index 6ba6d04..cbc8df0 100755
--- a/src/bin/paku
+++ b/src/bin/paku
@@ -87,19 +87,6 @@ my $json_str = do {
my $json = JSON::decode_json($json_str);
my $action = $ARGV[0] or die "Missing ACTION";
-
-sub pretty_version($pkg) {
- if ($pkg->{type} eq 'latest') {
- return ('latest', '');
- } else {
- my $ver = $pkg->{version};
- $ver =~ s/^v//;
- $ver =~ s/\./-/g;
- return ($ver, "-$ver");
- }
-}
-
-
sub emit_release() {
my $f = $ARGV[1];
my $name = File::Basename::basename $f;
@@ -149,11 +136,7 @@ sub emit_nix() {
$ns = rec {
EOF
for my $pkg (@{$json->{packages}}) {
- my $ver = $pkg->{version};
- $ver =~ s/^v//;
- $ver =~ s/\./-/g;
- if ($pkg->{type} eq 'latest') {
- $ver = 'latest';
+ if ($pkg->{label} eq 'latest') {
print <<~EOF;
$pkg->{name} = $pkg->{name}-latest;
EOF
@@ -163,7 +146,7 @@ sub emit_nix() {
$long =~ s/^(.)/ $1/gm;
print <<~EOF;
- $pkg->{name}-$ver = pkgs.stdenv.mkDerivation rec {
+ $pkg->{name}-$pkg->{label} = pkgs.stdenv.mkDerivation rec {
name = "$pkg->{name}";
version = "$pkg->{version}";
@@ -241,22 +224,18 @@ sub emit_guix() {
my @pkgs = ();
for my $pkg (@{$json->{packages}}) {
- my $ver = $pkg->{version};
- $ver =~ s/^v//;
- $ver =~ s/\./-/g;
- if ($pkg->{type} eq 'latest') {
+ if ($pkg->{label} eq 'latest') {
push @pkgs, "$pkg->{name}";
- $ver = 'latest';
}
my $long = $pkg->{'long-description'};
$long =~ s/^(.)/ $1/gm;
- push @pkgs, "$pkg->{name}-$ver";
+ push @pkgs, "$pkg->{name}-$pkg->{label}";
print <<~EOF;
- (define-public $pkg->{name}-$ver
+ (define-public $pkg->{name}-$pkg->{label}
(package
- (name "$pkg->{name}-$ver")
+ (name "$pkg->{name}-$pkg->{label}")
(version "$pkg->{version}")
(source
(origin
@@ -352,7 +331,7 @@ sub emit_debian() {
push @{$vars{destdebs}}, "\t\$(DIR)/debian-destdir/$pkg->{name}-$pkg->{version}.deb \\\n";
push @{$vars{debs}}, "\t\$(DIR)/debian/$pkg->{name}_$pkg->{version}_all.deb \\\n";
- my $ver = $pkg->{type} eq 'latest' ? '0.' . $pkg->{version} . '.latest' : $pkg->{version};
+ my $ver = $pkg->{label} eq 'latest' ? '0.' . $pkg->{version} . '.latest' : $pkg->{version};
$ver =~ s/^v//;
my $maintainer_b64 = MIME::Base64::encode_base64 $pkg->{maintainer}, '';
my $desc_b64 = MIME::Base64::encode_base64 $pkg->{description}, '';
@@ -479,14 +458,14 @@ sub emit_html() {
EOF
for my $pkg (@{$json->{packages}}) {
- my ($ver, $suffix) = pretty_version $pkg;
- my $apt_suffix = $suffix eq '' ? '' : "=$ver";
+ my $suffix = $pkg->{label} eq 'latest' ? '' : "-$pkg->{label}";
+ my $apt_suffix = $suffix =~ s/-/=/r;
print <<~EOF;
- <li id="$pkg->{name}-$ver">
+ <li id="$pkg->{name}-$pkg->{label}">
<details>
<summary>
- <a href="#$pkg->{name}-$ver">$pkg->{name}</a>
- ($ver) - $pkg->{description}
+ <a href="#$pkg->{name}-$pkg->{label}">$pkg->{name}</a>
+ ($pkg->{label}) - $pkg->{description}
</summary>
<p>
<a href="$pkg->{'base-url'}/">Homepage</a>