aboutsummaryrefslogtreecommitdiff
path: root/src/bin/paku
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-03-22 12:11:24 -0300
committerEuAndreh <eu@euandre.org>2023-03-22 15:51:52 -0300
commitb3ccc398cfd30ad9e243a041933204ea2e567535 (patch)
tree84ec606d88ace7e9d782d8e954b32d5d73bd6369 /src/bin/paku
parentsrc/bin/paku: Get Base64 from paku.lock instead of calculating it (diff)
downloadpackage-repository-b3ccc398cfd30ad9e243a041933204ea2e567535.tar.gz
package-repository-b3ccc398cfd30ad9e243a041933204ea2e567535.tar.xz
Support Homebrew
Diffstat (limited to '')
-rwxr-xr-xsrc/bin/paku70
1 files changed, 65 insertions, 5 deletions
diff --git a/src/bin/paku b/src/bin/paku
index 622f8ef..55372b6 100755
--- a/src/bin/paku
+++ b/src/bin/paku
@@ -123,7 +123,7 @@ sub emit_packages() {
}
sub emit_release() {
- my $f = $ARGV[0];
+ my $f = $ARGV[0] or die 'Missing "Packages" file';
my $name = File::Basename::basename $f;
my $size = (stat($f))[7];
@@ -189,7 +189,7 @@ sub emit_nix() {
src = fetchTarball {
url =
"$pkg->{url}";
- sha256 = "$pkg->{sha256}";
+ sha256 = "$pkg->{sha256nix}";
};
nativeBuildInputs = with pkgs; [
@@ -279,7 +279,7 @@ sub emit_guix() {
(method url-fetch)
(uri "$pkg->{url}")
(sha256
- (base32 "$pkg->{sha256base32}"))))
+ (base32 "$pkg->{sha256guix}"))))
(build-system gnu-build-system)
(native-inputs
EOF
@@ -459,6 +459,42 @@ sub emit_debian() {
print @targets;
}
+sub pascal_case($s) {
+ return join('', map(ucfirst, split '-', $s))
+}
+
+sub emit_homebrew() {
+ my $d = $ARGV[0] or die 'Missing "Formula/" directory';
+ my $json = load_json();
+ for my $pkg (@{$json->{packages}}) {
+ my $name = $pkg->{name} . (
+ $pkg->{label} eq 'latest' ? '' : "-$pkg->{label}"
+ );
+ open(my $fh, '>', "$d/$name.rb");
+ my $class_name = pascal_case $name;
+ print $fh <<~EOF;
+ class $class_name < Formula
+ desc '$pkg->{description}'
+ homepage '$pkg->{'base-url'}'
+ url '$pkg->{url}'
+ sha256 '$pkg->{sha256}'
+ license 'AGPL-3.0-or-later'
+
+ def install
+ system 'make'
+ system 'make', 'check'
+ system 'make', 'install', "PREFIX=#{prefix}"
+ end
+
+ test do
+ system "#{bin}/$pkg->{name}", '-V'
+ end
+ end
+ EOF
+ close $fh;
+ }
+}
+
sub emit_html() {
my $json = load_json();
print <<~EOF;
@@ -545,6 +581,16 @@ sub emit_html() {
</p>
<pre><code>\$ nix-env -i $pkg->{name}$suffix</code></pre>
</section>
+ <section>
+ <h2>Homebrew</h2>
+ <p>
+ After following the
+ <a href="#homebrew-instructions">Homebrew instructions</a>
+ to include this repository as a <code>tap</code>, you can
+ install it with:
+ </p>
+ <pre><code>\$ brew install $pkg->{name}$suffix</code></pre>
+ </section>
</details>
</li>
EOF
@@ -584,7 +630,6 @@ sub emit_html() {
<p>
Include my public key for validating the repository
signatures:
- <code>~/.config/guix/channels.scm</code>:
</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>
<p>
@@ -609,7 +654,7 @@ sub emit_html() {
<pre><code> nixpkgs = {
overlays = [
(import (fetchTarball {
- url = "https://euandre.org/git/package-repository/snapshot/package-repository-main.tar.gz";
+ url = "https://euandre.org/git/package-repository/snapshot/package-repository-main.tar.xz";
}) { inherit pkgs; })
];
};</code></pre>
@@ -618,6 +663,20 @@ sub emit_html() {
<code>org-euandre</code> attribute set.
</p>
</article>
+ <article id="homebrew-instructions">
+ <h2>Homebrew instructions</h2>
+ <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>
+ <p>
+ The explicit <code>--force-auto-update</code> option
+ is required, because <code>homebrew(1)</code> will only
+ fetch updates automatically for repositories hosted on
+ GitHub. With this option, repositories not on GitHub
+ are treated equally.
+ </p>
+ </article>
</main>
</body>
</html>
@@ -631,6 +690,7 @@ my %actions = (
nix => \&emit_nix,
guix => \&emit_guix,
debian => \&emit_debian,
+ homebrew => \&emit_homebrew,
html => \&emit_html,
);