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 --- default.nix | 10 +++++----- paku.lock | 11 +++++++++++ src/bin/paku | 35 ++++++++++++++++++++++++++--------- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/default.nix b/default.nix index c406b44..3f9db4d 100644 --- a/default.nix +++ b/default.nix @@ -32,7 +32,7 @@ self: super: { homepage = "https://euandre.org/s/git-permalink/"; changelog = "https://euandre.org/s/git-permalink/CHANGELOG.html"; downloadPage = "https://euandre.org/s/git-permalink/#releases"; - license = licenses.agpl3; + license = licenses.agpl3Plus; platforms = platforms.unix; }; }; @@ -67,7 +67,7 @@ self: super: { homepage = "https://euandre.org/s/git-permalink/"; changelog = "https://euandre.org/s/git-permalink/CHANGELOG.html"; downloadPage = "https://euandre.org/s/git-permalink/#releases"; - license = licenses.agpl3; + license = licenses.agpl3Plus; platforms = platforms.unix; }; }; @@ -101,7 +101,7 @@ self: super: { homepage = "https://euandre.org/s/remembering/"; changelog = "https://euandre.org/s/remembering/CHANGELOG.html"; downloadPage = "https://euandre.org/s/remembering/#releases"; - license = licenses.agpl3; + license = licenses.agpl3Plus; platforms = platforms.unix; }; }; @@ -137,7 +137,7 @@ self: super: { homepage = "https://euandre.org/s/td/"; changelog = "https://euandre.org/s/td/CHANGELOG.html"; downloadPage = "https://euandre.org/s/td/#releases"; - license = licenses.agpl3; + license = licenses.agpl3Plus; platforms = platforms.unix; }; }; @@ -172,7 +172,7 @@ self: super: { homepage = "https://euandre.org/s/guile-heredoc/"; changelog = "https://euandre.org/s/guile-heredoc/CHANGELOG.html"; downloadPage = "https://euandre.org/s/guile-heredoc/#releases"; - license = licenses.agpl3; + license = licenses.agpl3Plus; platforms = platforms.unix; }; }; diff --git a/paku.lock b/paku.lock index c02acb5..75537b2 100644 --- a/paku.lock +++ b/paku.lock @@ -13,9 +13,16 @@ "namespace": "org.euandre", "maintainer": "EuAndreh ", "name": "EuAndreh", + "base-url": "https://euandre.org/s/package-repository", + "vcs": { + "git": "git://euandre.org/package-repository", + "http": "https://euandre.org/git/package-repository/", + "tarball": "https://euandre.org/git/package-repository/snapshot/package-repository-main.tar.xz" + }, "packages": [ { "name": "git-permalink", + "license": "AGPL-3.0-or-later", "native-inputs": [], "inputs": [], "version": "v0.1.0", @@ -40,6 +47,7 @@ }, { "name": "git-permalink", + "license": "AGPL-3.0-or-later", "native-inputs": [], "inputs": [], "version": "v0.2.0", @@ -64,6 +72,7 @@ }, { "name": "remembering", + "license": "AGPL-3.0-or-later", "native-inputs": [], "inputs": [], "version": "v0.1.2", @@ -88,6 +97,7 @@ }, { "name": "td", + "license": "AGPL-3.0-or-later", "native-inputs": [], "inputs": [], "version": "4a8a7a2662c94b2581f587e9a4b81feba4f5e7d8", @@ -112,6 +122,7 @@ }, { "name": "guile-heredoc", + "license": "AGPL-3.0-or-later", "architectures": [ "i386", "x86_64", 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