示例#1
0
def gen_categories():
    """Generate categories listing."""
    categories = glob('*-*') + ['virtual', ]
    dep(['profiles/categories', ], categories)
    with open('profiles/categories', 'w') as file:
        for cat in sorted(categories):
            if not os.path.isdir(cat):
                print(warn('Category match on %s, may cause problems with '
                           'portage' % cat))
                continue
            file.write(cat + '\n')
    print(success('categories list generated!'))
示例#2
0
def gen_html():
    """Generate HTML output."""
    rst_files = glob('*.rst')
    dep(map(lambda s: s[:-4] + '.html', rst_files), rst_files, mapping=True)
    for file in glob('*.rst'):
        html_file = file[:-4] + '.html'
        if newer(html_file, file):
            break
        try:
            publish_file(open(file), destination=open(html_file, 'w'),
                         settings_overrides={'halt_level': 1})
        except SystemMessage:
            exit(1)
        print(success('%s generated!' % file))
    print(success('All reST generated!'))
示例#3
0
def gen_thanks():
    """Generate Sphinx contributor doc."""
    dep(['doc/thanks.rst', ], ['README.rst'])
    data = open('README.rst').read()
    data = sub("\n('+)\n", lambda m: '\n' + "-" * len(m.groups()[0]) + '\n',
               data)
    data = data.splitlines()
    start = data.index('Contributors')
    end = data.index('Python multi-ABI support')
    data[start + 1] = sub('-', '=', data[start + 1])

    with open('doc/thanks.rst', 'w') as file:
        add_nl = lambda x: map(lambda s: s + '\n', x)
        file.writelines(add_nl(data[start:end]))
        links = filter(lambda s: s.startswith(('.. _email:', '.. _GitHub:')),
                       data)
        file.writelines(add_nl(links))
    print(success('thanks.rst generated!'))
示例#4
0
def gen_manifests():
    """Generate Manifest files."""
    packages = glob('*-*/*/*') + glob('virtual/*/*')
    dep(glob('*-*/*/Manifest') + glob('virtual/*/Manifest'), packages)
    base_dir = os.path.abspath(os.curdir)
    if not SIGN_KEY:
        print(warn('No GnuPG key set!'))
    for package in sorted(packages):
        try:
            os.chdir(package)
            if not any(map(lambda f: newer(f, 'Manifest'), glob('*'))):
                break
            check_call(['repoman', 'manifest'])
            if SIGN_KEY:
                check_call(['gpg', '--local-user', SIGN_KEY, '--clearsign',
                            'Manifest'])
                os.rename('Manifest.asc', 'Manifest')
        finally:
            os.chdir(base_dir)
示例#5
0
def gen_removals():
    """Generate remind file for package removals."""
    dep(['support/removal.rem', ], ['profiles/package.mask', ])
    chunks = open("profiles/package.mask").read().split("\n\n")
    removals = defaultdict(list)
    for chunk in filter(lambda s: "\n# X-Removal: " in s, chunks):
        data = chunk[chunk.index("X-Removal"):].split("\n")
        removal_date = data[0][11:]
        removals[removal_date].append(data[1:])

    with open("support/removal.rem", "w") as file:
        file.write("# THIS FILE IS AUTOGENERATED FROM "
                   "profiles/package.mask\n\n")
        for date, items in sorted(removals.items()):
            for pkgs in items:
                for pkg in filter(None, pkgs):
                    file.write("REM %s *1 PRIORITY 2500 "
                               'MSG %%"Removal due for %s%%" %%a\n'
                               % (date, pkg))
    print(success('removal.rem generated!'))
示例#6
0
def gen_cupage_conf():
    """Generate a new cupage.conf file."""
    dep(['support/cupage.conf', ], glob('*-*/*/watch'))
    with open('support/cupage.conf', 'w') as f:
        for category in sorted(glob('*-*')):
            os.chdir(category)
            f.write('### %s {{{\n' % category)
            for package in sorted(glob('*')):
                watch_data = open('%s/watch' % package).read()[:-1]
                if watch_data.startswith('# Live ebuild'):
                    f.write('# %s is a live ebuild\n' % package)
                elif 'upstream is dead' in watch_data:
                    f.write("# %s's upstream is dead\n" % package)
                elif 'no further bumps' in watch_data:
                    f.write("# %s no longer receives bumps\n" % package)
                else:
                    if not watch_data.startswith('['):
                        f.write('[%s]\n' % package)
                    f.write(watch_data + '\n')
            f.write('# }}}\n\n')
            os.chdir(os.pardir)
    print(success('cupage.conf generated!'))
示例#7
0
def gen_news_sigs():
    """Generate news file signatures."""
    news_files = glob('metadata/news/*/*.txt')
    dep(map(lambda s: s + '.asc', news_files), news_files, mapping=True)
    if not SIGN_KEY:
        raise CommandError(fail('No GnuPG key set!'))
    base_dir = os.path.abspath(os.curdir)
    for path in news_files:
        try:
            dir, file = os.path.split(path)
            os.chdir(dir)
            sign_file = file + '.asc'
            if newer(sign_file, file):
                continue
            # Delete up front, if we can't sign we shouldn't leave stale
            # signatures
            if os.path.exists(sign_file):
                os.unlink(sign_file)
            check_call(['gpg', '--local-user', SIGN_KEY, '--detach-sign',
                        '--armor', file])
        finally:
            os.chdir(base_dir)
示例#8
0
def gen_sphinx_html():
    """Generate Sphinx HTML output."""
    dep(['doc/.build/doctrees/environment.pickle', ],
        glob('doc/*.rst') + glob('doc/packages/*.rst'))
    check_call(['make', '-C', 'doc', 'html'])