Skip to content

Commit

Permalink
Patch for TruffleRuby
Browse files Browse the repository at this point in the history
  • Loading branch information
yanecc committed May 31, 2024
1 parent b130429 commit 5d36d79
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion hooks/post_install.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ function PLUGIN:PostInstall(ctx)
makeGemsPath(sdkInfo.path)
return
end
mambaInstall(sdkInfo.path, sdkInfo.version)
unixInstall(sdkInfo.path, sdkInfo.version)
end
32 changes: 22 additions & 10 deletions lib/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,31 @@ function generateTruffleRuby(version, osType, archType)
end

-- post_install.lua
function unixInstall(path, version)
if compareVersion(version, "20.0.0") >= 0 then
patchTruffleRuby(path)
else
mambaInstall(path, version)
end
end

function patchTruffleRuby(path)
local command1 = path .. "/lib/truffle/post_install_hook.sh > /dev/null"
local command2 = "mkdir -p " .. path .. "/share/gems/bin"
local command3 = "rm -rf " .. path .. "/src"
for _, command in ipairs({ command1, command2, command3 }) do
local status = os.execute(command)
if status ~= 0 then
print("Failed to execute command: " .. command)
os.exit(1)
end
end
end

function mambaInstall(path, version)
local macromamba = path .. "/macromamba"
local command1 = "chmod +x " .. macromamba
local condaForge = os.getenv("Conda_Forge") or "conda-forge"
local command1 = "chmod +x " .. macromamba
local command2 = macromamba
.. " create -yqp "
.. path
Expand All @@ -244,15 +265,6 @@ function mambaInstall(path, version)
local command4 = "mkdir -p " .. path .. "/share/gems/bin"
local command5 = "rm -rf " .. path .. "/temp " .. path .. "/pkgs " .. path .. "/etc " .. path .. "/conda-meta"

if compareVersion(version, "20.0.0") >= 0 then
local status = os.execute(command4)
if status ~= 0 then
print("Failed to execute command: " .. command4)
os.exit(1)
end
return
end

downloadMacroMamba(macromamba)
for _, command in ipairs({ command1, command2, command3, command4, command5 }) do
local status = os.execute(command)
Expand Down
2 changes: 1 addition & 1 deletion metadata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PLUGIN = {}
--- Plugin name
PLUGIN.name = "ruby"
--- Plugin version
PLUGIN.version = "0.3.1"
PLUGIN.version = "0.3.2"
--- Plugin homepage
PLUGIN.homepage = "https://github.com/yanecc/vfox-ruby"
--- Plugin license, please choose a correct license according to your needs.
Expand Down

0 comments on commit 5d36d79

Please sign in to comment.