Exemplo n.º 1
0
        if not config.has_option(tree, 'output'):
            print("No output defined in section %s" % tree)
            sys.exit(3)

    with tempdir.tempdir() as kernel_tmpdir:
        # get cachedir, or use temporary directory
        if not config.has_option('DEFAULT', 'cachedir'):
            cachedir = os.path.join(kernel_tmpdir, 'cachedir')
        else:
            cachedir = config.get('DEFAULT', 'cachedir')

        if not os.path.isdir(cachedir):
            os.makedirs(cachedir)
        kernelobjdir = os.path.join(cachedir, 'kernel')

        backport_rev = git.rev_parse(tree=source_dir)

        for tree in trees:
            input = config.get(tree, 'input')
            output = config.get(tree, 'output')
            defconfig = None
            if config.has_option(tree, 'defconfig'):
                defconfig = config.get(tree, 'defconfig')
            branches = [
                r.strip() for r in config.get(tree, 'branches').split(',')
            ]

            update_cache_objects(input, kernelobjdir, input=True)

            wgitref = os.path.join(cachedir, 'backport-' + tree)
Exemplo n.º 2
0
        if not config.has_option(tree, 'output'):
            print("No output defined in section %s" % tree)
            sys.exit(3)

    with tempdir.tempdir() as kernel_tmpdir:
        # get cachedir, or use temporary directory
        if not config.has_option('DEFAULT', 'cachedir'):
            cachedir = os.path.join(kernel_tmpdir, 'cachedir')
        else:
            cachedir = config.get('DEFAULT', 'cachedir')

        if not os.path.isdir(cachedir):
            os.makedirs(cachedir)
        kernelobjdir = os.path.join(cachedir, 'kernel')

        backport_rev = git.rev_parse(tree=source_dir)

        for tree in trees:
            input = config.get(tree, 'input')
            output = config.get(tree, 'output')
            defconfig = None
            if config.has_option(tree, 'defconfig'):
                defconfig = config.get(tree, 'defconfig')
            branches = [r.strip() for r in config.get(tree, 'branches').split(',')]

            update_cache_objects(input, kernelobjdir, input=True)

            wgitref = os.path.join(cachedir, 'backport-' + tree)

            update_cache_objects(output, wgitref, input=False)
        if not config.has_option(tree, 'output'):
            print("No output defined in section %s" % tree)
            sys.exit(3)

    with tempdir.tempdir() as kernel_tmpdir:
        # get cachedir, or use temporary directory
        if not config.has_option('DEFAULT', 'cachedir'):
            cachedir = os.path.join(kernel_tmpdir, 'cachedir')
        else:
            cachedir = config.get('DEFAULT', 'cachedir')

        if not os.path.isdir(cachedir):
            os.makedirs(cachedir)
        kernelobjdir = os.path.join(cachedir, 'kernel')

        backport_rev = git.rev_parse(tree=source_dir)

        for tree in trees:
            input = config.get(tree, 'input')
            output = config.get(tree, 'output')
            defconfig = None
            if config.has_option(tree, 'defconfig'):
                defconfig = config.get(tree, 'defconfig')
            branches = [r.strip() for r in config.get(tree, 'branches').split(',')]

            update_cache_objects(input, kernelobjdir)

            wgitref = os.path.join(cachedir, 'backport-' + tree)

            update_cache_objects(output, wgitref)
Exemplo n.º 4
0
def handle_commit(args,
                  msg,
                  branch,
                  treename,
                  kernelobjdir,
                  tmpdir,
                  wgitdir,
                  backport_rev,
                  kernel_rev,
                  prev_kernel_rev=None,
                  defconfig=None,
                  env={},
                  commit_failure=True,
                  append_shortlog=None,
                  add_changeid=False):
    log = []

    def logwrite(l):
        log.append(l)

    wdir = os.path.join(tmpdir, kernel_rev)
    os.makedirs(wdir)
    env = env.copy()
    env.update({
        'GIT_COMMITTER_NAME': SCRIPT_GIT_NAME,
        'GIT_COMMITTER_EMAIL': SCRIPT_GIT_EMAIL,
    })
    try:
        bpid = gentree.Bp_Identity(integrate=False,
                                   kconfig_prefix='CPTCFG_',
                                   project_prefix='',
                                   project_dir=wdir,
                                   target_dir=wdir,
                                   target_dir_name='',
                                   kconfig_source_var='$BACKPORT_DIR')
        failure = gentree.process(kernelobjdir,
                                  open(args.copy_list, 'r'),
                                  bpid=bpid,
                                  git_revision=kernel_rev,
                                  base_name=tree,
                                  logwrite=logwrite,
                                  verbose=True,
                                  git_tracked_version=True)

        newline = '\n'
        if failure:
            env.update({
                'GIT_AUTHOR_NAME': SCRIPT_GIT_NAME,
                'GIT_AUTHOR_EMAIL': SCRIPT_GIT_EMAIL,
            })
            msg = 'Failed to create backport\n\n%s%s: %s' % (PREFIX, FAIL,
                                                             failure)
            for l in log:
                print(l)
            newline = ''
            append_shortlog = None
            if prev_kernel_rev:
                msg += '\n%s%s-last-success: %s' % (PREFIX, tree,
                                                    prev_kernel_rev)

        os.rename(wgitdir, os.path.join(wdir, '.git'))

        if not failure:
            git.rm(opts=['--ignore-unmatch', '-q', '--cached', '-r', '.'],
                   tree=wdir)
            if defconfig:
                os.symlink('defconfigs/%s' % defconfig,
                           os.path.join(wdir, 'defconfig'))
            git.add('.', tree=wdir)
        else:
            git.reset(opts=['-q'], tree=wdir)

        parents = [git.rev_parse('HEAD', tree=wdir)]
        if not failure or commit_failure:
            if append_shortlog:
                files = []
                for d in git.status(tree=wdir):
                    files.extend(d[1:])
                if files:
                    msg += '\n' + append_shortlog[2] + '\n\n'
                    msg += git.shortlog(append_shortlog[0],
                                        append_shortlog[1],
                                        tree=kernelobjdir,
                                        files=files)
                else:
                    msg += "\nNo commits changed the generated code.\n\n"

            msg += '''%(newline)s
%(PREFIX)sbackport: %(bprev)s
%(PREFIX)s%(tree)s: %(krev)s
''' % {
                'newline': newline,
                'PREFIX': PREFIX,
                'bprev': backport_rev,
                'tree': treename,
                'krev': kernel_rev,
            }

            if add_changeid:
                msg = add_changeid_to_message(msg)

            treeid = git.write_tree(tree=wdir)
            git.commit_tree(treeid, msg, parents, tree=wdir, env=env)
            git.push(opts=['-f', '-q', 'origin', branch], tree=wdir)
        os.rename(os.path.join(wdir, '.git'), wgitdir)
    finally:
        if os.path.isdir(wdir):
            shutil.rmtree(wdir)

    return failure
Exemplo n.º 5
0
        if not config.has_option(tree, 'output'):
            print("No output defined in section %s" % tree)
            sys.exit(3)

    with tempdir.tempdir() as kernel_tmpdir:
        # get cachedir, or use temporary directory
        if not config.has_option('DEFAULT', 'cachedir'):
            cachedir = os.path.join(kernel_tmpdir, 'cachedir')
        else:
            cachedir = config.get('DEFAULT', 'cachedir')

        if not os.path.isdir(cachedir):
            os.makedirs(cachedir)
        kernelobjdir = os.path.join(cachedir, 'kernel')

        backport_rev = git.rev_parse(tree=source_dir)

        for tree in trees:
            input = config.get(tree, 'input')
            output = config.get(tree, 'output')
            defconfig = None
            if config.has_option(tree, 'defconfig'):
                defconfig = config.get(tree, 'defconfig')
            branches = [
                r.strip() for r in config.get(tree, 'branches').split(',')
            ]

            update_cache_objects(input, kernelobjdir)

            wgitref = os.path.join(cachedir, 'backport-' + tree)