-
-
Notifications
You must be signed in to change notification settings - Fork 7
fix: homebrew distribution #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||||||||||
| class PdfSign < Formula | ||||||||||||||
| desc "Secure PDF signing with OpenPGP and Sigstore" | ||||||||||||||
| homepage "https://github.com/0x77dev/pdf-sign" | ||||||||||||||
| url "https://github.com/0x77dev/pdf-sign/releases/download/v0.2.0/pdf-sign-macos-arm64" | ||||||||||||||
| sha256 "sha256-hash-placeholder" # To be updated on release | ||||||||||||||
| license "GPL-3.0-only" | ||||||||||||||
|
|
||||||||||||||
| def install | ||||||||||||||
| bin.install "pdf-sign" | ||||||||||||||
| end | ||||||||||||||
|
Comment on lines
+8
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win Install the filename downloaded by the URL. The URL’s basename is Proposed fix- bin.install "pdf-sign"
+ bin.install "pdf-sign-macos-arm64" => "pdf-sign"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| test do | ||||||||||||||
| test.shell_script { "pdf-sign --help" } | ||||||||||||||
| end | ||||||||||||||
|
Comment on lines
+12
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "Locate formula:"
fd -a '^(pdf-sign\.rb|.*\.rb)$' . | sed 's#^\./##' | rg 'Formula|pdf-sign|test-shell-script|shell_script' || true
echo
echo "Formula snippet:"
if [ -f Formula/pdf-sign.rb ]; then
cat -n Formula/pdf-sign.rb | sed -n '1,80p'
fi
echo
echo "Search test.shell_script usage in repo:"
rg -n 'test\.shell_script|shell_script \{' . --glob '*.rb' || true
echo
echo "Search installed executable test patterns nearby:"
rg -n "bin/\S+.*--help|system \\\$?\\\$?\\{bin\\}/|test\s*\n\s*\{" . --glob '*.rb' | head -100Repository: 0x77dev/pdf-sign Length of output: 1102 🌐 Web query:
💡 Result: In a Homebrew formula, the test do block is used to verify that the installed software functions correctly [1]. While common commands like foo --version or foo --help are often used for basic smoke tests, Homebrew's official documentation considers them weak tests [1][2]. The preferred approach is to perform a test that exercises the application's actual functionality, such as processing an input file or performing a specific operation [1][3]. If you were to include a test using a system command (often preferred over bare backticks for better error handling and output separation), the modern syntax is to separate the command and its arguments as individual strings [4]: test do system bin/"foo", "--help" end Key considerations for writing tests in Homebrew: 1. Test Environment: The test do block automatically creates a temporary, isolated directory [1]. The environment variable HOME is set to this temporary directory, ensuring the test does not interact with your actual home directory [1]. 2. System Commands: Using system "cmd", "arg1", "arg2" is the recommended way to invoke executables [4]. This avoids shell injection issues and correctly handles arguments with spaces [4]. 3. Assertions: To verify output, you can use shell_output to capture the command's standard output [1]: assert_match "Usage:", shell_output("#{bin}/foo --help") 4. Best Practices: Aim for tests that do not require user input and verify real functionality, such as creating a small test file, running the tool against it, and checking the resulting output [1][5][6]. While a --help test is better than no test at all, reviewers and maintainers generally prefer tests that confirm the software is fully operational [1][3]. Citations:
🌐 Web query:
💡 Result: There is no specialized Citations:
🌐 Web query:
💡 Result: In the context of Homebrew, there is no specific command or DSL element named test.shell_script [1][2]. If you are looking to execute shell commands within a Homebrew formula during the test phase, you use the standard Ruby system/command execution methods provided within the test do block [2][3]. The recommended approach is to use methods like shell_output to run shell commands and assert their output [4][2]. Common patterns inside a formula's test do block include: 1. Using shell_output: This runs a command and returns the output, which you can then check with assertions like assert_match or assert_equal [4][2]. test do assert_match "expected output", shell_output("#{bin}/program --version") end 2. Using system: This executes a command and expects it to succeed (exit with 0). If the command fails, the test will fail [4][2]. test do system "#{bin}/program", "arg1", "arg2" end If you are referring to Homebrew's internal development tooling, there are files such as Library/Homebrew/test/utils/shell_spec.rb used for testing Homebrew's own utilities, but these are not part of the formula DSL available to users [5]. Additionally, Homebrew allows for external commands, which can be implemented as shell scripts, but these follow a naming convention (e.g., brew-extcmd) and are distinct from formula test blocks [6]. Citations:
Use the standard Homebrew test command API.
Proposed fix test do
- test.shell_script { "pdf-sign --help" }
+ system "#{bin}/pdf-sign", "--help"
end📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| end | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🔴 Critical | ⚡ Quick win
Replace the placeholder checksum before merging.
Line 5 is not a valid SHA-256 for the release artifact, so Homebrew’s download verification will reject installation. Compute the checksum for the exact v0.2.0 asset and commit it. (docs.brew.sh)
🤖 Prompt for AI Agents
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: 0x77dev/pdf-sign
Length of output: 786
🌐 Web query:
Homebrew formula binary installation error unsupported platform download URL linux Windows documentation💡 Result:
Homebrew is officially supported on Linux and Windows Subsystem for Linux (WSL) 2 [1][2]. It is not supported for native Windows (i.e., outside of WSL) [1][3]. If you are encountering an "unsupported platform" or similar binary installation error, it is likely due to one of the following reasons: 1. Improper Installation Path: Homebrew must be installed in its default, supported prefix to correctly download and utilize precompiled binary packages (known as bottles) [4][5]. The required paths are: - Linux/WSL: /home/linuxbrew/.linuxbrew [6][5] - macOS Intel: /usr/local [6][5] - macOS Apple Silicon: /opt/homebrew [6][5] Installing outside these paths often forces Homebrew to attempt to build from source, which is frequently unsupported or prone to failure [4][7]. 2. Architecture/Emulator Mismatch: Homebrew enforces strict architecture checks [8][7]. For example, attempting to install ARM-based Homebrew in an Intel default prefix (or vice versa) will trigger an error [7][9]. Ensure you are using the correct terminal architecture or that your shell is not being incorrectly translated (e.g., via Rosetta 2 on macOS) [8][9]. 3. WSL 1 Limitations: While Homebrew may function on WSL 1, it is considered a Tier 3 (experimental/unsupported) platform due to known compatibility issues [1][2]. The Homebrew project strongly recommends using WSL 2 [1][2]. To resolve most binary installation errors: - Ensure Homebrew is installed in the correct default prefix for your OS [4][5]. - Verify that your system meets the requirements (e.g., glibc/gcc on Linux) [1][2]. - If you have an unsupported configuration, the recommended solution is to perform a clean, default installation [4][7]. For further troubleshooting, consult the official Homebrew documentation at https://docs.brew.sh/ [5].
Citations:
Restrict or add artifacts for unsupported platforms.
This formula only exposes a macOS arm64 binary, while Homebrew also runs on Linux, WSL, and Intel Macs. Add platform-specific URLs/checksums or reject unsupported platforms with
on_linux,only_on :macos, and/or acaveats; otherwise those users can install an executable that will not run on their platform.🤖 Prompt for AI Agents