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
# Mac icon: convert upstream's SVG (installed at share/icons/hicolor//apps/glabels.svg)
# to .icns via sips. Prefer the scalable SVG; fall back to a sized variant if missing.
icon_src = share/"icons/hicolor/scalable/apps/glabels.svg"
unless icon_src.exist?
candidates = Dir[share/"icons/hicolor/*/apps/glabels.svg"].sort_by do |path|
size = path[%r{hicolor/(\d+)x\d+/}, 1].to_i
-size # largest first
end
icon_src = Pathname.new(candidates.first) if candidates.first
end
if icon_src && icon_src.exist?
begin
system "sips", "-s", "format", "icns",
icon_src.to_s,
"--out", (resources/"glabels-qt.icns").to_s
rescue => e
opoo "sips icon conversion failed (#{e.message}); .app will use generic Mac icon."
end
else
opoo "No upstream 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