From a2d27ba15ef5c4f39f87d00ff483fea0d3abd60d Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 26 Nov 2024 11:17:46 +0100 Subject: [PATCH 1/4] install: remove forgotten print() --- fdroidserver/install.py | 1 - 1 file changed, 1 deletion(-) diff --git a/fdroidserver/install.py b/fdroidserver/install.py index 4832049b..1fb1e6fb 100644 --- a/fdroidserver/install.py +++ b/fdroidserver/install.py @@ -80,7 +80,6 @@ def download_apk(appid='org.fdroid.fdroid', privacy_mode=False): # prefer APK in default release channel preferred_version = version break - print('skipping', version) mirrors = common.append_filename_to_mirrors( preferred_version['file']['name'][1:], common.FDROIDORG_MIRRORS From d2cc0203362cddd151e7d1ff36f260849b8ec792 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 26 Nov 2024 15:12:12 +0100 Subject: [PATCH 2/4] install: fix broken URL building logic for Maven Central The append logic was wrong, so it was trying to download URLs like: https://repo.maven.apache.org/maven2/org/fdroid/fdroid/F-Droid/maven-metadata.xml/org/fdroid/fdroid/F-Droid/1.20.0/F-Droid-1.20.0.apk Which should be: https://repo.maven.apache.org/maven2/org/fdroid/fdroid/F-Droid/1.20.0/F-Droid-1.20.0.apk Can be manually tested using: `test_download_fdroid_apk=1 python -m unittest -k test_download_fdroid_apk_from_maven` --- fdroidserver/install.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fdroidserver/install.py b/fdroidserver/install.py index 1fb1e6fb..529e36dc 100644 --- a/fdroidserver/install.py +++ b/fdroidserver/install.py @@ -136,10 +136,11 @@ def download_fdroid_apk_from_maven(privacy_mode=False): mirrors = MAVEN_CENTRAL_MIRRORS[:2] # skip the Google servers else: mirrors = MAVEN_CENTRAL_MIRRORS - mirrors = common.append_filename_to_mirrors( - os.path.join(path, 'maven-metadata.xml'), mirrors + metadata = net.download_using_mirrors( + common.append_filename_to_mirrors( + os.path.join(path, 'maven-metadata.xml'), mirrors + ) ) - metadata = net.download_using_mirrors(mirrors) version = XMLElementTree.parse(metadata).getroot().findall('*.//latest')[0].text mirrors = common.append_filename_to_mirrors( os.path.join(path, version, f'F-Droid-{version}.apk'), mirrors From 8c81033ea32f4804afb3b19d73f4c4f3e9901a8a Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 26 Nov 2024 15:20:06 +0100 Subject: [PATCH 3/4] FDroidPopenBytes: do not crash if options are not set This makes writing test cases a lot easier. For example: ====================================================================== ERROR: test_devices (tests.test_install.InstallTest.test_devices) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/hans/code/fdroid/server/tests/test_install.py", line 31, in test_devices devices = fdroidserver.install.devices() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/hans/code/fdroid/server/fdroidserver/install.py", line 225, in devices p = common.SdkToolsPopen(['adb', "devices"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/hans/code/fdroid/server/fdroidserver/common.py", line 2921, in SdkToolsPopen return FDroidPopen([abscmd] + commands[1:], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/hans/code/fdroid/server/fdroidserver/common.py", line 3024, in FDroidPopen result = FDroidPopenBytes(commands, cwd, envs, output, stderr_to_stdout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/hans/code/fdroid/server/fdroidserver/common.py", line 2987, in FDroidPopenBytes if output and options.verbose: ^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'verbose' --- fdroidserver/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 6a24c74e..a6cf2009 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -2976,7 +2976,7 @@ def FDroidPopenBytes(commands, cwd=None, envs=None, output=True, stderr_to_stdou while not stdout_reader.eof(): while not stdout_queue.empty(): line = stdout_queue.get() - if output and options.verbose: + if output and options and options.verbose: # Output directly to console sys.stderr.buffer.write(line) sys.stderr.flush() From 8fc340aaca6d7401cda5e71394d682b787fb65a3 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 26 Nov 2024 15:31:47 +0100 Subject: [PATCH 4/4] install: fix download dir when fetching from GitHub Releases --- fdroidserver/install.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fdroidserver/install.py b/fdroidserver/install.py index 529e36dc..74754520 100644 --- a/fdroidserver/install.py +++ b/fdroidserver/install.py @@ -115,7 +115,8 @@ def download_fdroid_apk_from_github(privacy_mode=False): token = None gh = github.GithubApi(token, 'https://github.com/f-droid/fdroidclient') latest_apk = gh.get_latest_apk() - return net.download_file(latest_apk) + filename = os.path.basename(latest_apk) + return net.download_file(latest_apk, os.path.join(common.get_cachedir(), filename)) def download_fdroid_apk_from_ipns(privacy_mode=False):