All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Hatle <mark.hatle@windriver.com>
To: <poky@yoctoproject.org>
Subject: Re: [PATCH 5/7] useradd-example: example recipe for using inherit useradd
Date: Tue, 31 May 2011 14:09:07 -0500	[thread overview]
Message-ID: <4DE53CD3.3090708@windriver.com> (raw)
In-Reply-To: <ea3163ab446883b772207bf0600f0198a3041a7a.1306865217.git.scott.a.garman@intel.com>

A few suggestions below to expand the example a bit.

On 5/31/11 1:13 PM, Scott Garman wrote:
> An example recipe for demonstrating/documenting how user and
> group manipulation is done with 'inherit useradd'
> 
> Signed-off-by: Scott Garman <scott.a.garman@intel.com>
> ---
>  .../recipes-skeleton/useradd/useradd-example.bb    |   59 ++++++++++++++++++++
>  1 files changed, 59 insertions(+), 0 deletions(-)
>  create mode 100644 meta-skeleton/recipes-skeleton/useradd/useradd-example.bb
>  create mode 100644 meta-skeleton/recipes-skeleton/useradd/useradd-example/file1
>  create mode 100644 meta-skeleton/recipes-skeleton/useradd/useradd-example/file2
>  create mode 100644 meta-skeleton/recipes-skeleton/useradd/useradd-example/file3
>  create mode 100644 meta-skeleton/recipes-skeleton/useradd/useradd-example/file4
> 
> diff --git a/meta-skeleton/recipes-skeleton/useradd/useradd-example.bb b/meta-skeleton/recipes-skeleton/useradd/useradd-example.bb
> new file mode 100644
> index 0000000..1e6ae87
> --- /dev/null
> +++ b/meta-skeleton/recipes-skeleton/useradd/useradd-example.bb
> @@ -0,0 +1,59 @@
> +SUMMARY = "Example recipe for using inherit useradd"
> +DESCRIPTION = "This recipe serves as an example for using features from useradd.bbclass"
> +SECTION = "examples"
> +PR = "r0"
> +LICENSE = "MIT"
> +LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58 \
> +                    file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
> +
> +SRC_URI = "file://file1 \
> +           file://file2 \
> +           file://file3 \
> +           file://file4"
> +
> +S = "${WORKDIR}"
> +

Move the package's up here to be clearer what we're doing:

PACKAGES =+ "${PN}-user3"

> +inherit useradd
> +
> +# Specify which package(s) should include the user/group code.
> +# Make sure that any packages which install files owned by custom
> +# users/groups are included here. The code which adds users and
> +# groups is idempotent.
> +USERADD_PACKAGES = "useradd-example"

List two packages above:

USERADD_PACKAGES = "useradd-example ${PN}-user3"

> +
> +# You *must* set USERADD_PARAM and/or GROUPADD_PARAM when
> +# you inherit useradd.
> +
> +# USERADD_PARAM specifies command line options to pass to the
> +# useradd command. Multiple users can be created by separating
> +# the commands with a semicolon. Here we'll create two users,
> +# user1 and user3:
> +USERADD_PARAM_useradd-example = "-u 1200 -d /home/user1 -r -s /bin/bash user1; -u 1201 -d /home/user3 -r -s /bin/bash user3"

Break the above apart into:

USERADD_PARAM_useradd-example = "-u 1200 -d /home/user1 -r -s /bin/bash user1;
-u 1201 -d /home/user2 -r -s /bin/bash user2"

USERADD_PARAM_${PN}-user3 = "-u 1202 -d /home/user3 -r -s /bin/bash user3"

> +
> +# GROUPADD_PARAM works the same way, which you set to the options
> +# you'd normally pass to the groupadd command. This will create
> +# groups group1, group2, and group3:
> +GROUPADD_PARAM_useradd-example = "-g 880 group1; -g 890 group2; -g 900 group3"

GROUPADD_PARAM_useradd-example = "-g 880 group1; -g 890 group2"

GROUPADD_PARAM_${PN}-user3 = "-g 900 group3"

> +
> +do_install () {
> +	install -d -m 755 ${D}/usr/share/user1
> +	install -d -m 755 ${D}/usr/share/user3
> +	install -p -m 644 file1 ${D}/usr/share/user1/
> +	install -p -m 644 file2 ${D}/usr/share/user1/
> +	install -p -m 644 file3 ${D}/usr/share/user3/
> +	install -p -m 644 file4 ${D}/usr/share/user3/
> +
> +	# The new users and groups are created before the do_install
> +	# step, so you are now free to make use of them:

To match the above split:

> +	chown -R user1 ${D}/usr/share/user1
> +	chown -R user3 ${D}/usr/share/user3
> +	chgrp group1 ${D}/usr/share/user1/file1
> +	chgrp group3 ${D}/usr/share/user1/file2
> +	chgrp group1 ${D}/usr/share/user3/file3
> +	chgrp group3 ${D}/usr/share/user3/file4

	chown -R user1 ${D}/usr/share/user1
	chown -R user3 ${D}/usr/share/user3
	chgrp group1 ${D}/usr/share/user1/file1
	chgrp group2 ${D}/usr/share/user1/file2
	chgrp group3 ${D}/usr/share/user3/file3
	chgrp group3 ${D}/usr/share/user3/file4

Since the user1 added groups 1 and 2..  while user3 only has group 3....

> +}
> +
> +PACKAGES =+ "${PN}-user3"

Moved the above line, so remove it here.

> +
> +FILES_${PN} = "/usr/share/user1/*"
> +FILES_${PN}-user3 = "/usr/share/user3/*"

This should now produce two split packages.  Each having different users and
groups being added.

> diff --git a/meta-skeleton/recipes-skeleton/useradd/useradd-example/file1 b/meta-skeleton/recipes-skeleton/useradd/useradd-example/file1
> new file mode 100644
> index 0000000..e69de29
> diff --git a/meta-skeleton/recipes-skeleton/useradd/useradd-example/file2 b/meta-skeleton/recipes-skeleton/useradd/useradd-example/file2
> new file mode 100644
> index 0000000..e69de29
> diff --git a/meta-skeleton/recipes-skeleton/useradd/useradd-example/file3 b/meta-skeleton/recipes-skeleton/useradd/useradd-example/file3
> new file mode 100644
> index 0000000..e69de29
> diff --git a/meta-skeleton/recipes-skeleton/useradd/useradd-example/file4 b/meta-skeleton/recipes-skeleton/useradd/useradd-example/file4
> new file mode 100644
> index 0000000..e69de29



  reply	other threads:[~2011-05-31 19:09 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-31 18:13 [PATCH 0/7] User/group creation at preinstall Scott Garman
2011-05-31 19:53 ` Scott Garman
2011-05-31 18:13 ` [PATCH 1/7] shadow: recipe and patch cleanup Scott Garman
2011-05-31 19:53   ` Scott Garman
2011-05-31 18:13 ` [PATCH 2/7] shadow: add a -native recipe with customized utilities Scott Garman
2011-05-31 19:53   ` Scott Garman
2011-06-01  9:47   ` Phil Blundell
2011-06-01 12:34     ` Martyn Welch
2011-06-01 13:42       ` Phil Blundell
2011-06-01 17:43     ` Scott Garman
2011-06-01 21:05       ` Mark Hatle
2011-06-02 11:19         ` Phil Blundell
2011-09-01 14:46   ` Phil Blundell
2011-09-01 16:41   ` Phil Blundell
2011-09-01 16:54     ` Mark Hatle
2011-09-01 16:58       ` Phil Blundell
2011-09-01 17:25         ` Mark Hatle
2011-09-01 19:44           ` Phil Blundell
2011-09-01 21:59             ` Richard Purdie
2011-09-02  0:02               ` Mark Hatle
2011-09-02  7:15               ` Phil Blundell
2011-09-02  9:50               ` Phil Blundell
2011-09-02 14:03                 ` Richard Purdie
2011-09-02 18:43                   ` Phil Blundell
2011-09-02 19:17                     ` Mark Hatle
2011-05-31 18:13 ` [PATCH 3/7] base-passwd: add -cross recipe with default login.defs Scott Garman
2011-05-31 19:53   ` Scott Garman
2011-05-31 18:13 ` [PATCH 4/7] useradd.bbclass: new class for managing user/group permissions Scott Garman
2011-05-31 19:53   ` Scott Garman
2011-05-31 18:13 ` [PATCH 5/7] useradd-example: example recipe for using inherit useradd Scott Garman
2011-05-31 19:53   ` Scott Garman
2011-05-31 19:09   ` Mark Hatle [this message]
2011-05-31 18:13 ` [PATCH 6/7] bitbake.conf: set PSEUDO_PASSWD within FAKEROOTENV Scott Garman
2011-05-31 19:53   ` Scott Garman
2011-05-31 18:13 ` [PATCH 7/7] package_rpm.bbclass: make RPM use on-disk permissions Scott Garman
2011-05-31 19:53   ` Scott Garman
2011-05-31 18:45 ` [poky] [PATCH 0/7] User/group creation at preinstall Koen Kooi
2011-05-31 18:45   ` Koen Kooi
2011-05-31 19:06   ` [poky] " Saul Wold
2011-05-31 19:06     ` Saul Wold
2011-05-31 19:09     ` Mark Hatle
2011-05-31 19:51     ` [poky] " Scott Garman
2011-05-31 19:51       ` Scott Garman
2011-05-31 19:57       ` [poky] " Otavio Salvador
2011-05-31 21:16         ` Mark Hatle
2011-05-31 21:16           ` [OE-core] " Mark Hatle
2011-05-31 21:27           ` [poky] " Scott Garman
2011-05-31 21:51             ` Richard Purdie
2011-05-31 21:25       ` Richard Purdie
2011-05-31 21:25         ` [OE-core] " Richard Purdie
2011-06-02 23:50 [PATCH 0/7] User/group creation at preinstall v2 Scott Garman
2011-06-02 23:50 ` [PATCH 5/7] useradd-example: example recipe for using inherit useradd Scott Garman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DE53CD3.3090708@windriver.com \
    --to=mark.hatle@windriver.com \
    --cc=poky@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.