mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-24 06:49:44 -05:00
Put tor binaries in desktop app resources, not cli resources, and fix Windows packaging
This commit is contained in:
parent
5b2fe2019c
commit
7ece466d82
7
.gitignore
vendored
7
.gitignore
vendored
@ -56,8 +56,7 @@ venv
|
||||
# other
|
||||
.vscode
|
||||
onionshare.dist-info
|
||||
|
||||
# Tor binaries
|
||||
cli/onionshare_cli/resources/tor
|
||||
desktop/src/onionshare/resources/tor
|
||||
desktop/*.whl
|
||||
desktop/linux
|
||||
desktop/windows
|
||||
desktop/windows
|
||||
|
@ -152,7 +152,7 @@ class Onion(object):
|
||||
is necessary for status updates to reach the GUI.
|
||||
"""
|
||||
|
||||
def __init__(self, common, use_tmp_dir=False):
|
||||
def __init__(self, common, use_tmp_dir=False, get_tor_paths=None):
|
||||
self.common = common
|
||||
self.common.log("Onion", "__init__")
|
||||
|
||||
@ -167,12 +167,14 @@ class Onion(object):
|
||||
self.bundle_tor_supported = True
|
||||
|
||||
# Set the path of the tor binary, for bundled tor
|
||||
if not get_tor_paths:
|
||||
get_tor_paths = self.common.get_tor_paths
|
||||
(
|
||||
self.tor_path,
|
||||
self.tor_geo_ip_file_path,
|
||||
self.tor_geo_ipv6_file_path,
|
||||
self.obfs4proxy_file_path,
|
||||
) = self.common.get_tor_paths()
|
||||
) = get_tor_paths()
|
||||
|
||||
# The tor process
|
||||
self.tor_proc = None
|
||||
|
@ -25,39 +25,39 @@ 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.
|
||||
|
||||
Install dependencies:
|
||||
|
||||
```
|
||||
pip install requests
|
||||
```
|
||||
|
||||
Download Tor Browser and extract the binaries by running:
|
||||
|
||||
```
|
||||
cd ..\cli
|
||||
pip install requests
|
||||
python scripts\get-tor-windows.py
|
||||
```
|
||||
|
||||
### Prepare the code
|
||||
|
||||
#### All platforms
|
||||
|
||||
OnionShare uses [Briefcase](https://briefcase.readthedocs.io/en/latest/).
|
||||
|
||||
Install Briefcase dependencies by following [these instructions](https://docs.beeware.org/en/latest/tutorial/tutorial-0.html#install-dependencies).
|
||||
|
||||
Now create and/or activate a virtual environment.
|
||||
|
||||
#### Linux and macOS
|
||||
|
||||
```
|
||||
python3 -m venv venv
|
||||
. venv/bin/activate
|
||||
```
|
||||
|
||||
Or in Windows:
|
||||
#### Windows
|
||||
|
||||
```
|
||||
python -m venv venv
|
||||
venv\Scripts\activate.bat
|
||||
```
|
||||
|
||||
#### All platforms
|
||||
|
||||
While your virtual environment is active, install briefcase from pip.
|
||||
|
||||
```
|
||||
@ -92,7 +92,9 @@ xvfb-run ./tests/run.sh
|
||||
|
||||
## Making a release
|
||||
|
||||
First, build a wheel package for OnionShare CLI:
|
||||
### Linux
|
||||
|
||||
Build a wheel package for OnionShare CLI:
|
||||
|
||||
```sh
|
||||
cd onionshare/cli
|
||||
@ -115,4 +117,31 @@ Make sure the virtual environment is active, and then run `briefcase create` and
|
||||
. venv/bin/activate
|
||||
briefcase create
|
||||
briefcase build
|
||||
```
|
||||
```
|
||||
|
||||
### Windows
|
||||
|
||||
Build a wheel package for OnionShare CLI (including Tor binaries, from Tor Browser):
|
||||
|
||||
```sh
|
||||
cd onionshare\cli
|
||||
poetry install
|
||||
poetry build
|
||||
```
|
||||
|
||||
This will make a file like `dist\onionshare_cli-$VERSION-py3-none-any.whl` (except with your specific version number). Move it into `..\desktop`:
|
||||
|
||||
```
|
||||
move dist\onionshare_cli-*-py3-none-any.whl ..\desktop
|
||||
cd ..\desktop
|
||||
```
|
||||
|
||||
Make sure the virtual environment is active, and then run `briefcase create`:
|
||||
|
||||
```sh
|
||||
venv\Scripts\activate.bat
|
||||
briefcase create
|
||||
briefcase package
|
||||
```
|
||||
|
||||
TODO: Codesign
|
@ -45,7 +45,7 @@ def main():
|
||||
)
|
||||
working_path = os.path.join(root_path, "build", "tor")
|
||||
exe_path = os.path.join(working_path, exe_filename)
|
||||
dist_path = os.path.join(root_path, "onionshare_cli", "resources", "tor")
|
||||
dist_path = os.path.join(root_path, "src", "onionshare", "resources", "tor")
|
||||
|
||||
# Make sure the working folder exists
|
||||
if not os.path.exists(working_path):
|
@ -50,7 +50,7 @@ class GuiCommon:
|
||||
strings.load_strings(self.common, self.get_resource_path("locale"))
|
||||
|
||||
# Start the Onion
|
||||
self.onion = Onion(common)
|
||||
self.onion = Onion(common, get_tor_paths=self.get_tor_paths)
|
||||
|
||||
# Lock filename
|
||||
self.lock_filename = os.path.join(self.common.build_data_dir(), "lock")
|
||||
@ -328,6 +328,44 @@ class GuiCommon:
|
||||
font-style: italic;
|
||||
}""",
|
||||
}
|
||||
|
||||
def get_tor_paths(self):
|
||||
if self.common.platform == "Linux":
|
||||
tor_path = shutil.which("tor")
|
||||
obfs4proxy_file_path = shutil.which("obfs4proxy")
|
||||
prefix = os.path.dirname(os.path.dirname(tor_path))
|
||||
tor_geo_ip_file_path = os.path.join(prefix, "share/tor/geoip")
|
||||
tor_geo_ipv6_file_path = os.path.join(prefix, "share/tor/geoip6")
|
||||
elif self.common.platform == "Windows":
|
||||
base_path = self.get_resource_path("tor")
|
||||
tor_path = os.path.join(base_path, "Tor", "tor.exe")
|
||||
obfs4proxy_file_path = os.path.join(base_path, "Tor", "obfs4proxy.exe")
|
||||
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")
|
||||
elif self.common.platform == "Darwin":
|
||||
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.common.platform == "BSD":
|
||||
tor_path = "/usr/local/bin/tor"
|
||||
tor_geo_ip_file_path = "/usr/local/share/tor/geoip"
|
||||
tor_geo_ipv6_file_path = "/usr/local/share/tor/geoip6"
|
||||
obfs4proxy_file_path = "/usr/local/bin/obfs4proxy"
|
||||
|
||||
return (
|
||||
tor_path,
|
||||
tor_geo_ip_file_path,
|
||||
tor_geo_ipv6_file_path,
|
||||
obfs4proxy_file_path,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def get_resource_path(filename):
|
||||
|
@ -665,7 +665,7 @@ class SettingsDialog(QtWidgets.QDialog):
|
||||
else:
|
||||
tor_status_update_func = None
|
||||
|
||||
onion = Onion(self.common, use_tmp_dir=True)
|
||||
onion = Onion(self.common, use_tmp_dir=True, get_tor_paths=self.common.gui.get_tor_paths)
|
||||
onion.connect(
|
||||
custom_settings=settings, tor_status_update_func=tor_status_update_func,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user