[packages/rpmlint] - up to 1.11 - enable building for rpm4 / python3
baggins
baggins at pld-linux.org
Sun Jan 17 18:35:55 CET 2021
commit f24c60bbc0494fca3ec58c0ff01e3fb9f56ff65e
Author: Jan Rękorajski <baggins at pld-linux.org>
Date: Sun Jan 17 18:35:29 2021 +0100
- up to 1.11
- enable building for rpm4 / python3
bash-completion.patch | 2 +-
python3.patch | 11 ++++++++
rpm4.15.patch | 34 +++++++++++++++++++++++
rpmlint-groups.patch | 4 +--
rpmlint.spec | 74 +++++++++++++++++++++++++++++++++++++++++++--------
5 files changed, 111 insertions(+), 14 deletions(-)
---
diff --git a/rpmlint.spec b/rpmlint.spec
index a4413b6..5476b0c 100644
--- a/rpmlint.spec
+++ b/rpmlint.spec
@@ -1,16 +1,17 @@
#
# Conditional build:
%bcond_without tests # build without tests
+%bcond_with rpm4 # build for rpm4
Summary: Tool for checking common errors in RPM packages
Summary(pl.UTF-8): Narzędzie do sprawdzania pakietów RPM pod kątem częstych błędów
Name: rpmlint
-Version: 1.9
-Release: 1
+Version: 1.11
+Release: 0.6
License: GPL v2
Group: Development/Building
Source0: https://github.com/rpm-software-management/rpmlint/archive/%{name}-%{version}.tar.gz
-# Source0-md5: 810d7fd565d389fec305ff80af53ba40
+# Source0-md5: 2642bb6f08f6e2a2f2c0fe9f07634d49
Source1: %{name}.config
Source3: %{name}-etc.config
Patch0: %{name}-groups.patch
@@ -20,10 +21,18 @@ Patch3: postshell.patch
Patch4: rpm5.patch
Patch5: bash-completion.patch
Patch6: revert-9f71923e.patch
+Patch7: rpm4.15.patch
+Patch8: python3.patch
URL: https://github.com/rpm-software-management/rpmlint
+%if %{with rpm4}
+BuildRequires: python3
+BuildRequires: python3-modules
+%{?with_tests:BuildRequires: python3-rpm >= 1:4.16}
+%else
BuildRequires: python >= 1:2.6
BuildRequires: python-modules
%{?with_tests:BuildRequires: python-rpm >= 5.4.10-12}
+%endif
BuildRequires: rpm-pythonprov
BuildRequires: rpmbuild(macros) >= 1.673
# tests require rpmlint in installed packages database
@@ -38,10 +47,17 @@ Requires: file
Requires: findutils
Requires: grep
Requires: gzip
+%if %{with rpm4}
+Requires: python3
+Requires: python3-magic
+Requires: python3-pyenchant
+Requires: python3-rpm >= 1:4.16
+%else
Requires: python >= 1.5.2
Requires: python-magic
Requires: python-pyenchant
Requires: python-rpm >= 5.4.10-12
+%endif
Requires: xz
BuildArch: noarch
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
@@ -69,13 +85,18 @@ Bashowe uzupełnianie parametrów dla polecenia rpmlint.
%prep
%setup -q -n %{name}-rpmlint-%{version}
-%patch0 -p1
+%{!?with_rpm4:%patch0 -p1}
%patch1 -p1
%patch2 -p1
%patch3 -p1
-%patch4 -p1
%patch5 -p1
+%if %{with rpm4}
+%patch7 -p1
+%patch8 -p1
+%else
+%patch4 -p1
%patch6 -p1
+%endif
cp -p config config.example
cp -p %{SOURCE3} config
@@ -83,20 +104,37 @@ cp -p %{SOURCE3} config
mv %{name} %{name}.py
%{__sed} -i -e 's,python ./rpmlint,./rpmlint.py,' test.sh
+touch __init__.py
+
+%if %{with rpm4}
+%{__sed} -i -e '1s,/usr/bin/python,%{__python3},' rpmdiff rpmlint.py
cat <<'EOF' > %{name}
#!/bin/sh
-exec python -tt -u -O %{py_sitescriptdir}/%{name}/rpmlint.pyc "$@"
+exec %{__python3} -tt -u -O %{py3_sitescriptdir}/%{name}/rpmlint.py "$@"
EOF
-touch __init__.py
+%else
+%{__sed} -i -e '1s,/usr/bin/python,%{__python},' rpmdiff rpmlint.py
+cat <<'EOF' > %{name}
+#!/bin/sh
+exec %{__python} -tt -u -O %{py_sitescriptdir}/%{name}/rpmlint.pyc "$@"
+EOF
+%endif
%build
+%if %{without rpm4}
# Create GROUPS for -groups.patch
rpmnv=$(rpm -q rpm --qf '%{N}-%{V}')
gzip -dc "%{_docdir}/$rpmnv/groups.gz" | awk '/^[A-Z].*/ { print }' > GROUPS
test -s GROUPS
+%endif
%{__make} \
bash_compdir=%{bash_compdir} \
+%if %{with rpm4}
+ PYTHON=%{__python3} \
+%else
+ PYTHON=%{__python} \
+%endif
COMPILE_PYC=1
%if %{with tests}
@@ -107,20 +145,28 @@ test -s GROUPS
rm -rf $RPM_BUILD_ROOT
%{__make} install \
bash_compdir=%{bash_compdir} \
+%if %{with rpm4}
+ PYTHON=%{__python3} \
+ LIBDIR=%{py3_sitescriptdir}/%{name} \
+%else
+ PYTHON=%{__python} \
+ LIBDIR=%{py_sitescriptdir}/%{name} \
+%endif
ETCDIR=%{_sysconfdir} \
MANDIR=%{_mandir} \
- LIBDIR=%{py_sitescriptdir}/%{name} \
BINDIR=%{_bindir} \
DESTDIR=$RPM_BUILD_ROOT
-install -p %{name} $RPM_BUILD_ROOT%{_bindir}/%{name}
+#install -p %{name} $RPM_BUILD_ROOT%{_bindir}/%{name}
install -d $RPM_BUILD_ROOT%{_datadir}/%{name}
-cp -p GROUPS $RPM_BUILD_ROOT%{_datadir}/%{name}
+%{!?with_rpm4:cp -p GROUPS $RPM_BUILD_ROOT%{_datadir}/%{name}}
cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_datadir}/%{name}/config
+%if %{without rpm4}
%py_ocomp $RPM_BUILD_ROOT%{py_sitescriptdir}
%py_comp $RPM_BUILD_ROOT%{py_sitescriptdir}
%py_postclean
+%endif
%clean
rm -rf $RPM_BUILD_ROOT
@@ -135,10 +181,16 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/rpmdiff.1*
%{_mandir}/man1/rpmlint.1*
%dir %{_datadir}/%{name}
-%{_datadir}/%{name}/GROUPS
%{_datadir}/%{name}/config
+%if %{with rpm4}
+%dir %{py3_sitescriptdir}/%{name}
+%{py3_sitescriptdir}/%{name}/__pycache__
+%{py3_sitescriptdir}/%{name}/*.py
+%else
%dir %{py_sitescriptdir}/%{name}
%{py_sitescriptdir}/%{name}/*.py[co]
+%{_datadir}/%{name}/GROUPS
+%endif
%files -n bash-completion-%{name}
%defattr(644,root,root,755)
diff --git a/bash-completion.patch b/bash-completion.patch
index 07395ca..4a671d4 100644
--- a/bash-completion.patch
+++ b/bash-completion.patch
@@ -6,7 +6,7 @@
MANDIR=/usr/share/man
+bash_compdir=$(shell pkg-config --variable=completionsdir bash-completion 2>/dev/null)
- FILES = rpmlint *.py INSTALL README README.devel COPYING tools/*.py \
+ FILES = rpmlint *.py INSTALL README.md README.devel COPYING tools/*.py \
Makefile config rpmdiff rpmdiff.1 rpmlint.bash-completion rpmlint.1 \
@@ -48,14 +48,13 @@
chmod +x $(DESTDIR)$(BINDIR)/$$file ; \
diff --git a/python3.patch b/python3.patch
new file mode 100644
index 0000000..ff5cb9e
--- /dev/null
+++ b/python3.patch
@@ -0,0 +1,11 @@
+--- rpmlint-rpmlint-1.11/PostCheck.py~ 2021-01-17 18:05:55.000000000 +0100
++++ rpmlint-rpmlint-1.11/PostCheck.py 2021-01-17 18:12:55.108297139 +0100
+@@ -75,7 +75,7 @@
+ tmpfd, tmpname = tempfile.mkstemp(prefix='rpmlint.')
+ tmpfile = os.fdopen(tmpfd, 'wb')
+ try:
+- tmpfile.write(script)
++ tmpfile.write(script.encode('utf-8'))
+ tmpfile.close()
+ ret = Pkg.getstatusoutput((prog, commandline, tmpname))
+ finally:
diff --git a/rpm4.15.patch b/rpm4.15.patch
new file mode 100644
index 0000000..812ef55
--- /dev/null
+++ b/rpm4.15.patch
@@ -0,0 +1,34 @@
+From 8fd904b53c028dded0b308ee95f1a5ff998584fd Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro at hroncok.cz>
+Date: Thu, 4 Jul 2019 00:31:49 +0200
+Subject: [PATCH] Ugly workaround for RPM 4.14 vs 4.15 python3 bindings
+ incompatibility
+
+Fixes https://github.com/rpm-software-management/rpmlint/issues/202
+---
+ Pkg.py | 11 ++++++++++-
+ 1 file changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/Pkg.py b/Pkg.py
+index 8d01f301..1b257716 100644
+--- a/Pkg.py
++++ b/Pkg.py
+@@ -143,8 +143,17 @@ def is_utf8(fname):
+
+
+ def is_utf8_bytestr(s):
++ """Returns True whether the given text is UTF-8.
++ Due to changes in rpm, needs to handle both bytes and unicode."""
+ try:
+- s.decode('UTF-8')
++ if hasattr(s, 'decode'):
++ s.decode('utf-8')
++ elif hasattr(s, 'encode'):
++ s.encode('utf-8')
++ else:
++ unexpected = type(s).__name__
++ raise TypeError(
++ 'Expected str/unicode/bytes, not {}'.format(unexpected))
+ except UnicodeError:
+ return False
+ return True
diff --git a/rpmlint-groups.patch b/rpmlint-groups.patch
index c1137e3..9cd9934 100644
--- a/rpmlint-groups.patch
+++ b/rpmlint-groups.patch
@@ -17,8 +17,8 @@ Use GROUPS file from rpmlint (this project) package rather than rpm
groupsfiles = [x for x in p.files() if x.endswith('/GROUPS')]
if groupsfiles:
filename = groupsfiles[0]
-- except: # the rpm package might not be installed
-+ except: # the rpmlint package might not be installed
+- except KeyError: # the rpm package might not be installed
++ except KeyError: # the rpmlint package might not be installed
pass
if filename and os.path.exists(filename):
with open(filename) as fobj:
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/rpmlint.git/commitdiff/f24c60bbc0494fca3ec58c0ff01e3fb9f56ff65e
More information about the pld-cvs-commit
mailing list