|
|
98862f |
'''Check whether the manpage extensions and directories list hardcoded in brp-compress
|
|
|
98862f |
are the same as the lists stored in pyproject_save_files.py.
|
|
|
98862f |
There is an open issue for RPM to provide them both as macros:
|
|
|
98862f |
https://github.com/rpm-software-management/rpm/issues/1865
|
|
|
98862f |
Once that happens, this script can be removed.
|
|
|
98862f |
'''
|
|
|
98862f |
|
|
|
98862f |
import argparse
|
|
|
98862f |
import re
|
|
|
98862f |
import sys
|
|
|
98862f |
|
|
|
98862f |
from pathlib import PosixPath
|
|
|
98862f |
|
|
|
98862f |
from pyproject_buildrequires import print_err
|
|
|
98862f |
from pyproject_save_files import prepend_mandirs, MANPAGE_EXTENSIONS
|
|
|
98862f |
|
|
|
98862f |
|
|
|
98862f |
|
|
|
98862f |
def read_brp_compress(filename):
|
|
|
98862f |
|
|
|
98862f |
contents = filename.read_text()
|
|
|
98862f |
# To avoid duplicity of the manpage extensions which are listed a few times
|
|
|
98862f |
# in the source file, they are stored in set and then retyped to a sorted list
|
|
|
98862f |
manpage_exts = sorted(
|
|
|
98862f |
set(re.findall(r'\(?(\w+)\\+\)?\$?', contents))
|
|
|
98862f |
)
|
|
|
98862f |
|
|
|
98862f |
# Get rid of ${PREFIX} when extracting the manpage directories
|
|
|
98862f |
mandirs = [
|
|
|
98862f |
entry.replace('.${PREFIX}', '/PREFIX')
|
|
|
98862f |
for entry in contents.split()
|
|
|
98862f |
if entry.startswith('.${PREFIX}')
|
|
|
98862f |
]
|
|
|
98862f |
|
|
|
98862f |
return manpage_exts, sorted(mandirs)
|
|
|
98862f |
|
|
|
98862f |
|
|
|
98862f |
def compare_mandirs(brp_compress_mandirs):
|
|
|
98862f |
'''
|
|
|
98862f |
Check whether each of brp-compress mandirs entry is present in the list
|
|
|
98862f |
stored in pyproject_save_files.py
|
|
|
98862f |
'''
|
|
|
98862f |
|
|
|
98862f |
pyp_save_files_mandirs = sorted(prepend_mandirs(prefix='/PREFIX'))
|
|
|
98862f |
if brp_compress_mandirs == pyp_save_files_mandirs:
|
|
|
98862f |
return True
|
|
|
98862f |
else:
|
|
|
98862f |
print_err('Mandir lists don\'t match, update the list in pyproject_save_files.py')
|
|
|
98862f |
print_err('brp-compress list:', brp_compress_mandirs)
|
|
|
98862f |
print_err('pyproject_save_files list:', pyp_save_files_mandirs)
|
|
|
98862f |
return False
|
|
|
98862f |
|
|
|
98862f |
|
|
|
98862f |
def compare_manpage_extensions(brp_compress_manpage_exts):
|
|
|
98862f |
'''
|
|
|
98862f |
Check whether each of brp-compress manpage extension is present in the list
|
|
|
98862f |
stored in pyproject_save_files.py
|
|
|
98862f |
'''
|
|
|
98862f |
|
|
|
98862f |
if brp_compress_manpage_exts == sorted(MANPAGE_EXTENSIONS):
|
|
|
98862f |
return True
|
|
|
98862f |
else:
|
|
|
98862f |
print_err('Manpage extension lists don\'t match, update the list in pyproject_save_files.py')
|
|
|
98862f |
print_err('brp-compress list:', brp_compress_manpage_exts)
|
|
|
98862f |
print_err('pyproject_save_files list:', sorted(MANPAGE_EXTENSIONS))
|
|
|
98862f |
return False
|
|
|
98862f |
|
|
|
98862f |
|
|
|
98862f |
def main(args):
|
|
|
98862f |
src_manpage_exts, src_mandirs = read_brp_compress(args.filename)
|
|
|
98862f |
extension_check_successful = compare_manpage_extensions(src_manpage_exts)
|
|
|
98862f |
mandir_check_successful = compare_mandirs(src_mandirs)
|
|
|
98862f |
if extension_check_successful and mandir_check_successful:
|
|
|
98862f |
sys.exit(0)
|
|
|
98862f |
else:
|
|
|
98862f |
sys.exit(1)
|
|
|
98862f |
|
|
|
98862f |
|
|
|
98862f |
if __name__ == '__main__':
|
|
|
98862f |
parser = argparse.ArgumentParser()
|
|
|
98862f |
parser.add_argument('-f', '--filename', type=PosixPath, required=True,
|
|
|
98862f |
help='Provide location of brp-compress file')
|
|
|
98862f |
main(parser.parse_args())
|