Пример #1
0
def _check_untagged_builds(session, collection, package_map, build_infos):
    """
    Check whether some of the builds we have weren't untagged/deleted in the
    meantime. Only checks last builds of packages.
    """
    for info in build_infos:
        package = package_map.get(info['package_name'])
        if package and util.is_build_newer(info, package.last_build):
            # the last build (possibly more) we have was untagged/deleted
            last_valid_build_query = (session.db.query(
                Build).filter((Build.package_id == package.id)
                              & (Build.epoch == info['epoch'])
                              & (Build.version == info['version'])
                              & (Build.release == info['release'])).order_by(
                                  Build.started.desc()))
            last_valid_build = last_valid_build_query.first()
            if not last_valid_build:
                # we don't have the build anymore, register it first
                register_real_builds(session, collection, [(package.id, info)])
                last_valid_build = last_valid_build_query.first()
            # set all following builds as untagged
            # last_build pointers get reset by the trigger
            (session.db.query(Build).filter(
                Build.package_id == package.id).filter(
                    Build.started > last_valid_build.started).update(
                        {'untagged': True}))
            session.log.info("{} is no longer tagged".format(
                package.last_build))
Пример #2
0
def _check_untagged_builds(session, collection, package_map, build_infos):
    """
    Check whether some of the builds we have weren't untagged/deleted in the
    meantime. Only checks last builds of packages.
    """
    for info in build_infos:
        package = package_map.get(info['package_name'])
        # info contains the last build for the package that Koji knows
        if package and util.is_build_newer(info, package.last_build):
            # The last build (possibly more) we have is newer than last build in Koji.
            # That means it was untagged or deleted.
            # Get the last build we have that was not untagged.
            last_valid_build_query = (session.db.query(
                Build).filter((Build.package_id == package.id)
                              & (Build.epoch == info['epoch'])
                              & (Build.version == info['version'])
                              & (Build.release == info['release'])).order_by(
                                  Build.started.desc()))
            last_valid_build = last_valid_build_query.first()
            if not last_valid_build:
                # We don't have the build anymore, register it again
                register_real_builds(session, collection, [(package.id, info)])
                # Now, it must find it as we've just inserted it
                last_valid_build = last_valid_build_query.first()
            # set all following builds as untagged
            # last_build pointers get reset by the trigger
            (session.db.query(Build).filter(Build.package_id == package.id).
             filter(Build.started > last_valid_build.started if
                    last_valid_build else true()).update({'untagged': True}))
            session.log.info("{} is no longer tagged".format(
                package.last_build))
Пример #3
0
def _check_new_real_builds(session, collection, package_map, build_infos):
    """
    Checks Koji for latest builds of packages and registers possible
    new real builds.
    """
    # Find task ids we have
    existing_task_ids = (
        session.db.query(Build.task_id)
        .join(Build.package)
        .filter(Package.collection_id == collection.id)
        .filter(Build.real)
        .all_flat(set)
    )
    # Find task ids we don't have and add them
    to_add = [info for info in build_infos if info['task_id'] not in existing_task_ids]
    if to_add:
        package_build_infos = []
        for info in to_add:
            package = package_map.get(info['package_name'])
            # If the build is old, ignore it. It's of no use and might confuse other parts
            if (
                    package and
                    (package.tracked or collection.poll_untracked) and
                    util.is_build_newer(package.last_build, info)
            ):
                package_build_infos.append((package.id, info))
        if package_build_infos:
            register_real_builds(session, collection, package_build_infos)
Пример #4
0
def _check_new_real_builds(session, collection, package_map, build_infos):
    """
    Checks Koji for latest builds of packages and registers possible
    new real builds.
    """
    # Find task ids we have
    existing_task_ids = (
        session.db.query(Build.task_id)
        .join(Build.package)
        .filter(Package.collection_id == collection.id)
        .filter(Build.real)
        .all_flat(set)
    )
    # Find task ids we don't have and add them
    to_add = [info for info in build_infos if info['task_id'] not in existing_task_ids]
    if to_add:
        package_build_infos = []
        for info in to_add:
            package = package_map.get(info['package_name'])
            # If the build is old, ignore it. It's of no use and might confuse other parts
            if (
                    package and
                    (package.tracked or collection.poll_untracked) and
                    util.is_build_newer(package.last_build, info)
            ):
                package_build_infos.append((package.id, info))
        if package_build_infos:
            register_real_builds(session, collection, package_build_infos)
Пример #5
0
def get_newer_build_if_exists(session, package):
    """
    Return Koji buildInfo of a newer build than the package's last build if there is one.

    :param session: KoscheiBackendSession
    :param package: The package whose build should be compared
    :return: buildInfo or None
    """
    [info] = session.secondary_koji_for(package.collection)\
        .listTagged(package.collection.dest_tag, latest=True,
                    package=package.name, inherit=True) or [None]
    if info and util.is_build_newer(package.last_build, info):
        return info
Пример #6
0
def get_newer_build_if_exists(session, package):
    """
    Return Koji buildInfo of a newer build than the package's last build if there is one.

    :param session: KoscheiBackendSession
    :param package: The package whose build should be compared
    :return: buildInfo or None
    """
    [info] = session.secondary_koji_for(package.collection)\
        .listTagged(package.collection.dest_tag, latest=True,
                    package=package.name, inherit=True) or [None]
    if info and util.is_build_newer(package.last_build, info):
        return info
Пример #7
0
def _check_untagged_builds(session, collection, package_map, build_infos):
    """
    Check whether some of the builds we have weren't untagged/deleted in the
    meantime. Only checks last builds of packages.
    """
    for info in build_infos:
        package = package_map.get(info['package_name'])
        # info contains the last build for the package that Koji knows
        if package and util.is_build_newer(info, package.last_build):
            # The last build (possibly more) we have is newer than last build in Koji.
            # That means it was untagged or deleted.
            # Get the last build we have that was not untagged.
            last_valid_build_query = (
                session.db.query(Build)
                .filter(
                    (Build.package_id == package.id) &
                    (Build.epoch == info['epoch']) &
                    (Build.version == info['version']) &
                    (Build.release == info['release'])
                )
                .order_by(Build.started.desc())
            )
            last_valid_build = last_valid_build_query.first()
            if not last_valid_build:
                # We don't have the build anymore, register it again
                register_real_builds(session, collection,
                                     [(package.id, info)])
                # Now, it must find it as we've just inserted it
                last_valid_build = last_valid_build_query.first()
            # set all following builds as untagged
            # last_build pointers get reset by the trigger
            (
                session.db.query(Build)
                .filter(Build.package_id == package.id)
                .filter(
                    Build.started > last_valid_build.started
                    if last_valid_build else true()
                )
                .update({'untagged': True})
            )
            session.log.info("{} is no longer tagged".format(package.last_build))
Пример #8
0
def _check_new_real_builds(session, collection, package_map, build_infos):
    """
    Checks Koji for latest builds of packages and registers possible
    new real builds.
    """
    existing_task_ids = (session.db.query(Build.task_id).join(
        Build.package).filter(Package.collection_id == collection.id).filter(
            Build.real).all_flat(set))
    to_add = [
        info for info in build_infos
        if info['task_id'] not in existing_task_ids
    ]
    if to_add:
        package_build_infos = []
        for info in to_add:
            package = package_map.get(info['package_name'])
            if (package and (package.tracked or collection.poll_untracked)
                    and util.is_build_newer(package.last_build, info)):
                package_build_infos.append((package.id, info))
        if package_build_infos:
            register_real_builds(session, collection, package_build_infos)
Пример #9
0
def get_newer_build_if_exists(session, package):
    [info] = session.secondary_koji_for(package.collection)\
        .listTagged(package.collection.dest_tag, latest=True,
                    package=package.name, inherit=True) or [None]
    if info and util.is_build_newer(package.last_build, info):
        return info