forked from pool/rpmlint
Accepting request 19427 from Base:System
Copy from Base:System/rpmlint based on submit request 19427 from user lnussel OBS-URL: https://build.opensuse.org/request/show/19427 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/rpmlint?expand=0&rev=45
This commit is contained in:
parent
773aa7d652
commit
6fb2056c2a
82
CheckAlternativesGhostFiles.py
Normal file
82
CheckAlternativesGhostFiles.py
Normal file
@ -0,0 +1,82 @@
|
||||
# vim:sw=4:et
|
||||
#############################################################################
|
||||
# File : CheckAlternativesGhostFiles.py
|
||||
# Package : rpmlint
|
||||
# Author : Michal Vyskocil
|
||||
# Purpose : Check if files used by update-alternatives are marked as %ghost
|
||||
#############################################################################
|
||||
|
||||
from Filter import *
|
||||
import AbstractCheck
|
||||
import rpm
|
||||
|
||||
class CheckAlternativesGhostFiles(AbstractCheck.AbstractCheck):
|
||||
|
||||
INSTALL="--install"
|
||||
SLAVE="--slave"
|
||||
|
||||
def __init__(self):
|
||||
AbstractCheck.AbstractCheck.__init__(self, "CheckAlternativesGhostFiles")
|
||||
|
||||
@classmethod
|
||||
def read_ghost_files(cls, script):
|
||||
ghost_files = []
|
||||
|
||||
if not script or not 'update-alternatives' in script:
|
||||
return ghost_files
|
||||
|
||||
|
||||
for command in ( \
|
||||
c.replace('\\\n', '').strip() \
|
||||
for c in script.split('update-alternatives') \
|
||||
if cls.INSTALL in c):
|
||||
|
||||
#parse install
|
||||
xs = command.split(None, 4)
|
||||
ghost_files.append(xs[1])
|
||||
|
||||
if cls.SLAVE in command:
|
||||
for sc in ( \
|
||||
c.strip() \
|
||||
for c in command[command.index(cls.SLAVE):].split(cls.SLAVE) \
|
||||
if c.strip() != ''):
|
||||
|
||||
xs = sc.split(None, 2)
|
||||
ghost_files.append(xs[0])
|
||||
|
||||
return ghost_files
|
||||
|
||||
def check(self, pkg):
|
||||
|
||||
if pkg.isSource():
|
||||
return
|
||||
|
||||
alt_files = []
|
||||
for script in (pkg.header[tag] for tag in (rpm.RPMTAG_POSTIN, rpm.RPMTAG_PREIN, rpm.RPMTAG_POSTTRANS)):
|
||||
alt_files.extend(self.read_ghost_files(script))
|
||||
|
||||
files = pkg.files()
|
||||
ghost_files = pkg.ghostFiles()
|
||||
for af in alt_files:
|
||||
if af in files:
|
||||
printWarning(pkg, 'alternative-file-is-not-marked-as-ghost %s' % (af))
|
||||
continue
|
||||
if not af in ghost_files:
|
||||
printWarning(pkg, 'no-ghost-alternative-file %s' % af)
|
||||
|
||||
|
||||
check=CheckAlternativesGhostFiles()
|
||||
|
||||
if Config.info:
|
||||
addDetails(
|
||||
|
||||
'alternative-file-is-not-marked-as-ghost',
|
||||
'''The alternative file is listed in filelist, but not marked as a ghost, which
|
||||
may cause a problems during update. Mark it as a %ghost.''',
|
||||
|
||||
'no-ghost-alternative-file',
|
||||
'''The alternative file is not in a filelist, add it to list marked as %ghost.
|
||||
Note: this error will be raised, if you use a hash ($) in file name, so for
|
||||
suppress, use rpm macros in spec file instead.''',
|
||||
|
||||
)
|
1
config
1
config
@ -33,6 +33,7 @@ addCheck("CheckDBusPolicy")
|
||||
addCheck("CheckFilelist")
|
||||
addCheck("CheckKDE4Deps")
|
||||
addCheck("KMPPolicyCheck")
|
||||
addCheck("CheckAlternativesGhostFiles")
|
||||
|
||||
# stuff autobuild takes care about
|
||||
addFilter(".*invalid-version.*")
|
||||
|
@ -1,3 +1,8 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Aug 28 10:45:02 UTC 2009 - mvyskocil@suse.cz
|
||||
|
||||
- Added CheckAlternativesGhostFiles.py - see bnc#534451 comment#17
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Aug 26 09:28:14 UTC 2009 - lnussel@suse.de
|
||||
|
||||
|
@ -23,7 +23,7 @@ Name: rpmlint
|
||||
BuildRequires: rpm-python
|
||||
Summary: Rpm correctness checker
|
||||
Version: 0.87
|
||||
Release: 2
|
||||
Release: 3
|
||||
Source0: %{name}-%{version}.tar.bz2
|
||||
Source1: config
|
||||
Source1001: config.in
|
||||
@ -44,6 +44,7 @@ Source15: CheckPolkitPrivs.py
|
||||
Source16: CheckDBUSServices.py
|
||||
Source17: CheckFilelist.py
|
||||
Source18: CheckDBusPolicy.py
|
||||
Source19: CheckAlternativesGhostFiles.py
|
||||
Source100: syntax-validator.py
|
||||
Url: http://rpmlint.zarb.org/
|
||||
License: GPL v2 or later
|
||||
@ -197,6 +198,7 @@ cp -p %{SOURCE15} .
|
||||
cp -p %{SOURCE16} .
|
||||
cp -p %{SOURCE17} .
|
||||
cp -p %{SOURCE18} .
|
||||
cp -p %{SOURCE19} .
|
||||
|
||||
%build
|
||||
make
|
||||
|
Loading…
Reference in New Issue
Block a user