Impl. checking PKGBUILD versions from in chroot
This commit is contained in:
parent
106adcd27b
commit
9ac2a1e934
1 changed files with 66 additions and 10 deletions
64
update.py
64
update.py
|
@ -755,17 +755,73 @@ def get_pkgbuild_version(
|
||||||
pkgver = None
|
pkgver = None
|
||||||
pkgrel = None
|
pkgrel = None
|
||||||
|
|
||||||
# TODO maybe sandbox sourcing the PKGBUILD
|
# Setup checking the PKGBUILD from within the chroot.
|
||||||
|
chroot_user_path = os.path.join(
|
||||||
|
other_state["tmpfs_chroot"]
|
||||||
|
if other_state["tmpfs"]
|
||||||
|
else other_state["chroot"],
|
||||||
|
other_state["USER"],
|
||||||
|
)
|
||||||
|
chroot_build_path = os.path.join(chroot_user_path, "build")
|
||||||
|
chroot_check_pkgbuild_path = os.path.join(chroot_build_path, "PKGBUILD")
|
||||||
|
chroot_check_sh_path = os.path.join(chroot_build_path, "check.sh")
|
||||||
|
|
||||||
|
try:
|
||||||
|
subprocess.run(
|
||||||
|
(
|
||||||
|
"/usr/bin/cp",
|
||||||
|
os.path.join(pkgdir, "PKGBUILD"),
|
||||||
|
chroot_check_pkgbuild_path,
|
||||||
|
),
|
||||||
|
check=True,
|
||||||
|
)
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
log_print(
|
||||||
|
f'ERROR: Failed to check PKGBUILD (moving PKGBUILD to chroot) for "{pkg}"!',
|
||||||
|
other_state=other_state,
|
||||||
|
)
|
||||||
|
return False, None, None, None
|
||||||
|
|
||||||
|
check_pkgbuild_script = """#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
source "/build/PKGBUILD"
|
||||||
|
echo "pkgver=$pkgver"
|
||||||
|
echo "pkgrel=$pkgrel"
|
||||||
|
echo "epoch=$epoch"
|
||||||
|
"""
|
||||||
|
|
||||||
|
if not create_executable_script(
|
||||||
|
chroot_check_sh_path, check_pkgbuild_script
|
||||||
|
):
|
||||||
|
log_print(
|
||||||
|
f'ERROR: Failed to check PKGBUILD (check PKGBUILD setup) for "{pkg}"!',
|
||||||
|
other_state=other_state,
|
||||||
|
)
|
||||||
|
return False, None, None, None
|
||||||
|
|
||||||
|
pkgbuild_output = str()
|
||||||
|
try:
|
||||||
pkgbuild_output = subprocess.run(
|
pkgbuild_output = subprocess.run(
|
||||||
(
|
(
|
||||||
"/usr/bin/env",
|
"/usr/bin/env",
|
||||||
"bash",
|
"sudo",
|
||||||
"-c",
|
"arch-nspawn",
|
||||||
f"source {os.path.join(pkgdir, 'PKGBUILD')}; echo \"pkgver=$pkgver\"; echo \"pkgrel=$pkgrel\"; echo \"epoch=$epoch\"",
|
chroot_user_path,
|
||||||
|
"/build/check.sh",
|
||||||
),
|
),
|
||||||
|
check=True,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
)
|
)
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
log_print(
|
||||||
|
f'ERROR: Failed to check PKGBUILD (checking PKGBUILD) for "{pkg}"!',
|
||||||
|
other_state=other_state,
|
||||||
|
)
|
||||||
|
return False, None, None, None
|
||||||
|
|
||||||
output_ver_re = re.compile(
|
output_ver_re = re.compile(
|
||||||
"^pkgver=([a-zA-Z0-9._+-]+)\\s*$", flags=re.M
|
"^pkgver=([a-zA-Z0-9._+-]+)\\s*$", flags=re.M
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue