#!/usr/bin/python3
import asyncio
+import functools
import json
import logging
import multiprocessing
import setproctitle
import signal
import socket
+import tempfile
from . import _pakfire
from . import config
# Set the process title
setproctitle.setproctitle("pakfire-worker job %s" % job_id)
- # XXX Do something for now
- import time
- time.sleep(10)
+ # Fetch the build architecture
+ arch = self.data.get("arch")
+
+ # Use the native architecture for noarch
+ if arch == "noarch":
+ arch = None
+
+ # Fetch the package URL
+ pkg = self.data.get("pkg")
+ if not pkg:
+ raise ValueError("Did not received a package URL")
+
+ # Setup Pakfire instance
+ try:
+ p = _pakfire.Pakfire(
+ conf=self.pakfire_conf,
+ arch=arch,
+
+ # Set up logging
+ #logger=logger.log,
+
+ # Enable build mode and disable snapshots
+ build=True,
+ enable_snapshot=False,
+ interactive=False,
+ )
+ finally:
+ # Delete the configuration file
+ os.unlink(self.pakfire_conf)
+
+ # Run the build
+ p.build(pkg, build_id=job_id)
def shutdown(self):
self.log.debug("Shutting down worker %s" % self.pid)
Handle signal SIGTERM.
"""
self.shutdown()
+
+ @functools.cached_property
+ def pakfire_conf(self):
+ """
+ Writes the pakfire configuration to file and returns its path
+ """
+ conf = self.data.get("conf")
+
+ # Write the configuration to file
+ f = tempfile.NamedTemporaryFile(delete=False)
+ if conf:
+ f.write(conf.encode())
+ f.close()
+
+ # Return the path
+ return f.name