class GlabelsQt < Formula
desc "gLabels Label Designer (Qt/C++) — Seth's packaging fork"
homepage "https://glabels.org"
url "https://git.sethpc.xyz/Seth/sethLabels.git",
tag: "3.99-master618-seth1",
revision: "2108e2cf1566cbfa120c12acb458a0dc498f1e79" # pragma: allowlist secret
license "GPL-3.0-only"
head "https://git.sethpc.xyz/Seth/sethLabels.git", branch: "main"
depends_on "cmake" => :build
depends_on "ninja" => :build
depends_on "pkgconf" => :build
depends_on "qt"
depends_on "zlib"
depends_on "qrencode" => :recommended # optional barcode backend
depends_on "zint" => :recommended # optional barcode backend
def install
system "cmake", "-S", ".", "-B", "build",
"-G", "Ninja",
"-DCMAKE_BUILD_TYPE=Release",
*std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
# Build a thin .app wrapper for Launchpad/Spotlight integration.
# Upstream's CMakeLists doesn't set MACOSX_BUNDLE, so we synthesize one.
# The launcher script execs the real CLI binary in #{bin}/glabels-qt.
on_macos do
app_bundle = prefix/"glabels-qt.app"
contents = app_bundle/"Contents"
macos_dir = contents/"MacOS"
resources = contents/"Resources"
macos_dir.mkpath
resources.mkpath
# Launcher script: 2-line shell that execs the real binary with all args.
launcher = macos_dir/"glabels-qt"
launcher.write <<~SH
#!/bin/bash
exec "#{bin}/glabels-qt" "$@"
SH
launcher.chmod 0755
# Info.plist: minimum keys for Launchpad/Spotlight to recognize the bundle.
(contents/"Info.plist").write <<~PLIST
CFBundleNamegLabels
CFBundleDisplayNamegLabels
CFBundleIdentifierorg.glabels.glabels-qt
CFBundleExecutableglabels-qt
CFBundleVersion#{version}
CFBundleShortVersionString#{version}
CFBundlePackageTypeAPPL
CFBundleIconFileglabels-qt.icns
LSMinimumSystemVersion10.13
NSHighResolutionCapable
PLIST
# Convert upstream PNG icon to .icns using sips (macOS built-in).
# Upstream installs hicolor PNGs at share/icons/hicolor//apps/glabels.png.
# Pick the largest available; fall back gracefully if none found.
candidate_pngs = Dir[share/"icons/hicolor/*/apps/glabels.png"].sort_by do |path|
size = path[%r{hicolor/(\d+)x\d+/}, 1].to_i
-size # largest first
end
if candidate_pngs.first
system "sips", "-s", "format", "icns",
candidate_pngs.first,
"--out", resources/"glabels-qt.icns"
else
opoo "No upstream PNG icon found; .app will use generic Mac icon."
end
end
end
def caveats
on_macos do
<<~CAVEATS
gLabels has been installed as a CLI binary at:
#{HOMEBREW_PREFIX}/bin/glabels-qt
#{HOMEBREW_PREFIX}/bin/glabels-batch-qt
For Launchpad / Spotlight / Dock integration, copy the .app bundle
to /Applications:
cp -R #{prefix}/glabels-qt.app /Applications/
(Re-run that command after each `brew upgrade glabels-qt` to refresh.)
CAVEATS
end
end
test do
assert_match "gLabels", shell_output("#{bin}/glabels-batch-qt --version")
end
end