forked from pool/rpmlint
0001-Tighten-wrong-script-interpreter-check-to-lower-fals.patch,
0001-Improve-XDG-Menu-checks-stability.patch OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=511
This commit is contained in:
parent
2b5cea76f9
commit
a18c3de7a9
122
0001-Improve-XDG-Menu-checks-stability.patch
Normal file
122
0001-Improve-XDG-Menu-checks-stability.patch
Normal file
@ -0,0 +1,122 @@
|
||||
From 3df5fd9507215cf70a1147ea631cf061475c7b34 Mon Sep 17 00:00:00 2001
|
||||
From: Dirk Mueller <dirk@dmllr.de>
|
||||
Date: Fri, 29 Sep 2017 09:12:33 +0200
|
||||
Subject: [PATCH] Improve XDG Menu checks stability
|
||||
|
||||
Running RawConfigParser on untrusted input can cause a lot
|
||||
of exceptions. Handle them gracefully and raise appropriate
|
||||
rpmlint errors. Also separate the code a little and cleaning it up.
|
||||
---
|
||||
MenuXDGCheck.py | 76 ++++++++++++++++++++++++++++++++++++++++-----------------
|
||||
1 file changed, 53 insertions(+), 23 deletions(-)
|
||||
|
||||
Index: rpmlint-rpmlint-1.10/MenuXDGCheck.py
|
||||
===================================================================
|
||||
--- rpmlint-rpmlint-1.10.orig/MenuXDGCheck.py
|
||||
+++ rpmlint-rpmlint-1.10/MenuXDGCheck.py
|
||||
@@ -8,15 +8,15 @@
|
||||
|
||||
import os
|
||||
try:
|
||||
- from ConfigParser import RawConfigParser
|
||||
+ import ConfigParser as cfgparser
|
||||
except:
|
||||
- from configparser import RawConfigParser
|
||||
+ import configparser as cfgparser
|
||||
|
||||
import AbstractCheck
|
||||
from Filter import addDetails, printError, printWarning
|
||||
from Pkg import getstatusoutput, is_utf8
|
||||
|
||||
-STANDARD_BIN_DIRS = ['/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/']
|
||||
+STANDARD_BIN_DIRS = ('/bin', '/sbin', '/usr/bin', '/usr/sbin')
|
||||
|
||||
|
||||
class MenuXDGCheck(AbstractCheck.AbstractFilesCheck):
|
||||
@@ -27,6 +27,43 @@ class MenuXDGCheck(AbstractCheck.Abstrac
|
||||
AbstractCheck.AbstractFilesCheck.__init__(
|
||||
self, "MenuXDGCheck", r"(?:/usr/share|/etc/opt/.*/share|/opt/.*)/applications/.*\.desktop$")
|
||||
|
||||
+ def parse_desktop_file(self, pkg, root, f, filename):
|
||||
+ cfp = cfgparser.RawConfigParser()
|
||||
+ try:
|
||||
+ cfp.read(f)
|
||||
+ except cfgparser.DuplicateSectionError as e:
|
||||
+ printError(
|
||||
+ pkg, 'desktopfile-duplicate-section', filename,
|
||||
+ '[%s]' % e.section)
|
||||
+ except cfgparser.DuplicateOptionError as e:
|
||||
+ printError(
|
||||
+ pkg, 'desktopfile-duplicate-option', filename,
|
||||
+ '[%s]/%s' % (e.section, e.option))
|
||||
+ except cfgparser.MissingSectionHeaderError:
|
||||
+ printError(
|
||||
+ pkg, 'desktopfile-missing-header', filename)
|
||||
+ except (cfgparser.ParsingError, UnicodeDecodeError) as e:
|
||||
+ printWarning(
|
||||
+ pkg, 'invalid-desktopfile', filename)
|
||||
+ else:
|
||||
+ binary = None
|
||||
+ if cfp.has_option('Desktop Entry', 'Exec'):
|
||||
+ binary = cfp.get('Desktop Entry', 'Exec').partition(' ')[0]
|
||||
+ if binary:
|
||||
+ found = False
|
||||
+ if binary.startswith('/'):
|
||||
+ found = os.path.exists(root + binary)
|
||||
+ else:
|
||||
+ for i in STANDARD_BIN_DIRS:
|
||||
+ if os.path.exists(root + i + '/' + binary):
|
||||
+ # no need to check if the binary is +x, rpmlint does it
|
||||
+ # in another place
|
||||
+ found = True
|
||||
+ break
|
||||
+ if not found:
|
||||
+ printWarning(
|
||||
+ pkg, 'desktopfile-without-binary', filename, binary)
|
||||
+
|
||||
def check_file(self, pkg, filename):
|
||||
root = pkg.dirName()
|
||||
f = root + filename
|
||||
@@ -43,25 +80,7 @@ class MenuXDGCheck(AbstractCheck.Abstrac
|
||||
if not is_utf8(f):
|
||||
printError(pkg, 'non-utf8-desktopfile', filename)
|
||||
|
||||
- cfp = RawConfigParser()
|
||||
- cfp.read(f)
|
||||
- binary = None
|
||||
- if cfp.has_option('Desktop Entry', 'Exec'):
|
||||
- binary = cfp.get('Desktop Entry', 'Exec').split(' ', 1)[0]
|
||||
- if binary:
|
||||
- found = False
|
||||
- if binary.startswith('/'):
|
||||
- found = os.path.exists(root + binary)
|
||||
- else:
|
||||
- for i in STANDARD_BIN_DIRS:
|
||||
- if os.path.exists(root + i + binary):
|
||||
- # no need to check if the binary is +x, rpmlint does it
|
||||
- # in another place
|
||||
- found = True
|
||||
- break
|
||||
- if not found:
|
||||
- printWarning(pkg, 'desktopfile-without-binary', filename,
|
||||
- binary)
|
||||
+ self.parse_desktop_file(pkg, root, f, filename)
|
||||
|
||||
|
||||
check = MenuXDGCheck()
|
||||
@@ -76,4 +95,15 @@ addDetails(
|
||||
'desktopfile-without-binary',
|
||||
'''the .desktop file is for a file not present in the package. You
|
||||
should check the requires or see if this is not a error''',
|
||||
+
|
||||
+'desktopfile-duplicate-section',
|
||||
+'''The .desktop file contains the mentioned section name twice, which
|
||||
+can trigger parsing ambiguities. Remove the duplicate.''',
|
||||
+
|
||||
+'desktopfile-duplicate-option',
|
||||
+'''The .desktop file contains the mentioned option key twice,
|
||||
+which can trigger parsing ambiguities. Remove the duplicate.''',
|
||||
+
|
||||
+'desktopfile-missing-header',
|
||||
+'''The .desktop file should start with a section header.''',
|
||||
)
|
@ -93,7 +93,8 @@ Thu Sep 28 10:40:08 UTC 2017 - dmueller@suse.com
|
||||
0001-Execute-chroot-tests-also-on-x86-rpms.patch,
|
||||
ignore-readelf-ar-error.diff, remove-ghostfile-checks.diff,
|
||||
fix-diag-sortorder.diff, drop-unicodedata-dep.diff,
|
||||
0001-Tighten-wrong-script-interpreter-check-to-lower-fals.patch
|
||||
0001-Tighten-wrong-script-interpreter-check-to-lower-fals.patch,
|
||||
0001-Improve-XDG-Menu-checks-stability.patch
|
||||
- drop config.in: unused
|
||||
- switch to python 3.x
|
||||
|
||||
|
84
rpmlint.spec
84
rpmlint.spec
@ -16,19 +16,13 @@
|
||||
#
|
||||
|
||||
|
||||
#!BuildIgnore: rpmlint-mini
|
||||
|
||||
Name: rpmlint
|
||||
BuildRequires: obs-service-format_spec_file
|
||||
BuildRequires: python3-flake8
|
||||
BuildRequires: python3-pytest
|
||||
BuildRequires: python3-rpm
|
||||
BuildRequires: xz
|
||||
Version: 1.10
|
||||
Release: 0
|
||||
Summary: Rpm correctness checker
|
||||
License: GPL-2.0+
|
||||
Group: System/Packages
|
||||
Version: 1.10
|
||||
Release: 0
|
||||
Url: https://github.com/rpm-software-management/rpmlint
|
||||
Source0: https://github.com/rpm-software-management/rpmlint/archive/rpmlint-%{version}.tar.gz
|
||||
Source1: rpmlint-checks-master.tar.xz
|
||||
Source2: config
|
||||
@ -36,19 +30,6 @@ Source11: pie.config
|
||||
Source12: licenses.config
|
||||
Source99: README.packaging.txt
|
||||
Source100: syntax-validator.py
|
||||
Url: https://github.com/rpm-software-management/rpmlint
|
||||
Requires: /usr/bin/readelf
|
||||
Requires: bash
|
||||
Requires: checkbashisms
|
||||
Requires: cpio
|
||||
Requires: dash
|
||||
Requires: desktop-file-utils
|
||||
Requires: file
|
||||
Requires: findutils
|
||||
Requires: python3-magic
|
||||
Requires: python3-pybeam
|
||||
Requires: python3-rpm
|
||||
Requires: python3-xml
|
||||
Patch00: rpmlint-suse.diff
|
||||
Patch01: suse-checks.diff
|
||||
Patch02: suse-version.diff
|
||||
@ -81,6 +62,7 @@ Patch38: 0001-Tighten-wrong-script-interpreter-check-to-lower-fals.patch
|
||||
Patch39: selfconflicts-provide.diff
|
||||
Patch40: no-badness-return.diff
|
||||
Patch41: suse-shlib-devel-dependency.diff
|
||||
Patch42: 0001-Improve-XDG-Menu-checks-stability.patch
|
||||
Patch43: stricter-interpreter-check.diff
|
||||
Patch44: confusing-invalid-spec-name.diff
|
||||
Patch48: suse-whitelist-opensuse.diff
|
||||
@ -99,7 +81,24 @@ Patch62: ignore-readelf-ar-error.diff
|
||||
Patch63: fix-diag-sortorder.diff
|
||||
Patch64: drop-unicodedata-dep.diff
|
||||
Patch70: rpmlint-all-pie.patch
|
||||
# BuildArch must at the end. is a bug: https://bugzilla.suse.com/show_bug.cgi?id=926766
|
||||
BuildRequires: obs-service-format_spec_file
|
||||
BuildRequires: python3-flake8
|
||||
BuildRequires: python3-pytest
|
||||
BuildRequires: python3-rpm
|
||||
BuildRequires: xz
|
||||
#!BuildIgnore: rpmlint-mini
|
||||
Requires: %{_bindir}/readelf
|
||||
Requires: bash
|
||||
Requires: checkbashisms
|
||||
Requires: cpio
|
||||
Requires: dash
|
||||
Requires: desktop-file-utils
|
||||
Requires: file
|
||||
Requires: findutils
|
||||
Requires: python3-magic
|
||||
Requires: python3-pybeam
|
||||
Requires: python3-rpm
|
||||
Requires: python3-xml
|
||||
BuildArch: noarch
|
||||
|
||||
%description
|
||||
@ -111,45 +110,46 @@ source packages can be checked.
|
||||
|
||||
cp -p %{SOURCE2} .
|
||||
chmod a-x rpmlint-checks-master/*.py
|
||||
# Only move top-level python files
|
||||
# Only move top-level python files
|
||||
mv rpmlint-checks-master/*.py .
|
||||
|
||||
%build
|
||||
make %{?_smp_mflags} PYTHON=/usr/bin/python3
|
||||
make %{?_smp_mflags} PYTHON=%{_bindir}/python3
|
||||
|
||||
%install
|
||||
make install DESTDIR=$RPM_BUILD_ROOT PYTHON=/usr/bin/python3
|
||||
make install DESTDIR=%{buildroot} PYTHON=%{_bindir}/python3
|
||||
# the provided bash-completion does not work and only prints bash errors
|
||||
rm -rf $RPM_BUILD_ROOT/etc/bash_completion.d
|
||||
mv $RPM_BUILD_ROOT/etc/rpmlint/config $RPM_BUILD_ROOT/usr/share/rpmlint/config
|
||||
head -n 8 $RPM_BUILD_ROOT/usr/share/rpmlint/config > $RPM_BUILD_ROOT/etc/rpmlint/config
|
||||
rm -rf %{buildroot}%{_sysconfdir}/bash_completion.d
|
||||
mv %{buildroot}%{_sysconfdir}/rpmlint/config %{buildroot}%{_datadir}/rpmlint/config
|
||||
head -n 8 %{buildroot}%{_datadir}/rpmlint/config > %{buildroot}%{_sysconfdir}/rpmlint/config
|
||||
# make sure that the package is sane
|
||||
for f in $RPM_BUILD_ROOT/usr/share/rpmlint/*.py $RPM_BUILD_ROOT/usr/share/rpmlint/config; do
|
||||
for f in %{buildroot}%{_datadir}/rpmlint/*.py %{buildroot}%{_datadir}/rpmlint/config; do
|
||||
echo $f
|
||||
env LC_ALL=C.utf8 python3 -tt %{SOURCE100} $f
|
||||
done
|
||||
%__install -m 644 %{SOURCE11} %{buildroot}/%{_sysconfdir}/rpmlint/
|
||||
install -m 644 %{SOURCE11} %{buildroot}/%{_sysconfdir}/rpmlint/
|
||||
|
||||
cp %{SOURCE12} licenses.config
|
||||
# note there is a tab character behind the -d, so don't copy&paste lightly
|
||||
cut '-d ' -f1 /usr/lib/obs/service/format_spec_file.files/licenses_changes.txt | tail -n +2 | sort -u | while read l; do
|
||||
cut '-d ' -f1 %{_prefix}/lib/obs/service/format_spec_file.files/licenses_changes.txt | tail -n +2 | sort -u | while read l; do
|
||||
sed -i -e "s/\(#VALIDLICENSES\)/\1\n '$l',/" licenses.config
|
||||
done
|
||||
%__install -m 644 licenses.config %{buildroot}/%{_sysconfdir}/rpmlint/
|
||||
install -m 644 licenses.config %{buildroot}/%{_sysconfdir}/rpmlint/
|
||||
|
||||
%check
|
||||
env PYTHON=/usr/bin/python3 ./test.sh
|
||||
env PYTHON=%{_bindir}/python3 ./test.sh
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,0755)
|
||||
%doc COPYING INSTALL README*
|
||||
%{_prefix}/bin/*
|
||||
%{_prefix}/share/rpmlint
|
||||
%config(noreplace) /etc/rpmlint/config
|
||||
%license COPYING
|
||||
%doc README*
|
||||
%{_bindir}/rpmlint
|
||||
%{_bindir}/rpmdiff
|
||||
%{_datadir}/rpmlint
|
||||
%config(noreplace) %{_sysconfdir}/rpmlint/config
|
||||
%config %{_sysconfdir}/rpmlint/pie.config
|
||||
%config %{_sysconfdir}/rpmlint/licenses.config
|
||||
%dir /etc/rpmlint
|
||||
/usr/share/man/man1/rpmlint.1.gz
|
||||
/usr/share/man/man1/rpmdiff.1.gz
|
||||
%dir %{_sysconfdir}/rpmlint
|
||||
%{_mandir}/man1/rpmlint.1%{ext_man}
|
||||
%{_mandir}/man1/rpmdiff.1%{ext_man}
|
||||
|
||||
%changelog
|
||||
|
Loading…
x
Reference in New Issue
Block a user