Casks/l/libreoffice-still.rb
cask "libreoffice-still" do
arch arm: "aarch64", intel: "x86-64"
folder = on_arch_conditional arm: "aarch64", intel: "x86_64"
version "7.6.7"
sha256 arm: "17686aff42734ea4feef08e1189bab3011220000f7784061314c1ae9e5942531",
intel: "42d2eeaeee7bcb0e76e9decdcb8f5a4beebf133ad31f7d42a5e96ea770860110"
url "https://download.documentfoundation.org/libreoffice/stable/#{version}/mac/#{folder}/LibreOffice_#{version}_MacOS_#{arch}.dmg",
verified: "download.documentfoundation.org/libreoffice/stable/"
name "LibreOffice Still"
desc "Free cross-platform office suite, stable version recommended for enterprises"
homepage "https://www.libreoffice.org/"
# LibreOffice "still" releases are the stable versions with a lower
# major/minor.
livecheck do
url "https://download.documentfoundation.org/libreoffice/stable/"
regex(%r{href=["']v?(\d+(?:\.\d+)+)/?["' >]}i)
strategy :page_match do |page, regex|
versions = page.scan(regex).map(&:first)
uniq_major_minor = versions.map { |version| Version.new(version).major_minor }.uniq.sort.reverse
next if uniq_major_minor.length < 2
versions.select { |version| Version.new(version).major_minor == uniq_major_minor[1] }
end
end
conflicts_with cask: "libreoffice"
depends_on macos: ">= :catalina"
app "LibreOffice.app"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/gengal"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/regview"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/senddoc"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/uno"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/unoinfo"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/unopkg"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/uri-encode"
binary "#{appdir}/LibreOffice.app/Contents/MacOS/xpdfimport"
# shim script (https://github.com/Homebrew/homebrew-cask/issues/18809)
shimscript = "#{staged_path}/soffice.wrapper.sh"
binary shimscript, target: "soffice"
preflight do
File.write shimscript, <<~EOS
#!/bin/sh
'#{appdir}/LibreOffice.app/Contents/MacOS/soffice' "$@"
EOS
end
zap trash: [
"~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/org.libreoffice.script.sfl*",
"~/Library/Application Support/LibreOffice",
"~/Library/Preferences/org.libreoffice.script.plist",
"~/Library/Saved Application State/org.libreoffice.script.savedState",
]
end