diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c7721931..eae0a7df 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -340,7 +340,8 @@ fdroid build: - fdroid build --verbose --latest org.fdroid.fdroid.privileged # each `fdroid build --on-server` run expects sudo, then uninstalls it - apt-get install sudo - - fdroid build --verbose --on-server --no-tarball --latest org.fdroid.fdroid + - currentVersionCode=`python3 -c "import yaml; print(yaml.load(open('metadata/org.fdroid.fdroid.yml'))['CurrentVersionCode'])"` + - fdroid build --verbose --on-server --no-tarball org.fdroid.fdroid:$currentVersionCode # test the plugin API and specifically the fetchsrclibs plugin, which diff --git a/completion/bash-completion b/completion/bash-completion index 17db9257..dd32b30f 100644 --- a/completion/bash-completion +++ b/completion/bash-completion @@ -282,6 +282,8 @@ __complete_signatures() { __complete_options return 0;; esac + _filedir 'apk' + return 0 } __complete_signindex() { diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 41a76605..15635923 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -362,6 +362,8 @@ def read_config(opts=None): logging.debug(_("Reading '{config_file}'").format(config_file=config_file)) with open(config_file, encoding='utf-8') as fp: config = yaml.safe_load(fp) + if not config: + config = {} elif os.path.exists(old_config_file): logging.warning(_("""{oldfile} is deprecated, use {newfile}""") .format(oldfile=old_config_file, newfile=config_file)) diff --git a/fdroidserver/index.py b/fdroidserver/index.py index e14c4185..01930409 100644 --- a/fdroidserver/index.py +++ b/fdroidserver/index.py @@ -1072,7 +1072,12 @@ def download_repo_index(url_str, etag=None, verify_fingerprint=True, timeout=600 raise VerificationException(_("No fingerprint in URL.")) fingerprint = query['fingerprint'][0] - url = urllib.parse.SplitResult(url.scheme, url.netloc, url.path + '/index-v1.jar', '', '') + if url.path.endswith('/index-v1.jar'): + path = url.path[:-13].rstrip('/') + else: + path = url.path.rstrip('/') + + url = urllib.parse.SplitResult(url.scheme, url.netloc, path + '/index-v1.jar', '', '') download, new_etag = net.http_get(url.geturl(), etag, timeout) if download is None: diff --git a/tests/common.TestCase b/tests/common.TestCase index ebaad78c..83f9e3af 100755 --- a/tests/common.TestCase +++ b/tests/common.TestCase @@ -1675,6 +1675,17 @@ class CommonTest(unittest.TestCase): self.assertIsNone(config.get('stats_server')) self.assertIsNotNone(config.get('char_limits')) + def test_with_zero_size_config(self): + """It should set defaults if config file has nothing in it""" + testdir = tempfile.mkdtemp(prefix=inspect.currentframe().f_code.co_name, dir=self.tmpdir) + os.chdir(testdir) + open('config.yml', 'w').close() + self.assertTrue(os.path.exists('config.yml')) + self.assertFalse(os.path.exists('config.py')) + config = fdroidserver.common.read_config(fdroidserver.common.options) + self.assertIsNone(config.get('stats_server')) + self.assertIsNotNone(config.get('char_limits')) + def test_with_config_yml(self): """Make sure it is possible to use config.yml alone.""" testdir = tempfile.mkdtemp( diff --git a/tests/index.TestCase b/tests/index.TestCase index e012f15e..e9220a23 100755 --- a/tests/index.TestCase +++ b/tests/index.TestCase @@ -23,6 +23,7 @@ if localmodule not in sys.path: import fdroidserver.common import fdroidserver.index +import fdroidserver.net import fdroidserver.signindex import fdroidserver.publish from testcommon import TmpCwd @@ -148,6 +149,17 @@ class IndexTest(unittest.TestCase): self.assertEqual(10, len(index['packages'])) self.assertEqual('new_etag', new_etag) + @patch('fdroidserver.net.http_get') + def test_download_repo_index_url_parsing(self, mock_http_get): + mock_http_get.side_effect = lambda url, etag, timeout: (None, url) + repo_url = 'https://example.org/fdroid/repo' + index_url = 'https://example.org/fdroid/repo/index-v1.jar' + fingerprint_url = 'https://example.org/fdroid/repo?fingerprint=' + GP_FINGERPRINT + slash_url = 'https://example.org/fdroid/repo//?fingerprint=' + GP_FINGERPRINT + for url in (repo_url, index_url, fingerprint_url, slash_url): + _ignored, returned_url = fdroidserver.index.download_repo_index(url, verify_fingerprint=False) + self.assertEqual(index_url, returned_url) + def test_v1_sort_packages(self): i = [{'packageName': 'org.smssecure.smssecure',