-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
also adding UNPACKDIR to the list of known vars from styhead release on Closes #568 Signed-off-by: Konrad Weihmann <[email protected]>
- Loading branch information
1 parent
87a1759
commit 0dbc722
Showing
5 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# oelint.vars.unpackdir | ||
|
||
severity: error | ||
|
||
## Example | ||
|
||
``` | ||
S = "${WORKDIR}" | ||
``` | ||
|
||
or | ||
|
||
``` | ||
B = "${WORKDIR}/foo/bar" | ||
``` | ||
|
||
## Why is this bad? | ||
|
||
Recently upstream changed the way sources are unpacked/refreshed | ||
on changes of the SRC_URI inputs. | ||
Unpacking in WORKDIR makes it impossible to determine what is | ||
a new resource and what might be a left-over from a previous run. | ||
Hence UNPACKDIR was introduced - users should refrain from | ||
using WORKDIR for S or B | ||
|
||
## Ways to fix it | ||
|
||
``` | ||
S = "${UNPACKDIR}" | ||
``` | ||
|
||
or | ||
|
||
``` | ||
B = "${UNPACKDIR}/foo/bar" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from typing import List, Tuple | ||
|
||
from oelint_parser.cls_item import Variable | ||
from oelint_parser.cls_stash import Stash | ||
|
||
from oelint_adv.cls_rule import Rule | ||
|
||
|
||
class VarRootfsPostprocessCommand(Rule): | ||
def __init__(self) -> None: | ||
super().__init__(id='oelint.vars.unpackdir', | ||
severity='error', | ||
valid_from_release='styhead', | ||
message='Use ${UNPACKDIR} instead of ${WORKDIR}') | ||
|
||
def check(self, _file: str, stash: Stash) -> List[Tuple[str, int, str]]: | ||
res = [] | ||
items: List[Variable] = stash.GetItemsFor(filename=_file, classifier=Variable.CLASSIFIER, | ||
attribute=Variable.ATTR_VAR, attributeValue=['S', 'B']) | ||
for i in items: | ||
if '${WORKDIR}' in i.VarValueStripped: | ||
res += self.finding(i.Origin, i.InFileLine) | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import pytest # noqa: I900 | ||
|
||
from .base import TestBaseClass | ||
|
||
|
||
class TestClassOelintVarsUnpackdir(TestBaseClass): | ||
|
||
@pytest.mark.parametrize('id_', ['oelint.vars.unpackdir']) | ||
@pytest.mark.parametrize('occurrence', [1]) | ||
@pytest.mark.parametrize('input_', | ||
[ | ||
{ | ||
'oelint_adv_test.bb': | ||
'S = "${WORKDIR}"', | ||
}, | ||
{ | ||
'oelint_adv_test.bb': | ||
''' | ||
B = "${WORKDIR}/foo/bar" | ||
''', | ||
}, | ||
], | ||
) | ||
def test_bad_new(self, input_, id_, occurrence): | ||
self.check_for_id(self._create_args(input_, ['--release=styhead']), id_, occurrence) | ||
|
||
@pytest.mark.parametrize('id_', ['oelint.vars.unpackdir']) | ||
@pytest.mark.parametrize('occurrence', [0]) | ||
@pytest.mark.parametrize('input_', | ||
[ | ||
{ | ||
'oelint_adv_test.bb': | ||
'S = "${WORKDIR}"', | ||
}, | ||
{ | ||
'oelint_adv_test.bb': | ||
''' | ||
B = "${WORKDIR}/foo/bar" | ||
''', | ||
}, | ||
], | ||
) | ||
def test_bad_old(self, input_, id_, occurrence): | ||
self.check_for_id(self._create_args(input_), id_, occurrence) | ||
|
||
@pytest.mark.parametrize('id_', ['oelint.vars.unpackdir']) | ||
@pytest.mark.parametrize('occurrence', [0]) | ||
@pytest.mark.parametrize('input_', | ||
[ | ||
{ | ||
'oelint_adv_test.bb': | ||
''' | ||
S = "${UNPACKDIR}" | ||
''', | ||
}, | ||
{ | ||
'oelint_adv_test.bb': | ||
''' | ||
B = "${UNPACKDIR}/foo/bar" | ||
''', | ||
}, | ||
{ | ||
'oelint_adv_test.bb': | ||
''' | ||
SOMEOTHER = "${WORKDIR}/foo/bar" | ||
''', | ||
}, | ||
], | ||
) | ||
def test_good_inherit(self, input_, id_, occurrence): | ||
self.check_for_id(self._create_args(input_, ['--release=styhead']), id_, occurrence) |