""", uuid,
)
+ async def get_by_buildid(self, buildid):
+ """
+ Fetches the debug information for the given BuildID
+ """
+ # Make the path
+ path = buildid_to_path(buildid)
+
+ # Search for the package containing this file
+ for package in self.search_by_filename(path, limit=1):
+ log.debug("Found debuginfo for %s in %s" % (buildid, package))
+
+ return package
+
async def create(self, upload, distro=None, commit=None):
"""
Creates a new package from an uploaded file
""", self.id, path,
)
+ def get_debuginfo(self, buildid):
+ path = buildid_to_path(buildid)
+
+ return self.get_file(path)
+
# Open
async def open(self):
# Read everything in a separate thread
return await asyncio.to_thread(f.readall)
+
+
+def buildid_to_path(buildid):
+ """
+ Returns the path where we expect to find the BuildID
+ """
+ return "/usr/lib/debug/.build-id/%s/%s.debug" % (buildid[0:2], buildid[2:])
from . import bugs
from . import builders
from . import builds
+from . import debuginfo
from . import distributions
from . import errors
from . import events
# Log
(r"/log", handlers.LogHandler),
+ # Debuginfo
+ (r"/buildid/([0-9a-f]{40})/debuginfo", debuginfo.DebugInfoHandler),
+
# Repositories
(r"/api/v1/repos/([\w\d\-]+)", repos.APIv1IndexHandler),
(r"/api/v1/repos/([\w\d\-]+)/([\w\d\-]+)", repos.APIv1ShowHandler),
--- /dev/null
+#!/usr/bin/python3
+
+import tornado.web
+
+from . import base
+
+class DebugInfoHandler(base.BaseHandler):
+ async def get(self, buildid):
+ package = await self.backend.packages.get_by_buildid(buildid)
+ if not package:
+ raise tornado.web.HTTPError(404, "Could not find package providing BuildID %s" % buildid)
+
+ # Fetch the debuginfo
+ file = package.get_debuginfo(buildid)
+ if not file:
+ raise tornado.web.HTTPError(404, "Could not find debuginfo in %s" % package)
+
+ # Send the payload
+ await file.sendfile(self)