Beispiel #1
0
def push(config, ctx):
    branch = get_remote_branch_name()

    args = None
    if ctx.is_rc:
        args = [
            config['PRJ_GIT_TREE'], '{0}^{{}}:{1}'.format(ctx.new_tag, branch),
            'tag',
            str(ctx.new_tag)
        ]
    else:
        args = [
            config['PRJ_GIT_TREE'], '{0}^{{}}:{1}'.format(ctx.new_tag, branch),
            '+{0}-rebase^{{}}:{1}-rebase'.format(ctx.new_tag, branch), 'tag',
            str(ctx.new_tag), 'tag', '{0}-rebase'.format(ctx.new_tag)
        ]

    gcp = ['git', 'push']
    if ctx.is_rc:
        gcp += ['-f']

    print('Dry run')
    cmd(gcp + ['-n'] + args, verbose=True)

    if confirm('OK to push?'):
        cmd(gcp + args)
def get_kernel_version():
    if not os.path.exists('/tmp/build'):
        os.makedirs('/tmp/build')

    cmd(['make', 'O=/tmp/build', 'defconfig'])
    line = cmd(['make', '-s', 'O=/tmp/build', 'kernelrelease'])
    return line.strip()[:-1]
def commit(config, rc):
    if is_dirty():
        print('repo is dirty -> abort', file=sys.stderr)
        return

    branch_name = get_remote_branch_name()
    post_fix = branch_name.split('-')[-1]
    branch_rebase = True if post_fix == 'rebase' else False

    old_head = cmd(['git', 'rev-parse', 'HEAD'])

    if branch_rebase:
        rt = get_last_rt(branch_name, '-rebase')
        if last_commit_was_release_commit():
            cmd(['git', 'reset', 'HEAD~'])
        localversion_set(config['LOCALVERSION'], rt)
    elif rc:
        rt = get_last_rt(branch_name, '-next')
        rt = rt[3:]
        rt = int(rt) + 1
        localversion_set(config['LOCALVERSION'], '-rt{0}-rc{1}'.format(rt, rc))
    else:
        localversion_inc(config['LOCALVERSION'])

    version = get_kernel_version()
    msg = 'Linux {0} {1}'.format(version, 'REBASE' if branch_rebase else '')

    print('git commit -m {0}'.format(msg))
    if confirm('OK to commit?'):
        cmd(['git', 'add', config['LOCALVERSION']])
        cmd(['git', 'commit', '-s', '-m', msg])
    else:
        cmd(['git', 'reset', '--hard', old_head])
Beispiel #4
0
def send_rc_patches(config, ctx):
    gmd = ['git', 'send-email', '--confirm=never']
    gmd += ['--to="{}"'.format(t) for t in config['MAIL_TO'].split(',')]
    gmd += [ctx.new_dir_mails]

    print('Dry run')
    gmdd = gmd.copy()
    gmdd.insert(2, '--dry-run')
    print(cmd(gmdd, verbose=True))
    if confirm('OK to send patches?'):
        cmd(gmd)
def create_series(old_tag, new_tag, dirname):
    cmd([
        'git', 'format-patch', '-q', '-o', dirname,
        '{0}..{1}'.format(old_tag, new_tag)
    ])

    patches = [
        f for f in os.listdir(dirname)
        if os.path.isfile(os.path.join(dirname, f))
    ]
    with open(dirname + '/series', 'w') as file:
        for p in patches:
            file.write('{0}\n'.format(p))
Beispiel #6
0
def tag(config):
    p = re.compile(r'^.*Linux ([0-9\.]+[-a-z0-9]+)( REBASE)*')
    lines = cmd(['git', 'log', '-1', '--pretty=%B'])
    for msg in iter(lines.splitlines()):
        m = p.match(msg)
        if not m:
            continue

        tag = 'v' + m.group(1) + ('-rebase' if m.group(2) else '')
        print('tagging as {0} with message \'{1}\''.format(tag, msg))
        if confirm('OK to tag?'):
            cmd(['git', 'tag', '-s', '-u', config['GPG_KEY_ID'],
                 '-m', msg, tag])
Beispiel #7
0
def announce(config, ctx):
    if ctx.is_rc:
        announce_rc(config, ctx)
        return

    # rfc2822.html
    # 3.3. Date and Time Specification
    timestamp = strftime('%a, %d %b %Y %H:%M:%S -0000', gmtime())

    stable_rt_text = ''
    with open(config['ANNOUNCE'], 'r') as f:
        stable_rt_text = f.read()

    print(
        stable_rt_text.format(date=timestamp,
                              mail_to=config['MAIL_TO'],
                              branch_name=get_remote_branch_name(),
                              branch_head=cmd(['git', 'rev-parse', 'HEAD']),
                              major=ctx.new_tag.major,
                              minor=ctx.new_tag.minor,
                              patch=ctx.new_tag.patch,
                              new_version=ctx.new_short_tag,
                              old_version=ctx.old_short_tag,
                              prj_dir=config['PRJ_DIR'],
                              new_tag_rt=ctx.new_tag.rt))

    print(
        cmd([
            'git', '--no-pager', 'shortlog',
            '{0}..{1}'.format(ctx.old_tag, ctx.new_tag)
        ]))

    print('---')

    print(
        cmd([
            'git', '--no-pager', 'diff', '--stat',
            '{0}..{1}'.format(ctx.old_tag, ctx.new_tag)
        ]))

    print('---')

    print(
        cmd([
            'git', '--no-pager', 'diff',
            '{0}..{1}'.format(ctx.old_tag, ctx.new_tag)
        ]))
def last_commit_was_release_commit():
    p = re.compile(r'^.*Linux ([0-9\.]+[-a-z0-9]+)( REBASE)*')
    lines = cmd(['git', 'log', '-1', '--pretty=%B'])
    for msg in iter(lines.splitlines()):
        m = p.match(msg)
        if not m:
            continue
        return True
    return False
def get_last_rt(branch_name, postfix):
    base_branch = branch_name[:-len(postfix)]
    last_tag = cmd(['git', 'describe', base_branch])
    m = re.search(r'(-rt[-a-z0-9]+)$', last_tag)
    if not m:
        print('Last tag tag {0} does not end in -rt[0-9]+ on {1}'.format(
            last_tag, branch_name),
              file=sys.stderr)
        sys.exit(1)
    return m.group(1)
Beispiel #10
0
def create_rc_patches(config, ctx):
    branch_name = get_local_branch_name()
    cmd(['git', 'checkout', '-b', 'next-tmp'])

    srt_env = os.environ.copy()
    srt_env['SRT_REVIEW_TAG'] = str(ctx.new_tag)
    srt_path = os.path.dirname(os.path.realpath(__file__))
    cmd([
        'git', 'filter-branch', '-f', '--msg-filter',
        srt_path + '/srt_git_filter.py',
        str(ctx.old_tag) + '..'
    ],
        env=srt_env)

    cmd([
        'git', 'format-patch',
        str(ctx.old_tag) + '..', '-o', ctx.new_dir_mails, '--subject-prefix',
        'PATCH RT', '--cover-letter'
    ])

    cmd(['git', 'checkout', branch_name])
    cmd(['git', 'branch', '-D', 'next-tmp'])
Beispiel #11
0
def upload(config, ctx):
    for f in ctx.get_files():
        if not os.path.isfile(f):
            print('Unable to read {0}, did you remember to create?'.format(f))
            sys.exit(1)

    path = config['PRJ_DIR']
    older_path = path + '/' + 'older'

    kup = ['kup']

    for f in ctx.get_files():
        basename = os.path.splitext(f)[0]
        kup.extend([
            'put', basename + '.xz', basename + '.sign', older_path + '/', '--'
        ])

    # skip incr_file
    for f in ctx.get_files()[:2]:
        kup.extend(['ln', older_path + '/' + os.path.basename(f), '../', '--'])

    # If we're uploading an -rc release, don't delete the old release.
    if not ctx.is_rc:
        kup.extend(
            ['rm', path + '/' + os.path.basename(ctx.old_fln_patch), '--'])
        kup.extend(
            ['rm', path + '/' + os.path.basename(ctx.old_fln_tar), '--'])

    kup.extend(['ls', path])

    print(pformat(kup))
    if confirm('OK to commit?'):
        try:
            cmd(kup)
        except CalledProcessError as e:
            print('kup failed with error code {0}'.format(e.returncode),
                  file=sys.stderr)
Beispiel #12
0
def create_tar_file(dirname, filename):
    cmd(['tar', '-C', dirname, '-cJf', filename, 'patches/'])