From e9034c37caab0eae66881a3669c320f6a98f4272 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 22 Mar 2023 17:42:06 -0300 Subject: src/bin/paku: Get license and repository information from paku.lock --- src/bin/paku | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/bin/paku b/src/bin/paku index 16967a3..1d97f3a 100755 --- a/src/bin/paku +++ b/src/bin/paku @@ -91,6 +91,18 @@ sub load_json() { return JSON::decode_json($json_str); } +my $licenses = { + guix => { + 'AGPL-3.0-or-later' => 'agpl3+', + }, + nix => { + 'AGPL-3.0-or-later' => 'agpl3Plus', + }, +}; +sub license_for($target, $id) { + return $licenses->{$target}->{$id}; +} + sub emit_packages() { for (@ARGV) { my $fh; @@ -174,6 +186,7 @@ sub emit_nix() { for my $pkg (@{$json->{packages}}) { my $long = $pkg->{'long-description'}; $long =~ s/^(.)/ $1/gm; + my $license = license_for 'nix', $pkg->{license}; my $suffix = $pkg->{label} eq 'latest' ? '' : "-$pkg->{label}"; print <<~EOF; @@ -221,7 +234,7 @@ sub emit_nix() { homepage = "$pkg->{homepage}"; changelog = "$pkg->{changelog}"; downloadPage = "$pkg->{'downloads-page'}"; - license = licenses.agpl3; + license = licenses.$license; platforms = platforms.unix; }; }; @@ -259,6 +272,7 @@ sub emit_guix() { my $long = $pkg->{'long-description'}; $long =~ s/^(.)/ $1/gm; my $ver = $pkg->{version} =~ s/^v//r; + my $license = license_for 'guix', $pkg->{license}; my $name = $pkg->{name} . ( $pkg->{label} eq 'latest' ? '' : "-$pkg->{label}" @@ -305,7 +319,7 @@ sub emit_guix() { (description "$pkg->{'long-description'}") (home-page "$pkg->{homepage}") - (license licenses:agpl3+))) + (license licenses:$license))) EOF } @@ -582,6 +596,9 @@ sub emit_html() { EOF } + my $channel_name = $json->{namespace} =~ s/\./-/gr; + my $overlay_name = $json->{namespace} =~ s/\./-/gr; + my $tap_name = $json->{namespace} =~ s/\./\//gr; print <<~EOF;
@@ -592,8 +609,8 @@ sub emit_html() {

(cons*
 		 (channel
-		  (name 'org-euandre)
-		  (url "git://euandre.org/package-repository")
+		  (name '$channel_name)
+		  (url "$json->{vcs}->{git}")
 		  (branch "main")
 		  (introduction
 		   (make-channel-introduction
@@ -617,14 +634,14 @@ sub emit_html() {
 		          Include my public key for validating the repository
 		          signatures:
 		        

-
\$ wget -qO- https://euandre.org/s/package-repository/debian/public-key.asc | sudo tee /etc/apt/trusted.gpg.d/euandre.org.asc
+
\$ wget -qO- $json->{'base-url'}/debian/public-key.asc | sudo tee /etc/apt/trusted.gpg.d/$json->{namespace}.asc

Afterwards, include this repository to the list of repositories that apt uses for sources by adding its URL to /etc/apt/sources.list:

-
\$ sudo apt-add-repository 'deb https://euandre.org/s/package-repository/debian ./'
+
\$ sudo apt-add-repository 'deb $json->{'base-url'}/debian ./'

apt-add-repository will already perform an apt update, so the packages from the @@ -640,13 +657,13 @@ sub emit_html() {

  nixpkgs = {
 		    overlays = [
 		      (import (fetchTarball {
-		        url = "https://euandre.org/git/package-repository/snapshot/package-repository-main.tar.xz";
+		        url = "$json->{vcs}->{tarball}";
 		      }) { inherit pkgs; })
 		    ];
 		  };

All the packages live under the - org-euandre attribute set. + $overlay_name attribute set.

@@ -654,7 +671,7 @@ sub emit_html() {

Add this repository as a tap:

-
\$ brew tap --force-auto-update org/euandre https://euandre.org/git/package-repository/
+
\$ brew tap --force-auto-update $tap_name $json->{vcs}->{http}

The explicit --force-auto-update option is required, because homebrew(1) will only -- cgit v1.2.3