예제 #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)
예제 #2
0
    def step11_push(self):
        os.chdir(self.work_tree)
        cmd(['git', 'checkout', self.branch_rt])

        stub_stdin(self, 'y')
        stub_stdouts(self)
        push(self.config, self.ctx)
예제 #3
0
def announce(config, ctx, args):
    if ctx.is_rc:
        announce_rc(config, ctx, args)
        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()

    r = cover_letter_replacements(config, ctx)

    r["date"] = timestamp
    r["branch_name"] = get_remote_branch_name()
    r["branch_head"] = cmd(['git', 'rev-parse', 'HEAD'])

    print(stable_rt_text.format(**r))

    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)]))
예제 #4
0
    def setUp(self):
        super().setUp()

        self.setup_release()

        cmd(['git', 'checkout', self.branch_rt_next])
        self.setup_add_patches(1, 3)
예제 #5
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']

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

    # create links from archive to latest dir.
    for f in ctx.get_files():
        kup.extend(['ln', older_path + '/' + os.path.basename(f), '../', '--'])

    # remove previous release from latest dir
    for f in ctx.get_old_files():
        kup.extend(['rm', path + '/' + os.path.basename(f), '--'])

    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)
예제 #6
0
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 sorted(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))
예제 #7
0
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])
예제 #8
0
    def step8_commit_rebase2(self):
        cmd(['git', 'checkout', self.branch_rt_rebase])
        cmd(['git', 'rebase', 'v4.4.15'])

        stub_stdin(self, 'y')
        stub_stdouts(self)
        commit(self.config, rc=False)
        ans = 'git commit -m Linux 4.4.15-rt5 REBASE\nOK to commit? (y/n): '
        self.assertEqual(sys.stdout.getvalue(), ans)
        lines = cmd(['git', 'show'])
        self.assertTrue(find_string(lines, 'Linux 4.4.15-rt5 REBASE'))
예제 #9
0
def send_rc_patches(config, ctx, args):
    gmd = ['git', 'send-email', '--confirm=never']
    if args.suppress_cc:
        gmd += ['--suppress-cc=all']
    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)
예제 #10
0
    def step10_create(self):
        cmd(['git', 'checkout', self.branch_rt])
        self.ctx = SrtContext(make_args(), path=self.work_tree)

        create(self.config, self.ctx)

        path = self.work_tree + '/patches/v4.4.15-rt5/'
        files = [
            path + 'patch-4.4.15-rt5.patch.xz',
            path + 'patches-4.4.15-rt5.tar.xz'
        ]
        for f in files:
            self.assertEqual(os.path.isfile(f), True)
예제 #11
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
            ])
예제 #12
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'])
예제 #13
0
 def step6_commit2(self):
     stub_stdin(self, 'y')
     stub_stdouts(self)
     commit(self.config, rc=False)
     ans = 'git commit -m Linux 4.4.15-rt5\nOK to commit? (y/n): '
     self.assertEqual(sys.stdout.getvalue(), ans)
     lines = cmd(['git', 'show'])
     self.assertTrue(find_string(lines, 'Linux 4.4.15-rt5'))
예제 #14
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'
    incr_path = path + '/' + 'incr'

    kup = ['kup']

    for i, f in enumerate(ctx.get_files()):
        basename = os.path.splitext(f)[0]
        if i == 2:
            kup.extend([
                'put', basename + '.xz', basename + '.sign', incr_path + '/',
                '--'
            ])
        else:
            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)
예제 #15
0
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
예제 #16
0
def get_last_rt(branch_name, postfix):
    base_branch = branch_name[:-len(postfix)]
    last_tag = cmd(['git', 'describe', '--abbrev=0', '--tags', base_branch])
    m = re.search(r'(-rt[0-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)
예제 #17
0
 def setup_stable_new_release(self, version):
     os.chdir(self.stable_repo)
     with open('version', 'w') as f:
         f.write(version)
         f.write('\n\n')
     cmd(['git', 'add', 'version'])
     cmd(['git', 'commit', '-m', 'New stable release'])
     cmd(['git', 'tag', '-a', '-m', 'v' + version, 'v' + version])
예제 #18
0
    def setup_stable_repo(self, version):
        os.mkdir(self.stable_repo)
        os.chdir(self.stable_repo)
        cmd(['git', 'init', '--initial-branch=master'])
        self.setup_git_tree('.')
        with open('version', 'w') as f:
            f.write(version)
            f.write('\n\n')
        with open('Makefile', 'w') as f:
            # make kernelrelease adds an bogus? char to the end of the string
            f.write(makefile)

        cmd(['git', 'add', 'version', 'Makefile'])
        cmd(['git', 'commit', '-m', 'Initial stable commit'])
        cmd(['git', 'tag', '-a', '-m', 'v' + version, 'v' + version])
예제 #19
0
    def setup_gpg(self):
        self.gnupghome = tempfile.mkdtemp()
        os.chmod(self.gnupghome, 0o700)

        cfg_file = self.gnupghome + '/gpg.batch'
        with open(cfg_file, 'w') as f:
            f.write(gnupg_config)

        cmd(['gpg2', '--batch', '--generate-key', cfg_file],
            env={'GNUPGHOME': self.gnupghome})
        lines = cmd(['gpg2', '--list-secret-keys', '--with-colons'],
                    env={'GNUPGHOME': self.gnupghome})

        key = ''
        for line in lines.splitlines():
            c = line.split(':')
            if c[0] != 'fpr':
                continue
            key = c[-2]
            break

        self.config['GPG_KEY_ID'] = key
        self.config['GNUPGHOME'] = self.gnupghome
예제 #20
0
    def setup_add_patches(self, start, stop):
        os.chdir(self.work_tree)
        cmd(['git', 'checkout', self.branch_rt_next])
        cmd(['git', 'reset', '--hard', self.branch_rt])

        for n in range(start, stop):
            filename = 'file{}.txt'.format(n)
            with open(filename, 'w') as f:
                f.write(filename)
                f.write('\n')

            cmd(['git', 'add', filename])
            msg = """\
            Add {}

            Here goes nothing and you are no fun.
            """.format(filename)
            msg = textwrap.dedent(msg)
            cmd(['git', 'commit', '-m', msg])
예제 #21
0
    def setup_release(self):
        os.chdir(self.work_tree)
        cmd(['git', 'checkout', self.branch_rt])

        # step1_commit()
        stub_stdin(self, 'y')
        stub_stdouts(self)
        commit(self.config, rc=False)

        # step2_tag()
        stub_stdin(self, 'y')
        stub_stdouts(self)
        tag(self.config)

        # step3_commit_rebase()
        cmd(['git', 'checkout', self.branch_rt_rebase])
        cmd(['git', 'rebase', 'v4.4.14'])

        stub_stdin(self, 'y')
        stub_stdouts(self)
        commit(self.config, rc=False)

        # step4_tag_rebase()
        stub_stdin(self, 'y')
        stub_stdouts(self)
        tag(self.config)

        # step5_create()
        ctx = SrtContext(self.work_tree)
        ctx.add_tag('old', 'v4.4.13-rt3')
        ctx.add_tag('new', 'v4.4.14-rt4')
        ctx.init()

        # step8_push()
        os.chdir(self.work_tree)
        cmd(['git', 'checkout', self.branch_rt])

        stub_stdin(self, 'y')
        stub_stdouts(self)
        push(self.config, ctx)
예제 #22
0
def get_kernel_version():
    tmp = tempfile.mkdtemp()
    cmd(['make', 'O=%s' % tmp, 'defconfig'])
    line = cmd(['make', '-s', 'O=%s' % tmp, 'kernelrelease'])
    shutil.rmtree(tmp)
    return line.strip()[:-1]
예제 #23
0
def create_tar_file(dirname, filename):
    cmd(['tar', '-C', dirname, '-cJf', filename, 'patches/'])
예제 #24
0
 def do_merge(self):
     os.chdir(self.work_tree)
     cmd(['git', 'checkout', self.branch_rt])
     cmd(['git', 'fetch', '--all'])
     cmd(['git', 'merge', 'v4.4.14'])
예제 #25
0
 def setup_rt_repo(self):
     os.chdir(self.tdir)
     cmd(['git', 'clone', self.stable_repo, os.path.basename(self.rt_repo)])
     self.setup_git_tree(self.rt_repo)
     os.chdir(self.rt_repo)
     with open('rt.patch', 'w') as f:
         f.write('adding magic rt feature\n')
     with open(self.config['LOCALVERSION'], 'w') as f:
         f.write('-rt3\n')
     cmd(['git', 'add', 'rt.patch', self.config['LOCALVERSION']])
     cmd(['git', 'commit', '-m', 'Add -rt patches'])
     cmd(['git', 'checkout', '-b', self.branch_rt])
     cmd(['git', 'branch', self.branch_rt_rebase])
     cmd(['git', 'branch', self.branch_rt_next])
     cmd(['git', 'tag', '-a', '-m', 'v4.4.13-rt3', 'v4.4.13-rt3'])
     cmd(['git', 'checkout', 'master'])
예제 #26
0
 def do_merge(self, version):
     os.chdir(self.work_tree)
     cmd(['git', 'checkout', self.branch_rt])
     cmd(['git', 'fetch', '--all'])
     cmd(['git', 'merge', 'v' + version])
예제 #27
0
 def setup_git_tree(self, path):
     cmd(['git', '-C', path, 'config', 'user.name', 'Mighty Eagle'])
     cmd(['git', '-C', path, 'config', 'user.email', '*****@*****.**'])
예제 #28
0
 def setup_work_tree(self):
     os.chdir(self.tdir)
     cmd(['git', 'clone', self.rt_repo, os.path.basename(self.work_tree)])
     self.setup_git_tree(self.work_tree)
     os.chdir(self.work_tree)
     cmd(['git', 'remote', 'add', 'stable', self.stable_repo])