# Builds
- def create_build(self, filename, **kwargs):
- build_id = self.hub.create_build(filename, **kwargs)
-
- return self.get_build(build_id)
+ async def build(self, *args, **kwargs):
+ return await self.hub.build(*args, **kwargs)
def get_build(self, build_id):
return Build(self, build_id)
def get_build(self, uuid):
return self._request("/builds/%s" % uuid, decode="json")
- def create_build(self, path, type, arches=None, distro=None):
+ async def build(self, path, arches=None):
"""
Create a new build on the hub
"""
- assert type in ("scratch", "release")
+ # Upload the souce file to the server
+ upload_id = await self.upload(path)
- # XXX Check for permission to actually create a build
+ log.debug("%s has been uploaded as %s" % (path, upload_id))
- # Upload the souce file to the server
- upload_id = self.upload_file(path)
+ # Create a new build
+ build_id = await self._request("POST", "/builds",
+ upload_id=upload_id, arches=arches)
- data = {
- "arches" : ",".join(arches or []),
- "build_type" : type,
- "distro" : distro or "",
- "upload_id" : upload_id,
- }
+ log.debug("Build creates as %s" % build_id)
- return self._request("/builds/create", data=data, decode="ascii")
+ return build_id
# Job actions
sys.exit(ret or 0)
async def _build(self, client, ns):
- # Create a temporary directory.
- temp_dir = tempfile.mkdtemp()
-
- # Format arches.
- if ns.arch:
- arches = self.args.arch.split(",")
- else:
- arches = None
+ # Create a temporary directory if we need to call dist
+ tmp = tempfile.TemporaryDirectory(prefix="pakfire-client-")
try:
- # Package all packages first and save the actual filenames
- packages = []
+ # XXX implement calling dist
+ # Build all packages
for package in ns.packages:
- if package.endswith(".%s" % MAKEFILE_EXTENSION):
- # Create a source package from the makefile.
- p = self.pakfire()
- package = p.dist(package, temp_dir)
- packages.append(package)
-
- elif package.endswith(".%s" % PACKAGE_EXTENSION):
- packages.append(package)
-
- else:
- raise Exception("Unknown filetype: %s" % package)
-
- assert packages
-
- # Upload the packages to the build service
- for package in packages:
- build = client.create_build(package, type="scratch", arches=arches)
-
- # Show information about the uploaded build
- summary = build.dump()
- for line in summary.splitlines():
- print(" %s" % line)
+ await client.build(package, arches=ns.arch)
finally:
- # Cleanup the temporary directory and all files.
- if os.path.exists(temp_dir):
- shutil.rmtree(temp_dir, ignore_errors=True)
+ tmp.cleanup()
async def _check_connection(self, client, ns):
success = client.check_connection()