Skip to content

Commit

Permalink
Merge pull request #94 from seriouscatsoserious/srs-branch
Browse files Browse the repository at this point in the history
Fix for Mac unzip issues
  • Loading branch information
seriouscatsoserious authored Jun 17, 2024
2 parents dc5fdcd + 2e9e2a0 commit b8a0a00
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 26 deletions.
25 changes: 10 additions & 15 deletions models/chain_provider.gd
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func read_conf():

conf.close()


func write_start_script():
print("Writing start script: ", get_start_path())
if FileAccess.file_exists(get_start_path()):
Expand All @@ -142,50 +143,46 @@ func write_start_script():
if id == "testsail" || id == "ethsail" || id == "zsail":
env = "SIDESAIL_DATADIR=" + base_dir



var cmd = '"' + get_executable_path() + '"'
var cmd = get_executable_path()
match id:
"thunder", "bitnames", "bitassets":
var drivechain = Appstate.get_drivechain_provider()
if drivechain == null:
return

# Remove explicit network, mainchain RPC, and RPC port configurations
var data_dir = ' -d "' + ProjectSettings.globalize_path(base_dir + '/data') + '"'
var dc_user = ' -u "' + drivechain.rpc_user + '"'
var dc_pass = ' -p "' + drivechain.rpc_password + '"'
cmd = cmd + "" + data_dir + dc_user + dc_pass
var data_dir = " -d " + ProjectSettings.globalize_path(base_dir + "/data")
var dc_user = " -u " + drivechain.rpc_user
var dc_pass = " -p " + drivechain.rpc_password
cmd = cmd + data_dir + dc_user + dc_pass
_:
cmd = cmd + ' --conf="' + get_conf_path() + '"'
cmd = cmd + " --conf=" + get_conf_path()

var file = FileAccess.open(get_start_path(), FileAccess.WRITE)
match Appstate.get_platform():
Appstate.platform.LINUX:
file.store_line("#!/bin/bash")
if env != "":
file.store_line("export " + env)
file.store_link("export "+env)

file.store_line(cmd)

Appstate.platform.MAC:
file.store_line("#!/bin/bash")
cmd = cmd.replace("Application Support", "Application\\ Support")
if env != "":
file.store_line("export " + env)
file.store_line("export "+env)

file.store_line(cmd)

Appstate.platform.WIN:
if env != "":
file.store_line("set " + env)

file.store_line('start "" ' + cmd)

file.store_line("start " + cmd)

file.close()



func write_dir():
var dir = ProjectSettings.globalize_path(base_dir)
Expand Down Expand Up @@ -246,5 +243,3 @@ func get_executable_path() -> String:
func get_local_zip_hash() -> String:
return FileAccess.get_sha256(ProjectSettings.globalize_path(base_dir + "/" + id + ".zip"))



Original file line number Diff line number Diff line change
Expand Up @@ -483,22 +483,16 @@ func _on_download_complete(result, response_code, _headers, body):
func unzip_file_and_setup_binary(base_dir: String, zip_path: String):
var prog = "unzip"
var args = [zip_path, "-d", base_dir]
print(zip_path)
print(base_dir)

if Appstate.get_platform() == Appstate.platform.WIN:
prog = "powershell.exe"
var escaped_zip_path = "'" + zip_path.replace("/", "\\") + "'"
var escaped_base_dir = "'" + base_dir.replace("/", "\\") + "'"
args = ["-Command", "Expand-Archive -Force " + escaped_zip_path + " " + escaped_base_dir]
print(args)
args = ["-Command", 'Expand-Archive -Force ' + zip_path + ' ' + base_dir]


print("Unzipping ", zip_path, ": ", prog, " ", args)
print("Unzipping ", zip_path, ": ", prog, " ", args, )

# We used to check for the exit code here. However, unzipping sometimes
# throw bad errors on symbolic links, but output the files just fine...
var result = OS.execute(prog, args)
print("Unzip result: ", result)
OS.execute(prog, args)

chain_provider.write_start_script()
if Appstate.get_platform() != Appstate.platform.WIN:
Expand All @@ -516,7 +510,7 @@ func unzip_file_and_setup_binary(base_dir: String, zip_path: String):
#OS.execute("chmod", ["+x", ProjectSettings.globalize_path(chain_provider.base_dir + "/" + zside_params_name)])

update_view()


func reset_download():
remove_child(download_req)
Expand Down

0 comments on commit b8a0a00

Please sign in to comment.