コード例 #1
0
ファイル: debcheck.py プロジェクト: rr4/laniakea
def _create_debcheck(session, suite_name):
    from laniakea.native import Debcheck, create_native_baseconfig, \
        get_suiteinfo_all_suites, get_suiteinfo_for_suite

    bconf = create_native_baseconfig()

    scan_suites = []
    if suite_name:
        # we only scan a specific suite
        suite = session.query(ArchiveSuite) \
            .filter(ArchiveSuite.name == suite_name).one()
        scan_suites = [get_suiteinfo_for_suite(suite)]
    else:
        scan_suites = get_suiteinfo_all_suites()

    return Debcheck(bconf), scan_suites
コード例 #2
0
def command_sync(options):
    ''' Synchronize a dedicated set of packages '''

    if not options.packages:
        print('You need to define at least one package to synchronize!')
        sys.exit(1)

    bconf, sconf = get_sync_config()

    with session_scope() as session:
        si = session.query(SynchrotronConfig) \
            .join(SynchrotronConfig.destination_suite) \
            .join(SynchrotronConfig.source) \
            .filter(ArchiveSuite.name == options.dest_suite,
                    SynchrotronSource.suite_name == options.src_suite).one_or_none()
        if not si:
            log.error(
                'Unable to find a sync config for this source/destination combination.'
            )
            sys.exit(4)
            return

        if not si.sync_enabled:
            log.error(
                'Can not synchronize package: Synchronization is disabled for this configuration.'
            )
            sys.exit(3)
            return

        incoming_suite = get_suiteinfo_for_suite(si.destination_suite)
        sconf.syncBinaries = si.sync_binaries
        sconf.source.defaultSuite = si.source.suite_name
        sconf.source.repoUrl = si.source.repo_url

        engine = SyncEngine(bconf, sconf, incoming_suite)

        blacklist_pkgnames = get_package_blacklist()
        engine.setSourceSuite(si.source.suite_name)
        engine.setBlacklist(blacklist_pkgnames)

        ret = engine.syncPackages(options.component, options.packages,
                                  options.force)
        publish_synced_spkg_events(engine, si.source.os_name,
                                   si.source.suite_name,
                                   si.destination_suite.name, options.force)
        if not ret:
            sys.exit(2)
コード例 #3
0
def command_autosync(options):
    ''' Automatically synchronize packages '''

    with session_scope() as session:
        autosyncs = session.query(SynchrotronConfig).filter(SynchrotronConfig.sync_enabled == True) \
            .filter(SynchrotronConfig.sync_auto_enabled == True).all()  # noqa: E712

        bconf, sconf = get_sync_config()
        blacklist_pkgnames = get_package_blacklist()  # the blacklist is global for now

        for autosync in autosyncs:
            incoming_suite = get_suiteinfo_for_suite(autosync.destination_suite)
            sconf.syncBinaries = autosync.sync_binaries
            sconf.source.defaultSuite = autosync.source.suite_name
            sconf.source.repoUrl = autosync.source.repo_url

            log.info('Synchronizing packages from {}/{} with {}'.format(autosync.source.os_name, autosync.source.suite_name,
                                                                        autosync.destination_suite.name))

            emitter = EventEmitter(LkModule.SYNCHROTRON)

            engine = SyncEngine(bconf, sconf, incoming_suite)
            engine.setBlacklist(blacklist_pkgnames)

            ret, issue_data = engine.autosync()
            publish_synced_spkg_events(engine,
                                       autosync.source.os_name,
                                       autosync.source.suite_name,
                                       autosync.destination_suite.name,
                                       emitter=emitter)
            if not ret:
                sys.exit(2)
                return

            for ssuite in sconf.source.suites:
                session.query(SynchrotronIssue) \
                    .filter(SynchrotronIssue.source_suite == ssuite.name,
                            SynchrotronIssue.target_suite == incoming_suite.name,
                            SynchrotronIssue.config_id == autosync.id) \
                    .delete()

            for info in issue_data:
                issue = SynchrotronIssue()
                issue.config = autosync
                issue.kind = SynchrotronIssueKind(info.kind)
                issue.package_name = info.packageName
                issue.source_suite = info.sourceSuite
                issue.target_suite = info.targetSuite
                issue.source_version = info.sourceVersion
                issue.target_version = info.targetVersion
                issue.details = info.details
                session.add(issue)

                data = {'name': issue.package_name,
                        'src_os': autosync.source.os_name,
                        'src_suite': issue.source_suite,
                        'dest_suite': issue.target_suite,
                        'src_version': issue.source_version,
                        'dest_version': issue.target_version,
                        'kind': str(issue.kind)}

                emitter.submit_event('autosync-issue', data)
コード例 #4
0
def command_autosync(options):
    ''' Automatically synchronize packages '''

    with session_scope() as session:
        autosyncs = session.query(SynchrotronConfig).filter(SynchrotronConfig.sync_enabled == True) \
            .filter(SynchrotronConfig.sync_auto_enabled == True).all()  # noqa: E712

        bconf, sconf = get_sync_config()
        blacklist_pkgnames = get_package_blacklist(
        )  # the blacklist is global for now

        for autosync in autosyncs:
            incoming_suite = get_suiteinfo_for_suite(
                autosync.destination_suite)
            sconf.syncBinaries = autosync.sync_binaries
            sconf.source.defaultSuite = autosync.source.suite_name
            sconf.source.repoUrl = autosync.source.repo_url

            log.info('Synchronizing packages from {}/{} with {}'.format(
                autosync.source.os_name, autosync.source.suite_name,
                autosync.destination_suite.name))

            emitter = EventEmitter(LkModule.SYNCHROTRON)

            engine = SyncEngine(bconf, sconf, incoming_suite)
            engine.setBlacklist(blacklist_pkgnames)

            ret, issue_data = engine.autosync()
            publish_synced_spkg_events(engine,
                                       autosync.source.os_name,
                                       autosync.source.suite_name,
                                       autosync.destination_suite.name,
                                       emitter=emitter)
            if not ret:
                sys.exit(2)
                return

            existing_sync_issues = {}
            for ssuite in sconf.source.suites:
                all_issues = session.query(SynchrotronIssue) \
                                    .filter(SynchrotronIssue.source_suite == ssuite.name,
                                            SynchrotronIssue.target_suite == incoming_suite.name,
                                            SynchrotronIssue.config_id == autosync.id) \
                                    .all()
                for eissue in all_issues:
                    eid = '{}-{}-{}:{}'.format(eissue.package_name,
                                               eissue.source_version,
                                               eissue.target_version,
                                               str(eissue.kind))
                    existing_sync_issues[eid] = eissue

            for info in issue_data:
                issue_kind = SynchrotronIssueKind(info.kind)
                eid = '{}-{}-{}:{}'.format(info.packageName,
                                           info.sourceVersion,
                                           info.targetVersion, str(issue_kind))
                issue = existing_sync_issues.pop(eid, None)
                if issue:
                    # the issue already exists, so we just update it
                    new_issue = False
                else:
                    new_issue = True
                    issue = SynchrotronIssue()
                    issue.config = autosync
                    issue.package_name = info.packageName
                    issue.source_version = info.sourceVersion
                    issue.target_version = info.targetVersion
                    issue.kind = issue_kind

                issue.source_suite = info.sourceSuite
                issue.target_suite = info.targetSuite

                issue.details = info.details

                if new_issue:
                    session.add(issue)

                    data = {
                        'name': issue.package_name,
                        'src_os': autosync.source.os_name,
                        'suite_src': issue.source_suite,
                        'suite_dest': issue.target_suite,
                        'version_src': issue.source_version,
                        'version_dest': issue.target_version,
                        'kind': str(issue.kind)
                    }

                    emitter.submit_event('new-autosync-issue', data)

            for eissue in existing_sync_issues.values():
                session.delete(eissue)

                data = {
                    'name': eissue.package_name,
                    'src_os': autosync.source.os_name,
                    'suite_src': eissue.source_suite,
                    'suite_dest': eissue.target_suite,
                    'version_src': eissue.source_version,
                    'version_dest': eissue.target_version,
                    'kind': str(eissue.kind)
                }

                emitter.submit_event('resolved-autosync-issue', data)