diff options
author | Scott Garman <scott.a.garman@intel.com> | 2011-05-18 10:44:59 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-07-01 17:17:34 +0100 |
commit | 39502562bf06042eac1e67ec5972b9fcbea1528f (patch) | |
tree | 82ff660ca3386ae6ae32af2372841d8649ea78ce /meta-skeleton | |
parent | 14be7dbb159c43bdc5e2d128beb057d4b769a447 (diff) | |
download | poky-39502562bf06042eac1e67ec5972b9fcbea1528f.tar.gz |
useradd-example: example recipe for using inherit useradd
An example recipe for demonstrating/documenting how user and
group manipulation is done with 'inherit useradd'
(From OE-Core rev: 89a89caa555e288314c72594a589dcac081154ad)
Signed-off-by: Scott Garman <scott.a.garman@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta-skeleton')
5 files changed, 76 insertions, 0 deletions
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 0000000000..02d56f6abc --- /dev/null +++ b/meta-skeleton/recipes-skeleton/useradd/useradd-example.bb | |||
@@ -0,0 +1,76 @@ | |||
1 | SUMMARY = "Example recipe for using inherit useradd" | ||
2 | DESCRIPTION = "This recipe serves as an example for using features from useradd.bbclass" | ||
3 | SECTION = "examples" | ||
4 | PR = "r0" | ||
5 | LICENSE = "MIT" | ||
6 | LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58 \ | ||
7 | file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" | ||
8 | |||
9 | SRC_URI = "file://file1 \ | ||
10 | file://file2 \ | ||
11 | file://file3 \ | ||
12 | file://file4" | ||
13 | |||
14 | S = "${WORKDIR}" | ||
15 | |||
16 | PACKAGES =+ "${PN}-user3" | ||
17 | |||
18 | inherit useradd | ||
19 | |||
20 | # Specify which package(s) should include the user/group code. | ||
21 | # Make sure that any packages which install files owned by custom | ||
22 | # users/groups are included here. The code which adds users and | ||
23 | # groups is idempotent. | ||
24 | USERADD_PACKAGES = "${PN} ${PN}-user3" | ||
25 | |||
26 | # You *must* set USERADD_PARAM and/or GROUPADD_PARAM when | ||
27 | # you inherit useradd. | ||
28 | |||
29 | # USERADD_PARAM specifies command line options to pass to the | ||
30 | # useradd command. Multiple users can be created by separating | ||
31 | # the commands with a semicolon. Here we'll create two users, | ||
32 | # user1 and user2: | ||
33 | USERADD_PARAM_${PN} = "-u 1200 -d /home/user1 -r -s /bin/bash user1; -u 1201 -d /home/user2 -r -s /bin/bash user2" | ||
34 | |||
35 | # user3 will be managed in the useradd-example-user3 pacakge: | ||
36 | USERADD_PARAM_${PN}-user3 = "-u 1202 -d /home/user3 -r -s /bin/bash user3" | ||
37 | |||
38 | # GROUPADD_PARAM works the same way, which you set to the options | ||
39 | # you'd normally pass to the groupadd command. This will create | ||
40 | # groups group1 and group2: | ||
41 | GROUPADD_PARAM_${PN} = "-g 880 group1; -g 890 group2" | ||
42 | |||
43 | # Likewise, we'll manage group3 in the useradd-example-user3 package: | ||
44 | GROUPADD_PARAM_${PN}-user3 = "-g 900 group3" | ||
45 | |||
46 | do_install () { | ||
47 | install -d -m 755 ${D}/usr/share/user1 | ||
48 | install -d -m 755 ${D}/usr/share/user2 | ||
49 | install -d -m 755 ${D}/usr/share/user3 | ||
50 | |||
51 | install -p -m 644 file1 ${D}/usr/share/user1/ | ||
52 | install -p -m 644 file2 ${D}/usr/share/user1/ | ||
53 | |||
54 | install -p -m 644 file2 ${D}/usr/share/user2/ | ||
55 | install -p -m 644 file3 ${D}/usr/share/user2/ | ||
56 | |||
57 | install -p -m 644 file3 ${D}/usr/share/user3/ | ||
58 | install -p -m 644 file4 ${D}/usr/share/user3/ | ||
59 | |||
60 | # The new users and groups are created before the do_install | ||
61 | # step, so you are now free to make use of them: | ||
62 | chown -R user1 ${D}/usr/share/user1 | ||
63 | chown -R user2 ${D}/usr/share/user2 | ||
64 | chown -R user3 ${D}/usr/share/user3 | ||
65 | |||
66 | chgrp -R group1 ${D}/usr/share/user1 | ||
67 | chgrp -R group2 ${D}/usr/share/user2 | ||
68 | chgrp -R group3 ${D}/usr/share/user3 | ||
69 | } | ||
70 | |||
71 | FILES_${PN} = "/usr/share/user1/* /usr/share/user2/*" | ||
72 | FILES_${PN}-user3 = "/usr/share/user3/*" | ||
73 | |||
74 | # Prevents do_package failures with: | ||
75 | # debugsources.list: No such file or directory: | ||
76 | INHIBIT_PACKAGE_DEBUG_SPLIT = "1" | ||
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 0000000000..e69de29bb2 --- /dev/null +++ b/meta-skeleton/recipes-skeleton/useradd/useradd-example/file1 | |||
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 0000000000..e69de29bb2 --- /dev/null +++ b/meta-skeleton/recipes-skeleton/useradd/useradd-example/file2 | |||
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 0000000000..e69de29bb2 --- /dev/null +++ b/meta-skeleton/recipes-skeleton/useradd/useradd-example/file3 | |||
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 0000000000..e69de29bb2 --- /dev/null +++ b/meta-skeleton/recipes-skeleton/useradd/useradd-example/file4 | |||