示例#1
0
def main():
    import argparse
    parser = argparse.ArgumentParser(description='mirror into pruned git repository')
    parser.add_argument('defconfig', metavar='defconfig-file', type=str,
                        help='the defconfig file to use')
    parser.add_argument('output_tree', metavar='output-tree', type=str,
                        help='output tree name')
    parser.add_argument('branches', metavar='branch', type=str, nargs='*', default=['master'],
                        help='branches to look at (can use globbing, default: only "master")')
    parser.add_argument('--noverify', dest='noverify', action='store_const',
                        const=True, default=False,
                        help='don\'t verify the code/Kconfig')
    parser.add_argument('--modcompat', dest='modcompat', action='store_const',
                        const=True, default=False,
                        help='create module compatibility')
    args = parser.parse_args()
    mirror = GitMirror(INPUT_TREE, OUTPUT_TREE + args.output_tree,
                       args.branches,
                       lambda config: prune_one(config, args),
                       CID_PREFIX)
    mirror.is_modified = lambda tree: git.is_modified(ignore=['versions'], tree=tree)
    mirror.always_commit_new_branch = True
    mirror.git_name = 'iwlwifi publisher'
    mirror.filter_message = _filter_message
    mirror.mirror()
示例#2
0
def check_prune(defconfig):
    msg = git.commit_message('HEAD')

    restriction = None
    data = None
    for line in msg.split('\n'):
        # handle RFC 822 style folded lines
        if data and line[0].isspace():
            data += line[1:]
            continue
        else:
            data = line

        kv = data.split('=', 1)
        data = ''
        if len(kv) != 2:
            continue
        k, v = kv
        if k == 'restriction':
            restriction = v
    if restriction != 'nopublic':
        return 0

    # if we want the top-most patch to have no public changes,
    # remember where we were
    commit = git.rev_parse()
    # first reset to the previous patch:
    git.reset(["-q", "--hard", "HEAD~1"])
    git.clean(['-fdxq'])
    # then prune, commit and remember the state
    prune(defconfig, False, '.')
    git.commit_all("prune test",
                   env={
                       'GIT_COMMITTER_NAME': 'prune tester',
                       'GIT_COMMITTER_EMAIL': '',
                       'GIT_AUTHOR_NAME': 'prune tester',
                       'GIT_AUTHOR_EMAIL': '',
                   })
    pruned_prev = git.rev_parse()
    # go back to the top commit
    git.reset(["-q", "--hard", commit])
    git.clean(['-fdxq'])
    # prune this one again
    prune(defconfig, False, '.')
    # reset to the previous prune
    git.reset([pruned_prev])
    # and check if anything is left:
    if git.is_modified():
        print("FAILURE: restriction=nopublic patch modifies prune tree")
        subprocess.call(['git', 'diff'])
        ret = 1
    else:
        ret = 0
    # eases development:
    git.reset(["-q", "--hard", commit])
    return ret