From 49dcc53076f673e04f3f0cf98df1f02d5365a9c8 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 27 Feb 2024 17:07:57 +0100 Subject: [PATCH] install: download_fdroid_apk() to fetch the recommended initial APK --- fdroidserver/install.py | 12 ++++++++++++ tests/install.TestCase | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/fdroidserver/install.py b/fdroidserver/install.py index 362d5aed..3c9316e9 100644 --- a/fdroidserver/install.py +++ b/fdroidserver/install.py @@ -72,6 +72,18 @@ def download_apk(appid='org.fdroid.fdroid'): return str(f.rename(f.with_stem(f'{appid}_{versionCode}')).resolve()) +def download_fdroid_apk(): + """Directly download the current F-Droid APK and verify it. + + This downloads the "download button" link, which is the version + that is best tested for new installs. + + """ + mirror = common.FDROIDORG_MIRRORS[0] + mirror['url'] = urlunparse(urlparse(mirror['url'])._replace(path='F-Droid.apk')) + return net.download_using_mirrors([mirror]) + + def devices(): p = SdkToolsPopen(['adb', "devices"]) if p.returncode != 0: diff --git a/tests/install.TestCase b/tests/install.TestCase index cef5c022..540a2bf0 100755 --- a/tests/install.TestCase +++ b/tests/install.TestCase @@ -7,6 +7,8 @@ import os import sys import unittest +from pathlib import Path + localmodule = os.path.realpath( os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..') ) @@ -33,6 +35,11 @@ class InstallTest(unittest.TestCase): for device in devices: self.assertIsInstance(device, str) + @unittest.skipUnless(os.getenv('test_download_fdroid_apk'), 'requires net access') + def test_download_fdroid_apk(self): + f = fdroidserver.install.download_fdroid_apk() + self.assertTrue(Path(f).exists()) + if __name__ == "__main__": os.chdir(os.path.dirname(__file__))