Require FDROID_REPO_URL/FDROID_REPO_NAME so fdroid-update.sh cannot publish fdroidserver's placeholder

The published repo advertised fdroidserver's own demo values
(repo.address "https://MyFirstFDroidRepo.org/fdroid/repo", repo.name "My
First F-Droid Repo Demo") because fdroid-update.sh wrote config.yml itself
but never set repo_url/repo_name/repo_description, so fdroidserver fell
back to its template. The "Add to F-Droid" button on the generated
index.html is built from repo_url, which is how bit noticed. A publish
that succeeds while advertising the wrong URL is silently wrong -- worse
than a failed job.

Add FDROID_REPO_URL/FDROID_REPO_NAME/FDROID_REPO_DESCRIPTION environment
variables (not new positionals -- the script already has five plus
pass-through extra args). The first two are now a hard requirement, naming
the missing one; FDROID_REPO_DESCRIPTION stays optional. This is a breaking
change to a public composite action's interface, acceptable only because
weblib-viewer is the sole consumer and is updated in the same change
(weblib-viewer#26).

Also discovered while wiring this up and worth recording since it
contradicts the "no /fdroid/repo suffix" assumption in weblib's working
notes: fdroidserver's own common.py unconditionally refuses to run once
config.yml sets repo_url at all, unless it ends in the literal suffix
"/repo" -- there is no flag to disable that check, and the value is
embedded verbatim as repo.address. So FDROID_REPO_URL has to end in /repo,
and publish.sh's existing <prefix> argument has to put the published tree
under a URL path that actually ends in /repo to match, or fdroid update
refuses to run at all (checked positive) / the address points at a path
the bucket never serves (checked against the live fdroid-weblib-dev bucket
layout).

Extends test_fdroid_update.sh: config.yml carries the values, the resulting
index-v2.json has the right repo.address/name/description (not
fdroidserver's placeholder), a name with an embedded single quote survives
the YAML round-trip, and the script fails when FDROID_REPO_URL or
FDROID_REPO_NAME is absent or FDROID_REPO_URL lacks the /repo suffix.
run_tests.sh: 104 passed / 4 skipped (was 98/4).

Filed as fdroid-repo-ci#11.

Co-authored-by: bit <bit@das-labor.org>
This commit is contained in:
2026-09-09 20:23:16 +00:00
co-authored by bit
parent ec4d950e18
commit 4a25e3681a
3 changed files with 139 additions and 4 deletions
+44 -1
View File
@@ -67,8 +67,28 @@ echo "--- fault: missing password env var is refused ---"
assert_failure "fdroid-update.sh refuses when the password env var is unset" \
env -u IDX_KS_PASS bash "$here/fdroid-update.sh" "$work" index.jks indexkey IDX_KS_PASS
echo "--- revert: a real run, needs no network ---"
export IDX_KS_PASS=idxpass123
echo "--- fault: missing FDROID_REPO_URL is refused (fdroid-repo-ci#11) ---"
assert_failure "fdroid-update.sh refuses when FDROID_REPO_URL is unset" \
env -u FDROID_REPO_URL FDROID_REPO_NAME="weblib" \
bash "$here/fdroid-update.sh" "$work" index.jks indexkey IDX_KS_PASS
echo "--- fault: missing FDROID_REPO_NAME is refused (fdroid-repo-ci#11) ---"
assert_failure "fdroid-update.sh refuses when FDROID_REPO_NAME is unset" \
env -u FDROID_REPO_NAME FDROID_REPO_URL="https://example.invalid" \
bash "$here/fdroid-update.sh" "$work" index.jks indexkey IDX_KS_PASS
echo "--- fault: FDROID_REPO_URL not ending in /repo is refused by fdroidserver itself ---"
assert_failure "fdroid-update.sh (fdroidserver) refuses a repo_url without the /repo suffix" \
env FDROID_REPO_URL="https://fdroid-repo-ci-test.example.invalid" \
FDROID_REPO_NAME="fdroid-repo-ci test repo" \
bash "$here/fdroid-update.sh" "$work" index.jks indexkey IDX_KS_PASS
echo "--- revert: a real run, needs no network ---"
export FDROID_REPO_URL="https://fdroid-repo-ci-test.example.invalid/repo"
export FDROID_REPO_NAME="fdroid-repo-ci test repo"
export FDROID_REPO_DESCRIPTION="a throwaway repo built by test_fdroid_update.sh"
assert_success "fdroid-update.sh runs fdroid update successfully" \
bash "$here/fdroid-update.sh" "$work" index.jks indexkey IDX_KS_PASS
@@ -80,6 +100,17 @@ echo "--- index-v2.json is valid JSON, not just a non-empty file ---"
assert_success "index-v2.json parses as JSON" \
bash "$here/with-nixpkgs.sh" python3 python3 -c "import json; json.load(open('repo/index-v2.json'))"
echo "--- index-v2.json carries the repo metadata, not fdroidserver's placeholder ---"
assert_success "repo.address is FDROID_REPO_URL, not MyFirstFDroidRepo.org" \
bash "$here/with-nixpkgs.sh" python3 python3 -c "
import json
repo = json.load(open('repo/index-v2.json'))['repo']
assert repo['address'] == 'https://fdroid-repo-ci-test.example.invalid/repo', repo['address']
assert repo['name']['en-US'] == 'fdroid-repo-ci test repo', repo['name']
assert repo['description']['en-US'] == 'a throwaway repo built by test_fdroid_update.sh', repo['description']
assert 'MyFirstFDroidRepo' not in json.dumps(repo)
"
echo "--- index-v1.jar is a validly signed jar (its own signature, not apksigner's) ---"
assert_success "jarsigner -verify accepts the signed index" \
bash "$here/with-nixpkgs.sh" jdk21 jarsigner -verify repo/index-v1.jar
@@ -88,4 +119,16 @@ echo "--- config.yml never holds a literal password ---"
assert_failure "config.yml has no literal password (uses {env: ...} instead)" \
grep -q "idxpass123" "$work/config.yml"
echo "--- a value with an embedded single quote survives config.yml round-trip ---"
export FDROID_REPO_NAME="bit's test repo"
assert_success "fdroid-update.sh accepts a name with an embedded quote" \
bash "$here/fdroid-update.sh" "$work" index.jks indexkey IDX_KS_PASS
assert_success "the quoted name round-trips through config.yml into index-v2.json" \
bash "$here/with-nixpkgs.sh" python3 python3 -c "
import json
repo = json.load(open('repo/index-v2.json'))['repo']
assert repo['name']['en-US'] == \"bit's test repo\", repo['name']
"
export FDROID_REPO_NAME="fdroid-repo-ci test repo"
report_and_exit