Пример #1
0
def cmd_bisect(cfg):
    if len(cfg.get('merge_ref')) != 1:
        raise Exception(
            "Bisecting currently works only with exactly one mergeref")

    ktree = skt.ktree(cfg.get('baserepo'),
                      ref=cfg.get('commitgood'),
                      wdir=cfg.get('workdir'))
    head = ktree.checkout()

    cfg['workdir'] = ktree.getpath()
    cfg['buildinfo'] = None

    logging.info("Building good commit: %s", head)
    cmd_build(cfg)
    cmd_publish(cfg)
    os.unlink(cfg.get('tarpkg'))

    runner = skt.runner.getrunner(*cfg.get('runner'))

    retcode = runner.run(cfg.get('buildurl'),
                         cfg.get('krelease'),
                         wait=True,
                         host=cfg.get('host'),
                         uid="[bisect] [good %s]" % head,
                         reschedule=False)

    cfg['host'] = runner.gethost()

    if retcode != 0:
        logging.warning("Good commit %s failed, aborting bisect", head)
        cmd_cleanup(cfg)
        return

    ktree.merge_git_ref(cfg.get('merge_ref')[0][0], cfg.get('commitbad'))
    binfo = ktree.bisect_start(head)

    ret = 0
    while ret == 0:
        cmd_build(cfg)
        cmd_publish(cfg)
        os.unlink(cfg.get('tarpkg'))
        retcode = runner.run(cfg.get('buildurl'),
                             cfg.get('krelease'),
                             wait=True,
                             host=cfg.get('host'),
                             uid="[bisect] [%s]" % binfo,
                             reschedule=False)

        (ret, binfo) = ktree.bisect_iter(retcode)

    cmd_cleanup(cfg)
Пример #2
0
def cmd_merge(cfg):
    global retcode
    utypes = []
    ktree = skt.ktree(cfg.get('baserepo'),
                      ref=cfg.get('ref'),
                      wdir=cfg.get('workdir'))
    bhead = ktree.checkout()
    commitdate = ktree.get_commit_date(bhead)
    save_state(
        cfg, {
            'baserepo': cfg.get('baserepo'),
            'basehead': bhead,
            'commitdate': commitdate
        })

    try:
        idx = 0
        for mb in cfg.get('merge_ref'):
            save_state(cfg, {
                'meregerepo_%02d' % idx: mb[0],
                'mergehead_%02d' % idx: head
            })
            (retcode, head) = ktree.merge_git_ref(*mb)

            utypes.append("[git]")
            idx += 1
            if retcode != 0:
                return

        if cfg.get('patchlist') != None:
            utypes.append("[local patch]")
            idx = 0
            for patch in cfg.get('patchlist'):
                save_state(cfg, {'localpatch_%02d' % idx: patch})
                ktree.merge_patch_file(patch)
                idx += 1

        if cfg.get('pw') != None:
            utypes.append("[patchwork]")
            idx = 0
            for patch in cfg.get('pw'):
                save_state(cfg, {'patchwork_%02d' % idx: patch})
                ktree.merge_patchwork_patch(patch)
                idx += 1
    except Exception as e:
        save_state(cfg, {'mergelog': ktree.mergelog})
        raise e

    uid = "[baseline]"
    if len(utypes):
        uid = " ".join(utypes)

    kpath = ktree.getpath()
    buildinfo = ktree.dumpinfo()
    buildhead = ktree.get_commit()

    save_state(
        cfg, {
            'workdir': kpath,
            'buildinfo': buildinfo,
            'buildhead': buildhead,
            'uid': uid
        })