diff options
author | NoisyCoil <noisycoil@tutanota.com> | 2022-11-01 09:30:37 +0100 |
---|---|---|
committer | NoisyCoil <noisycoil@tutanota.com> | 2022-11-01 09:30:37 +0100 |
commit | 48aa621869cf1edb125ddf519ff1e12e7f35e9be (patch) | |
tree | 48cde4eb12216dff3c41c968a289f664e065cb95 /desktop/scripts | |
parent | cc66ebb3491e02c2ba92e57c9ac12530aaad0a4b (diff) | |
parent | 8427252fb8f101ed3e7ad5bbd1251c711469170c (diff) | |
download | onionshare-48aa621869cf1edb125ddf519ff1e12e7f35e9be.tar.gz onionshare-48aa621869cf1edb125ddf519ff1e12e7f35e9be.zip |
Merge branch 'pyside6' into pyside6-package
Diffstat (limited to 'desktop/scripts')
-rw-r--r-- | desktop/scripts/get-tor.py | 109 |
1 files changed, 44 insertions, 65 deletions
diff --git a/desktop/scripts/get-tor.py b/desktop/scripts/get-tor.py index 88cb2fa5..dbda23d7 100644 --- a/desktop/scripts/get-tor.py +++ b/desktop/scripts/get-tor.py @@ -19,6 +19,9 @@ expected_win64_sha256 = ( expected_macos_sha256 = ( "b80d3dba83b343fab7a6c8fc08440b2751da1ac12f86fe593da8e74069e4d7f6" ) +expected_macos_aarch64_sha256 = ( + "0ff0badfaab6ec797b80998c933205f5d1083828ff08bf190780c16ab71a76bf" +) expected_linux64_sha256 = ( "90cdce3854e9114ee7232aaa74672a2d9f3a40b6fa8ac33971f586ee3a3cf75a" ) @@ -29,6 +32,8 @@ win64_url = f"https://dist.torproject.org/torbrowser/{torbrowser_version}/torbro win64_filename = f"torbrowser-install-win64-{torbrowser_version}_en-US.exe" macos_url = f"https://dist.torproject.org/torbrowser/{torbrowser_version}/TorBrowser-{torbrowser_version}-osx64_en-US.dmg" macos_filename = f"TorBrowser-{torbrowser_version}-osx64_en-US.dmg" +macos_aarch64_url = f"https://www.torproject.org/dist/torbrowser/12.0a4/TorBrowser-12.0a4-osx64_ALL.dmg" +macos_aarch64_filename = f"TorBrowser-12.0a4-osx64_ALL.dmg" linux64_url = f"https://dist.torproject.org/torbrowser/{torbrowser_version}/tor-browser-linux64-{torbrowser_version}_en-US.tar.xz" linux64_filename = f"tor-browser-linux64-{torbrowser_version}_en-US.tar.xz" @@ -205,90 +210,64 @@ def get_tor_macos_x86_64(): def get_tor_macos_aarch64(): - # Versions and shasums - torbin_version = "0.4.7.10" - libevent_version = "2.1.12" - expected_torbin_sha256 = "01abf45e673649f6c0fee07f1fcffcce82b2bdb5f5db0c15a9cdcfda6e5eb187" - expected_geoip_sha256 = "7e777efc194ea9788171636085b19875d19397d3249fbb88136534037a3dc38f" - expected_geoip6_sha256 = "f11bd1d7546cad00b6db0a1594f3ac1daf9f541004fd7efb5414e068693d6add" - expected_libevent_sha256 = "2de95fd8cf8849028f9146f04cbde8cc7399ba0191b65ab92825a9a5e691a464" - # Build paths + dmg_tor_path = os.path.join( + "/Volumes", "Tor Browser", "Tor Browser.app", "Contents" + ) + dmg_path = os.path.join(working_path, macos_aarch64_filename) dist_path = os.path.join(root_path, "onionshare", "resources", "tor") + if not os.path.exists(dist_path): + os.makedirs(dist_path, exist_ok=True) - # Make sure homebrew is installed and in path - brew_path = shutil.which("brew") - if brew_path is None: - print("brew not found in path. Homebrew must be installed") - sys.exit(-1) - brew_prefix = os.path.dirname(os.path.dirname(brew_path)) - - # Check that tor is installed, otherwise install it - tor_path = os.path.join(brew_prefix, "Cellar", "tor", torbin_version) - libevent_path = os.path.join(brew_prefix, "Cellar", "libevent", libevent_version) - torbin_path = os.path.join(tor_path, "bin", "tor") - if not os.path.exists(torbin_path): - print(f"Installing tor v{torbin_version}...") - if subprocess.call([os.path.join(brew_path), "install", "tor"]) != 0: - print(f"Could not install tor using homebrew") - sys.exit(-1) - - # Compute the hashes - torbin_data = open(torbin_path, "rb").read() - torbin_sha256 = hashlib.sha256(torbin_data).hexdigest() - geoip_data = open( - os.path.join(tor_path, "share", "tor", "geoip"), - "rb").read() - geoip_sha256 = hashlib.sha256(geoip_data).hexdigest() - geoip6_data = open( - os.path.join(tor_path, "share", "tor", "geoip6"), - "rb").read() - geoip6_sha256 = hashlib.sha256(geoip6_data).hexdigest() - libeventlib_path = os.path.join(libevent_path, "lib", "libevent-2.1.7.dylib") - libevent_data = open(libeventlib_path, "rb").read() - libevent_sha256 = hashlib.sha256(libevent_data).hexdigest() - - # Compare the hashes - if torbin_sha256 != expected_torbin_sha256: - print("ERROR! The sha256 doesn't match (tor):") - print("expected: {}".format(expected_torbin_sha256)) - print(" actual: {}".format(torbin_sha256)) - sys.exit(-1) - if geoip_sha256 != expected_geoip_sha256: - print("ERROR! The sha256 doesn't match (geoip):") - print("expected: {}".format(expected_geoip_sha256)) - print(" actual: {}".format(geoip_sha256)) - sys.exit(-1) - if geoip6_sha256 != expected_geoip6_sha256: - print("ERROR! The sha256 doesn't match (geoip6):") - print("expected: {}".format(expected_geoip6_sha256)) - print(" actual: {}".format(geoip6_sha256)) - sys.exit(-1) - if libevent_sha256 != expected_libevent_sha256: - print("ERROR! The sha256 doesn't match (libevent):") - print("expected: {}".format(expected_libevent_sha256)) - print(" actual: {}".format(libevent_sha256)) + # Make sure the working folder exists + if not os.path.exists(working_path): + os.makedirs(working_path) + + # Make sure the zip is downloaded + if not os.path.exists(dmg_path): + print("Downloading {}".format(macos_aarch64_url)) + r = requests.get(macos_aarch64_url) + open(dmg_path, "wb").write(r.content) + dmg_sha256 = hashlib.sha256(r.content).hexdigest() + else: + dmg_data = open(dmg_path, "rb").read() + dmg_sha256 = hashlib.sha256(dmg_data).hexdigest() + + # Compare the hash + if dmg_sha256 != expected_macos_aarch64_sha256: + print("ERROR! The sha256 doesn't match:") + print("expected: {}".format(expected_macos_aarch64_sha256)) + print(" actual: {}".format(dmg_sha256)) sys.exit(-1) - + + # Mount the dmg, copy data to the working path + subprocess.call(["hdiutil", "attach", dmg_path]) + # Copy into dist shutil.copyfile( - os.path.join(tor_path, "share", "tor", "geoip"), + os.path.join(dmg_tor_path, "Resources", "TorBrowser", "Tor", "geoip"), os.path.join(dist_path, "geoip"), ) shutil.copyfile( - os.path.join(tor_path, "share", "tor", "geoip6"), + os.path.join(dmg_tor_path, "Resources", "TorBrowser", "Tor", "geoip6"), os.path.join(dist_path, "geoip6"), ) shutil.copyfile( - torbin_path, + os.path.join(dmg_tor_path, "MacOS", "Tor", "tor.real"), os.path.join(dist_path, "tor"), ) os.chmod(os.path.join(dist_path, "tor"), 0o755) shutil.copyfile( - libeventlib_path, + os.path.join(dmg_tor_path, "MacOS", "Tor", "libevent-2.1.7.dylib"), os.path.join(dist_path, "libevent-2.1.7.dylib"), ) + # Eject dmg + subprocess.call(["diskutil", "eject", "/Volumes/Tor Browser"]) + + # Fetch the built-in bridges + update_tor_bridges() + def get_tor_linux64(): # Build paths |