Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
ci(aur): verify sources the way a user's makepkg resolves them
Etienne Lescot8d414f35b80b
diff --git a/.github/workflows/aur-publish.yml b/.github/workflows/aur-publish.ymlindex fce4e0f11..a1aea9483 100644--- a/.github/workflows/aur-publish.yml+++ b/.github/workflows/aur-publish.yml@@ -331,6 +331,85 @@ jobs:fiecho "Diff limited to the expected bump."+ # Les sommes ci-dessus sont calculées sur les URLs. makepkg, lui, ne+ # télécharge qu'en dernier recours : il prend d'abord un fichier du même+ # nom posé à côté du PKGBUILD (`$startdir`), puis son cache (`$SRCDEST`),+ # dans cet ordre (get_filepath, libmakepkg/util/source.sh). Un LICENSE+ # commité dans le dépôt AUR a ainsi fait échouer chaque build propre de+ # 1.10.0 à 1.12.2, pendant que ce workflow publiait des sommes justes.+ # On rejoue donc la vérification comme un utilisateur, cache vide.+ # `--verifysource` télécharge et contrôle, sans extraire ni appeler+ # aucune fonction du PKGBUILD, et la clé de déploiement n'est toujours+ # pas sur le disque.+ - name: Verify sources the way a user's makepkg resolves them+ if: steps.aur_secret.outputs.configured == 'true'+ working-directory: aur-repo+ env:+ VERSION: ${{ steps.meta.outputs.version }}+ PACKAGE: ${{ vars.AUR_PACKAGE_NAME }}+ run: |+ set -euo pipefail+ FAILED=0++ # Nom local de chaque source, tel que makepkg le range : la partie+ # avant `::` si elle existe, sinon le dernier segment de l'URL.+ SRC_BLOCK=$(awk '/^source=\(/{f=1} f{print} f&&/\)[[:space:]]*$/{exit}' PKGBUILD)+ mapfile -t ENTRIES < <(grep -oE '"[^"]*"' <<<"$SRC_BLOCK" | tr -d '"' \+ | sed -e "s/\\\${pkgver}/${VERSION}/g" -e "s/\\\$pkgver/${VERSION}/g" \+ -e "s/\\\${pkgname}/${PACKAGE}/g" -e "s/\\\$pkgname/${PACKAGE}/g")+ NAMES=()+ for entry in "${ENTRIES[@]}"; do+ if [[ "$entry" == *"::"* ]]; then+ NAMES+=("${entry%%::*}")+ else+ NAMES+=("${entry##*/}")+ fi+ done++ # Sommes publiées aujourd'hui sur l'AUR (HEAD du clone) et sommes du bump.+ sums_of() { grep -E '^sha256sums=' | grep -oE "'[^']*'|\"[^\"]*\"" | tr -d "'\"" || true; }+ mapfile -t NEW_SUMS < <(sums_of < PKGBUILD)+ mapfile -t OLD_SUMS < <(git show HEAD:PKGBUILD | sums_of)++ for i in "${!NAMES[@]}"; do+ name=${NAMES[$i]}++ # Un fichier du dépôt AUR qui porte le nom d'une source la masque :+ # l'utilisateur reçoit ce fichier, jamais celui de la release.+ if [[ -e "$name" ]]; then+ echo "::warning::'${name}' is committed in the AUR repository under the same name as a source. makepkg uses that file and never downloads the URL, so users get the committed copy, not the release's. Remove it from the AUR repository."+ fi++ # Sans version dans le nom, paru et yay ressortent la copie de la+ # version précédente de leur cache. Sans conséquence tant que le+ # contenu ne change pas, bloquant dès qu'il change.+ if [[ "$name" != *"$VERSION"* ]]; then+ OLD=${OLD_SUMS[$i]:-}+ NEW=${NEW_SUMS[$i]:-}+ if [[ "${#OLD_SUMS[@]}" -eq "${#NEW_SUMS[@]}" && -n "$OLD" && "$OLD" != "$NEW" ]]; then+ echo "::error::Source '${name}' has no version in its file name and its content changed in this release (sha256 ${OLD:0:8} -> ${NEW:0:8}). makepkg reuses a cached file of the same name, so every user who built an earlier version would fail the checksum. Give it a versioned name on the AUR side, e.g. \"${name}-\${pkgver}::<url>\", and update package() to match. This workflow only rewrites pkgver/pkgrel/sha256sums, so it keeps that rename."+ FAILED=1+ else+ echo "::warning::Source '${name}' has no version in its file name. Harmless for this release, since its content did not change, but the first release that changes it will fail for every user holding a cached copy. Give it a versioned name on the AUR side, e.g. \"${name}-\${pkgver}::<url>\", and update package() to match."+ fi+ fi+ done++ # Cache neuf, comme un clone propre : seuls les fichiers du dépôt AUR+ # peuvent encore s'intercaler, et c'est précisément ce qu'on teste.+ WORK=$(mktemp -d)+ mkdir -p "$WORK/srcdest" "$WORK/build"+ if ! SRCDEST="$WORK/srcdest" BUILDDIR="$WORK/build" makepkg --verifysource; then+ echo "::error::makepkg --verifysource failed on an empty cache, so a user building this PKGBUILD from a clean clone would fail the same way. See the warnings above for a committed file that shadows a source."+ FAILED=1+ fi++ if [[ "$FAILED" != "0" ]]; then+ echo "::error::Refusing to publish a PKGBUILD that would fail on users' machines."+ exit 1+ fi+ echo "Sources verified as a user's makepkg resolves them."+- name: Dry run — stop before touching the AURif: steps.aur_secret.outputs.configured == 'true' && inputs.dry_runworking-directory: aur-repo