Merge pull request #2030 from onionshare/mig/fix-get-tor-url

Update get-tor.py script to use platform-specific json files
This commit is contained in:
Saptak Sengupta 2025-04-01 17:55:47 +05:30 committed by GitHub
commit 16644b009f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 11 deletions

View File

@ -41,7 +41,7 @@ jobs:
key: ${{ runner.os }}-win64-tor-${{ hashFiles('desktop/scripts/get-tor.py') }}
- name: Get tor binaries from Tor Browser (64-bit)
run: cd desktop && C:\hostedtoolcache\windows\Python\3.12.8\x64\Scripts\poetry run python .\scripts\get-tor.py win64
run: cd desktop && C:\hostedtoolcache\windows\Python\3.12.8\x64\Scripts\poetry run python .\scripts\get-tor.py windows-x86_64
- name: Install Go >=1.23.5
uses: actions/setup-go@v5

View File

@ -39,7 +39,7 @@ poetry install
- Download and install [7-Zip (x64)](https://7-zip.org/). Add `C:\Program Files\7-Zip` to your path.
- Download and install [gpg4win](https://gpg4win.org/). Add `C:\Program Files (x86)\GnuPG\bin` to your path.
Download Tor Browser and extract the binaries for your platform. The platform must be `win64`, `macos`, or `linux-x86_64`.
Download Tor Browser and extract the binaries for your platform. The platform must be `windows-x86_64`, `macos`, or `linux-x86_64`.
```sh
poetry run python ./scripts/get-tor.py [platform]

View File

@ -12,7 +12,7 @@ import tempfile
import gnupg
torbrowser_latest_url = (
"https://aus1.torproject.org/torbrowser/update_3/release/downloads.json"
"https://aus1.torproject.org/torbrowser/update_3/release"
)
tor_dev_fingerprint = "EF6E286DDA85EA2A4BA7DE684E2C6E8793298290"
@ -24,13 +24,12 @@ working_path = os.path.join(root_path, "build", "tor")
def get_latest_tor_version_urls(platform):
r = requests.get(torbrowser_latest_url)
if r.status_code != 200 or platform not in r.json()["downloads"]:
print("Tor browser latest version url not working")
sys.exit(-1)
r = requests.get(f"{torbrowser_latest_url}/download-{platform}.json")
if r.status_code != 200:
raise RuntimeError("Tor browser latest version url not working")
platform_url = r.json()["downloads"][platform]["ALL"]["binary"]
platform_sig_url = r.json()["downloads"][platform]["ALL"]["sig"]
platform_url = r.json()["binary"]
platform_sig_url = r.json()["sig"]
platform_filename = platform_url.split("/")[-1]
return platform_url, platform_filename, platform_sig_url
@ -320,7 +319,7 @@ def main(platform):
"""
Download Tor Browser and extract tor binaries
"""
valid_platforms = ["win64", "macos", "linux-x86_64"]
valid_platforms = ["windows-x86_64", "macos", "linux-x86_64"]
if platform not in valid_platforms:
click.echo(f"platform must be one of: {valid_platforms}")
return
@ -337,7 +336,7 @@ def main(platform):
)
print(f"Imported Tor GPG key: {torkey.fingerprints}")
if platform == "win64":
if platform == "windows-x86_64":
get_tor_windows(
gpg, torkey, platform_url, platform_filename, expected_platform_sig
)