Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Mac unzip issues #94

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading