#!/usr/bin/env python3 """Surgical recipe fixes for PaganOS recipes repo. Validates YAML after each edit.""" import os, re, sys, yaml R = "/var/lib/pagan-sync/recipes" def patch(path, old, new, must=True): fp = os.path.join(R, path) s = open(fp, encoding="utf-8").read() if old not in s: if must: print(f"FAIL: pattern not found in {path}") sys.exit(1) print(f"SKIP (already applied?): {path}") return s = s.replace(old, new, 1) open(fp, "w", encoding="utf-8").write(s) try: yaml.safe_load(s) print(f"OK: {path}") except Exception as e: print(f"YAML ERROR in {path}: {e}") sys.exit(1) # 1. icu: drop the legacy 77.1 double-build patch("utils/icu/PAGBUILD.yaml", """ bsdtar xf icu4c-${pkgver}-sources.tgz mv ${pkgname} ${pkgname}-${pkgver} bsdtar xf icu4c-77_1-src.tgz mv ${pkgname} ${pkgname}-77.1 cd ${pkgname}-${pkgver}/source """, """ bsdtar xf icu4c-${pkgver}-sources.tgz mv ${pkgname} ${pkgname}-${pkgver} cd ${pkgname}-${pkgver}/source """) patch("utils/icu/PAGBUILD.yaml", """ make DESTDIR=${PKGDIR} install cd ../.. cd ${pkgname}-77.1/source ./configure --prefix=/usr/local make make prefix=${PKGDIR}/usr/local install install -Dm644 ../LICENSE ${PKGDIR}/usr/share/licenses/${pkgname}/LICENSE """, """ make DESTDIR=${PKGDIR} install cd ../.. install -Dm644 ../LICENSE ${PKGDIR}/usr/share/licenses/${pkgname}/LICENSE """) # 2. glm: correct sha256 patch("utils/glm/PAGBUILD.yaml", "3aa4347b8f13cba882df1c7b61a6ca910c75a875c56ec3d75d7dc9ae8eac34df", "6775e47231a446fd086d660ecc18bcd076531cfedd912fbd66e576b118607001") # 3. gnome-themes-extra: perl-xml-parser for intltool patch("gui/gnome-themes-extra/PAGBUILD.yaml", """makedepends: - gtk3 - intltool - librsvg """, """makedepends: - gtk3 - intltool - librsvg - perl-xml-parser """) # 4. gtkspell: perl-xml-parser for intltool patch("gui/gtkspell/PAGBUILD.yaml", """makedepends: - gtk3 - enchant """, """makedepends: - gtk3 - enchant - perl-xml-parser """) # 5. enchant: skip unit tests (UnitTest++ not packaged) patch("gui/enchant/PAGBUILD.yaml", "--mandir=/usr/share/man \\\\\n\\t--disable-static", "--mandir=/usr/share/man \\\\\n\\t--disable-static \\\\\n\\t--without-unit-tests") # 6. efivar: drop missing patch file patch("core/efivar/PAGBUILD.yaml", """source: - efivar-${pkgver}.patch - 'https://github.com/rhboot/efivar/archive/refs/tags/${pkgver}.tar.gz' """, """source: - 'https://github.com/rhboot/efivar/archive/refs/tags/${pkgver}.tar.gz' """) patch("core/efivar/PAGBUILD.yaml", """ cd ${pkgname}-${pkgver} patch -Np1 -i ../efivar-${pkgver}.patch make ERRORS='' all """, """ cd ${pkgname}-${pkgver} make ERRORS='' all """) # 7. benchmark: disable tests (Werror in test build) patch("utils/benchmark/PAGBUILD.yaml", " -DBENCHMARK_ENABLE_GTEST_TESTS=OFF \\", " -DBENCHMARK_ENABLE_GTEST_TESTS=OFF \\\n -DBENCHMARK_ENABLE_TESTING=OFF \\") # 8. gmp: explicit -std=gnu17 (GCC16 default rejects old-style () decls in gmp tests) patch("core/gmp/PAGBUILD.yaml", """ cp -v configfsf.guess config.guess cp -v configfsf.sub config.sub """, """ cp -v configfsf.guess config.guess cp -v configfsf.sub config.sub CFLAGS+=' -std=gnu17' """) print("ALL DONE")