aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-03-22 17:42:06 -0300
committerEuAndreh <eu@euandre.org>2023-03-22 17:42:06 -0300
commite9034c37caab0eae66881a3669c320f6a98f4272 (patch)
tree3ef737d7cdbbd19764381771990d6c9abce6a478 /src
parentsrc/bin/paku: Use homepage, changelog and downloads-page from paku.lock directly (diff)
downloadpackage-repository-e9034c37caab0eae66881a3669c320f6a98f4272.tar.gz
package-repository-e9034c37caab0eae66881a3669c320f6a98f4272.tar.xz
src/bin/paku: Get license and repository information from paku.lock
Diffstat (limited to 'src')
-rwxr-xr-xsrc/bin/paku35
1 files changed, 26 insertions, 9 deletions
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;
</ul>
<article id="guix-instructions">
@@ -592,8 +609,8 @@ sub emit_html() {
</p>
<pre><code>(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:
</p>
- <pre><code>\$ wget -qO- https://euandre.org/s/package-repository/debian/public-key.asc | sudo tee /etc/apt/trusted.gpg.d/euandre.org.asc</code></pre>
+ <pre><code>\$ wget -qO- $json->{'base-url'}/debian/public-key.asc | sudo tee /etc/apt/trusted.gpg.d/$json->{namespace}.asc</code></pre>
<p>
Afterwards, include this repository to the list of
repositories that <code>apt</code> uses for sources
by adding its URL to
<code>/etc/apt/sources.list</code>:
</p>
- <pre><code>\$ sudo apt-add-repository 'deb https://euandre.org/s/package-repository/debian ./'</code></pre>
+ <pre><code>\$ sudo apt-add-repository 'deb $json->{'base-url'}/debian ./'</code></pre>
<p>
<code>apt-add-repository</code> will already perform
an <code>apt update</code>, so the packages from the
@@ -640,13 +657,13 @@ sub emit_html() {
<pre><code> nixpkgs = {
overlays = [
(import (fetchTarball {
- url = "https://euandre.org/git/package-repository/snapshot/package-repository-main.tar.xz";
+ url = "$json->{vcs}->{tarball}";
}) { inherit pkgs; })
];
};</code></pre>
<p>
All the packages live under the
- <code>org-euandre</code> attribute set.
+ <code>$overlay_name</code> attribute set.
</p>
</article>
<article id="homebrew-instructions">
@@ -654,7 +671,7 @@ sub emit_html() {
<p>
Add this repository as a tap:
</p>
- <pre><code>\$ brew tap --force-auto-update org/euandre https://euandre.org/git/package-repository/</code></pre>
+ <pre><code>\$ brew tap --force-auto-update $tap_name $json->{vcs}->{http}</code></pre>
<p>
The explicit <code>--force-auto-update</code> option
is required, because <code>homebrew(1)</code> will only