예제 #1
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!'))
예제 #2
0
def layman_check():
    """Check basic layman config validity."""
    dtd_loc = ('http://git.overlays.gentoo.org/gitweb/?'
               'p=proj/repositories-xml-format.git;a=blob_plain;'
               'f=schema/%s;hb=HEAD')

    if not lxml or not httplib2:
        raise CommandError(fail("Layman validity checks require the httplib2 "
                                "and lxml Python packages"))

    http = httplib2.Http(cache='.http_cache')

    layman_dtd = http.request(dtd_loc % 'layman-global.dtd')[1]
    repos_dtd = http.request(dtd_loc % 'repositories.dtd')[1]

    failed = False
    for dtd, file in [(layman_dtd, 'layman.xml'), (repos_dtd, 'layman2.xml')]:
        dtd = etree.DTD(StringIO(dtd))
        doc = etree.parse('support/%s' % file)
        if not dtd.validate(doc):
            print(fail('%s is invalid' % file))
            failed = True

    if not failed:
        print(success('layman files valid!'))
예제 #3
0
def rst_check():
    """Check syntax of reST-formatted files."""
    for file in glob('*.rst'):
        try:
            publish_file(open(file), destination=StringIO(),
                         settings_overrides={'halt_level': 1})
        except SystemMessage:
            exit(1)
    print(success('All reST files pass!'))
예제 #4
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!'))
예제 #5
0
def keyword_check():
    """Check for missing keywords."""
    for file in glob('metadata/md5-cache/*/*'):
        # Skip live packages, they shouldn't have stable keywords anyway
        if file.endswith('-9999'):
            continue
        meta = dict([line.strip().split('=', 1) for line in open(file)])
        pkg = file.split('/', 2)[2]
        if 'amd64' not in meta['KEYWORDS']:
            print(fail('[~]amd64 keyword missing in %r' % pkg))
        if 'x86' not in meta['KEYWORDS']:
            print(fail('[~]x86 keyword missing in %r' % pkg))
    print(success('All packages checked for keywords'))
예제 #6
0
def cupage_check():
    """Make sure a watch file exists for each package."""
    failures = 0
    packages = glob('*-*/*')
    for package in packages:
        if not os.path.isfile(os.path.join(package, 'watch')):
            print(fail('Missing watch file in %r' % package))
            failures += 1
    if failures == 0:
        print(success('All watch files present!'))
    else:
        print(fail('%d watch file%s missing!'
                   % (failures, 's' if failures > 1 else '')))
        exit(failures)
예제 #7
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!'))
예제 #8
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!'))
예제 #9
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!'))