SHA256
1
0
forked from pool/rpmlint

- Update to version 13.2+git20150520.a374c88:

+ add tmpfiles.d checks

- skip files handled by tmpfile mechnism in regular ghost file check
  (move-ghost-file-check-to-TmpFilesCh.diff)

OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=329
This commit is contained in:
Ludwig Nussel 2015-05-20 08:02:50 +00:00 committed by Git OBS Bridge
parent 5ad6c8a066
commit d61b2e51fe
9 changed files with 142 additions and 5 deletions

View File

@ -1,4 +1,4 @@
<servicedata>
<service name="tar_scm">
<param name="url">http://github.com/openSUSE/rpmlint-tests.git</param>
<param name="changesrevision">278efdf8570197e08c9d647af7187119cf891a61</param></service></servicedata>
<param name="changesrevision">a374c88b73eb58e49989ecab59e2d602aa11be94</param></service></servicedata>

1
config
View File

@ -42,6 +42,7 @@ addCheck("CheckPAMModules")
addCheck("CheckRCLinks")
addCheck("CheckAppdata")
addCheck("CheckSystemdInstall")
addCheck("TmpFilesCheck")
# stuff autobuild takes care about
addFilter(".*invalid-version.*")

View File

@ -0,0 +1,123 @@
From: Ludwig Nussel <ludwig.nussel@suse.de>
Date: Wed, 20 May 2015 09:57:28 +0200
Subject: [PATCH] move ghost file check to TmpFilesCheck
files handled by the tmpfiles mechanism can be skipped by the normal
ghost check
---
PostCheck.py | 18 ------------------
TmpFilesCheck.py | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 18 deletions(-)
diff --git a/PostCheck.py b/PostCheck.py
index aeb18d3..53f2d0c 100644
--- a/PostCheck.py
+++ b/PostCheck.py
@@ -119,20 +119,6 @@ class PostCheck(AbstractCheck.AbstractCheck):
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:
@@ -201,10 +187,6 @@ class PostCheck(AbstractCheck.AbstractCheck):
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,
diff --git a/TmpFilesCheck.py b/TmpFilesCheck.py
index 8c4db8d..06be7bb 100644
--- a/TmpFilesCheck.py
+++ b/TmpFilesCheck.py
@@ -14,6 +14,7 @@ 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'''
@@ -26,6 +27,11 @@ class TmpFilesCheck(AbstractCheck.AbstractCheck):
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')
@@ -35,6 +41,13 @@ class TmpFilesCheck(AbstractCheck.AbstractCheck):
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.match(postin)) and \
+ (not prein or not pattern.match(prein)):
+ printWarning(pkg,
+ 'postin-without-tmpfile-creation', fn)
+
for line in open(pkgfile.path):
# skip comments
line = line.split('#')[0].split('\n')[0]
@@ -54,15 +67,37 @@ class TmpFilesCheck(AbstractCheck.AbstractCheck):
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',

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:889b4f6c005f69e34bd57410208c93665e14d3a46818c8913757ac17057dc2cc
size 10276

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:81c5b5f0e7ec9015b33685d29b25aee433ae0f858087a08490abb69438e50c9c
size 10648

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed May 20 08:02:15 UTC 2015 - lnussel@suse.de
- Update to version 13.2+git20150520.a374c88:
+ add tmpfiles.d checks
-------------------------------------------------------------------
Tue May 19 12:21:46 UTC 2015 - lnussel@suse.de

View File

@ -22,7 +22,7 @@
BuildRequires: rpmlint-mini
Name: rpmlint-tests
Version: 13.2+git20150519.278efdf
Version: 13.2+git20150520.a374c88
Release: 0
Summary: rpmlint regression tests
License: SUSE-Public-Domain

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed May 20 07:58:52 UTC 2015 - lnussel@suse.de
- skip files handled by tmpfile mechnism in regular ghost file check
(move-ghost-file-check-to-TmpFilesCh.diff)
-------------------------------------------------------------------
Tue May 19 11:35:07 UTC 2015 - lnussel@suse.de

View File

@ -109,6 +109,7 @@ Patch50: save-content-to-an-array.diff
Patch51: add-check-for-tmpfiles-created-at-r.diff
Patch52: fix-ghost-file-handling.diff
Patch53: remove-files-attr-not-set-check.diff
Patch54: move-ghost-file-check-to-TmpFilesCh.diff
# PATCHLIST END
# BuildArch must at the and. is a bug: https://bugzilla.suse.com/show_bug.cgi?id=926766
BuildArch: noarch