2008-04-21 18:36:30 +02:00
|
|
|
# vim:sw=4:et
|
|
|
|
#############################################################################
|
|
|
|
# File : BrandingPolicyCheck.py
|
|
|
|
# Package : rpmlint
|
|
|
|
# Author : Dirk Mueller
|
|
|
|
# Purpose : Verify that branding related things comply
|
|
|
|
#############################################################################
|
|
|
|
|
|
|
|
from Filter import *
|
|
|
|
import AbstractCheck
|
|
|
|
import rpm
|
|
|
|
import re
|
|
|
|
import commands
|
|
|
|
import stat
|
|
|
|
import Config
|
|
|
|
import os
|
|
|
|
import string
|
|
|
|
import Pkg
|
|
|
|
|
|
|
|
class BrandingPolicyCheck(AbstractCheck.AbstractCheck):
|
|
|
|
def __init__(self):
|
|
|
|
self.map = []
|
|
|
|
AbstractCheck.AbstractCheck.__init__(self, "BrandingPolicyCheck")
|
|
|
|
|
|
|
|
def check(self, pkg):
|
|
|
|
if pkg.isSource():
|
|
|
|
return
|
|
|
|
|
|
|
|
pkg_requires = set(map(lambda x: string.split(x[0],'(')[0], pkg.requires()))
|
2009-04-07 14:17:44 +02:00
|
|
|
pkg_conflicts = set(map(lambda x: x[0], pkg.conflicts()))
|
2008-04-21 18:36:30 +02:00
|
|
|
|
|
|
|
# verify that only generic branding is required by non-branding packages
|
2008-05-01 14:19:31 +02:00
|
|
|
for r in pkg.requires():
|
2008-04-21 18:36:30 +02:00
|
|
|
if (pkg.name.find('-branding-') < 0 and
|
2008-05-01 14:19:31 +02:00
|
|
|
(r[0].find('-theme-') >= 0 or r[0].find('-branding-') >= 0)):
|
2008-05-06 01:35:08 +02:00
|
|
|
printError(pkg,'suse-branding-specific-branding-req', r[0])
|
2008-05-01 14:19:31 +02:00
|
|
|
if r[0].endswith('branding') or r[0].endswith('theme'):
|
2010-10-29 10:29:16 +02:00
|
|
|
# XXX: that startswith 1 breaks with openSUSE 20...
|
|
|
|
if (r[1] != rpm.RPMSENSE_EQUAL or not r[2][1].startswith('1')):
|
2010-10-28 13:38:59 +02:00
|
|
|
printError(pkg,'suse-branding-unversioned-requires', r[0])
|
2008-04-21 18:36:30 +02:00
|
|
|
|
|
|
|
# verify that it doesn't conflict with branding
|
|
|
|
for r in pkg_conflicts:
|
2010-05-03 23:18:30 +02:00
|
|
|
if r.startswith("otherproviders("):
|
|
|
|
continue
|
2008-04-21 18:36:30 +02:00
|
|
|
if r.find('-theme-') >= 0 or r.find('-branding-') >= 0:
|
|
|
|
printError(pkg,'suse-branding-branding-conflict', r)
|
|
|
|
|
|
|
|
if pkg.name.find('-branding-') < 0:
|
|
|
|
return
|
|
|
|
|
|
|
|
branding_basename=pkg.name.partition('-branding-')[0]
|
|
|
|
branding_style=pkg.name.partition('-branding-')[2]
|
|
|
|
generic_branding = ("%s-branding" % (branding_basename))
|
|
|
|
|
|
|
|
pkg_provides = set(map(lambda x: string.split(x[0],'(')[0], pkg.provides()))
|
2008-05-01 14:19:31 +02:00
|
|
|
pkg_supplements = set(map(lambda x: x[0], pkg.supplements()))
|
|
|
|
|
|
|
|
# verify that it only supplements with packageand
|
|
|
|
found_correct=False
|
2008-08-06 01:56:12 +02:00
|
|
|
correct_supplement="packageand(%s:branding-%s)" % (branding_basename, branding_style)
|
2008-05-01 14:19:31 +02:00
|
|
|
for s in pkg_supplements:
|
|
|
|
if s.startswith('packageand('):
|
|
|
|
if s != correct_supplement:
|
|
|
|
printError(pkg,'suse-branding-wrong-branding-supplement', s)
|
|
|
|
else:
|
|
|
|
found_correct=True
|
|
|
|
else:
|
|
|
|
printError(pkg,'suse-branding-excessive-supplement', s)
|
|
|
|
|
|
|
|
if not found_correct:
|
2008-08-06 01:56:12 +02:00
|
|
|
printError(pkg,'suse-branding-supplement-missing', correct_supplement)
|
2008-05-01 14:19:31 +02:00
|
|
|
|
|
|
|
# nothing else
|
|
|
|
for r in pkg.recommends():
|
|
|
|
printError(pkg,'suse-branding-excessive-recommends', r[0])
|
|
|
|
for r in pkg.suggests():
|
|
|
|
printError(pkg,'suse-branding-excessive-suggests', r[0])
|
|
|
|
for r in pkg.enhances():
|
|
|
|
printError(pkg,'suse-branding-excessive-enhances', r[0])
|
2008-04-21 18:36:30 +02:00
|
|
|
|
|
|
|
# check for provide foo-branding
|
|
|
|
branding_provide=None
|
|
|
|
for p in pkg.provides():
|
|
|
|
if p[0] == generic_branding:
|
|
|
|
branding_provide=p
|
|
|
|
break
|
|
|
|
|
2008-11-18 13:33:47 +01:00
|
|
|
# check for Conflicts: otherproviders(kde4-kdm-branding)
|
|
|
|
conflict_prop = "otherproviders(%s)" % (generic_branding)
|
|
|
|
have_conflict_prop = False
|
|
|
|
for c in pkg_conflicts:
|
2009-04-07 14:17:44 +02:00
|
|
|
if c == conflict_prop:
|
2008-11-18 13:33:47 +01:00
|
|
|
have_conflict_prop = True
|
|
|
|
break
|
|
|
|
|
|
|
|
if not have_conflict_prop:
|
|
|
|
printError(pkg,'suse-branding-missing-conflicts', conflict_prop)
|
|
|
|
|
2008-04-21 18:36:30 +02:00
|
|
|
if not branding_provide:
|
|
|
|
printError(pkg,'suse-branding-no-branding-provide')
|
|
|
|
else:
|
2010-10-28 13:38:59 +02:00
|
|
|
if (len(branding_provide) < 2 or branding_provide[1] != rpm.RPMSENSE_EQUAL):
|
|
|
|
printError(pkg, 'suse-branding-unversioned-provides', branding_provide[0])
|
2008-04-21 18:36:30 +02:00
|
|
|
|
|
|
|
for r in pkg.requires():
|
|
|
|
if r[0].find('-theme-') >= 0 or r[0].find('-branding-') >= 0:
|
2010-10-28 13:38:59 +02:00
|
|
|
if (r[1] != rpm.RPMSENSE_EQUAL or not r[2].startswith('1')):
|
|
|
|
printError(pkg, 'suse-branding-unversioned-requires', r[0])
|
2008-04-21 18:36:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
check=BrandingPolicyCheck()
|
|
|
|
|
|
|
|
if Config.info:
|
|
|
|
addDetails(
|
|
|
|
'suse-branding-specific-branding-req',
|
|
|
|
"""bla""",
|
|
|
|
'suse-branding-no-branding-provides',
|
2010-10-28 13:38:59 +02:00
|
|
|
"""Please add a provides entry similar to 'Provides: %name-branding = %version'.""",
|
|
|
|
'suse-branding-unversioned-provides',
|
|
|
|
"""Please make sure that your provides entry reads like 'Provides: %name-branding = %version'.""",
|
2008-05-01 14:19:31 +02:00
|
|
|
'suse-branding-supplement-missing',
|
|
|
|
"""branding packages should provide a supplemnent in the form
|
|
|
|
Supplements: packageand(basepackage:branding-<flavour>)
|
2008-11-18 13:33:47 +01:00
|
|
|
""",
|
2010-10-28 13:38:59 +02:00
|
|
|
'suse-branding-unversioned-requires',
|
|
|
|
"""Please make sure that your requires entry reads like 'Requires: %name-branding = <versionnumber>'.""",
|
2008-11-18 13:33:47 +01:00
|
|
|
'suse-branding-missing-conflicts',
|
|
|
|
"""Any branding flavor package that provides the generic branding
|
|
|
|
must also conflict with all other branding packages via a special
|
|
|
|
otherproviders()""",
|
2008-04-21 18:36:30 +02:00
|
|
|
)
|