Skip to content

Commit

Permalink
Merge pull request #171865 from secwang/master
Browse files Browse the repository at this point in the history
j 9.5.2
  • Loading branch information
miccal committed May 5, 2024
2 parents dd7669e + da6ebfd commit 6cbc970
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions Casks/j/j.rb
@@ -1,47 +1,59 @@
cask "j" do
version "9.5"
sha256 "066a3e5deef9359ca66cd16cc5cd80745dfc4ad49b59726b0f6cb5002c3f4a92"
version "9.5.2"
sha256 "78efb1db5423939e776f0053ff074a5c641b376e0517ded04773e38c001609c5"

url "https://www.jsoftware.com/download/j#{version}/install/j#{version}_mac64.zip"
url "https://www.jsoftware.com/download/j#{version.major_minor}/install/j#{version}_mac64.zip"
name "J"
desc "Programming language for mathematical, statistical and logical analysis of data"
homepage "https://www.jsoftware.com/"

apps = %w[jbrk jcon jqt]
apps.each do |a|
app "j#{version}/#{a}.app"
app "j#{version.major_minor}/#{a}.app"
end

livecheck do
url "https://code.jsoftware.com/wiki/System/Installation"
regex(/Jv?(\d+(?:\.\d+)+)\srelease/i)
regex(/Jv?(\d+(?:\.\d+)+)\s+release/i)
strategy :page_match do |page, regex|
# Identify partial release version (e.g., J1.2) on installation page
release = page.scan(regex)
.flatten
.max_by { |v| Version.new(v) }
next if release.blank?

# Fetch the release install page (containing full versions like 1.2.3)
install_page = Homebrew::Livecheck::Strategy.page_content("https://www.jsoftware.com/download/j#{release}/install/")
install_page[:content]&.scan(/href=.*?j[._-]?v?(\d+(?:\.\d+)+)[._-]mac/i)
&.map { |match| match[0] }
end
end

installer script: "j#{version}/macos-fix.command"
installer script: "j#{version.major_minor}/macos-fix.command"
installer script: {
executable: "j#{version}/bin/jconsole",
executable: "j#{version.major_minor}/bin/jconsole",
args: ["-js", "load 'pacman'", "'install' jpkg '*'", "exit 0"],
}

["jcon", "jconsole"].each do |b|
binary "j#{version}/bin/jconsole", target: b
binary "j#{version.major_minor}/bin/jconsole", target: b
end
commands = ["jbrk", "jhs", "jqt"]
commands.each do |b|
binary "j#{version}/bin/#{b}.command", target: b
binary "j#{version.major_minor}/bin/#{b}.command", target: b
end

postflight do
# Use `readlink` to get full path of symlinked commands.
commands.each do |c|
command = "#{staged_path}/j#{version}/bin/#{c}.command"
command = "#{staged_path}/j#{version.major_minor}/bin/#{c}.command"
File.write command, File.read(command).gsub("$0", '$(/usr/bin/readlink "$0" || /bin/echo "$0")')
end

# Fix relative paths inside App bundles.
apps.each do |a|
apprun = "#{appdir}/#{a}.app/Contents/MacOS/apprun"
File.write apprun, File.read(apprun).gsub(%r{`dirname "\$0"`.*?/bin}, "#{staged_path}/j#{version}/bin")
File.write apprun, File.read(apprun).gsub(%r{`dirname "\$0"`.*?/bin}, "#{staged_path}/j#{version.major_minor}/bin")
end
end

Expand Down

0 comments on commit 6cbc970

Please sign in to comment.