Exemple #1
0
def accept_dud(session, dud, builder):
    fire = dud.get_firehose()
    failed = True if dud.get('X-Debile-Failed', None) == "Yes" else False

    job = session.query(Job).get(dud['X-Debile-Job'])

    fire, _ = idify(fire)
    fire = uniquify(session, fire)

    result = Result.from_job(job)
    result.failed = failed
    result.firehose = fire
    session.merge(result)  # Needed because a *lot* of the Firehose is
    # going to need unique ${WORLD}.

    job.dud_uploaded(session, result)
    session.commit()  # Neato.

    repo = result.get_repo()
    try:
        repo.add_dud(dud)
    except FilesAlreadyRegistered:
        return reject_dud(session, dud, "dud-files-already-registered")

    emit('receive', 'result', result.debilize())
Exemple #2
0
def accept_source_changes(session, changes, user):
    group = changes.get('X-Lucy-Group', "default")
    suite = changes['Distribution']

    try:
        group_suite = session.query(GroupSuite).filter(
            Group.name==group,
            Suite.name==suite,
        ).one()
    except MultipleResultsFound:
        return reject_changes(session, changes, "internal-error")
    except NoResultFound:
        return reject_changes(session, changes, "invalid-suite-for-group")

    dsc = changes.get_dsc_obj()
    if dsc['Source'] != changes['Source']:
        return reject_changes(session, changes, "dsc-does-not-march-changes")
    if dsc['Version'] != changes['Version']:
        return reject_changes(session, changes, "dsc-does-not-march-changes")

    try:
        source = session.query(Source).filter(
            Source.name==dsc['Source'],
            Source.version==dsc['Version'],
            GroupSuite.group==group_suite.group,
        ).one()
        return reject_changes(session, changes, "source-already-in-group")
    except MultipleResultsFound:
        return reject_changes(session, changes, "internal-error")
    except NoResultFound:
        pass

    component = session.query(Component).filter_by(name="main").one()

    if 'Build-Architecture-Indep' in dsc:
        valid_affinities = dsc['Build-Architecture-Indep']
    elif 'X-Build-Architecture-Indep' in dsc:
        valid_affinities = dsc['X-Build-Architecture-Indep']
    elif 'X-Arch-Indep-Build-Arch' in dsc:
        valid_affinities = dsc['X-Arch-Indep-Build-Arch']
    else:
        valid_affinities = "any"

    source = create_source(dsc, group_suite, component, user)
    create_jobs(source, valid_affinities)

    session.add(source)  # OK. Populated entry. Let's insert.
    session.commit()  # Neato.

    # OK. We have a changes in order. Let's roll.
    repo = Repo(group_suite.group.repo_path)
    repo.add_changes(changes)

    emit('accept', 'source', source.debilize())

    # OK. It's safely in the database and repo. Let's cleanup.
    for fp in [changes.get_filename()] + changes.get_files():
        os.unlink(fp)
Exemple #3
0
def accept_source_changes(session, changes, user):

    gid = changes.get('X-Lucy-Group', "default")
    sid = changes['Distribution']

    MAINTAINER = re.compile("(?P<name>.*) \<(?P<email>.*)\>")

    group = session.query(Group).filter_by(name=gid).one()
    suite = session.query(Suite).filter_by(name=sid).one()

    source = Source(
        uploader=user,
        name=changes['Source'],
        version=changes['Version'],
        group=group,
        suite=suite,
        uploaded_at=dt.datetime.utcnow(),
        updated_at=dt.datetime.utcnow()
    )

    source.maintainers.append(Maintainer(
        comaintainer=False,
        **MAINTAINER.match(changes['Maintainer']).groupdict()
    ))

    dsc = changes.get_dsc_obj()

    whos = (x.strip() for x in dsc.get("Uploaders", "").split(",") if x != "")

    for who in whos:
        source.maintainers.append(Maintainer(
            comaintainer=True,
            **MAINTAINER.match(who).groupdict()
        ))

    arches = dsc['Architecture'].split()
    source.create_jobs(session, arches)

    session.add(source)  # OK. Populated entry. Let's insert.
    session.commit()  # Neato.

    # OK. We have a changes in order. Let's roll.
    repo = group.get_repo()
    repo.add_changes(changes)

    # OK. It's safely in the database and repo. Let's cleanup.
    for fp in [changes.get_filename()] + changes.get_files():
        os.unlink(fp)
Exemple #4
0
def accept_binary_changes(session, changes, builder):
    # OK. We'll relate this back to a build job.
    job = changes.get('X-Debile-Job', None)
    if job is None:
        return reject_changes(session, changes, "no-job")
    job = session.query(Job).get(job)
    source = job.source

    if changes.get('Source') != source.name:
        return reject_changes(session, changes, "binary-source-name-mismatch")

    if changes.get("Version") != source.version:
        return reject_changes(session, changes, "binary-source-version-mismatch")

    if changes.get('X-Lucy-Group', "default") != source.group_suite.group.name:
        return reject_changes(session, changes, "binary-source-group-mismatch")

    if changes.get('Distribution') != source.group_suite.suite.name:
        return reject_changes(session, changes, "binary-source-suite-mismatch")

    if changes.get("Architecture") != job.arch.name:
        return reject_changes(session, changes, "wrong-architecture")

    if builder != job.builder:
        return reject_changes(session, changes, "wrong-builder")

    binary = Binary.from_job(job)

    ## OK. Let's make sure we can add this.
    try:
        repo = Repo(job.source.group_suite.group.repo_path)
        repo.add_changes(changes)
    except RepoSourceAlreadyRegistered:
        return reject_changes(session, changes, 'stupid-source-thing')

    job.changes_uploaded(session, binary)
    session.add(binary)
    session.commit()

    emit('accept', 'binary', binary.debilize())

    # OK. It's safely in the database and repo. Let's cleanup.
    for fp in [changes.get_filename()] + changes.get_files():
        os.unlink(fp)
Exemple #5
0
def accept_binary_changes(session, changes, builder):
    # OK. We'll relate this back to a build job.
    job = changes.get('X-Debile-Job', None)
    if job is None:
        return reject_changes(session, changes, "no-job")
    job = session.query(Job).get(job)
    source = job.source

    if changes.get('Source') != source.name:
        return reject_changes(session, changes, "binary-source-name-mismatch")

    if changes.get("Version") != source.version:
        return reject_changes(session, changes,
                              "binary-source-version-mismatch")

    if changes.get("Architecture") != job.arch.name:
        return reject_changes(session, changes, "wrong-architecture")

    if builder != job.builder:
        return reject_changes(session, changes, "wrong-builder")

    binary = Binary.from_job(job)

    ## OK. Let's make sure we can add this.
    repo = binary.group.get_repo()
    try:
        repo.add_changes(changes)
    except RepoSourceAlreadyRegistered:
        return reject_changes(session, changes, 'stupid-source-thing')

    job.changes_uploaded(session, binary)
    session.add(binary)
    session.commit()

    emit('accept', 'binary', binary.debilize())

    # OK. It's safely in the database and repo. Let's cleanup.
    for fp in [changes.get_filename()] + changes.get_files():
        os.unlink(fp)
Exemple #6
0
def accept_dud(session, dud, builder):
    fire = dud.get_firehose()
    failed = True if dud['X-Debile-Failed'] == "Yes" else False

    job = session.query(Job).get(dud['X-Debile-Job'])

    fire, _ = idify(fire)
    fire = uniquify(session, fire)

    result = Result()
    result.job = job
    result.source = job.source
    result.check = job.check
    result.firehose = fire
    # result.binary = # XXX: FIX THIS
    session.merge(result)  # Needed because a *lot* of the Firehose is 
    # going to need unique ${WORLD}.
    session.commit()  # Neato.

    # OK. It's safely in the database and repo. Let's cleanup.
    for fp in [dud.get_filename()] + dud.get_files():
        os.unlink(fp)
Exemple #7
0
def accept_binary_changes(session, changes, builder):
    # OK. We'll relate this back to a build job.
    job = changes.get('X-Debile-Job', None)
    if job is None:
        return reject_changes(session, changes, "no-job")
    job = session.query(Job).get(job)
    source = job.source

    if changes.get('Source') != source.name:
        return reject_changes(session, changes, "binary-source-name-mismatch")

    if changes.get("Version") != source.version:
        return reject_changes(
            session, changes, "binary-source-version-mismatch")

    arch = changes['Architecture']
    if " " in arch:
        return reject_changes(session, changes, "multi-arch-upload")

    arch = session.query(Arch).filter_by(name=arch).one()
    binary = Binary.from_source(source, builder=builder, arch=arch)

    ## OK. Let's make sure we can add this.
    repo = binary.group.get_repo()
    try:
        repo.add_changes(changes)
    except RepoSourceAlreadyRegistered:
        return reject_changes(session, changes, 'stupid-source-thing')

    binary.create_jobs(session)

    session.add(binary)
    session.commit()

    # OK. It's safely in the database and repo. Let's cleanup.
    for fp in [changes.get_filename()] + changes.get_files():
        os.unlink(fp)
    def _create_debile_source(self, session, pkg):
        user = session.query(Person).filter_by(email="*****@*****.**").one()

        group_suite = (
            session.query(GroupSuite)
            .join(GroupSuite.group)
            .join(GroupSuite.suite)
            .filter(Group.name == "default", Suite.name == pkg.suite)
            .one()
        )
        component = session.query(Component).filter(Component.name == pkg.component).one()

        aroot = None
        if pkg.queue_name:
            # package is in a build-queue
            aroot = self._buildq_path
        else:
            aroot = self._archive_path

        dsc_fname = "{root}/{directory}/{filename}".format(root=aroot, directory=pkg.directory, filename=pkg.dsc)

        dsc = Dsc(open(dsc_fname))
        if "Build-Architecture-Indep" in dsc:
            valid_affinities = dsc["Build-Architecture-Indep"]
        elif "X-Build-Architecture-Indep" in dsc:
            valid_affinities = dsc["X-Build-Architecture-Indep"]
        elif "X-Arch-Indep-Build-Arch" in dsc:
            valid_affinities = dsc["X-Arch-Indep-Build-Arch"]
        else:
            valid_affinities = "any"

        source = create_source(dsc, group_suite, component, user, self._affinity_preference, valid_affinities)
        source.directory = pkg.directory
        source.dsc_filename = pkg.dsc
        session.add(source)

        for aname in pkg.installed_archs:
            arch = session.query(Arch).filter_by(name=aname).one()
            binary = Binary(source=source, arch=arch, uploaded_at=source.uploaded_at)
            session.add(binary)

            for name, arch, filename in pkg.binaries:
                if arch == binary.arch.name:
                    directory, _, filename = filename.rpartition("/")
                    deb = Deb(binary=binary, directory=directory, filename=filename)
                    session.add(deb)

        create_jobs(source, dose_report="No dose-builddebcheck report available yet.")

        oldsources = session.query(Source).filter(Source.group_suite == source.group_suite, Source.name == source.name)
        for oldsource in oldsources:
            if version_compare(oldsource.version, source.version) >= 0:
                continue

            # Drop any old jobs that are still pending.
            for job in oldsource.jobs:
                if (job.check.build and not any(job.built_binaries)) or not any(job.results):
                    session.delete(job)
                elif job.failed is None:
                    job.failed = any(result.failed for result in job.results)
                    job.builder = None
                    job.assigned_at = None
                    job.finished_at = None

            # Actually remove jobs marked for deletion above.
            session.commit()

            # If after cleanup there is no build jobs left, remove the source completely
            if not any(job.check.build for job in oldsource.jobs):
                session.delete(oldsource)

        print("Created source for %s %s" % (source.name, source.version))
        emit("accept", "source", source.debilize())
Exemple #9
0
def accept_source_changes(session, changes, user):

    gid = changes.get('X-Lucy-Group', "default")
    sid = changes['Distribution']

    try:
        group = session.query(Group).filter_by(name=gid).one()
        suite = session.query(Suite).filter_by(name=sid).one()
    except MultipleResultsFound:
        return reject_changes(session, changes, "internal-error")
    except NoResultFound:
        return reject_changes(session, changes, "invalid-group-or-suite")

    try:
        source = session.query(Source).filter_by(
            name=changes['Source'],
            version=changes['Version'],
            group=group,
        ).one()
        return reject_changes(session, changes, "source-already-in-group")
    except MultipleResultsFound:
        return reject_changes(session, changes, "internal-error")
    except NoResultFound:
        pass

    MAINTAINER = re.compile("(?P<name>.*) \<(?P<email>.*)\>")

    source = Source(uploader=user,
                    name=changes['Source'],
                    version=changes['Version'],
                    group=group,
                    suite=suite,
                    uploaded_at=dt.datetime.utcnow(),
                    updated_at=dt.datetime.utcnow())

    source.maintainers.append(
        Maintainer(comaintainer=False,
                   **MAINTAINER.match(changes['Maintainer']).groupdict()))

    dsc = changes.get_dsc_obj()

    whos = (x.strip() for x in dsc.get("Uploaders", "").split(",") if x != "")

    for who in whos:
        source.maintainers.append(
            Maintainer(comaintainer=True, **MAINTAINER.match(who).groupdict()))

    arches = dsc['Architecture'].split()
    create_jobs(source, session, arches)

    session.add(source)  # OK. Populated entry. Let's insert.
    session.commit()  # Neato.

    # OK. We have a changes in order. Let's roll.
    repo = group.get_repo()
    repo.add_changes(changes)

    emit('accept', 'source', source.debilize())

    # OK. It's safely in the database and repo. Let's cleanup.
    for fp in [changes.get_filename()] + changes.get_files():
        os.unlink(fp)
    def _create_debile_source(self, session, pkg):
        user = session.query(Person).filter_by(
            email="*****@*****.**").one()

        group_suite = session.query(GroupSuite).join(GroupSuite.group).join(
            GroupSuite.suite).filter(
                Group.name == "default",
                Suite.name == pkg.suite,
            ).one()
        component = session.query(Component).filter(
            Component.name == pkg.component).one()

        dsc_fname = "{root}/{directory}/{filename}".format(
            root=self._archive_path,
            directory=pkg.directory,
            filename=pkg.dsc,
        )

        dsc = Dsc(open(dsc_fname))
        if 'Build-Architecture-Indep' in dsc:
            valid_affinities = dsc['Build-Architecture-Indep']
        elif 'X-Build-Architecture-Indep' in dsc:
            valid_affinities = dsc['X-Build-Architecture-Indep']
        elif 'X-Arch-Indep-Build-Arch' in dsc:
            valid_affinities = dsc['X-Arch-Indep-Build-Arch']
        else:
            valid_affinities = "any"

        source = create_source(dsc, group_suite, component, user,
                               self._affinity_preference, valid_affinities)
        source.directory = pkg.directory
        source.dsc_filename = pkg.dsc
        session.add(source)

        for aname in pkg.installed_archs:
            arch = session.query(Arch).filter_by(name=aname).one()
            binary = Binary(source=source,
                            arch=arch,
                            uploaded_at=source.uploaded_at)
            session.add(binary)

            for name, arch, filename in pkg.binaries:
                if arch == binary.arch.name:
                    directory, _, filename = filename.rpartition('/')
                    deb = Deb(binary=binary,
                              directory=directory,
                              filename=filename)
                    session.add(deb)

        create_jobs(source,
                    dose_report="No dose-builddebcheck report available yet.")

        oldsources = session.query(Source).filter(
            Source.group_suite == source.group_suite,
            Source.name == source.name,
        )
        for oldsource in oldsources:
            if version_compare(oldsource.version, source.version) >= 0:
                continue

            # Drop any old jobs that are still pending.
            for job in oldsource.jobs:
                if (job.check.build and
                        not any(job.built_binaries)) or not any(job.results):
                    session.delete(job)
                elif job.failed is None:
                    job.failed = any(result.failed for result in job.results)
                    job.builder = None
                    job.assigned_at = None
                    job.finished_at = None

            # Actually remove jobs marked for deletion above.
            session.commit()

            # If after cleanup there is no build jobs left, remove the source completely
            if not any(job.check.build for job in oldsource.jobs):
                session.delete(oldsource)

        print("Created source for %s %s" % (source.name, source.version))
        emit('accept', 'source', source.debilize())