fix: add local pacman repo for inter-package deps
calamares-branding-antergos-next depends on calamares, but makepkg -s couldn't resolve it since calamares was only in /tmp/pkgout/, not in a pacman repo. Now build-packages.py: - Injects an [antergos-local] repo into pacman.conf - Runs repo-add after each successful build - Re-syncs pacman before each subsequent build - Exits with ::error if any package fails
This commit is contained in:
+47
-4
@@ -3,15 +3,44 @@ import subprocess
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import glob
|
import glob
|
||||||
|
import sys
|
||||||
|
|
||||||
|
LOCAL_REPO = "/tmp/pkgout"
|
||||||
|
|
||||||
|
def repo_init():
|
||||||
|
os.makedirs(LOCAL_REPO, exist_ok=True)
|
||||||
|
conf_path = "/etc/pacman.conf"
|
||||||
|
with open(conf_path) as f:
|
||||||
|
conf = f.read()
|
||||||
|
if "[antergos-local]" not in conf:
|
||||||
|
with open(conf_path, "w") as f:
|
||||||
|
f.write(conf.replace(
|
||||||
|
"[core]",
|
||||||
|
"[antergos-local]\nSigLevel = Never\nServer = file:///tmp/pkgout\n\n[core]"
|
||||||
|
))
|
||||||
|
|
||||||
|
def repo_add(pkg_path):
|
||||||
|
db = f"{LOCAL_REPO}/antergos-local.db.tar.gz"
|
||||||
|
subprocess.run(["repo-add", db, pkg_path], capture_output=True)
|
||||||
|
|
||||||
|
def repo_has(pkgname):
|
||||||
|
db = f"{LOCAL_REPO}/antergos-local.db.tar.gz"
|
||||||
|
if not os.path.exists(db):
|
||||||
|
return False
|
||||||
|
result = subprocess.run(
|
||||||
|
["bsdtar", "-tf", db],
|
||||||
|
capture_output=True, text=True
|
||||||
|
)
|
||||||
|
return pkgname in result.stdout
|
||||||
|
|
||||||
with open("packages.yaml") as f:
|
with open("packages.yaml") as f:
|
||||||
pkgs = yaml.safe_load(f)["packages"]
|
pkgs = yaml.safe_load(f)["packages"]
|
||||||
|
|
||||||
os.makedirs("/tmp/pkgout", exist_ok=True)
|
repo_init()
|
||||||
|
|
||||||
for pkg in pkgs:
|
for pkg in pkgs:
|
||||||
local_pkgbuild = f"packages/{pkg}/PKGBUILD"
|
local_pkgbuild = f"packages/{pkg}/PKGBUILD"
|
||||||
build_dir = f"/tmp/{pkg}"
|
build_dir = f"/tmp/build-{pkg}"
|
||||||
|
|
||||||
if os.path.exists(build_dir):
|
if os.path.exists(build_dir):
|
||||||
shutil.rmtree(build_dir)
|
shutil.rmtree(build_dir)
|
||||||
@@ -22,8 +51,22 @@ for pkg in pkgs:
|
|||||||
subprocess.run(["git", "clone", f"https://aur.archlinux.org/{pkg}.git", build_dir])
|
subprocess.run(["git", "clone", f"https://aur.archlinux.org/{pkg}.git", build_dir])
|
||||||
|
|
||||||
subprocess.run(["chown", "-R", "builder:builder", build_dir])
|
subprocess.run(["chown", "-R", "builder:builder", build_dir])
|
||||||
subprocess.run(["su", "-", "builder", "-c", f"cd {build_dir} && makepkg -s --noconfirm --noprogress --skippgpcheck --skipinteg"])
|
|
||||||
|
|
||||||
subprocess.run(f"cp {build_dir}/*.pkg.tar.zst /tmp/pkgout/ || true", shell=True)
|
# Sync pacman so makepkg -s can resolve local packages
|
||||||
|
subprocess.run(["pacman", "-Sy", "--noconfirm"], capture_output=True)
|
||||||
|
|
||||||
|
result = subprocess.run(
|
||||||
|
["su", "-", "builder", "-c", f"cd {build_dir} && makepkg -s --noconfirm --noprogress --skippgpcheck --skipinteg"],
|
||||||
|
capture_output=True, text=True
|
||||||
|
)
|
||||||
|
if result.returncode != 0:
|
||||||
|
print(f"::error::BUILD FAILED: {pkg}")
|
||||||
|
print(result.stdout[-500:])
|
||||||
|
print(result.stderr[-500:])
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
for pkg_file in glob.glob(f"{build_dir}/*.pkg.tar.zst"):
|
||||||
|
shutil.copy(pkg_file, LOCAL_REPO)
|
||||||
|
repo_add(pkg_file)
|
||||||
|
|
||||||
print("Done!")
|
print("Done!")
|
||||||
|
|||||||
Reference in New Issue
Block a user