diff options
Diffstat (limited to 'install/get-tor-osx.py')
-rw-r--r-- | install/get-tor-osx.py | 83 |
1 files changed, 54 insertions, 29 deletions
diff --git a/install/get-tor-osx.py b/install/get-tor-osx.py index 861dc935..c68a81a6 100644 --- a/install/get-tor-osx.py +++ b/install/get-tor-osx.py @@ -34,17 +34,24 @@ import shutil import subprocess import requests + def main(): - dmg_url = 'https://archive.torproject.org/tor-package-archive/torbrowser/8.0.8/TorBrowser-8.0.8-osx64_en-US.dmg' - dmg_filename = 'TorBrowser-8.0.8-osx64_en-US.dmg' - expected_dmg_sha256 = '1dc01b95146352593c3f18ece25f8735120565f921e22c2827df819effdddca3' + dmg_url = "https://archive.torproject.org/tor-package-archive/torbrowser/8.5.5/TorBrowser-8.5.5-osx64_en-US.dmg" + dmg_filename = "TorBrowser-8.5.5-osx64_en-US.dmg" + expected_dmg_sha256 = ( + "9c1b7840bd251a4c52f0c919991e57cafb9178c55e11fa49f83ffacce3c20511" + ) # Build paths - root_path = os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))) - working_path = os.path.join(root_path, 'build', 'tor') - dmg_tor_path = os.path.join('/Volumes', 'Tor Browser', 'Tor Browser.app', 'Contents') + root_path = os.path.dirname( + os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) + ) + working_path = os.path.join(root_path, "build", "tor") + dmg_tor_path = os.path.join( + "/Volumes", "Tor Browser", "Tor Browser.app", "Contents" + ) dmg_path = os.path.join(working_path, dmg_filename) - dist_path = os.path.join(root_path, 'dist', 'OnionShare.app', 'Contents') + dist_path = os.path.join(root_path, "dist", "OnionShare.app", "Contents") # Make sure the working folder exists if not os.path.exists(working_path): @@ -54,10 +61,10 @@ def main(): if not os.path.exists(dmg_path): print("Downloading {}".format(dmg_url)) r = requests.get(dmg_url) - open(dmg_path, 'wb').write(r.content) + open(dmg_path, "wb").write(r.content) dmg_sha256 = hashlib.sha256(r.content).hexdigest() else: - dmg_data = open(dmg_path, 'rb').read() + dmg_data = open(dmg_path, "rb").read() dmg_sha256 = hashlib.sha256(dmg_data).hexdigest() # Compare the hash @@ -68,34 +75,52 @@ def main(): sys.exit(-1) # Mount the dmg, copy data to the working path - subprocess.call(['hdiutil', 'attach', dmg_path]) + subprocess.call(["hdiutil", "attach", dmg_path]) # Make sure Resources/tor exists before copying files - if os.path.exists(os.path.join(dist_path, 'Resources', 'Tor')): - shutil.rmtree(os.path.join(dist_path, 'Resources', 'Tor')) - os.makedirs(os.path.join(dist_path, 'Resources', 'Tor')) - if os.path.exists(os.path.join(dist_path, 'MacOS', 'Tor')): - shutil.rmtree(os.path.join(dist_path, 'MacOS', 'Tor')) - os.makedirs(os.path.join(dist_path, 'MacOS', 'Tor')) + if os.path.exists(os.path.join(dist_path, "Resources", "Tor")): + shutil.rmtree(os.path.join(dist_path, "Resources", "Tor")) + os.makedirs(os.path.join(dist_path, "Resources", "Tor")) + if os.path.exists(os.path.join(dist_path, "MacOS", "Tor")): + shutil.rmtree(os.path.join(dist_path, "MacOS", "Tor")) + os.makedirs(os.path.join(dist_path, "MacOS", "Tor")) # Modify the tor script to adjust the path - tor_script = open(os.path.join(dmg_tor_path, 'Resources', 'TorBrowser', 'Tor', 'tor'), 'r').read() - tor_script = tor_script.replace('../../../MacOS/Tor', '../../MacOS/Tor') - open(os.path.join(dist_path, 'Resources', 'Tor', 'tor'), 'w').write(tor_script) + tor_script = open( + os.path.join(dmg_tor_path, "Resources", "TorBrowser", "Tor", "tor"), "r" + ).read() + tor_script = tor_script.replace("../../../MacOS/Tor", "../../MacOS/Tor") + open(os.path.join(dist_path, "Resources", "Tor", "tor"), "w").write(tor_script) # Copy into dist - shutil.copyfile(os.path.join(dmg_tor_path, 'Resources', 'TorBrowser', 'Tor', 'geoip'), os.path.join(dist_path, 'Resources', 'Tor', 'geoip')) - shutil.copyfile(os.path.join(dmg_tor_path, 'Resources', 'TorBrowser', 'Tor', 'geoip6'), os.path.join(dist_path, 'Resources', 'Tor', 'geoip6')) - os.chmod(os.path.join(dist_path, 'Resources', 'Tor', 'tor'), 0o755) - shutil.copyfile(os.path.join(dmg_tor_path, 'MacOS', 'Tor', 'tor.real'), os.path.join(dist_path, 'MacOS', 'Tor', 'tor.real')) - shutil.copyfile(os.path.join(dmg_tor_path, 'MacOS', 'Tor', 'libevent-2.1.6.dylib'), os.path.join(dist_path, 'MacOS', 'Tor', 'libevent-2.1.6.dylib')) - os.chmod(os.path.join(dist_path, 'MacOS', 'Tor', 'tor.real'), 0o755) + shutil.copyfile( + os.path.join(dmg_tor_path, "Resources", "TorBrowser", "Tor", "geoip"), + os.path.join(dist_path, "Resources", "Tor", "geoip"), + ) + shutil.copyfile( + os.path.join(dmg_tor_path, "Resources", "TorBrowser", "Tor", "geoip6"), + os.path.join(dist_path, "Resources", "Tor", "geoip6"), + ) + os.chmod(os.path.join(dist_path, "Resources", "Tor", "tor"), 0o755) + shutil.copyfile( + os.path.join(dmg_tor_path, "MacOS", "Tor", "tor.real"), + os.path.join(dist_path, "MacOS", "Tor", "tor.real"), + ) + shutil.copyfile( + os.path.join(dmg_tor_path, "MacOS", "Tor", "libevent-2.1.6.dylib"), + os.path.join(dist_path, "MacOS", "Tor", "libevent-2.1.6.dylib"), + ) + os.chmod(os.path.join(dist_path, "MacOS", "Tor", "tor.real"), 0o755) # obfs4proxy binary - shutil.copyfile(os.path.join(dmg_tor_path, 'MacOS', 'Tor', 'PluggableTransports', 'obfs4proxy'), os.path.join(dist_path, 'Resources', 'Tor', 'obfs4proxy')) - os.chmod(os.path.join(dist_path, 'Resources', 'Tor', 'obfs4proxy'), 0o755) + shutil.copyfile( + os.path.join(dmg_tor_path, "MacOS", "Tor", "PluggableTransports", "obfs4proxy"), + os.path.join(dist_path, "Resources", "Tor", "obfs4proxy"), + ) + os.chmod(os.path.join(dist_path, "Resources", "Tor", "obfs4proxy"), 0o755) # Eject dmg - subprocess.call(['diskutil', 'eject', '/Volumes/Tor Browser']) + subprocess.call(["diskutil", "eject", "/Volumes/Tor Browser"]) + -if __name__ == '__main__': +if __name__ == "__main__": main() |