mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Make OnionShare briefcase work in macOS
This commit is contained in:
parent
d9153758cd
commit
b2f30e90b3
@ -77,7 +77,9 @@ class Common:
|
|||||||
os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))),
|
os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))),
|
||||||
"resources",
|
"resources",
|
||||||
)
|
)
|
||||||
return os.path.join(resources_path, filename)
|
path = os.path.join(resources_path, filename)
|
||||||
|
self.log("Common", "get_resource_path", path)
|
||||||
|
return path
|
||||||
|
|
||||||
def get_tor_paths(self):
|
def get_tor_paths(self):
|
||||||
if self.platform == "Linux":
|
if self.platform == "Linux":
|
||||||
@ -93,26 +95,11 @@ class Common:
|
|||||||
tor_geo_ip_file_path = os.path.join(base_path, "Data", "Tor", "geoip")
|
tor_geo_ip_file_path = os.path.join(base_path, "Data", "Tor", "geoip")
|
||||||
tor_geo_ipv6_file_path = os.path.join(base_path, "Data", "Tor", "geoip6")
|
tor_geo_ipv6_file_path = os.path.join(base_path, "Data", "Tor", "geoip6")
|
||||||
elif self.platform == "Darwin":
|
elif self.platform == "Darwin":
|
||||||
if os.path.basename(sys.argv[0]) == "onionshare-cli":
|
tor_path = shutil.which("tor")
|
||||||
tor_path = shutil.which("tor")
|
obfs4proxy_file_path = shutil.which("obfs4proxy")
|
||||||
obfs4proxy_file_path = shutil.which("obfs4proxy")
|
prefix = os.path.dirname(os.path.dirname(tor_path))
|
||||||
prefix = os.path.dirname(os.path.dirname(tor_path))
|
tor_geo_ip_file_path = os.path.join(prefix, "share/tor/geoip")
|
||||||
tor_geo_ip_file_path = os.path.join(prefix, "share/tor/geoip")
|
tor_geo_ipv6_file_path = os.path.join(prefix, "share/tor/geoip6")
|
||||||
tor_geo_ipv6_file_path = os.path.join(prefix, "share/tor/geoip6")
|
|
||||||
else:
|
|
||||||
base_path = os.path.dirname(
|
|
||||||
os.path.dirname(os.path.dirname(self.get_resource_path("")))
|
|
||||||
)
|
|
||||||
tor_path = os.path.join(base_path, "Resources", "Tor", "tor")
|
|
||||||
tor_geo_ip_file_path = os.path.join(
|
|
||||||
base_path, "Resources", "Tor", "geoip"
|
|
||||||
)
|
|
||||||
tor_geo_ipv6_file_path = os.path.join(
|
|
||||||
base_path, "Resources", "Tor", "geoip6"
|
|
||||||
)
|
|
||||||
obfs4proxy_file_path = os.path.join(
|
|
||||||
base_path, "Resources", "Tor", "obfs4proxy"
|
|
||||||
)
|
|
||||||
elif self.platform == "BSD":
|
elif self.platform == "BSD":
|
||||||
tor_path = "/usr/local/bin/tor"
|
tor_path = "/usr/local/bin/tor"
|
||||||
tor_geo_ip_file_path = "/usr/local/share/tor/geoip"
|
tor_geo_ip_file_path = "/usr/local/share/tor/geoip"
|
||||||
|
@ -17,6 +17,20 @@ If you're using Linux, install `tor` and `obfs4proxy` from either the [official
|
|||||||
|
|
||||||
#### macOS
|
#### macOS
|
||||||
|
|
||||||
|
Download and install Python 3.9.0 from https://www.python.org/downloads/release/python-390/. I downloaded `python-3.9.0-macosx10.9.pkg`. (You may need to also run `/Applications/Python\ 3.9/Install\ Certificates.command`.)
|
||||||
|
|
||||||
|
Install some python dependencies:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pip3 install --user poetry requests
|
||||||
|
```
|
||||||
|
|
||||||
|
Download Tor Browser and extract the binaries:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./scripts/get-tor-osx.py
|
||||||
|
```
|
||||||
|
|
||||||
#### Windows
|
#### Windows
|
||||||
|
|
||||||
These instructions include adding folders to the path in Windows. To do this, go to Start and type "advanced system settings", and open "View advanced system settings" in the Control Panel. Click Environment Variables. Under "System variables" double-click on Path. From there you can add and remove folders that are available in the PATH.
|
These instructions include adding folders to the path in Windows. To do this, go to Start and type "advanced system settings", and open "View advanced system settings" in the Control Panel. Click Environment Variables. Under "System variables" double-click on Path. From there you can add and remove folders that are available in the PATH.
|
||||||
@ -25,7 +39,7 @@ Download Python 3.8.6, 32-bit (x86) from https://www.python.org/downloads/releas
|
|||||||
|
|
||||||
Download and install 7-Zip from http://www.7-zip.org/download.html. I downloaded `7z1900.exe`. Add `C:\Program Files (x86)\7-Zip` to your path.
|
Download and install 7-Zip from http://www.7-zip.org/download.html. I downloaded `7z1900.exe`. Add `C:\Program Files (x86)\7-Zip` to your path.
|
||||||
|
|
||||||
Download Tor Browser and extract the binaries by running:
|
Download Tor Browser and extract the binaries:
|
||||||
|
|
||||||
```
|
```
|
||||||
pip install requests
|
pip install requests
|
||||||
|
41
desktop/scripts/get-tor-osx.py
Normal file → Executable file
41
desktop/scripts/get-tor-osx.py
Normal file → Executable file
@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""
|
"""
|
||||||
OnionShare | https://onionshare.org/
|
OnionShare | https://onionshare.org/
|
||||||
@ -36,10 +37,10 @@ import requests
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
dmg_url = "https://archive.torproject.org/tor-package-archive/torbrowser/10.0/TorBrowser-10.0-osx64_en-US.dmg"
|
dmg_url = "https://archive.torproject.org/tor-package-archive/torbrowser/10.0.2/TorBrowser-10.0.2-osx64_en-US.dmg"
|
||||||
dmg_filename = "TorBrowser-10.0-osx64_en-US.dmg"
|
dmg_filename = "TorBrowser-10.0.2-osx64_en-US.dmg"
|
||||||
expected_dmg_sha256 = (
|
expected_dmg_sha256 = (
|
||||||
"4e1ca7068bc29d5e8ffba85ecc8fec36c52ae582faea67bcdf445cd57192fb08"
|
"ac8d28f6f8d92e220f72ef7b0cb2bba45d5e0d4b243dc50806e33e08278e7730"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Build paths
|
# Build paths
|
||||||
@ -51,7 +52,9 @@ def main():
|
|||||||
"/Volumes", "Tor Browser", "Tor Browser.app", "Contents"
|
"/Volumes", "Tor Browser", "Tor Browser.app", "Contents"
|
||||||
)
|
)
|
||||||
dmg_path = os.path.join(working_path, dmg_filename)
|
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, "src", "onionshare", "resources", "tor")
|
||||||
|
if not os.path.exists(dist_path):
|
||||||
|
os.makedirs(dist_path, exist_ok=True)
|
||||||
|
|
||||||
# Make sure the working folder exists
|
# Make sure the working folder exists
|
||||||
if not os.path.exists(working_path):
|
if not os.path.exists(working_path):
|
||||||
@ -77,46 +80,30 @@ def main():
|
|||||||
# Mount the dmg, copy data to the working path
|
# 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"))
|
|
||||||
|
|
||||||
# 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)
|
|
||||||
|
|
||||||
# Copy into dist
|
# Copy into dist
|
||||||
shutil.copyfile(
|
shutil.copyfile(
|
||||||
os.path.join(dmg_tor_path, "Resources", "TorBrowser", "Tor", "geoip"),
|
os.path.join(dmg_tor_path, "Resources", "TorBrowser", "Tor", "geoip"),
|
||||||
os.path.join(dist_path, "Resources", "Tor", "geoip"),
|
os.path.join(dist_path, "geoip"),
|
||||||
)
|
)
|
||||||
shutil.copyfile(
|
shutil.copyfile(
|
||||||
os.path.join(dmg_tor_path, "Resources", "TorBrowser", "Tor", "geoip6"),
|
os.path.join(dmg_tor_path, "Resources", "TorBrowser", "Tor", "geoip6"),
|
||||||
os.path.join(dist_path, "Resources", "Tor", "geoip6"),
|
os.path.join(dist_path, "geoip6"),
|
||||||
)
|
)
|
||||||
os.chmod(os.path.join(dist_path, "Resources", "Tor", "tor"), 0o755)
|
|
||||||
shutil.copyfile(
|
shutil.copyfile(
|
||||||
os.path.join(dmg_tor_path, "MacOS", "Tor", "tor.real"),
|
os.path.join(dmg_tor_path, "MacOS", "Tor", "tor.real"),
|
||||||
os.path.join(dist_path, "MacOS", "Tor", "tor.real"),
|
os.path.join(dist_path, "tor"),
|
||||||
)
|
)
|
||||||
|
os.chmod(os.path.join(dist_path, "tor"), 0o755)
|
||||||
shutil.copyfile(
|
shutil.copyfile(
|
||||||
os.path.join(dmg_tor_path, "MacOS", "Tor", "libevent-2.1.7.dylib"),
|
os.path.join(dmg_tor_path, "MacOS", "Tor", "libevent-2.1.7.dylib"),
|
||||||
os.path.join(dist_path, "MacOS", "Tor", "libevent-2.1.7.dylib"),
|
os.path.join(dist_path, "libevent-2.1.7.dylib"),
|
||||||
)
|
)
|
||||||
os.chmod(os.path.join(dist_path, "MacOS", "Tor", "tor.real"), 0o755)
|
|
||||||
# obfs4proxy binary
|
# obfs4proxy binary
|
||||||
shutil.copyfile(
|
shutil.copyfile(
|
||||||
os.path.join(dmg_tor_path, "MacOS", "Tor", "PluggableTransports", "obfs4proxy"),
|
os.path.join(dmg_tor_path, "MacOS", "Tor", "PluggableTransports", "obfs4proxy"),
|
||||||
os.path.join(dist_path, "Resources", "Tor", "obfs4proxy"),
|
os.path.join(dist_path, "obfs4proxy"),
|
||||||
)
|
)
|
||||||
os.chmod(os.path.join(dist_path, "Resources", "Tor", "obfs4proxy"), 0o755)
|
os.chmod(os.path.join(dist_path, "obfs4proxy"), 0o755)
|
||||||
|
|
||||||
# Eject dmg
|
# Eject dmg
|
||||||
subprocess.call(["diskutil", "eject", "/Volumes/Tor Browser"])
|
subprocess.call(["diskutil", "eject", "/Volumes/Tor Browser"])
|
||||||
|
@ -34,10 +34,10 @@ import requests
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
exe_url = "https://archive.torproject.org/tor-package-archive/torbrowser/10.0/torbrowser-install-10.0_en-US.exe"
|
exe_url = "https://archive.torproject.org/tor-package-archive/torbrowser/10.0.2/torbrowser-install-10.0.2_en-US.exe"
|
||||||
exe_filename = "torbrowser-install-10.0_en-US.exe"
|
exe_filename = "torbrowser-install-10.0.2_en-US.exe"
|
||||||
expected_exe_sha256 = (
|
expected_exe_sha256 = (
|
||||||
"3d1a337da0e6eae32071e6de21963ba628a1a0939477bf823aa7df9051215410"
|
"c685c550fc420c39cbe40e453f2201789af5f64e7b024c9339c2a3bd01e61c2d"
|
||||||
)
|
)
|
||||||
# Build paths
|
# Build paths
|
||||||
root_path = os.path.dirname(
|
root_path = os.path.dirname(
|
||||||
@ -69,22 +69,26 @@ def main():
|
|||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
# Extract the bits we need from the exe
|
# Extract the bits we need from the exe
|
||||||
subprocess.Popen([
|
subprocess.Popen(
|
||||||
"7z",
|
[
|
||||||
"e",
|
"7z",
|
||||||
"-y",
|
"e",
|
||||||
exe_path,
|
"-y",
|
||||||
"Browser\TorBrowser\Tor",
|
exe_path,
|
||||||
"-o%s" % os.path.join(working_path, "Tor"),
|
"Browser\TorBrowser\Tor",
|
||||||
]).wait()
|
"-o%s" % os.path.join(working_path, "Tor"),
|
||||||
subprocess.Popen([
|
]
|
||||||
"7z",
|
).wait()
|
||||||
"e",
|
subprocess.Popen(
|
||||||
"-y",
|
[
|
||||||
exe_path,
|
"7z",
|
||||||
"Browser\TorBrowser\Data\Tor\geoip*",
|
"e",
|
||||||
"-o%s" % os.path.join(working_path, "Data"),
|
"-y",
|
||||||
]).wait()
|
exe_path,
|
||||||
|
"Browser\TorBrowser\Data\Tor\geoip*",
|
||||||
|
"-o%s" % os.path.join(working_path, "Data"),
|
||||||
|
]
|
||||||
|
).wait()
|
||||||
|
|
||||||
# Copy into the onionshare resources
|
# Copy into the onionshare resources
|
||||||
if os.path.exists(dist_path):
|
if os.path.exists(dist_path):
|
||||||
|
@ -344,17 +344,11 @@ class GuiCommon:
|
|||||||
tor_geo_ip_file_path = os.path.join(base_path, "Data", "Tor", "geoip")
|
tor_geo_ip_file_path = os.path.join(base_path, "Data", "Tor", "geoip")
|
||||||
tor_geo_ipv6_file_path = os.path.join(base_path, "Data", "Tor", "geoip6")
|
tor_geo_ipv6_file_path = os.path.join(base_path, "Data", "Tor", "geoip6")
|
||||||
elif self.common.platform == "Darwin":
|
elif self.common.platform == "Darwin":
|
||||||
base_path = os.path.dirname(
|
base_path = self.get_resource_path("tor")
|
||||||
os.path.dirname(os.path.dirname(self.get_resource_path("")))
|
tor_path = os.path.join(base_path, "tor")
|
||||||
)
|
obfs4proxy_file_path = os.path.join(base_path, "obfs4proxy.exe")
|
||||||
tor_path = os.path.join(base_path, "Resources", "Tor", "tor")
|
tor_geo_ip_file_path = os.path.join(base_path, "geoip")
|
||||||
tor_geo_ip_file_path = os.path.join(base_path, "Resources", "Tor", "geoip")
|
tor_geo_ipv6_file_path = os.path.join(base_path, "geoip6")
|
||||||
tor_geo_ipv6_file_path = os.path.join(
|
|
||||||
base_path, "Resources", "Tor", "geoip6"
|
|
||||||
)
|
|
||||||
obfs4proxy_file_path = os.path.join(
|
|
||||||
base_path, "Resources", "Tor", "obfs4proxy"
|
|
||||||
)
|
|
||||||
elif self.common.platform == "BSD":
|
elif self.common.platform == "BSD":
|
||||||
tor_path = "/usr/local/bin/tor"
|
tor_path = "/usr/local/bin/tor"
|
||||||
tor_geo_ip_file_path = "/usr/local/share/tor/geoip"
|
tor_geo_ip_file_path = "/usr/local/share/tor/geoip"
|
||||||
|
Loading…
Reference in New Issue
Block a user