mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Initial support for Linux 64-bit, desktop/scripts/get-tor.py for macos-aarch64
This commit is contained in:
parent
7936cb85be
commit
5479d185ca
1
.gitignore
vendored
1
.gitignore
vendored
@ -61,3 +61,4 @@ venv
|
|||||||
.python-version
|
.python-version
|
||||||
onionshare.dist-info
|
onionshare.dist-info
|
||||||
desktop/onionshare/resources/tor
|
desktop/onionshare/resources/tor
|
||||||
|
TODO*
|
||||||
|
@ -31,7 +31,9 @@ poetry install
|
|||||||
|
|
||||||
**Windows users:** Download and install 7-Zip from https://7-zip.org/download.html. [Add](https://medium.com/@kevinmarkvi/how-to-add-executables-to-your-path-in-windows-5ffa4ce61a53) `C:\Program Files (x86)\7-Zip` to your path.
|
**Windows users:** Download and install 7-Zip from https://7-zip.org/download.html. [Add](https://medium.com/@kevinmarkvi/how-to-add-executables-to-your-path-in-windows-5ffa4ce61a53) `C:\Program Files (x86)\7-Zip` to your path.
|
||||||
|
|
||||||
Download Tor Browser and extract the binaries for your platform. The platform must be `win32`, `win64`, `macos`, or `linux64`.
|
**Apple Silicon users:** Install homebrew following the instructions at https://brew.sh.
|
||||||
|
|
||||||
|
Download Tor and extract the binaries for your platform. The platform must be `win32`, `win64`, `macos-x86_64`, `macos-aarch64` or `linux64`.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
poetry run python ./scripts/get-tor.py [platform]
|
poetry run python ./scripts/get-tor.py [platform]
|
||||||
|
@ -47,7 +47,6 @@ class Application(QtWidgets.QApplication):
|
|||||||
|
|
||||||
def __init__(self, common):
|
def __init__(self, common):
|
||||||
if common.platform == "Linux" or common.platform == "BSD":
|
if common.platform == "Linux" or common.platform == "BSD":
|
||||||
self.setAttribute(QtCore.Qt.AA_X11InitThreads, True)
|
|
||||||
self.setDesktopFileName("org.onionshare.OnionShare")
|
self.setDesktopFileName("org.onionshare.OnionShare")
|
||||||
self.setOrganizationDomain("org.onionshare.OnionShare")
|
self.setOrganizationDomain("org.onionshare.OnionShare")
|
||||||
self.setOrganizationName("OnionShare")
|
self.setOrganizationName("OnionShare")
|
||||||
|
@ -144,7 +144,7 @@ def get_tor_windows(platform):
|
|||||||
update_tor_bridges()
|
update_tor_bridges()
|
||||||
|
|
||||||
|
|
||||||
def get_tor_macos():
|
def get_tor_macos_x86_64():
|
||||||
# Build paths
|
# Build paths
|
||||||
dmg_tor_path = os.path.join(
|
dmg_tor_path = os.path.join(
|
||||||
"/Volumes", "Tor Browser", "Tor Browser.app", "Contents"
|
"/Volumes", "Tor Browser", "Tor Browser.app", "Contents"
|
||||||
@ -204,6 +204,92 @@ def get_tor_macos():
|
|||||||
update_tor_bridges()
|
update_tor_bridges()
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
dist_path = os.path.join(root_path, "onionshare", "resources", "tor")
|
||||||
|
|
||||||
|
# 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))
|
||||||
|
sys.exit(-1)
|
||||||
|
|
||||||
|
# Copy into dist
|
||||||
|
shutil.copyfile(
|
||||||
|
os.path.join(tor_path, "share", "tor", "geoip"),
|
||||||
|
os.path.join(dist_path, "geoip"),
|
||||||
|
)
|
||||||
|
shutil.copyfile(
|
||||||
|
os.path.join(tor_path, "share", "tor", "geoip6"),
|
||||||
|
os.path.join(dist_path, "geoip6"),
|
||||||
|
)
|
||||||
|
shutil.copyfile(
|
||||||
|
torbin_path,
|
||||||
|
os.path.join(dist_path, "tor"),
|
||||||
|
)
|
||||||
|
os.chmod(os.path.join(dist_path, "tor"), 0o755)
|
||||||
|
shutil.copyfile(
|
||||||
|
libeventlib_path,
|
||||||
|
os.path.join(dist_path, "libevent-2.1.7.dylib"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_tor_linux64():
|
def get_tor_linux64():
|
||||||
# Build paths
|
# Build paths
|
||||||
tarball_path = os.path.join(working_path, linux64_filename)
|
tarball_path = os.path.join(working_path, linux64_filename)
|
||||||
@ -334,7 +420,7 @@ def main(platform):
|
|||||||
"""
|
"""
|
||||||
Download Tor Browser and extract tor binaries
|
Download Tor Browser and extract tor binaries
|
||||||
"""
|
"""
|
||||||
valid_platforms = ["win32", "win64", "macos", "linux64"]
|
valid_platforms = ["win32", "win64", "macos-x86_64", "macos-aarch64", "linux64"]
|
||||||
if platform not in valid_platforms:
|
if platform not in valid_platforms:
|
||||||
click.echo(f"platform must be one of: {valid_platforms}")
|
click.echo(f"platform must be one of: {valid_platforms}")
|
||||||
return
|
return
|
||||||
@ -343,8 +429,10 @@ def main(platform):
|
|||||||
get_tor_windows(platform)
|
get_tor_windows(platform)
|
||||||
elif platform == "win64":
|
elif platform == "win64":
|
||||||
get_tor_windows(platform)
|
get_tor_windows(platform)
|
||||||
elif platform == "macos":
|
elif platform == "macos-x86_64":
|
||||||
get_tor_macos()
|
get_tor_macos_x86_64()
|
||||||
|
elif platform == "macos-aarch64":
|
||||||
|
get_tor_macos_aarch64()
|
||||||
elif platform == "linux64":
|
elif platform == "linux64":
|
||||||
get_tor_linux64()
|
get_tor_linux64()
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user