add support for updating .SRCINFO
This commit is contained in:
parent
c64ae96953
commit
e62b5a478a
2 changed files with 49 additions and 6 deletions
|
@ -88,12 +88,40 @@ class Supervisor:
|
|||
|
||||
def build(self, name: str, dir: Path, wait=False) -> bool:
|
||||
# attempts to build PKGBUILD in specified "dir" using specified container "name"
|
||||
self.run(name, "makepkg -sfc --noconfirm --noprogressbar", dir)
|
||||
cmd = "makepkg -sfc --noconfirm --noprogressbar"
|
||||
self.run(name, cmd, dir)
|
||||
|
||||
if wait:
|
||||
return self.wait_success(name)
|
||||
return True
|
||||
|
||||
def update_srcinfo(self, name: str, dir: Path) -> bool:
|
||||
# runs "makepkg --printsrcinfo" in the container
|
||||
# and saves the output to `$dir/.SRCINFO`
|
||||
# todo: we should probably wait until the build container is done?
|
||||
self.ensure_up_to_date()
|
||||
dir_path = dir.resolve()
|
||||
volumes = {}
|
||||
if dir != Path(""):
|
||||
volumes[str(dir_path)] = {"bind": repo_mount_point, "mode": "rw"}
|
||||
|
||||
output = self.dc.containers.run(
|
||||
self.image_name,
|
||||
"makepkg --printsrcinfo",
|
||||
working_dir=repo_mount_point,
|
||||
volumes=volumes,
|
||||
stdout=True,
|
||||
stderr=True,
|
||||
name=f"{self.name_container(name)}-srcinfo"
|
||||
)
|
||||
|
||||
output_str = output.decode("utf-8")
|
||||
|
||||
with open(dir / ".SRCINFO", "w") as f:
|
||||
f.write(output_str)
|
||||
|
||||
return True
|
||||
|
||||
def finished(self, name: str) -> bool:
|
||||
# returns whether the container is finished
|
||||
container = self.containers.get(name)
|
||||
|
|
|
@ -98,6 +98,13 @@ class BuildCommand(Command):
|
|||
"repo", description="Location of directory where the PKGBUILD is located"
|
||||
)
|
||||
]
|
||||
options = [
|
||||
option(
|
||||
"no-update-srcinfo",
|
||||
"S",
|
||||
description="Do not write a new .SRCINFO file",
|
||||
),
|
||||
]
|
||||
|
||||
def handle(self) -> int:
|
||||
fpath = Path(self.argument("repo")).resolve()
|
||||
|
@ -121,12 +128,20 @@ class BuildCommand(Command):
|
|||
self.line(
|
||||
f"Building <info>{basename}</info> in container <info>{s.name_container(basename)}</info>"
|
||||
)
|
||||
success = s.build(basename, fpath)
|
||||
|
||||
success = s.build(basename, fpath, wait=True)
|
||||
|
||||
if success:
|
||||
self.line("Build successful")
|
||||
return 0
|
||||
else:
|
||||
self.line("Build failed! Container logs:", "error")
|
||||
print(s.logs(basename))
|
||||
return 2
|
||||
|
||||
self.line("Build failed! Container logs:", "error")
|
||||
print(s.logs(basename))
|
||||
return 2
|
||||
if not self.option("no-update-srcinfo"):
|
||||
self.line(
|
||||
f"Updating .SRCINFO for <info>{basename}</info>"
|
||||
)
|
||||
s.update_srcinfo(basename, fpath)
|
||||
|
||||
return 0
|
||||
|
|
Loading…
Reference in a new issue