1 diff -urN rpm-4.5.orig/macros.in rpm-4.5/macros.in
2 --- rpm-4.5.orig/macros.in 2019-06-01 18:55:39.553000000 +0200
3 +++ rpm-4.5/macros.in 2019-11-01 12:11:16.312000000 +0100
4 @@ -1404,25 +1404,46 @@
6 # Path to scripts to autogenerate python package dependencies,
8 -# Note: Used iff _use_internal_dependency_generator is non-zero. The
9 +# Note: Used if _use_internal_dependency_generator is non-zero. The
10 # helpers are also used by %{_rpmhome}/rpmdeps {--provides|--requires}.
11 -%__python_provides /usr/bin/env PYVER=%py_ver %{_rpmhome}/pythondeps.sh --provides
12 -%__python_requires /usr/bin/env PYVER=%py_ver %{_rpmhome}/pythondeps.sh --requires
14 -# Useful macros for building *.rpm python packages (for python > 1.6).
15 +%__python_provides %{_rpmhome}/pythoneggs.py --provides
16 +%__python_requires %{_rpmhome}/pythoneggs.py --requires
18 -%python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")
19 -%python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")
20 -%python_version %(%{__python} -c "import sys; print(sys.version[0:3])")
21 +%python_sitearch %(%{__python} -c "import os; from distutils.sysconfig import get_python_lib; lib=get_python_lib(1); print os.path.islink(lib) and os.path.abspath(os.path.join(os.path.dirname(lib),os.readlink(lib))) or lib")
22 +%python_sitelib %(%{__python} -c "import os; from distutils.sysconfig import get_python_lib; lib=get_python_lib(); print os.path.islink(lib) and os.path.abspath(os.path.join(os.path.dirname(lib),os.readlink(lib))) or lib")
23 +%python_version %(%{__python} -c "import sys; print(sys.version[0:3])")
25 +# python main version
26 +%py_ver %(%{__python} -c "import sys; v=sys.version_info[:2]; print '%%d.%%d'%%v" 2>/dev/null || echo PYTHON-NOT-FOUND)
27 +%py_prefix %(%{__python} -c "import sys; print sys.prefix" 2>/dev/null || echo PYTHON-NOT-FOUND)
28 +%py_platlibdir %(%{__python} -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib(standard_lib=1,plat_specific=1)' 2>/dev/null || echo PYTHON-LIBDIR-NOT-FOUND)
29 +%py_purelibdir %(%{__python} -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib(standard_lib=1,plat_specific=0)' 2>/dev/null || echo PYTHON-LIBDIR-NOT-FOUND)
30 +# backward compatibility
31 +%py_libdir %py_purelibdir
33 +%py_platsitedir %(%{__python} -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib(plat_specific=1)' 2>/dev/null || echo PYTHON-LIBDIR-NOT-FOUND)
34 +%py_puresitedir %(%{__python} -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_lib()' 2>/dev/null || echo PYTHON-LIBDIR-NOT-FOUND)
35 +%py_sitedir %py_puresitedir
37 +%py_dyndir %{py_platlibdir}/lib-dynload
39 +%py_incdir %(%{__python} -c 'import distutils.sysconfig; print distutils.sysconfig.get_python_inc()' 2>/dev/null || echo PYTHON-INCLUDEDIR-NOT-FOUND)
42 -find %1 -name '*.pyc' -name '*.pyo' -exec rm -f {} \\; \
43 -%{__python} %{?O:-O} -c "import sys, os, compileall; br='%{buildroot}'; compileall.compile_dir(sys.argv[1], ddir=br and (sys.argv[1][len(os.path.abspath(br)):]+'/') or None)" %1 \
44 +find %1 -name '*.pyc' -exec rm -f {} \\; \
45 +%{__python} -c "import sys, os, compileall; br='%{buildroot}'; compileall.compile_dir(sys.argv[1], ddir=br and (sys.argv[1][len(os.path.abspath(br)):]+'/') or None)" %1 \
47 +find %1 -name '*.pyo' -exec rm -f {} \\; \
48 +%{__python} -O -c "import sys, os, compileall; br='%{buildroot}'; compileall.compile_dir(sys.argv[1], ddir=br and (sys.argv[1][len(os.path.abspath(br)):]+'/') or None)" %1 \
51 +# pure python modules compilation
52 +%py_comp %{__python} -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('%{buildroot}'):])"
54 +%py_ocomp %{__python} -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('%{buildroot}'):])"
57 -%define maxver %(%{__python} -c "import sys; a,b=sys.version_info[:2]; print '%%d.%%d'%%(a,b+1)" 2>/dev/null || echo PYTHON-NOT-FOUND) \
58 -BuildRequires: python %{-d:python-devel} \
59 -PreReq: python >= %{python_version}, python < %{maxver}
60 +BuildRequires: %{__python} %{-d:python-devel}
62 #------------------------------------------------------------------------
63 # php(...) configuration.
64 diff -urN rpm-4.5.orig/scripts/Makefile.am rpm-4.5/scripts/Makefile.am
65 --- rpm-4.5.orig/scripts/Makefile.am 2019-06-01 18:55:39.553000000 +0200
66 +++ rpm-4.5/scripts/Makefile.am 2019-11-01 12:03:59.288000000 +0100
68 find-requires.perl freshen.sh gendiff getpo.sh http.req \
69 check-java-closure.sh java.prov.sh java.req.sh \
70 javadeps.sh libtooldeps.sh pkgconfigdeps.sh \
71 - perldeps.pl perl.prov perl.req pythondeps.sh mimetypedeps.sh \
72 + perldeps.pl perl.prov perl.req pythondeps.sh pythoneggs.py \
74 php.prov php.req rpm2cpio \
75 rpmdb_loadcvt rpmdiff rpmdiff.cgi \
76 rpm.daily rpm.log rpm.xinetd \
79 find-requires.perl getpo.sh http.req \
80 javadeps.sh libtooldeps.sh pkgconfigdeps.sh \
81 - perldeps.pl perl.prov perl.req pythondeps.sh mimetypedeps.sh \
82 + perldeps.pl perl.prov perl.req pythondeps.sh pythoneggs.py \
86 rpm.daily rpm.log rpm.xinetd \
87 diff -urN rpm-4.5.orig/scripts/pythoneggs.py rpm-4.5/scripts/pythoneggs.py
88 --- rpm-4.5.orig/scripts/pythoneggs.py 1970-01-01 01:00:00.000000000 +0100
89 +++ rpm-4.5/scripts/pythoneggs.py 2019-03-09 02:30:08.000000000 +0100
91 +#!/usr/bin/env python
92 +# -*- coding: utf-8 -*-
94 +# Copyright 2010 Per Øyvind Karlsen <peroyvind@mandriva.org>
96 +# This program is free software. It may be redistributed and/or modified under
97 +# the terms of the LGPL version 2.1 (or later).
99 +# RPM5 python (egg) dependency generator.
102 +from getopt import getopt
103 +from os.path import basename, dirname, isdir, sep, splitext
104 +from sys import argv, stdin, version
105 +from pkg_resources import Distribution, FileMetadata, PathMetadata
106 +from distutils.sysconfig import get_python_lib
107 +from subprocess import Popen, PIPE, STDOUT
112 +opts, args = getopt(argv[1:], 'hPRSCOEb:',
113 + ['help', 'provides', 'requires', 'suggests', 'conflicts', 'obsoletes', 'extras','buildroot='])
123 +def make_pldver(raw):
124 + if re.match(r'^[0-9\.]+$', raw) == None:
125 + pldver = re.sub(r'([\d\.]+)(.+)', r'\1-0.\2', raw)
131 + if o in ('-h', '--help'):
132 + print '-h, --help\tPrint help'
133 + print '-P, --provides\tPrint Provides'
134 + print '-R, --requires\tPrint Requires'
135 + print '-S, --suggests\tPrint Suggests'
136 + print '-C, --conflicts\tPrint Conflicts'
137 + print '-O, --obsoletes\tPrint Obsoletes (unused)'
138 + print '-E, --extras\tPrint Extras '
139 + print '-b, --buildroot\tBuildroot for package '
141 + elif o in ('-P', '--provides'):
143 + elif o in ('-R', '--requires'):
145 + elif o in ('-S', '--suggests'):
147 + elif o in ('-C', '--conflicts'):
149 + elif o in ('-O', '--obsoletes'):
151 + elif o in ('-E', '--extras'):
153 + elif o in ('-b', '--buildroot'):
157 + return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
159 +typelib_check = False
161 +if is_exe("/usr/lib/rpm/gi-find-deps.sh") and is_exe("/usr/bin/g-ir-dep-tool"):
165 + typelib_check = True
175 + files = stdin.readlines()
180 + name = 'python(abi)'
181 + # add dependency based on path, versioned if within versioned python directory
182 + if py_abi and (lower.endswith('.py') or lower.endswith('.pyc') or lower.endswith('.pyo')):
183 + if not name in py_deps:
185 + purelib = get_python_lib(standard_lib=1, plat_specific=0).split(version[:3])[0]
186 + platlib = get_python_lib(standard_lib=1, plat_specific=1).split(version[:3])[0]
187 + for lib in (purelib, platlib):
189 + spec = ('==',f.split(lib)[1].split(sep)[0])
190 + if not spec in py_deps[name]:
191 + py_deps[name].append(spec)
192 + # Pipe files to find typelib requires
194 + p = Popen(['/usr/lib/rpm/gi-find-deps.sh', '-R',str(buildroot)], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
195 + (stdoutdata, stderrdata) = p.communicate(input=str(f)+"\n")
197 + if stdoutdata and stdoutdata:
198 + py_deps[stdoutdata.strip()]= ""
200 + # XXX: hack to workaround RPM internal dependency generator not passing directories
201 + dlower = dirname(lower)
202 + if dlower.endswith('.egg') or \
203 + dlower.endswith('.egg-info') or \
204 + dlower.endswith('.egg-link'):
207 + # Determine provide, requires, conflicts & suggests based on egg metadata
208 + if lower.endswith('.egg') or \
209 + lower.endswith('.egg-info') or \
210 + lower.endswith('.egg-link'):
211 + dist_name = basename(f)
213 + path_item = dirname(f)
214 + metadata = PathMetadata(path_item, f)
217 + metadata = FileMetadata(f)
218 + dist = Distribution.from_location(path_item, dist_name, metadata)
220 + # If egg metadata says package name is python, we provide python(abi)
221 + if dist.key == 'python':
222 + name = 'python(abi)'
223 + if not name in py_deps:
225 + py_deps[name].append(('==', dist.py_version))
226 + if dist.py_version .split(".")[0] == '3':
227 + name = 'python3egg(%s)' % dist.key
229 + name = 'pythonegg(%s)' % dist.key
230 + if not name in py_deps:
233 + spec = ('==', make_pldver(dist.version))
234 + if not spec in py_deps[name]:
235 + py_deps[name].append(spec)
236 + if Requires or (Suggests and dist.extras):
237 + name = 'python(abi)'
238 + # If egg metadata says package name is python, we don't add dependency on python(abi)
239 + if dist.key == 'python':
241 + if name in py_deps:
243 + elif py_abi and dist.py_version:
244 + if not name in py_deps:
246 + spec = ('==', dist.py_version)
247 + if not spec in py_deps[name]:
248 + py_deps[name].append(spec)
249 + # fake python version for dist.requires(), so deps like
250 + # [:python_version < '3']
252 + # will be handled correctly
253 + old_python_version = platform.python_version
254 + def new_python_version():
255 + return dist.py_version
256 + platform.python_version = new_python_version
257 + deps = dist.requires()
259 + depsextras = dist.requires(extras=dist.extras)
261 + for dep in reversed(depsextras):
263 + depsextras.remove(dep)
265 + platform.python_version = old_python_version
266 + # add requires/suggests based on egg metadata
268 + if dist.py_version .split(".")[0] == '3':
269 + name = 'python3egg(%s)' % dep.key
271 + name = 'pythonegg(%s)' % dep.key
272 + for spec in dep.specs:
273 + if spec[0] != '!=':
274 + if not name in py_deps:
276 + plddep = (spec[0], make_pldver(spec[1]))
277 + if not plddep in py_deps[name]:
278 + py_deps[name].append(plddep)
281 + # Unused, for automatic sub-package generation based on 'extras' from egg metadata
282 + # TODO: implement in rpm later, or...?
284 + deps = dist.requires()
285 + extras = dist.extras
287 + for extra in extras:
288 + print '%%package\textras-%s' % extra
289 + print 'Summary:\t%s extra for %s python egg' % (extra, dist.key)
290 + print 'Group:\t\tDevelopment/Python'
291 + depsextras = dist.requires(extras=[extra])
292 + for dep in reversed(depsextras):
294 + depsextras.remove(dep)
297 + for spec in dep.specs:
298 + if spec[0] == '!=':
299 + print 'Conflicts:\t%s %s %s' % (dep.key, '==', spec[1])
301 + print 'Requires:\t%s %s %s' % (dep.key, spec[0], spec[1])
302 + print '%%description\t%s' % extra
303 + print '%s extra for %s python egg' % (extra, dist.key)
304 + print '%%files\t\textras-%s\n' % extra
306 + # Should we really add conflicts for extras?
307 + # Creating a meta package per extra with suggests on, which has
308 + # the requires/conflicts in stead might be a better solution...
309 + for dep in dist.requires(extras=dist.extras):
311 + for spec in dep.specs:
312 + if spec[0] == '!=':
313 + if not name in py_deps:
315 + spec = ('==', spec[1])
316 + if not spec in py_deps[name]:
317 + py_deps[name].append(spec)
318 +names = py_deps.keys()
322 + # Print out versioned provides, requires, suggests, conflicts
323 + for spec in py_deps[name]:
324 + print '%s %s %s' % (name, spec[0], spec[1])
326 + # Print out unversioned provides, requires, suggests, conflicts