diff --git a/.gitea/workflows/package.yml b/.gitea/workflows/package.yml index 1c5dee4..2808111 100644 --- a/.gitea/workflows/package.yml +++ b/.gitea/workflows/package.yml @@ -154,6 +154,23 @@ jobs: fi echo "release_id=$release_id" + # A pacman version is immutable: clients cache the package by name and + # repo.laxacube.ch serves it through a CDN, so a rebuild published + # under the same version leaves those caches holding bytes the index + # no longer matches, and pacman reports the file as corrupted. A + # re-run that rebuilds identical bytes stays allowed. + local_sha256="$(cut -d' ' -f1 "$PACKAGE_FILE.sha256")" + published_sha256="" + sha_url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/download/$tag/$PACKAGE_NAME.sha256" + if curl -fsSL "$sha_url" -o "$RUNNER_TEMP/published.sha256"; then + published_sha256="$(cut -d' ' -f1 "$RUNNER_TEMP/published.sha256")" + fi + if [ -n "$published_sha256" ] && [ "$published_sha256" != "$local_sha256" ]; then + echo "::error::$PACKAGE_NAME is already published with sha256 $published_sha256 but this build is $local_sha256" + echo "::error::bump pkgrel in packaging/PKGBUILD so the rebuild is published as its own version" + exit 1 + fi + # A re-run must replace its own artefacts instead of failing on them. assets="$(curl -sS -H "$auth" "$api/releases/$release_id/assets")" attach() { @@ -194,15 +211,19 @@ jobs: -H 'Content-Type: application/octet-stream' \ --data-binary "@$PACKAGE_FILE" echo - # The index is rebuilt server-side, so wait for the package before - # reporting success. + # The index is rebuilt server-side and the file is served through a + # CDN, so a HEAD is not enough: the index and the file can disagree + # for as long as the CDN caches the previous build under this name, + # and the checksum is exactly what pacman verifies before installing. url="https://repo.laxacube.ch/x86_64/$PACKAGE_NAME" + expected="$(cut -d' ' -f1 "$PACKAGE_FILE.sha256")" for _ in 1 2 3 4 5 6; do - if curl -fsSI "$url" > /dev/null; then + if [ "$(curl -fsSL "$url" | sha256sum | cut -d' ' -f1)" = "$expected" ]; then echo "published $url" exit 0 fi sleep 5 done - echo "::error::the upload was accepted but $url is not served yet" + echo "::error::$url does not serve this build (expected sha256 $expected)" + echo "::error::the CDN is probably still caching an older file under this name: purge it before re-running" exit 1 diff --git a/README.md b/README.md index fd8f61e..5a789e4 100644 --- a/README.md +++ b/README.md @@ -320,8 +320,11 @@ contrôles sur chaque PR et chaque push sur `main` qui ne modifie pas que Pour reconstruire la même version du fork (correctif de packaging), incrémentez `pkgrel` dans `packaging/PKGBUILD` puis lancez le workflow à la main (*Actions → Release → Run workflow*) : le paquet `0.1.7-2` remplace alors le -`0.1.7-1`. Une nouvelle version du fork demande `version`, `pkgver` et les deux -front-ends, avec `pkgrel=1` ; pour suivre une nouvelle version de kitty, mettre +`0.1.7-1`. Une version déjà publiée n'est jamais réécrite avec un autre build : +le workflow refuse de remplacer un paquet dont l'empreinte a changé et demande +d'incrémenter `pkgrel`, sinon les caches (CDN, pacman) servent un fichier qui ne +correspond plus à la base. Une nouvelle version du fork demande `version`, +`pkgver` et les deux front-ends, avec `pkgrel=1` ; pour suivre une nouvelle version de kitty, mettre à jour `_kittyver` et `kitty/constants.py`. La publication vers `repo.laxacube.ch` utilise le secret `REPO_TOKEN` du dépôt, la release Gitea le secret `RELEASE_TOKEN` ; sans diff --git a/packaging/README.md b/packaging/README.md index d2e731e..3e25750 100644 --- a/packaging/README.md +++ b/packaging/README.md @@ -91,6 +91,15 @@ fork, incrémentez `pkgrel` ici et lancez le workflow manuellement ; le paquet serveur. Le `PKGBUILD` lit `FWS_SOURCE_REF` (`commit=` depuis la CI) pour construire le commit publié plutôt que la tête de `main`. +Une version publiée n'est jamais réécrite : deux builds du même commit ne sont +pas identiques à l'octet près, et le CDN comme le cache pacman gardent le fichier +sous son nom, donc republier `0.1.7-1` avec un autre contenu donne des caches qui +désaccordent avec la base et pacman rejette le téléchargement (`paquet non valide +ou corrompu`). Le workflow refuse ce cas et demande d'incrémenter `pkgrel`. +Après l'envoi, il relit aussi le paquet servi et compare son `sha256` à celui du +build, pour ne pas annoncer une publication que les clients ne peuvent pas +installer. + `pkgver` est la version du fork FWS (fichier `version` à la racine), pas celle de kitty : la version amont embarquée est dans `_kittyver`. `packaging/check-version.sh` vérifie avant le build que `version` et `pkgver`