homebrew-cask/Casks/p/p4v.rb

49 lines
1.6 KiB
Ruby

cask "p4v" do
version "2023.2,2467475"
sha256 "fba5813f43a9af3a9080611ec5bb0ad4713dc06360e005a4ee8c1d1b9e4ee4c7"
url "https://filehost.perforce.com/perforce/r#{version.major[-2..]}.#{version.minor}/bin.macosx12u/P4V.dmg"
name "Perforce Helix Visual Client"
name "P4Merge"
name "P4V"
desc "Visual client for Helix Core"
homepage "https://www.perforce.com/products/helix-core-apps/helix-visual-client-p4v"
livecheck do
url "https://www.perforce.com/support/software-release-index"
regex(%r{(?:Patch|Release) for[^<]+?Helix Visual Client[^<]+?v?(\d+(?:\.\d+)+)/(\d+)}im)
strategy :page_match do |page, regex|
page.scan(regex).map { |match| "#{match[0]},#{match[1]}" }
end
end
app "p4v.app"
app "p4admin.app"
app "p4merge.app"
binary "p4vc"
# shim script (https://github.com/Homebrew/homebrew-cask/issues/18809)
p4_wrapper = "#{staged_path}/p4.wrapper.sh"
binary p4_wrapper, target: "p4v"
binary p4_wrapper, target: "p4admin"
binary p4_wrapper, target: "p4merge"
preflight do
File.write p4_wrapper, <<~EOS
#!/bin/bash
set -euo pipefail
COMMAND=$(basename "$0")
if [[ "$COMMAND" == "p4merge" ]]; then
exec "#{appdir}/${COMMAND}.app/Contents/Resources/launch${COMMAND}" "$@" 2> /dev/null
else
exec "#{appdir}/${COMMAND}.app/Contents/MacOS/${COMMAND}" "$@" 2> /dev/null
fi
EOS
end
zap trash: [
"~/Library/Preferences/com.perforce.p4v",
"~/Library/Preferences/com.perforce.p4v.plist",
"~/Library/Saved Application State/com.perforce.p4v.savedState",
]
end