Ejemplo n.º 1
0
def iterate():
    arches = config["arches"]
    suites = config["suites"]
    checks = config.get("checks", list(PLUGINS.keys()))

    # job is a serialized dictionary from debile-master ORM
    with workon(suites, arches, checks) as job:
        if job is None:
            raise IDidNothingError("No more jobs")

        source = proxy.get_source(job["source_id"])

        package = {
            "name": source["name"],
            "version": source["version"],
            "type": "source",
            "arch": "all",
            "source": source,
            "binary": None,
        }

        if job["binary_id"]:
            binary = proxy.get_binary(job["binary_id"])
            package = {
                "name": binary["name"],
                "version": binary["version"],
                "type": "binary",
                "arch": binary["arch"],
                "source": source,
                "binary": binary,
            }

        with checkout(job, package) as check:
            run, version = load_module(job["name"])
            firehose = create_firehose(package, version)

            type_ = package["type"]
            if type_ == "source":
                target = check  # Only get one.
            elif type_ == "binary":
                target = check  # tons and tons
            else:
                raise Exception("Unknown type")

            firehose, log, failed, changes = run(target, package, job, firehose)

            prefix = "%s" % (str(job["id"]))

            dudf = "{prefix}.dud".format(prefix=prefix)
            dud = Dud_()
            dud["Created-By"] = "Dummy Entry <*****@*****.**>"
            dud["Source"] = package["source"]["name"]
            dud["Version"] = package["source"]["version"]
            dud["Architecture"] = package["arch"]
            dud["X-Debile-Failed"] = "Yes" if failed else "No"
            if type_ == "binary":
                dud["Binary"] = package["binary"]["name"]

            job["failed"] = failed

            with open("{prefix}.firehose.xml".format(prefix=prefix), "wb") as fd:
                fd.write(firehose.to_xml_bytes())

            dud.add_file("{prefix}.firehose.xml".format(prefix=prefix))

            with open("{prefix}.log".format(prefix=prefix), "wb") as fd:
                fd.write(log.encode("utf-8"))

            dud.add_file("{prefix}.log".format(prefix=prefix))

            with open(dudf, "w") as fd:
                dud.dump(fd=fd)

            if changes:
                upload(changes, job, package)

            upload(dudf, job, package)
Ejemplo n.º 2
0
def run_job(config, job):
    group = job['group_obj']
    source = job['source_obj']
    binary = job['binary_obj']

    package = {
        "name": source['name'],
        "version": source['version'],
        "type": "source" if binary is None else "binary",
        "arch": job['arch'],
        "affinity": source['affinity'] if job['arch'] in ["all", "source"] else job['arch'],
        "suite": source['suite'],
        "component": source['component'],
        "group": group,
        "source": source,
        "binary": binary,
    }

    with checkout(package) as target:
        run, version = load_module(job['check'])
        firehose = create_firehose(package, version)

        firehose, log, failed, changes = run(
            target, package, job, firehose)

        datestr = formatdate()
        binstr = None

        if changes:
            f = open(changes, 'r')
            obj = Changes(f)
            obj['Distribution'] = source['suite']
            obj['X-Debile-Group'] = source['group']
            obj['X-Debile-Job'] = str(job['id'])
            obj.dump(fd=open(changes, 'wb'))

            datestr = obj['Date']
            binstr = obj['Binary']
        elif binary:
            binstr = " ".join(deb['filename'].partition("_")[0] for deb in binary['debs'])

        dud = Changes()
        dud['Format'] = "1.8"
        dud['Date'] = datestr
        dud['Source'] = source['name']
        if binstr:
            dud['Binary'] = binstr
        dud['Version'] = source['version']
        dud['Architecture'] = job['arch']
        dud['Distribution'] = source['suite']
        dud['X-Debile-Group'] = source['group']
        dud['X-Debile-Check'] = job['check']
        dud['X-Debile-Job'] = str(job['id'])
        dud['X-Debile-Failed'] = "Yes" if failed else "No"

        job['failed'] = failed

        _, _, v = source['version'].rpartition(":")
        prefix = "%s_%s_%s.%d" % (source['name'], v, job['arch'], job['id'])

        with open('{prefix}.firehose.xml'.format(
                prefix=prefix), 'wb') as fd:
            fd.write(firehose.to_xml_bytes())
        dud.add_file('{prefix}.firehose.xml'.format(prefix=prefix))

        with open('{prefix}.log'.format(prefix=prefix), 'wb') as fd:
            fd.write(log.encode('utf-8'))
        dud.add_file('{prefix}.log'.format(prefix=prefix))

        dudf = "{prefix}.dud".format(prefix=prefix)
        with open(dudf, 'w') as fd:
            dud.dump(fd=fd)

        if changes:
            upload(changes, job, config['gpg'], config['dput']['host'])
        upload(dudf, job, config['gpg'], config['dput']['host'])
Ejemplo n.º 3
0
def run_job(config, job):
    group = job['group_obj']
    source = job['source_obj']
    binary = job['binary_obj']

    package = {
        "name": source['name'],
        "version": source['version'],
        "type": "source" if binary is None else "binary",
        "arch": job['arch'],
        "affinity": source['affinity'] if job['arch'] in ["all", "source"] else job['arch'],
        "suite": source['suite'],
        "component": source['component'],
        "group": group,
        "source": source,
        "binary": binary,
        "config": config,
    }

    with checkout(package) as target:
        run, version = load_module(job['check'])
        firehose = create_firehose(package, version)

        firehose, log, failed, changes, files = run(
            target, package, job, firehose)

        datestr = formatdate()
        binstr = None

        if changes:
            with open(changes, 'r') as f:
                obj = Changes(f)
            obj['Distribution'] = source['suite']
            obj['X-Debile-Group'] = source['group']
            obj['X-Debile-Job'] = str(job['id'])
            with open(changes, 'wb') as f:
                obj.dump(fd=f)

            datestr = obj['Date']
            binstr = obj['Binary']
        elif binary:
            binstr = " ".join(deb['filename'].partition("_")[0] for deb in binary['debs'])

        dud = Changes()
        dud['Format'] = "1.8"
        dud['Date'] = datestr
        dud['Source'] = source['name']
        if binstr:
            dud['Binary'] = binstr
        dud['Version'] = source['version']
        dud['Architecture'] = job['arch']
        dud['Distribution'] = source['suite']
        dud['X-Debile-Group'] = source['group']
        dud['X-Debile-Check'] = job['check']
        dud['X-Debile-Job'] = str(job['id'])
        dud['X-Debile-Failed'] = "Yes" if failed else "No"

        job['failed'] = failed

        _, _, v = source['version'].rpartition(":")
        prefix = "%s_%s_%s.%d" % (source['name'], v, job['arch'], job['id'])

        with open('{prefix}.firehose.xml'.format(
                prefix=prefix), 'wb') as fd:
            fd.write(firehose.to_xml_bytes())
        dud.add_file('{prefix}.firehose.xml'.format(prefix=prefix))

        with open('{prefix}.log'.format(prefix=prefix), 'wb') as fd:
            fd.write(log.encode('utf-8'))
        dud.add_file('{prefix}.log'.format(prefix=prefix))

        if files is not None:
            for f in files:
                shutil.copyfile(f, os.path.basename(f))
                dud.add_file(os.path.basename(f))

        dudf = "{prefix}.dud".format(prefix=prefix)
        with open(dudf, 'w') as fd:
            dud.dump(fd=fd)

        if changes:
            upload(changes, job, config['gpg'], config['dput']['host'])
        upload(dudf, job, config['gpg'], config['dput']['host'])
Ejemplo n.º 4
0
def iterate():
    arches = config['arches']
    suites = config['suites']
    components = config['components']
    checks = config.get('checks', list(PLUGINS.keys()))

    # job is a serialized dictionary from debile-master ORM
    with workon(suites, components, arches, checks) as job:
        if job is None:
            raise IDidNothingError("No more jobs")

        group = proxy.get_group(job['group_id'])
        source = proxy.get_source(job['source_id'])
        binary = proxy.get_binary(job['binary_id']) if job['binary_id'] else None

        package = {
            "name": source['name'],
            "version": source['version'],
            "type": "source" if binary is None else "binary",
            "arch": "all" if binary is None else binary['arch'],
            "suite": source['suite'],
            "component": source['component'],
            "group": group,
            "source": source,
            "binary": binary,
        }

        with checkout(job, package) as check:
            run, version = load_module(job['check'])
            firehose = create_firehose(package, version)

            type_ = package['type']
            if type_ == "source":
                target = check  # Only get one.
            elif type_ == "binary":
                target = check  # tons and tons
            else:
                raise Exception("Unknown type")

            firehose, log, failed, changes = run(
                target, package, job, firehose)

            prefix = "%s" % (str(job['id']))

            dudf = "{prefix}.dud".format(prefix=prefix)
            dud = Dud_()
            dud['Created-By'] = "Dummy Entry <*****@*****.**>"
            dud['Source'] = package['source']['name']
            dud['Version'] = package['source']['version']
            dud['Architecture'] = package['arch']
            dud['X-Debile-Failed'] = "Yes" if failed else "No"
            if type_ == 'binary':
                dud['Binary'] = package['binary']['name']

            job['failed'] = failed

            with open('{prefix}.firehose.xml'.format(
                    prefix=prefix), 'wb') as fd:
                fd.write(firehose.to_xml_bytes())

            dud.add_file('{prefix}.firehose.xml'.format(prefix=prefix))

            with open('{prefix}.log'.format(prefix=prefix), 'wb') as fd:
                fd.write(log.encode('utf-8'))

            dud.add_file('{prefix}.log'.format(prefix=prefix))

            with open(dudf, 'w') as fd:
                dud.dump(fd=fd)

            if changes:
                upload(changes, job, package)
            upload(dudf, job, package)
Ejemplo n.º 5
0
def iterate():
    arches = config['arches']
    suites = config['suites']
    checks = config.get('checks', list(PLUGINS.keys()))

    # job is a serialized dictionary from debile-master ORM
    with workon(suites, arches, checks) as job:
        if job is None:
            raise IDidNothingError("No more jobs")

        source = proxy.get_source(job['source_id'])

        package = {
            "name": source['name'],
            "version": source['version'],
            "type": "source",
            "arch": "all",
            "source": source,
            "binary": None,
        }

        if job['binary_id']:
            binary = proxy.get_binary(job['binary_id'])
            package = {
                "name": binary['name'],
                "version": binary['version'],
                "type": "binary",
                "arch": binary['arch'],
                "source": source,
                "binary": binary,
            }

        with checkout(job, package) as check:
            run, version = load_module(job['name'])
            firehose = create_firehose(package, version)

            type_ = package['type']
            if type_ == "source":
                target = check  # Only get one.
            elif type_ == "binary":
                target = check  # tons and tons
            else:
                raise Exception("Unknown type")

            firehose, log, failed, changes = run(
                target, package, job, firehose)

            prefix = "%s" % (str(job['id']))

            dudf = "{prefix}.dud".format(prefix=prefix)
            dud = Dud_()
            dud['Created-By'] = "Dummy Entry <*****@*****.**>"
            dud['Source'] = package['source']['name']
            dud['Version'] = package['source']['version']
            dud['Architecture'] = package['arch']
            dud['X-Debile-Failed'] = "Yes" if failed else "No"
            if type_ == 'binary':
                dud['Binary'] = package['binary']['name']

            job['failed'] = failed

            with open('{prefix}.firehose.xml'.format(
                    prefix=prefix), 'wb') as fd:
                fd.write(firehose.to_xml_bytes())

            dud.add_file('{prefix}.firehose.xml'.format(prefix=prefix))

            with open('{prefix}.log'.format(prefix=prefix), 'wb') as fd:
                fd.write(log.encode('utf-8'))

            dud.add_file('{prefix}.log'.format(prefix=prefix))

            with open(dudf, 'w') as fd:
                dud.dump(fd=fd)

            if changes:
                upload(changes, job, package)
            upload(dudf, job, package)