pkg_state[pkg]["repo_path"] = AUR_GIT_REPO_PATH_TEMPLATE.format(pkg)
try:
subprocess.run(
- ["git", "clone", pkg_state[pkg]["repo_path"], pkgdir],
+ (
+ "/usr/bin/env",
+ "git",
+ "clone",
+ pkg_state[pkg]["repo_path"],
+ pkgdir,
+ ),
check=True,
)
except subprocess.CalledProcessError:
# fetch all
try:
subprocess.run(
- ["git", "fetch", "-p", "--all"],
+ ("/usr/bin/env", "git", "fetch", "-p", "--all"),
check=True,
cwd=pkgdir,
)
remotes = []
try:
result = subprocess.run(
- ["git", "remote"],
+ ("/usr/bin/env", "git", "remote"),
check=True,
cwd=pkgdir,
capture_output=True,
selected_remote = None
try:
result = subprocess.run(
- ["git", "status", "-sb", "--porcelain"],
+ ("/usr/bin/env", "git", "status", "-sb", "--porcelain"),
check=True,
cwd=pkgdir,
capture_output=True,
current_branch_hash = None
try:
result = subprocess.run(
- ["git", "log", "-1", "--format=format:%H"],
+ ("/usr/bin/env", "git", "log", "-1", "--format=format:%H"),
check=True,
cwd=pkgdir,
capture_output=True,
remote_branch_hash = None
try:
result = subprocess.run(
- ["git", "log", "-1", "--format=format:%H", selected_remote],
+ (
+ "/usr/bin/env",
+ "git",
+ "log",
+ "-1",
+ "--format=format:%H",
+ selected_remote,
+ ),
check=True,
cwd=pkgdir,
capture_output=True,
# update current branch if not same commit
if current_branch_hash != remote_branch_hash:
try:
- subprocess.run(["git", "pull"], check=True, cwd=pkgdir)
+ subprocess.run(
+ ("/usr/bin/env", "git", "pull"), check=True, cwd=pkgdir
+ )
except subprocess.CalledProcessError:
try:
subprocess.run(
- ["git", "restore", "."],
+ ("/usr/bin/env", "git", "restore", "."),
check=True,
cwd=pkgdir,
)
subprocess.run(
- ["git", "pull"],
+ ("/usr/bin/env", "git", "pull"),
check=True,
cwd=pkgdir,
)
pkgdir = os.path.join(other_state["clones_dir"], pkg)
log_print('Checking PKGBUILD for "{}"...'.format(pkg))
try:
- subprocess.run([editor, "PKGBUILD"], check=True, cwd=pkgdir)
+ subprocess.run(
+ ("/usr/bin/env", editor, "PKGBUILD"), check=True, cwd=pkgdir
+ )
except subprocess.CalledProcessError:
log_print('ERROR: Failed checking PKGBUILD for "{}"'.format(pkg))
return "abort"
'Running "makechrootpkg ... --nobuild" to ensure pkgver in PKGBUILD is updated...'
)
command_list = [
+ "/usr/bin/env",
"makechrootpkg",
"-c",
"-r",
if not dep_fullpath:
log_print('ERROR: Failed to get dep "{}"'.format(dep))
sys.exit(1)
- command_list.insert(1, "-I")
- command_list.insert(2, dep_fullpath)
+ command_list.insert(2, "-I")
+ command_list.insert(3, dep_fullpath)
for aur_dep in pkg_state[pkg]["aur_deps"]:
aur_dep_fullpath = get_latest_pkg(
aur_dep, other_state["pkg_out_dir"]
'ERROR: Failed to get aur_dep "{}"'.format(aur_dep)
)
sys.exit(1)
- command_list.insert(1, "-I")
- command_list.insert(2, aur_dep_fullpath)
+ command_list.insert(2, "-I")
+ command_list.insert(3, aur_dep_fullpath)
subprocess.run(
command_list + post_command_list,
check=True,
# TODO maybe sandbox sourcing the PKGBUILD
pkgbuild_output = subprocess.run(
- [
+ (
+ "/usr/bin/env",
"bash",
"-c",
f"source {os.path.join(pkgdir, 'PKGBUILD')}; echo \"pkgver=$pkgver\"; echo \"pkgrel=$pkgrel\"; echo \"epoch=$epoch\"",
- ],
+ ),
capture_output=True,
text=True,
)
current_version = None
try:
result = subprocess.run(
- "tar -tf {} | grep '{}.*/$'".format(
- repo, pkg_state[pkg]["pkg_name"]
+ (
+ "/usr/bin/env",
+ "bash",
+ "-c"
+ "tar -tf {} | grep '{}.*/$'".format(
+ repo, pkg_state[pkg]["pkg_name"]
+ ),
),
check=True,
capture_output=True,
encoding="UTF-8",
- shell=True,
)
reprog = re.compile(
"^{}-(?P<epoch>[0-9]+:)?(?P<version>[^-/: ]*-[0-9]+)/$".format(
if not SUDO_PROC:
log_print("sudo -v")
try:
- subprocess.run(["sudo", "-v"], check=True)
+ subprocess.run(("/usr/bin/env", "sudo", "-v"), check=True)
except subprocess.CalledProcessError:
return False
SUDO_PROC = subprocess.Popen(
- ["while true; do sudo -v; sleep 2m; done"], shell=True
+ "while true; do sudo -v; sleep 2m; done", shell=True
)
atexit.register(cleanup_sudo, sudo_proc=SUDO_PROC)
return True
tempf_name = tempf.name
try:
subprocess.run(
- [
+ (
"/usr/bin/env",
"sudo",
"cp",
tempf_name,
dest_filename,
- ],
+ ),
check=True,
)
subprocess.run(
- [
+ (
"/usr/bin/env",
"sudo",
"chmod",
"a+rx",
dest_filename,
- ],
+ ),
check=True,
)
subprocess.run(
- [
+ (
"/usr/bin/env",
"rm",
"-f",
tempf_name,
- ],
+ ),
check=True,
)
except subprocess.CalledProcessError:
# set up ccache stuff
try:
subprocess.run(
- [
+ (
+ "/usr/bin/env",
"sudo",
"sed",
"-i",
"/^BUILDENV=/s/!ccache/ccache/",
f"{chroot}/root/etc/makepkg.conf",
- ],
+ ),
check=True,
)
except subprocess.CalledProcessError:
# cleanup ccache stuff
try:
subprocess.run(
- [
+ (
+ "/usr/bin/env",
"sudo",
"sed",
"-i",
"/^BUILDENV=/s/ ccache/ !ccache/",
f"{chroot}/root/etc/makepkg.conf",
- ],
+ ),
check=True,
)
except subprocess.CalledProcessError:
# cleanup sccache stuff
try:
subprocess.run(
- [
+ (
+ "/usr/bin/env",
"sudo",
"rm",
"-f",
f"{chroot}/root/usr/local/bin/clang",
f"{chroot}/root/usr/local/bin/clang++",
f"{chroot}/root/usr/local/bin/rustc",
- ],
+ ),
check=False,
)
except BaseException:
cleanup_sccache(other_state["chroot"])
command_list = [
+ "/usr/bin/env",
"makechrootpkg",
"-c",
"-r",
if not dep_fullpath:
log_print('ERROR: Failed to get dep "{}"'.format(dep))
sys.exit(1)
- command_list.insert(1, "-I")
- command_list.insert(2, dep_fullpath)
+ command_list.insert(2, "-I")
+ command_list.insert(3, dep_fullpath)
for aur_dep in pkg_state[pkg]["aur_deps"]:
aur_dep_fullpath = get_latest_pkg(
aur_dep, other_state["pkg_out_dir"]
if not aur_dep_fullpath:
log_print('ERROR: Failed to get aur_dep "{}"'.format(aur_dep))
sys.exit(1)
- command_list.insert(1, "-I")
- command_list.insert(2, aur_dep_fullpath)
+ command_list.insert(2, "-I")
+ command_list.insert(3, aur_dep_fullpath)
if "ccache_dir" in pkg_state[pkg]:
- command_list.insert(1, "-d")
- command_list.insert(2, f'{pkg_state[pkg]["ccache_dir"]}:/ccache')
+ command_list.insert(2, "-d")
+ command_list.insert(3, f'{pkg_state[pkg]["ccache_dir"]}:/ccache')
post_command_list.insert(1, "CCACHE_DIR=/ccache")
elif "sccache_dir" in pkg_state[pkg]:
- command_list.insert(1, "-d")
- command_list.insert(2, f'{pkg_state[pkg]["sccache_dir"]}:/sccache')
+ command_list.insert(2, "-d")
+ command_list.insert(3, f'{pkg_state[pkg]["sccache_dir"]}:/sccache')
post_command_list.insert(1, "SCCACHE_DIR=/sccache")
post_command_list.insert(
2, f'SCCACHE_CACHE_SIZE={pkg_state[pkg]["sccache_cache_size"]}'
log_print(f'Signing "{other_state["repo"]}"...')
try:
subprocess.run(
- [
+ (
"/usr/bin/rm",
"-f",
str(
f"{other_state['repo']}.sig",
)
),
- ]
+ )
)
subprocess.run(
- [
- "/usr/bin/gpg",
+ (
+ "/usr/bin/env",
+ "gpg",
"--batch",
"--passphrase-fd",
"0",
"--detach-sign",
str(
os.path.join(
- other_state["pkg_out_dir"], f"{other_state['repo']}"
+ other_state["pkg_out_dir"], other_state["repo"]
)
),
- ],
+ ),
check=True,
input=signing_gpg_pass,
text=True,
if repo_sig_name.rfind("/") != -1:
repo_sig_name = repo_sig_name.rsplit(sep="/", maxsplit=1)[1]
subprocess.run(
- [
- "/usr/bin/ln",
+ (
+ "/usr/bin/env",
+ "ln",
"-sf",
repo_sig_name,
str(
os.path.join(
- other_state["pkg_out_dir"], f"{other_state['repo']}"
+ other_state["pkg_out_dir"], other_state["repo"]
)
).removesuffix(".tar")
+ ".sig",
- ]
+ )
)
except subprocess.CalledProcessError:
log_print(f'WARNING: Failed to sign "{other_state["repo"]}"')
tempnf.flush()
try:
subprocess.run(
- [
+ (
+ "/usr/bin/env",
"gpg",
"--batch",
"--passphrase-fd",
signing_key_fp,
"--detach-sign",
tempnf.name,
- ],
+ ),
check=True,
input=passphrase,
text=True,
log_print("Updating the chroot...")
try:
subprocess.run(
- [
+ (
+ "/usr/bin/env",
"arch-nspawn",
"{}/root".format(other_state["chroot"]),
"pacman",
"-Syu",
- ],
+ ),
check=True,
)
except subprocess.CalledProcessError: