Example #1
0
    def run(self):
        db = getDatabase()
        srpm = db.session.query(Package).filter(Package.id == self.args["srpm_id"]).one()

        try:
            self.timeout = int(pyfaf.config.CONFIG["llvmbuild.maxbuildtimesec"])
        except Exception as ex:
            self.result = "Error converting config 'llvmbuild.maxbuildtimesec' to integer: {0}".format(str(ex))
            raise FailTaskException

        self.killed = False
        signal.signal(signal.SIGALRM, self.terminate)
        signal.alarm(self.timeout)

        self.child = subprocess.Popen(["faf-llvm-build", self.args["srpm_id"], self.args["os"],
                                       self.args["tag"], "-vv", "--use-llvm-ld", "--use-wrappers",
                                       "--save-results"],
                                      stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

        line = self.child.stdout.readline()
        while line:
            sys.stdout.write(line)
            sys.stdout.flush()
            line = None if self.child.stdout.closed else self.child.stdout.readline()

        if self.child.wait():
            self.result = "LLVM build failed with exitcode {0}".format(self.child.returncode)
            raise FailTaskException

        signal.alarm(0)

        self.result = "RPM rebuilt successfully"
Example #2
0
def find_solutions_problem(problem, db=None, finders=None, osr=None):
    """
    Return a list of Solution objects for a given `problem` sorted from highest
    to lowest priority.
    Use `finders` to optionally list `SolutionFinder` objects to be used.
    Otherwise all solution finders are used.
    Use `osr` to optionally list `OpSysRelease` objects to find the solutions for.
    """

    if db is None:
        db = getDatabase()

    if finders is None:
        finders = list(solution_finders.keys())

    solutions = []
    for finder_name in finders:
        solution_finder = solution_finders[finder_name]
        sf_solutions = solution_finder.find_solutions_problem(db, problem, osr)
        if sf_solutions:
            solutions += [(solution_finder.solution_priority, solution)
                          for solution in sf_solutions]

    return [solution[1] for solution in
            sorted(solutions, key=lambda solution: solution[0])]
Example #3
0
    def _save_invalid_ureport(self, ureport, errormsg, reporter=None):
        try:
            db = getDatabase()

            new = InvalidUReport()
            new.errormsg = errormsg
            new.date = datetime.datetime.utcnow()
            new.reporter = reporter
            db.session.add(new)
            db.session.flush()

            new.save_lob("ureport", ureport)
        except Exception as ex:
            logging.error(str(ex))
Example #4
0
    def __init__(self, os, tag, md_cache_dir=None, session=None, attribs={}):
        """
        session - database session
        """
        if md_cache_dir is None:
            md_cache_dir = config.CONFIG["llvmbuild.repodir"]

        self.session = storage.getDatabase().session if session is None else session
        self.os = self.session.query(OpSys).filter(OpSys.name == os).first()
        self.tag = self.session.query(Tag).filter(Tag.opsys_id == self.os.id).filter(Tag.name == tag).first()

        GenericRepo.__init__(self,
                             name="libsolv-{0}-{1}".format(os, tag),
                             type="faf-storage",
                             md_cache_dir=md_cache_dir,
                             attribs=attribs)
Example #5
0
def find_solutions_report(report, db=None, finders=None, osr=None):
    """
    Check whether a Solution exists for a report (pyfaf.storage.Report or
    uReport dict). Return a list pyfaf.storage.SfPrefilterSolution objects
    sorted by priority or None.
    """

    if db is None:
        db = getDatabase()

    if finders is None:
        finders = list(solution_finders.keys())

    solutions = []
    if isinstance(report, Report):
        for finder_name in finders:
            solution_finder = solution_finders[finder_name]
            solution = solution_finder.find_solution_db_report(db, report, osr)
            if solution:
                if not isinstance(solution, list):
                    solution = [solution, ]
                solutions.append((solution_finder.solution_priority, solution))

    elif isinstance(report, dict):
        for finder_name in finders:
            solution_finder = solution_finders[finder_name]
            solution = solution_finder.find_solution_ureport(db, report, osr)
            if solution:
                if not isinstance(solution, list):
                    solution = [solution, ]
                solutions.append((solution_finder.solution_priority, solution))

    else:
        raise ValueError("`report` must be an instance of either "
                         "pyfaf.storage.Report or dict")

    if solutions:
        sorted_solutions = []
        for solution_list in sorted(solutions, key=lambda solution: solution[0]):
                                # The second item in the tuple created above
            sorted_solutions += solution_list[1]

        # Make sure all solutions are proper
        return [s for s in sorted_solutions if hasattr(s, "cause")]

    return None
Example #6
0
    def _save_unknown_opsys(self, opsys):
        try:
            db = getDatabase()

            name = opsys.get("name")
            version = opsys.get("version")

            db_unknown_opsys = get_unknown_opsys(db, name, version)
            if db_unknown_opsys is None:
                db_unknown_opsys = UnknownOpSys()
                db_unknown_opsys.name = name
                db_unknown_opsys.version = version
                db_unknown_opsys.count = 0
                db.session.add(db_unknown_opsys)

            db_unknown_opsys.count += 1
            db.session.flush()
        except Exception as ex:
            logging.error(str(ex))
Example #7
0
def find_solution(report, db=None, finders=None):
    """
    Check whether a Solution exists for a report (pyfaf.storage.Report or
    uReport dict). Return pyfaf.storage.SfPrefilterSolution object for the
    solution with the highest priority (i.e. lowest number) or None.
    """

    if db is None:
        db = getDatabase()

    if finders is None:
        finders = solution_finders.keys()

    solutions = []

    if isinstance(report, Report):
        for finder_name in finders:
            solution_finder = solution_finders[finder_name]
            solution = solution_finder.find_solution_db_report(db, report)
            if solution is not None:
                solutions.append((solution_finder.solution_priority, solution))

    elif isinstance(report, dict):
        for finder_name in finders:
            solution_finder = solution_finders[finder_name]
            solution = solution_finder.find_solution_ureport(db, report)
            if solution is not None:
                solutions.append((solution_finder.solution_priority, solution))

    else:
        raise ValueError("`report` must be an instance of either "
                         "pyfaf.storage.Report or dict")

    if len(solutions) > 0:
        return sorted(solutions, key=lambda solution: solution[0])[0][1]
    else:
        return None