Skip to content

Commit

Permalink
[73_37] Retry 5 times to create the dmg
Browse files Browse the repository at this point in the history
  • Loading branch information
da-liii committed Nov 29, 2024
1 parent 58fdfd6 commit af33f2d
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion xmake/research.lua
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,25 @@ target("research") do
end
end

function execWithRetry(command, args, maxRetries, retryDelay)
local retries = 0
local result

while retries <= maxRetries do
result = os.execute(command .. " " .. table.concat(args, " "))
if result then
return true, "Command executed successfully"
else
retries = retries + 1
if retries > maxRetries then
return false, "Command failed after " .. maxRetries .. " retries"
else
-- os.execute("sleep " .. retryDelay)
end
end
end
end

target("research_packager") do
set_enabled(is_plat("macosx") and is_mode("release"))
set_kind("phony")
Expand All @@ -322,6 +341,12 @@ target("research_packager") do
local app_dir = target:installdir() .. "/../../"
os.cp("$(buildir)/Info.plist", app_dir .. "/Contents")
os.execv("codesign", {"--force", "--deep", "--sign", "-", app_dir})
os.execv("/usr/bin/sudo /usr/bin/hdiutil create $(buildir)/" .. dmg_name .. " -fs HFS+ -srcfolder " .. app_dir)
hdiutil_command= "/usr/bin/sudo /usr/bin/hdiutil create $(buildir)/" .. dmg_name .. " -fs HFS+ -srcfolder " .. app_dir
local success, message= execWithRetry(hdiutil_command, {}, 5, 1)
if success then
print(message)
else
print("Error: " .. message)
end
end)
end

0 comments on commit af33f2d

Please sign in to comment.