@@ -16,12 +16,18 @@ function PLUGIN:PreInstall(ctx)
1616 local download_url
1717 local PRE_BUILT_OS_RELEASE = erlangUtils .get_config_from_env (" USE_PREBUILT_OTP" )
1818 if RUNTIME .osType == " windows" then
19+ -- For Windows, always use OTP- prefix for regular versions
20+ local win_tag = erlang_version
21+ if not (string.match (erlang_version , " latest$" ) or string.match (erlang_version , " ^maint%-" )) then
22+ win_tag = " OTP-" .. erlang_version
23+ end
24+
1925 if RUNTIME .archType == " amd64" then
20- download_url = " https://github.com/erlang/otp/releases/download/OTP- " ..
21- erlang_version .. " /otp_win64_" .. erlang_version .. " .exe"
26+ download_url = " https://github.com/erlang/otp/releases/download/" ..
27+ win_tag .. " /otp_win64_" .. erlang_version .. " .exe"
2228 else
23- download_url = " https://github.com/erlang/otp/releases/download/OTP- " ..
24- erlang_version .. " /otp_win32_" .. erlang_version .. " .exe"
29+ download_url = " https://github.com/erlang/otp/releases/download/" ..
30+ win_tag .. " /otp_win32_" .. erlang_version .. " .exe"
2531 end
2632 elseif RUNTIME .osType == " linux" and PRE_BUILT_OS_RELEASE then
2733 local SUPPORT_OS_RELEASE = { " ubuntu-14.04" , " ubuntu-16.04" , " ubuntu-18.04" , " ubuntu-20.04" , " ubuntu-22.04" ,
@@ -47,26 +53,55 @@ function PLUGIN:PreInstall(ctx)
4753 RUNTIME .archType .. " . Supported architectures: amd64, x86_64, arm64, aarch64" )
4854 end
4955
56+ -- Prepare tag name and file prefix for download URL
57+ -- Special versions like master-latest, maint-latest etc. don't need OTP- prefix
58+ -- Regular versions like 28.0.1 need OTP- prefix for GitHub tag but not for filename
59+ local tag_name = erlang_version
60+ local file_prefix = erlang_version
61+
62+ if not (string.match (erlang_version , " latest$" ) or string.match (erlang_version , " ^maint%-" )) then
63+ -- Regular version like "28.0.1" -> tag should be "OTP-28.0.1"
64+ tag_name = " OTP-" .. erlang_version
65+ file_prefix = " OTP-" .. erlang_version
66+ end
67+
5068 -- Use different URL patterns based on architecture
5169 if mapped_arch == " aarch64" then
5270 -- https://github.com/erlef/otp_builds/releases/download/maint-25-latest/otp-aarch64-apple-darwin.tar.gz
5371 download_url = " https://github.com/erlef/otp_builds/releases/download/" ..
54- erlang_version .. " /otp-aarch64-apple-darwin.tar.gz"
72+ tag_name .. " /otp-aarch64-apple-darwin.tar.gz"
5573 elseif mapped_arch == " arm64" then
56- -- https://github.com/erlef/otp_builds/releases/download/OTP-28.0.1/OTP-28.0.1-macos-arm64.tar.gz
57- download_url = " https://github.com/erlef/otp_builds/releases/download/" ..
58- erlang_version .. " /" .. erlang_version .. " -macos-arm64.tar.gz"
74+ if string.match (erlang_version , " latest$" ) or string.match (erlang_version , " ^maint%-" ) then
75+ -- For latest versions: use aarch64 naming for arm64
76+ download_url = " https://github.com/erlef/otp_builds/releases/download/" ..
77+ tag_name .. " /otp-aarch64-apple-darwin.tar.gz"
78+ else
79+ -- For regular versions: https://github.com/erlef/otp_builds/releases/download/OTP-28.0.1/OTP-28.0.1-macos-arm64.tar.gz
80+ download_url = " https://github.com/erlef/otp_builds/releases/download/" ..
81+ tag_name .. " /" .. file_prefix .. " -macos-arm64.tar.gz"
82+ end
5983 elseif mapped_arch == " amd64" then
60- -- https://github.com/erlef/otp_builds/releases/download/OTP-28.0.1/OTP-28.0.1-macos-amd64.tar.gz
61- download_url = " https://github.com/erlef/otp_builds/releases/download/" ..
62- erlang_version .. " /" .. erlang_version .. " -macos-amd64.tar.gz"
84+ if string.match (erlang_version , " latest$" ) or string.match (erlang_version , " ^maint%-" ) then
85+ -- For latest versions: use x86_64 naming for amd64
86+ download_url = " https://github.com/erlef/otp_builds/releases/download/" ..
87+ tag_name .. " /otp-x86_64-apple-darwin.tar.gz"
88+ else
89+ -- For regular versions: https://github.com/erlef/otp_builds/releases/download/OTP-28.0.1/OTP-28.0.1-macos-amd64.tar.gz
90+ download_url = " https://github.com/erlef/otp_builds/releases/download/" ..
91+ tag_name .. " /" .. file_prefix .. " -macos-amd64.tar.gz"
92+ end
6393 elseif mapped_arch == " x86_64" then
64- -- https://github.com/erlef/otp_builds/releases/download/OTP-28.0.1/otp- x86_64-apple-darwin.tar.gz
94+ -- For x86_64, always use the same naming pattern as aarch64
6595 download_url = " https://github.com/erlef/otp_builds/releases/download/" ..
66- erlang_version .. " /otp-x86_64-apple-darwin.tar.gz"
96+ tag_name .. " /otp-x86_64-apple-darwin.tar.gz"
6797 end
6898 else
69- download_url = " https://github.com/erlang/otp/archive/refs/tags/OTP-" .. erlang_version .. " .tar.gz"
99+ -- For source code download, always use OTP- prefix for regular versions
100+ local source_tag = erlang_version
101+ if not (string.match (erlang_version , " latest$" ) or string.match (erlang_version , " ^maint%-" )) then
102+ source_tag = " OTP-" .. erlang_version
103+ end
104+ download_url = " https://github.com/erlang/otp/archive/refs/tags/" .. source_tag .. " .tar.gz"
70105 end
71106
72107 print (" Download Erlang/OTP from " .. download_url )
0 commit comments