SHA256
1
0
forked from pool/rpmlint

* Add TmpFilesCheck

* Flake8 / Stop leaking filedescriptors
- Update rpmlint-tests:
  * Stop leaking filedescriptors
  * Address various deprecation warnings
  * Avoid leaking fds and further Python 3.x porting
- drop sourced-dirs.diff, fix-shared-library-matching.diff,
       suse-python-abi-check.diff, add-check-for-tmpfiles-created-at-r.diff: obsolete
      ignore-readelf-ar-error.diff, remove-ghostfile-checks.diff

OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=499
This commit is contained in:
Dirk Mueller 2017-09-30 08:27:35 +00:00 committed by Git OBS Bridge
parent b2de5e99ae
commit 680daa4eb0
14 changed files with 60 additions and 220 deletions

View File

@ -3,4 +3,4 @@
<param name="url">http://github.com/openSUSE/rpmlint-tests.git</param>
<param name="changesrevision">27b6cb37e629d20ad4d7c0a590a73fbce5ae6009</param></service><service name="tar_scm">
<param name="url">http://github.com/openSUSE/rpmlint-checks.git</param>
<param name="changesrevision">3131f769085523c453232e07fd6827698064c68f</param></service></servicedata>
<param name="changesrevision">3803f11cea43a4238b96c1a083c1582e5177c35b</param></service></servicedata>

View File

@ -1,168 +0,0 @@
From: Ludwig Nussel <ludwig.nussel@suse.de>
Date: Fri, 5 Sep 2014 12:53:40 +0200
Subject: [PATCH] add check for tmpfiles created at runtime
this check parses files in /usr/lib/tmpfiles.d and verifies that
entries that create files or directories are actually listed in
%files.
The check also handles the ghost file check as rpmlint shouldn't
complain about ghost files handled by the tmpfiles mechanism.
---
PostCheck.py | 18 ---------
TmpFilesCheck.py | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 111 insertions(+), 18 deletions(-)
create mode 100644 TmpFilesCheck.py
Index: rpmlint-rpmlint-1.10/PostCheck.py
===================================================================
--- rpmlint-rpmlint-1.10.orig/PostCheck.py
+++ rpmlint-rpmlint-1.10/PostCheck.py
@@ -112,20 +112,6 @@ class PostCheck(AbstractCheck.AbstractCh
self.check_aux(
pkg, files, prog[idx], script[idx], tag[2], prereq)
- ghost_files = pkg.ghostFiles()
- if ghost_files:
- postin = pkg[rpm.RPMTAG_POSTIN]
- prein = pkg[rpm.RPMTAG_PREIN]
- for f in ghost_files:
- if f in pkg.missingOkFiles():
- continue
- if not postin and not prein:
- printWarning(pkg, 'ghost-files-without-postin')
- if (not postin or f not in postin) and \
- (not prein or f not in prein):
- printWarning(pkg,
- 'postin-without-ghost-file-creation', f)
-
def check_aux(self, pkg, files, prog, script, tag, prereq):
if script:
if prog:
@@ -195,10 +181,6 @@ class PostCheck(AbstractCheck.AbstractCh
check = PostCheck()
# Add information about checks
-addDetails(
-'postin-without-ghost-file-creation',
-'''A file tagged as ghost is not created during %prein nor during %postin.''',
-)
for scriptlet in map(lambda x: '%' + x, RPM_SCRIPTLETS):
addDetails(
'one-line-command-in-%s' % scriptlet,
Index: rpmlint-rpmlint-1.10/TmpFilesCheck.py
===================================================================
--- /dev/null
+++ rpmlint-rpmlint-1.10/TmpFilesCheck.py
@@ -0,0 +1,111 @@
+# -*- coding: utf-8 -*-
+#############################################################################
+# File : TmpFilesCheck.py
+# Package : rpmlint
+# Author : Ludwig Nussel
+# Created on : Wed Sep 03 10:36 2014
+# Purpose : Check systemd created tmpfiles are included in filelist
+#############################################################################
+
+import os
+import re
+
+from Filter import addDetails, printError, printWarning
+import AbstractCheck
+import Pkg
+import stat
+import rpm
+
+class TmpFilesCheck(AbstractCheck.AbstractCheck):
+ '''Check systemd created tmpfiles are included in filelist'''
+
+ def __init__(self):
+ AbstractCheck.AbstractCheck.__init__(self, "TmpFilesCheck")
+ self._spec_file = None
+
+ def check(self, pkg):
+ if pkg.isSource():
+ return
+
+ # file names handled by systemd-tmpfiles
+ tmp_files = set()
+ postin = pkg[rpm.RPMTAG_POSTIN]
+ prein = pkg[rpm.RPMTAG_PREIN]
+
+ # see tmpfiles.d(5)
+ interesting_types = ('f', 'F', 'w', 'd', 'D', 'p', 'L', 'c', 'b')
+
+ for fn, pkgfile in pkg.files().items():
+ if not fn.startswith('/usr/lib/tmpfiles.d/'):
+ continue
+ if not stat.S_ISREG(pkgfile.mode):
+ printWarning(pkg, "tmpfile-not-regular-file", fn)
+ continue
+
+ pattern = re.compile(r'systemd-tmpfiles --create .*%s'%re.escape(fn))
+ if (not postin or not pattern.search(postin)) and \
+ (not prein or not pattern.search(prein)):
+ printWarning(pkg,
+ 'postin-without-tmpfile-creation', fn)
+
+ for line in open(pkgfile.path):
+ # skip comments
+ line = line.split('#')[0].split('\n')[0]
+ line = line.lstrip()
+ if not len(line):
+ continue
+ line = re.split(r'\s+', line)
+ # format is
+ #Type Path Mode UID GID Age Argument
+ # we only need type and path
+ if len(line) < 3:
+ continue
+ t = line[0]
+ p = line[1]
+ if t.endswith('!'):
+ t = t[:-1]
+ if not t in interesting_types:
+ continue
+
+ tmp_files.add(p)
+
+ if not p in pkg.files():
+ printWarning(pkg, "tmpfile-not-in-filelist", p)
+ continue
+ if not pkg.files()[p].is_ghost:
+ printWarning(pkg, "tmpfile-not-ghost", p)
+
+ # now check remaining ghost files that are not already
+ # handled by systemd-tmpfiles
+ ghost_files = set(pkg.ghostFiles()) - tmp_files
+ if ghost_files:
+ for f in ghost_files:
+ if f in pkg.missingOkFiles():
+ continue
+ if not postin and not prein:
+ printWarning(pkg, 'ghost-files-without-postin')
+ if (not postin or f not in postin) and \
+ (not prein or f not in prein):
+ printWarning(pkg,
+ 'postin-without-ghost-file-creation', f)
+
+
+
+check = TmpFilesCheck()
+
+addDetails(
+'postin-without-ghost-file-creation',
+'''A file tagged as ghost is not created during %prein nor during %postin.''',
+'postin-without-tmpfile-creation',
+'''Please use the %tmpfiles_create macro in %post for each of your tmpfiles.d files''',
+'tmpfile-not-regular-file',
+'''files in tmpfiles.d need to be regular files''', # otherwise we won't open it :-)
+'tmpfile-not-in-filelist',
+'''please add the specified file to your %files section as %ghost so
+users can easily query who created the file, it gets uninstalled on
+package removal and finally other rpmlint checks see it''',
+'tmpfile-not-ghost',
+'''the specified file is not marked as %ghost although created at
+runtime via tmpfiles mechanism.'''
+)
+# vim: sw=4 et

View File

@ -15,7 +15,7 @@ Index: rpmlint-rpmlint-1.10/TagsCheck.py
# () are here for grouping purpose in the regexp
forbidden_words_regex = re.compile(r'(%s)' % Config.getOption('ForbiddenWords'), re.IGNORECASE)
valid_buildhost_regex = re.compile(Config.getOption('ValidBuildHost'))
+valid_filedep_regex = re.compile('(?:/s?bin/|^/etc/|^/usr/lib/sendmail$)')
+valid_filedep_regex = re.compile(r'(?:/s?bin/|^/etc/|^/usr/lib/sendmail$)')
use_epoch = Config.getOption('UseEpoch', False)
use_utf8 = Config.getOption('UseUTF8', Config.USEUTF8_DEFAULT)
max_line_len = Config.getOption('MaxLineLength', 79)

View File

@ -0,0 +1,34 @@
--- rpmlint-rpmlint-1.10.orig/PostCheck.py
+++ rpmlint-rpmlint-1.10/PostCheck.py
@@ -112,20 +112,6 @@ class PostCheck(AbstractCheck.AbstractCh
self.check_aux(
pkg, files, prog[idx], script[idx], tag[2], prereq)
- ghost_files = pkg.ghostFiles()
- if ghost_files:
- postin = pkg[rpm.RPMTAG_POSTIN]
- prein = pkg[rpm.RPMTAG_PREIN]
- for f in ghost_files:
- if f in pkg.missingOkFiles():
- continue
- if not postin and not prein:
- printWarning(pkg, 'ghost-files-without-postin')
- if (not postin or f not in postin) and \
- (not prein or f not in prein):
- printWarning(pkg,
- 'postin-without-ghost-file-creation', f)
-
def check_aux(self, pkg, files, prog, script, tag, prereq):
if script:
if prog:
@@ -195,10 +181,6 @@ class PostCheck(AbstractCheck.AbstractCh
check = PostCheck()
# Add information about checks
-addDetails(
-'postin-without-ghost-file-creation',
-'''A file tagged as ghost is not created during %prein nor during %postin.''',
-)
for scriptlet in map(lambda x: '%' + x, RPM_SCRIPTLETS):
addDetails(
'one-line-command-in-%s' % scriptlet,

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f16222b4d4e129fddec7ea32970867406516ad57fe7f0403462d6a7f2ef1d53d
size 22360
oid sha256:8744139e880d6f294c6ac9879af99ab3cf7d1497e38d2a113b375d08334cfa6e
size 23208

View File

@ -1,15 +1,3 @@
From: Some One <nobody@opensuse.org>
Date: Thu, 9 Apr 2015 14:55:37 +0200
Subject: [PATCH] rpmlint-suse.diff
===================================================================
---
FilesCheck.py | 2 +-
I18NCheck.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
Index: rpmlint-rpmlint-1.10/FilesCheck.py
===================================================================
--- rpmlint-rpmlint-1.10.orig/FilesCheck.py
+++ rpmlint-rpmlint-1.10/FilesCheck.py
@@ -184,7 +184,7 @@ compr_regex = re.compile(r'\.(gz|z|Z|zip
@ -30,7 +18,7 @@ Index: rpmlint-rpmlint-1.10/I18NCheck.py
package_regex = re.compile('-(' + '|'.join(LANGUAGES) + ')$')
-locale_regex = re.compile('^(/usr/share/locale/([^/]+))/')
+locale_regex = re.compile('^(/(usr|opt/kde3|opt/gnome)/share/locale/([^/]+))/')
+locale_regex = re.compile(r'^(/(usr|opt/kde3|opt/gnome)/share/locale/([^/]+))/')
correct_subdir_regex = re.compile('^(([a-z][a-z]([a-z])?(_[A-Z][A-Z])?)([.@].*$)?)$')
lc_messages_regex = re.compile('/usr/share/locale/([^/]+)/LC_MESSAGES/.*(mo|po)$')
man_regex = re.compile('/usr(?:/share)?/man/([^/]+)/man[0-9n][^/]*/[^/]+$')

View File

@ -1,17 +1,17 @@
-------------------------------------------------------------------
Sat Sep 30 07:53:20 UTC 2017 - opensuse-packaging@opensuse.org
- Update to version master:
* Stop leaking filedescriptors
* Address various deprecation warnings
-------------------------------------------------------------------
Fri Sep 29 12:06:57 UTC 2017 - opensuse-packaging@opensuse.org
Fri Sep 29 12:06:57 UTC 2017 - dmueller@suse.com
- Update rpmlint-checks:
* Flake8 fixes
* Properly anchor systemd path checks
* Python 3.x porting
* Add TmpFilesCheck
* Flake8 / Stop leaking filedescriptors
- Update rpmlint-tests:
* Stop leaking filedescriptors
* Address various deprecation warnings
* Avoid leaking fds and further Python 3.x porting
-------------------------------------------------------------------
Thu Sep 28 10:40:08 UTC 2017 - dmueller@suse.com
@ -82,13 +82,14 @@ Thu Sep 28 10:40:08 UTC 2017 - dmueller@suse.com
* test: Test for unexpected errors in default and C locales
* Remove obsolete LC_ALL setting from Makefile
- drop version-control-internal-file.diff, boo1027577-license_tag.patch: upstream
- drop sourced-dirs.diff, fix-shared-library-matching.diff, suse-python-abi-check.diff: obsolete
- drop sourced-dirs.diff, fix-shared-library-matching.diff,
suse-python-abi-check.diff, add-check-for-tmpfiles-created-at-r.diff: obsolete
- drop suse-readd_terminator_in_regex.patch: merged into original patch
- add suse-tests-without-badness.patch,
0001-Extend-scm_regex-to-capture-more-SCM-system-files.patch,
0003-Tighten-lib_regex-to-avoid-false-positive-in-python-.patch,
0001-Execute-chroot-tests-also-on-x86-rpms.patch,
ignore-readelf-ar-error.diff
ignore-readelf-ar-error.diff, remove-ghostfile-checks.diff
- drop config.in: unused
- switch to python 3.x

View File

@ -48,6 +48,7 @@ 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
@ -90,7 +91,7 @@ Patch53: suse-manpages-for-rc-scripts.diff
Patch54: suse-ignore-specfile-errors.diff
Patch55: invalid-filerequires.diff
Patch57: check-for-self-provides.diff
Patch58: add-check-for-tmpfiles-created-at-r.diff
Patch58: remove-ghostfile-checks.diff
Patch59: 0001-Extend-scm_regex-to-capture-more-SCM-system-files.patch
Patch60: 0003-Tighten-lib_regex-to-avoid-false-positive-in-python-.patch
Patch61: 0001-Execute-chroot-tests-also-on-x86-rpms.patch
@ -99,8 +100,6 @@ Patch70: rpmlint-all-pie.patch
# BuildArch must at the end. is a bug: https://bugzilla.suse.com/show_bug.cgi?id=926766
BuildArch: noarch
%py_requires
%description
Rpmlint is a tool to check common errors on rpm packages. Binary and
source packages can be checked.

View File

@ -24,8 +24,8 @@ Index: rpmlint-rpmlint-1.10/BinariesCheck.py
chroot_call_regex = create_regexp_call('chroot')
# 401eb8: e8 c3 f0 ff ff callq 400f80 <chdir@plt>
objdump_call_regex = re.compile(br'callq?\s(.*)')
+ debuginfo_regex = re.compile('^\s+\[\s*\d+\]\s+\.debug_.*\s+')
+ symtab_regex = re.compile('^\s+\[\s*\d+\]\s+\.symtab\s+')
+ debuginfo_regex = re.compile(r'^\s+\[\s*\d+\]\s+\.debug_.*\s+')
+ symtab_regex = re.compile(r'^\s+\[\s*\d+\]\s+\.symtab\s+')
+ gethostbyname_call_regex = create_regexp_call(r'(gethostbyname|gethostbyname2|gethostbyaddr|gethostbyname_r|gethostbyname2_r|gethostbyaddr_r)')
forbidden_functions = Config.getOption("WarnOnFunction")

View File

@ -1,21 +1,10 @@
From: Some One <nobody@opensuse.org>
Date: Thu, 9 Apr 2015 14:55:38 +0200
Subject: [PATCH] suse-pkg-config-check.diff
===================================================================
---
TagsCheck.py | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
Index: rpmlint-rpmlint-1.10/TagsCheck.py
===================================================================
--- rpmlint-rpmlint-1.10.orig/TagsCheck.py
+++ rpmlint-rpmlint-1.10/TagsCheck.py
@@ -416,6 +416,7 @@ lib_devel_number_regex = re.compile(r'^l
invalid_url_regex = re.compile(Config.getOption('InvalidURL'), re.IGNORECASE)
lib_package_regex = re.compile(r'(?:^(?:compat-)?lib.*?(\.so.*)?|libs?[\d-]*)$', re.IGNORECASE)
leading_space_regex = re.compile(r'^\s+')
+pkg_config_regex = re.compile('^/usr/(?:lib\d*|share)/pkgconfig/')
+pkg_config_regex = re.compile(r'^/usr/(?:lib\d*|share)/pkgconfig/')
license_regex = re.compile(r'\(([^)]+)\)|\s(?:and|or|AND|OR)\s')
invalid_version_regex = re.compile(r'([0-9](?:rc|alpha|beta|pre).*)', re.IGNORECASE)
# () are here for grouping purpose in the regexp

View File

@ -56,9 +56,9 @@ Index: rpmlint-rpmlint-1.10/TagsCheck.py
changelog_version_regex = re.compile(r'[^>]([^ >]+)\s*$')
@@ -418,6 +447,7 @@ lib_package_regex = re.compile(r'(?:^(?:
leading_space_regex = re.compile(r'^\s+')
pkg_config_regex = re.compile('^/usr/(?:lib\d*|share)/pkgconfig/')
pkg_config_regex = re.compile(r'^/usr/(?:lib\d*|share)/pkgconfig/')
license_regex = re.compile(r'\(([^)]+)\)|\s(?:and|or|AND|OR)\s')
+license_exception_regex = re.compile('(\S+)\sWITH\s(\S+)')
+license_exception_regex = re.compile(r'(\S+)\sWITH\s(\S+)')
invalid_version_regex = re.compile(r'([0-9](?:rc|alpha|beta|pre).*)', re.IGNORECASE)
# () are here for grouping purpose in the regexp
forbidden_words_regex = re.compile(r'(%s)' % Config.getOption('ForbiddenWords'), re.IGNORECASE)

View File

@ -2,7 +2,7 @@ Index: rpmlint-rpmlint-1.10/test.sh
===================================================================
--- rpmlint-rpmlint-1.10.orig/test.sh
+++ rpmlint-rpmlint-1.10/test.sh
@@ -19,7 +19,13 @@ for i in $TESTPATH/test.*.py; do
@@ -19,7 +19,10 @@ for i in $TESTPATH/test.*.py; do
fi
done
@ -11,9 +11,6 @@ Index: rpmlint-rpmlint-1.10/test.sh
+
+run_rpmlint="$PYTHON ./rpmlint -f config -C $(pwd)"
+
+echo "Removing Badness.."
+cp config config.backup
+sed -e "s,setOption(\"Badnes.*,," config
echo "Check that rpmlint executes with no unexpected errors"
echo "...in default locale"

View File

@ -15,7 +15,7 @@ Index: rpmlint-rpmlint-1.10/SpecCheck.py
buildarch_regex = re_tag_compile('BuildArch(?:itectures)?')
buildprereq_regex = re_tag_compile('BuildPreReq')
prereq_regex = re_tag_compile(r'PreReq(\(.*\))')
+suse_version_regex = re.compile('%suse_version\s*[<>=]+\s*(\d+)')
+suse_version_regex = re.compile(r'%suse_version\s*[<>=]+\s*(\d+)')
make_check_regex = re.compile(r'(^|\s|%{?__)make}?\s+(check|test)')
rm_regex = re.compile(r'(^|\s)((.*/)?rm|%{?__rm}?) ')

View File

@ -15,7 +15,7 @@ Index: rpmlint-rpmlint-1.10/BinariesCheck.py
srcname_regex = re.compile(r'(.*?)-[0-9]')
invalid_dir_ref_regex = re.compile(r'/(home|tmp)(\W|$)')
ocaml_mixed_regex = re.compile(r'^Caml1999X0\d\d$')
+usr_arch_share_regex = re.compile('/share/.*/(?:x86|i.86|x86_64|ppc|ppc64|s390|s390x|ia64|m68k|arm|aarch64)')
+usr_arch_share_regex = re.compile(r'/share/.*/(?:x86|i.86|x86_64|ppc|ppc64|s390|s390x|ia64|m68k|arm|aarch64)')
def dir_base(path):