Created
September 1, 2017 06:29
-
-
Save meeuw/0726338d378656edddbe39fc3609f95b to your computer and use it in GitHub Desktop.
convert fedora python spec file to epel python spec file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
print('''%if 0%{?python3_pkgversion} | |
%global python3_pkgversion 34 | |
%endif | |
''') | |
with open(sys.argv[1]) as f: | |
skip_until_startswith = None | |
for line in f: | |
if line == '%py2_install\n' or line == '%py2_build\n' or 'py.test-%{python2_version}' in line or '%{__python2}' in line: | |
continue | |
if skip_until_startswith: | |
if line.startswith(skip_until_startswith): | |
skip_until_startswith = None | |
else: | |
continue | |
if line.startswith('Name: '): | |
line = line.replace('python', 'python3') | |
if line.startswith('%package -n python2-'): | |
skip_until_startswith = "%package -n python3-" | |
continue | |
if line.startswith('%files -n python2-%{pypi_name}'): | |
skip_until_startswith = '%files -n python3-%{pypi_name}' | |
continue | |
if line.startswith('%package') or \ | |
line.startswith('Requires') or \ | |
line.startswith('BuildRequires') or \ | |
line.startswith('%description') or \ | |
line.startswith('%files') or \ | |
line.startswith('%{?python_provide'): | |
line = line.replace(' python3', ' python%{python3_pkgversion}') | |
line = line.replace('C.UTF-8', 'en_US.utf8') | |
print (line, end="") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment