kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Serve the self-hosted APT repo from apt.learningequality.org and migrate existing consumers

Open rtibbles opened this issue 5 months ago • 5 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

Move the self-hosted Debian/Ubuntu APT repo — currently served per-installer at learningequality.github.io/kolibri-installer-debian/ and …/kolibri-server/ — onto a self-owned subdomain, apt.learningequality.org, and self-migrate the existing installed base onto it with no user action. The subdomain becomes the canonical, backend-independent APT URL.

Piloting on kolibri-server (low-risk); a hard prerequisite for kolibri-installer-debian's seamless publish.

Complexity: High · Target branch: develop

Context

The self-hosted APT repos are the documented install method for Debian 13 (Trixie) and up (via manual curl pubkey.asc + echo "deb …" > sources.list.d/…) at:

  • deb [signed-by=…] https://learningequality.github.io/kolibri-installer-debian/ stable main
  • deb [signed-by=…] https://learningequality.github.io/kolibri-server/ stable main

Researched constraints that shape the mechanism:

  • The source is manually added, not package-owned, so it can't be rewritten by simply upgrading a config package that owns it.
  • apt follows real HTTP 301/302 redirects (Location header, since 0.7.21) and GPG-verifies against the signed-by key regardless of host — but a github.io path can't do a 301 redirect.
  • Archived repos keep their Pages serving (read-only, frozen at last push) — so once the old repos are archived at their cutover state, stragglers still resolve the old URL and still get the cutover release whenever they next upgrade.
  • Kubernetes' apt.kubernetes.io→pkgs.k8s.io move shows the failure mode: a manual source on a non-redirectable host, not tied to an auto-upgrading package, forced a manual cutover that broke stragglers. Ours avoids that because the source rides with kolibri/kolibri-server, which auto-upgrade.

The Change

  • A reprepro APT-repo publish workflow that:

    • syncs the current repo state (db/, pool/, dists/, conf/) down from the bucket, adds the new .deb(s) with reprepro includedeb stable, and syncs back up (read-modify-write);
    • so packages and versions from prior releases persist — a release shipping only kolibri leaves the existing kolibri-server package live;
    • syncs with gcloud storage rsync (-c -d);
    • authenticates via google-github-actions/auth + setup-gcloud, reusing release_kolibri.yml's GH_UPLOADER_GCP_SA_CREDENTIALS;
    • targets KOLIBRI_PUBLIC_RELEASE_GCS_BUCKET at an apt/ path;
    • uses rsync (not the upload-cloud-storage action, which is upload-only) so it can do the sync-down leg;
    • signs the repo (conf/distributions with a stable suite + exported pubkey.asc);
    • serializes publishes with a concurrency lock so concurrent releases can't clobber the shared repo state;
    • replaces server's Pages-artifact deploy and debian's gh-pages force-push (which rebuilt fresh each release) with one unified, stateful publish.
  • A kolibri-archive-keyring repo-config package (its own debian/ packaging under platforms/, the packages-microsoft-prod pattern) that:

    • ships an apt source file (/etc/apt/sources.list.d/kolibri.sources) pointing at apt.learningequality.org, plus the signing key;
    • replaces the manual curl+echo recipe with one downloadable package;
    • carries future URL/key changes as its own updates.

    A new user then installs with:

    curl -fsSLO https://apt.learningequality.org/kolibri-archive-keyring.deb
    sudo dpkg -i kolibri-archive-keyring.deb
    sudo apt update && sudo apt install kolibri
    
  • A postinst cutover snippet, written for the kolibri-server package here, that:

    • if a github.io Kolibri source exists in /etc/apt/sources.list.d/, replaces it with the keyring package's .sources (or rewrites the URL);
    • is a no-op when absent (e.g. Launchpad-PPA installs);
    • is reused by debian for the kolibri package in its own migration.
  • A one-shot, committed seed script that:

    • pushes a given .deb to the old github.io gh-pages branch(es) exactly once;
    • is run for the cutover release — the first release after this merges, carrying the postinst;
    • lets existing consumers on the old URL receive it and self-migrate;
    • is documented as run-once, not part of the ongoing release.

Out of Scope

  • The installer migrations (server, debian) themselves — they publish to this host.
  • The Launchpad PPA path — unaffected; this is the self-hosted repo only.
  • server/debian package consolidation — #141.
  • Bucket-hosting the backend — a later, invisible DNS switch.
  • Retaining multiple older versions of a package (reprepro Limit) — deferred; latest-per-suite for now, restore an older version if support is ever dropped.
  • Admin/ops/infra setup (subdomain + Cloudflare, secrets, running the one-shot seed, the readthedocs user-manual update, archiving the old repos) — tracked on #13720, not code here.

Acceptance Criteria

  • [ ] The publish workflow read-modify-writes the reprepro repo on the release GCS bucket's apt/ path (gcloud storage rsync down → includedeb → rsync up, auth reused from release_kolibri.yml).
  • [ ] The published repo is signed with the repo key, and serves pubkey.asc.
  • [ ] A second publish adds its .deb without dropping packages/versions already in the repo (publish A, then B, then both resolve).
  • [ ] The kolibri-archive-keyring .deb builds and installs the apt source file + signing key.
  • [ ] After installing it, apt update works with no manually-added source line.
  • [ ] kolibri-server's postinst rewrites an existing github.io source to the new URL (verified on Debian 13).
  • [ ] The postinst is a no-op when no github.io source is present (Launchpad-PPA install).
  • [ ] The seed script pushes a .deb to the old gh-pages branch(es), safe to run once.
  • [ ] The seed script is documented as run-once.
  • [ ] End-to-end on Debian 13: a client on the old github.io source, after upgrading to the cutover release, is rewritten to apt.learningequality.org and fetches later updates from there — no manual action.

References

  • Docs (Debian 13 self-hosted-repo warning): https://kolibri.readthedocs.io/en/latest/install.html
  • apt follows HTTP redirects: https://bugs.launchpad.net/bugs/18645
  • GitHub Pages can't emit real 301s: https://github.com/orgs/community/discussions/22407
  • Archived repos keep Pages serving: https://docs.github.com/en/repositories/archiving-a-github-repository
  • Repo-config-package prior art: https://github.com/microsoft/linux-package-repositories
  • Migration cautionary tale — Kubernetes: https://kubernetes.io/blog/2023/08/31/legacy-package-repository-deprecation/

AI usage

Used Claude Code to research and draft this issue; I drove scope and decisions. Claude verified the mechanism's constraints against GitHub's own docs, the Launchpad apt bug tracker, and the reprepro/GCS documentation.

rtibbles avatar Jul 05 '26 00:07 rtibbles

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 23 '26 23:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 24 '26 07:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 25 '26 00:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 30 '26 01:07 rtibblesbot

Fixed in #15054 - remaining tasks will be handled out of band of code changes.

rtibbles avatar Aug 04 '26 19:08 rtibbles