Skip to content

Commit

Permalink
pkgspecific: make message more clear
Browse files Browse the repository at this point in the history
as the rule applies to all package names, not just only PN.
As this rule is also triggered when the used package is unknown,
we should make that more clear.
Also use the valid override delimiter found in the stash
instead of printing old and new syntax

Signed-off-by: Konrad Weihmann <[email protected]>
  • Loading branch information
priv-kweihmann committed Jan 6, 2024
1 parent 90a363a commit 70b3c6e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions oelint_adv/rule_base/rule_var_pkgspecific.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def __init__(self):
'FILES', 'pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm', 'ALLOW_EMPTY']
super().__init__(id='oelint.vars.pkgspecific',
severity='error',
message='Variable {VAR} is package-specific and therefore it should be {VAR}_${PN} or {VAR}:${PN}',
message='Variable {VAR} is package-specific and therefore it should be {VAR}{DEL}<known package name>',
appendix=self.needles)

def check(self, _file, stash):
Expand All @@ -22,6 +22,9 @@ def check(self, _file, stash):
_packages = list(get_valid_package_names(stash, _file))
items = stash.GetItemsFor(
filename=_file, classifier=Variable.CLASSIFIER)
if not items:
return res
delimiter = items[-1].OverrideDelimiter
for i in items:
if i.VarName == 'inherit':
continue
Expand All @@ -32,5 +35,5 @@ def check(self, _file, stash):
stash, _file, i.GetMachineEntry())]
if not _machine or not any(x in _packages for x in _machine):
res += self.finding(i.Origin, i.InFileLine,
override_msg=self.Msg.replace('{VAR}', i.VarName), appendix=i.VarName)
override_msg=self.Msg.format(self.Msg, VAR=i.VarName, DEL=delimiter), appendix=i.VarName)
return res

0 comments on commit 70b3c6e

Please sign in to comment.