[v2] image-account-extenstion: rebuild on varflag changes

Message ID 20240418073149.319864-1-benedikt.niedermayr@siemens.com
State Superseded, archived
Headers show
Series [v2] image-account-extenstion: rebuild on varflag changes | expand

Commit Message

Niedermayr, BENEDIKT April 18, 2024, 7:31 a.m. UTC
From: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>

When adding items (e.g. foo) to the USER or GROUP variables, the
buildsystem automatically creates new variables (USER_foo).
One can then set these variables, or more precise, the variable
flags (e.g. USER_foo[password]) to control differents aspects
of the user creation.
Isar does not trigger a rebuild when applying changes to these
variable flags since they are not recognized by the
tasks signature generation.

The same applies to the USERS and GROUPS variables as well as
for the SOURCE_DATE_EPOCH variable.

Signed-off-by: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
---
 meta/classes/image-account-extension.bbclass | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Comments

MOESSBAUER, Felix April 18, 2024, 3:45 p.m. UTC | #1
On Thu, 2024-04-18 at 09:31 +0200, 'B. Niedermayr' via isar-users
wrote:
> From: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
> 
> When adding items (e.g. foo) to the USER or GROUP variables, the
> buildsystem automatically creates new variables (USER_foo).
> One can then set these variables, or more precise, the variable
> flags (e.g. USER_foo[password]) to control differents aspects
> of the user creation.
> Isar does not trigger a rebuild when applying changes to these
> variable flags since they are not recognized by the
> tasks signature generation.
> 
> The same applies to the USERS and GROUPS variables as well as
> for the SOURCE_DATE_EPOCH variable.
> 
> Signed-off-by: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
> ---
>  meta/classes/image-account-extension.bbclass | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/meta/classes/image-account-extension.bbclass
> b/meta/classes/image-account-extension.bbclass
> index 3d4e1d1dd175..4ab0aae87015 100644
> --- a/meta/classes/image-account-extension.bbclass
> +++ b/meta/classes/image-account-extension.bbclass
> @@ -8,6 +8,18 @@
>  USERS ??= ""
>  GROUPS ??= ""
>  
> +python() {
> +    d.appendVarFlag("image_postprocess_accounts", "vardeps", " USERS
> GROUPS SOURCE_DATE_EPOCH")

Hi, I prefer to avoid inline-python as much as possible, due to its
hard to understand side effects. The same logic can also be written as:

image_postprocess_accounts[vardeps] += "USERS GROUPS SOURCE_DATE_EPOCH"

Happy Coding!
Felix

> +
> +    for entry in (d.getVar("GROUPS") or "").split():
> +        group_entry = "GROUP_{}".format(entry)
> +        d.appendVarFlag("image_postprocess_accounts", "vardeps", "
> {}".format(group_entry))
> +
> +    for entry in (d.getVar("USERS") or "").split():
> +        user_entry = "USER_{}".format(entry)
> +        d.appendVarFlag("image_postprocess_accounts", "vardeps", "
> {}".format(user_entry))
> +}
> +
>  def image_create_groups(d: "DataSmart") -> None:
>      """Creates the groups defined in the ``GROUPS`` bitbake
> variable.
>  
> @@ -134,7 +146,7 @@ python image_postprocess_accounts() {
>      import os
>      if d.getVar("SOURCE_DATE_EPOCH") != None:
>          os.environ["SOURCE_DATE_EPOCH"] =
> d.getVar("SOURCE_DATE_EPOCH")
> - 
> +
>      image_create_groups(d)
>      image_create_users(d)
>  }
> -- 
> 2.34.1
>
Niedermayr, BENEDIKT April 18, 2024, 4:10 p.m. UTC | #2
On Thu, 2024-04-18 at 15:45 +0000, Moessbauer, Felix (T CED OES-DE) wrote:
> On Thu, 2024-04-18 at 09:31 +0200, 'B. Niedermayr' via isar-users
> wrote:
> > From: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
> > 
> > When adding items (e.g. foo) to the USER or GROUP variables, the
> > buildsystem automatically creates new variables (USER_foo).
> > One can then set these variables, or more precise, the variable
> > flags (e.g. USER_foo[password]) to control differents aspects
> > of the user creation.
> > Isar does not trigger a rebuild when applying changes to these
> > variable flags since they are not recognized by the
> > tasks signature generation.
> > 
> > The same applies to the USERS and GROUPS variables as well as
> > for the SOURCE_DATE_EPOCH variable.
> > 
> > Signed-off-by: Benedikt Niedermayr <benedikt.niedermayr@siemens.com>
> > ---
> >  meta/classes/image-account-extension.bbclass | 14 +++++++++++++-
> >  1 file changed, 13 insertions(+), 1 deletion(-)
> > 
> > diff --git a/meta/classes/image-account-extension.bbclass
> > b/meta/classes/image-account-extension.bbclass
> > index 3d4e1d1dd175..4ab0aae87015 100644
> > --- a/meta/classes/image-account-extension.bbclass
> > +++ b/meta/classes/image-account-extension.bbclass
> > @@ -8,6 +8,18 @@
> >  USERS ??= ""
> >  GROUPS ??= ""
> >  
> > +python() {
> > +    d.appendVarFlag("image_postprocess_accounts", "vardeps", " USERS
> > GROUPS SOURCE_DATE_EPOCH")
> 
> Hi, I prefer to avoid inline-python as much as possible, due to its
> hard to understand side effects. The same logic can also be written as:

I'm fine with that. 

v3 follows straight after... 

Regards,
Benedikt

> 
> image_postprocess_accounts[vardeps] += "USERS GROUPS SOURCE_DATE_EPOCH"
> 
> Happy Coding!
> Felix
> 
> > +
> > +    for entry in (d.getVar("GROUPS") or "").split():
> > +        group_entry = "GROUP_{}".format(entry)
> > +        d.appendVarFlag("image_postprocess_accounts", "vardeps", "
> > {}".format(group_entry))
> > +
> > +    for entry in (d.getVar("USERS") or "").split():
> > +        user_entry = "USER_{}".format(entry)
> > +        d.appendVarFlag("image_postprocess_accounts", "vardeps", "
> > {}".format(user_entry))
> > +}
> > +
> >  def image_create_groups(d: "DataSmart") -> None:
> >      """Creates the groups defined in the ``GROUPS`` bitbake
> > variable.
> >  
> > @@ -134,7 +146,7 @@ python image_postprocess_accounts() {
> >      import os
> >      if d.getVar("SOURCE_DATE_EPOCH") != None:
> >          os.environ["SOURCE_DATE_EPOCH"] =
> > d.getVar("SOURCE_DATE_EPOCH")
> > - 
> > +
> >      image_create_groups(d)
> >      image_create_users(d)
> >  }
> > -- 
> > 2.34.1
> > 
> 
> -- 
> Siemens AG, Technology
> Linux Expert Center
> 
>

Patch

diff --git a/meta/classes/image-account-extension.bbclass b/meta/classes/image-account-extension.bbclass
index 3d4e1d1dd175..4ab0aae87015 100644
--- a/meta/classes/image-account-extension.bbclass
+++ b/meta/classes/image-account-extension.bbclass
@@ -8,6 +8,18 @@ 
 USERS ??= ""
 GROUPS ??= ""
 
+python() {
+    d.appendVarFlag("image_postprocess_accounts", "vardeps", " USERS GROUPS SOURCE_DATE_EPOCH")
+
+    for entry in (d.getVar("GROUPS") or "").split():
+        group_entry = "GROUP_{}".format(entry)
+        d.appendVarFlag("image_postprocess_accounts", "vardeps", " {}".format(group_entry))
+
+    for entry in (d.getVar("USERS") or "").split():
+        user_entry = "USER_{}".format(entry)
+        d.appendVarFlag("image_postprocess_accounts", "vardeps", " {}".format(user_entry))
+}
+
 def image_create_groups(d: "DataSmart") -> None:
     """Creates the groups defined in the ``GROUPS`` bitbake variable.
 
@@ -134,7 +146,7 @@  python image_postprocess_accounts() {
     import os
     if d.getVar("SOURCE_DATE_EPOCH") != None:
         os.environ["SOURCE_DATE_EPOCH"] = d.getVar("SOURCE_DATE_EPOCH")
- 
+
     image_create_groups(d)
     image_create_users(d)
 }