Message ID | 20251009175300.7480-1-bhstalel@gmail.com |
---|---|
State | New |
Headers | show |
Series | [bitbake-devel] lib/bb/data_smart: add removeFromVar method | expand |
Le jeu. 9 oct. 2025 à 19:53, BELHADJ SALEM Talel via lists.openembedded.org <bhstalel=gmail.com@lists.openembedded.org> a écrit : > Tested with: > > MY_VARIABLE = "foo hello foo world" > python () { > d.removeFromVar('MY_VARIABLE', 'foo') > } > > $ bitbake-getvar -r example --value MY_VARIABLE > hello world > Out of curiosity, what does the variable history look like? (same command without the --value) > Signed-off-by: Talel BELHAJ SALEM <bhstalel@gmail.com> > --- > lib/bb/data_smart.py | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py > index 2e0d30858..554255f3d 100644 > --- a/lib/bb/data_smart.py > +++ b/lib/bb/data_smart.py > @@ -714,6 +714,11 @@ class DataSmart(MutableMapping): > self.varhistory.record(**loginfo) > self.setVar(var + ":prepend", value, ignore=True, parsing=True) > > + def removeFromVar(self, var, value, **loginfo): > + loginfo['op'] = 'remove' > + self.varhistory.record(**loginfo) > + self.setVar(var + ":remove", value, ignore=True, parsing=True) > + > def delVar(self, var, **loginfo): > self.expand_cache = {} > > -- > 2.51.0 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#18156): > https://lists.openembedded.org/g/bitbake-devel/message/18156 > Mute This Topic: https://lists.openembedded.org/mt/115676008/4316185 > Group Owner: bitbake-devel+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [ > yoann.congal@smile.fr] > -=-=-=-=-=-=-=-=-=-=-=- > >
It has two actions on it : set and remove: $ bitbake-getvar -r example MY_VARIABLE > # > # $MY_VARIABLE [2 operations] > # set /work/meta-test/recipes-example/example/example_0.1.bb:5 > # "foo hello foo world" > # remove example_0.1.bb:8 > [__anon_9__work_meta_test_recipes_example_example_example_0_1_bb] > # "foo" > # pre-expansion value: > # "foo hello foo world" > MY_VARIABLE=" hello world" On Thu, Oct 9, 2025 at 6:57 PM Yoann Congal <yoann.congal@smile.fr> wrote: > > > Le jeu. 9 oct. 2025 à 19:53, BELHADJ SALEM Talel via > lists.openembedded.org <bhstalel=gmail.com@lists.openembedded.org> a > écrit : > >> Tested with: >> >> MY_VARIABLE = "foo hello foo world" >> python () { >> d.removeFromVar('MY_VARIABLE', 'foo') >> } >> >> $ bitbake-getvar -r example --value MY_VARIABLE >> hello world >> > > Out of curiosity, what does the variable history look like? (same command > without the --value) > > >> Signed-off-by: Talel BELHAJ SALEM <bhstalel@gmail.com> >> --- >> lib/bb/data_smart.py | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py >> index 2e0d30858..554255f3d 100644 >> --- a/lib/bb/data_smart.py >> +++ b/lib/bb/data_smart.py >> @@ -714,6 +714,11 @@ class DataSmart(MutableMapping): >> self.varhistory.record(**loginfo) >> self.setVar(var + ":prepend", value, ignore=True, parsing=True) >> >> + def removeFromVar(self, var, value, **loginfo): >> + loginfo['op'] = 'remove' >> + self.varhistory.record(**loginfo) >> + self.setVar(var + ":remove", value, ignore=True, parsing=True) >> + >> def delVar(self, var, **loginfo): >> self.expand_cache = {} >> >> -- >> 2.51.0 >> >> >> -=-=-=-=-=-=-=-=-=-=-=- >> Links: You receive all messages sent to this group. >> View/Reply Online (#18156): >> https://lists.openembedded.org/g/bitbake-devel/message/18156 >> Mute This Topic: https://lists.openembedded.org/mt/115676008/4316185 >> Group Owner: bitbake-devel+owner@lists.openembedded.org >> Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [ >> yoann.congal@smile.fr] >> -=-=-=-=-=-=-=-=-=-=-=- >> >> > > -- > Yoann Congal > Smile ECS >
Le jeu. 9 oct. 2025 à 20:03, Talel BELHADJ SALEM <bhstalel@gmail.com> a écrit : > It has two actions on it : set and remove: > > $ bitbake-getvar -r example MY_VARIABLE >> # >> # $MY_VARIABLE [2 operations] >> # set /work/meta-test/recipes-example/example/example_0.1.bb:5 >> # "foo hello foo world" >> # remove example_0.1.bb:8 >> [__anon_9__work_meta_test_recipes_example_example_example_0_1_bb] >> # "foo" >> # pre-expansion value: >> # "foo hello foo world" >> MY_VARIABLE=" hello world" > > Thank you. It does look good! > On Thu, Oct 9, 2025 at 6:57 PM Yoann Congal <yoann.congal@smile.fr> wrote: > >> >> >> Le jeu. 9 oct. 2025 à 19:53, BELHADJ SALEM Talel via >> lists.openembedded.org <bhstalel=gmail.com@lists.openembedded.org> a >> écrit : >> >>> Tested with: >>> >>> MY_VARIABLE = "foo hello foo world" >>> python () { >>> d.removeFromVar('MY_VARIABLE', 'foo') >>> } >>> >>> $ bitbake-getvar -r example --value MY_VARIABLE >>> hello world >>> >> >> Out of curiosity, what does the variable history look like? (same command >> without the --value) >> >> >>> Signed-off-by: Talel BELHAJ SALEM <bhstalel@gmail.com> >>> --- >>> lib/bb/data_smart.py | 5 +++++ >>> 1 file changed, 5 insertions(+) >>> >>> diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py >>> index 2e0d30858..554255f3d 100644 >>> --- a/lib/bb/data_smart.py >>> +++ b/lib/bb/data_smart.py >>> @@ -714,6 +714,11 @@ class DataSmart(MutableMapping): >>> self.varhistory.record(**loginfo) >>> self.setVar(var + ":prepend", value, ignore=True, parsing=True) >>> >>> + def removeFromVar(self, var, value, **loginfo): >>> + loginfo['op'] = 'remove' >>> + self.varhistory.record(**loginfo) >>> + self.setVar(var + ":remove", value, ignore=True, parsing=True) >>> + >>> def delVar(self, var, **loginfo): >>> self.expand_cache = {} >>> >>> -- >>> 2.51.0 >>> >>> >>> -=-=-=-=-=-=-=-=-=-=-=- >>> Links: You receive all messages sent to this group. >>> View/Reply Online (#18156): >>> https://lists.openembedded.org/g/bitbake-devel/message/18156 >>> Mute This Topic: https://lists.openembedded.org/mt/115676008/4316185 >>> Group Owner: bitbake-devel+owner@lists.openembedded.org >>> Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [ >>> yoann.congal@smile.fr] >>> -=-=-=-=-=-=-=-=-=-=-=- >>> >>> >> >> -- >> Yoann Congal >> Smile ECS >> >
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py index 2e0d30858..554255f3d 100644 --- a/lib/bb/data_smart.py +++ b/lib/bb/data_smart.py @@ -714,6 +714,11 @@ class DataSmart(MutableMapping): self.varhistory.record(**loginfo) self.setVar(var + ":prepend", value, ignore=True, parsing=True) + def removeFromVar(self, var, value, **loginfo): + loginfo['op'] = 'remove' + self.varhistory.record(**loginfo) + self.setVar(var + ":remove", value, ignore=True, parsing=True) + def delVar(self, var, **loginfo): self.expand_cache = {}
Tested with: MY_VARIABLE = "foo hello foo world" python () { d.removeFromVar('MY_VARIABLE', 'foo') } $ bitbake-getvar -r example --value MY_VARIABLE hello world Signed-off-by: Talel BELHAJ SALEM <bhstalel@gmail.com> --- lib/bb/data_smart.py | 5 +++++ 1 file changed, 5 insertions(+)