From 7ab8d86396cf84cfeedae086f261b9596691d748 Mon Sep 17 00:00:00 2001
From: Joel Grunbaum <joelgrun@gmail.com>
Date: Sun, 08 Feb 2026 01:15:14 +0000
Subject: [PATCH] Try to allow vcs rebuilds
---
src/archrepobuild/builder.py | 13 ++++++++++++-
verify_build_logic.py | 44 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 1 deletions(-)
diff --git a/src/archrepobuild/builder.py b/src/archrepobuild/builder.py
index a99af5d..dea86f9 100644
--- a/src/archrepobuild/builder.py
+++ b/src/archrepobuild/builder.py
@@ -76,6 +76,7 @@
sign: bool = False,
key: str = "",
clean: bool = True,
+ force: bool = False,
skip_checksums: bool = False,
extra_args: list[str] | None = None,
env_overrides: dict[str, str] | None = None,
@@ -102,6 +103,8 @@
cmd.append("-c")
if sign and key:
cmd.extend(["--sign", "--key", key])
+ if force:
+ cmd.append("-f")
if skip_checksums:
cmd.append("--skipchecksums")
if extra_args:
@@ -122,7 +125,14 @@
)
if result.returncode != 0:
- return False, result.stderr or result.stdout, []
+ error = result.stderr or result.stdout
+ if "A package has already been built" in error:
+ logger.info("Package already built, treating as success")
+ # Find built packages anyway
+ artifacts = list(package_dir.glob("*.pkg.tar.*"))
+ artifacts = [a for a in artifacts if not a.name.endswith(".sig")]
+ return True, "", artifacts
+ return False, error, []
# Find built packages
artifacts = list(package_dir.glob("*.pkg.tar.*"))
@@ -318,6 +328,7 @@
self.config.signing.enabled,
self.config.signing.key,
self.config.building.clean,
+ force or is_vcs,
override.skip_checksums,
override.extra_args,
override.env,
diff --git a/verify_build_logic.py b/verify_build_logic.py
new file mode 100644
index 0000000..b59a3f8
--- /dev/null
+++ b/verify_build_logic.py
@@ -0,0 +1,44 @@
+import asyncio
+from pathlib import Path
+import os
+import sys
+
+# Add src to path
+sys.path.insert(0, str(Path(__file__).parent / "src"))
+
+from archrepobuild.builder import _run_makepkg
+
+async def test_already_built():
+ print("Testing 'already built' message handling...")
+
+ # Create a mock PKGBUILD directory
+ test_dir = Path("test_build_logic")
+ test_dir.mkdir(exist_ok=True)
+ pkgbuild = test_dir / "PKGBUILD"
+ pkgbuild.write_text("pkgname=testpkg\npkgver=1.0\npkgrel=1\narch=('any')\n")
+
+ # Manually create a dummy package file to trigger the error if we run twice
+ package_file = test_dir / "testpkg-1.0-1-any.pkg.tar.zst"
+ package_file.write_text("dummy")
+
+ # Run _run_makepkg. It should fail with returncode != 0 but we should catch it.
+ # Note: We can't easily mock the subprocess output of makepkg here
+ # but we can check if it behaves correctly when real makepkg is called.
+
+ success, error, artifacts = _run_makepkg(test_dir, force=False)
+
+ print(f"Success: {success}")
+ print(f"Error: {error}")
+ print(f"Artifacts: {artifacts}")
+
+ if success and "testpkg-1.0-1-any.pkg.tar.zst" in [a.name for a in artifacts]:
+ print("✓ Successfully handled 'already built' message")
+ else:
+ print("✗ Failed to handle 'already built' message (or makepkg didn't report it)")
+
+ # Cleanup
+ shutil = __import__('shutil')
+ shutil.rmtree(test_dir)
+
+if __name__ == "__main__":
+ asyncio.run(test_already_built())
--
Gitblit v1.10.0