From 72e3d07acb73e7578c727b466a86b6d800eb84fd Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof Date: Fri, 3 Jun 2022 09:17:28 +0200 Subject: [PATCH 1/2] Simplify primary mirror logic Assume repo_url/archive_url to be valid URL and mark it as a primary mirror. --- fdroidserver/index.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fdroidserver/index.py b/fdroidserver/index.py index fbc6a351..02443cae 100644 --- a/fdroidserver/index.py +++ b/fdroidserver/index.py @@ -713,14 +713,13 @@ def v2_repo(repodict, repodir, archive): repo["address"] = repodict["address"] repo["webBaseUrl"] = "https://f-droid.org/packages/" - if "repo_url" in common.config: - primary_mirror = common.config["repo_url"][:-len("/repo")] - if "mirrors" in repodict and primary_mirror not in repodict["mirrors"]: - repodict["mirrors"].append(primary_mirror) - if "mirrors" in repodict: repo["mirrors"] = [{"url": mirror} for mirror in repodict["mirrors"]] + # the first entry is traditionally the primary mirror + if repodict['address'] not in repodict["mirrors"]: + repo["mirrors"].insert(0, {"url": repodict['address'], "isPrimary": True}) + repo["timestamp"] = repodict["timestamp"] anti_features = load_locale("antiFeatures", repodir) From 1073dd57f79d586a35d1ca27f96026599060b57b Mon Sep 17 00:00:00 2001 From: Jochen Sprickerhof Date: Fri, 3 Jun 2022 09:35:43 +0200 Subject: [PATCH 2/2] Make webBaseUrl configurable --- fdroidserver/index.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fdroidserver/index.py b/fdroidserver/index.py index 02443cae..8e5dafd7 100644 --- a/fdroidserver/index.py +++ b/fdroidserver/index.py @@ -91,11 +91,15 @@ def make(apps, apks, repodir, archive): repodict['description'] = common.config['archive_description'] archive_url = common.config.get('archive_url', common.config['repo_url'][:-4] + 'archive') repodict['address'] = archive_url + if 'archive_web_base_url' in common.config: + repodict["webBaseUrl"] = common.config['archive_web_base_url'] urlbasepath = os.path.basename(urllib.parse.urlparse(archive_url).path) else: repodict['name'] = common.config['repo_name'] repodict['icon'] = common.config.get('repo_icon', common.default_config['repo_icon']) repodict['address'] = common.config['repo_url'] + if 'repo_web_base_url' in common.config: + repodict["webBaseUrl"] = common.config['repo_web_base_url'] repodict['description'] = common.config['repo_description'] urlbasepath = os.path.basename(urllib.parse.urlparse(common.config['repo_url']).path) @@ -711,7 +715,8 @@ def v2_repo(repodict, repodir, archive): repo["icon"] = config["archive" if archive else "repo"]["icon"] repo["address"] = repodict["address"] - repo["webBaseUrl"] = "https://f-droid.org/packages/" + if "webBaseUrl" in repodict: + repo["webBaseUrl"] = repodict["webBaseUrl"] if "mirrors" in repodict: repo["mirrors"] = [{"url": mirror} for mirror in repodict["mirrors"]]