From b3ccc398cfd30ad9e243a041933204ea2e567535 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 22 Mar 2023 12:11:24 -0300 Subject: Support Homebrew --- src/bin/paku | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 5 deletions(-) (limited to 'src/bin/paku') 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() {

\$ nix-env -i $pkg->{name}$suffix
+
+

Homebrew

+

+ After following the + Homebrew instructions + to include this repository as a tap, you can + install it with: +

+
\$ brew install $pkg->{name}$suffix
+
EOF @@ -584,7 +630,6 @@ sub emit_html() {

Include my public key for validating the repository signatures: - ~/.config/guix/channels.scm:

\$ wget -qO- https://euandre.org/s/package-repository/debian/public-key.asc | sudo tee /etc/apt/trusted.gpg.d/euandre.org.asc

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

  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; })
 		    ];
 		  };
@@ -618,6 +663,20 @@ sub emit_html() { org-euandre attribute set.

+
+

Homebrew instructions

+

+ Add this repository as a tap: +

+
\$ brew tap --force-auto-update org/euandre https://euandre.org/git/package-repository/
+

+ The explicit --force-auto-update option + is required, because homebrew(1) will only + fetch updates automatically for repositories hosted on + GitHub. With this option, repositories not on GitHub + are treated equally. +

+
@@ -631,6 +690,7 @@ my %actions = ( nix => \&emit_nix, guix => \&emit_guix, debian => \&emit_debian, + homebrew => \&emit_homebrew, html => \&emit_html, ); -- cgit v1.2.3