summaryrefslogtreecommitdiffstats
path: root/meta-skeleton/recipes-skeleton/useradd/useradd-example.bb
diff options
context:
space:
mode:
Diffstat (limited to 'meta-skeleton/recipes-skeleton/useradd/useradd-example.bb')
-rw-r--r--meta-skeleton/recipes-skeleton/useradd/useradd-example.bb75
1 files changed, 75 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..53d2340af5
--- /dev/null
+++ b/meta-skeleton/recipes-skeleton/useradd/useradd-example.bb
@@ -0,0 +1,75 @@
1SUMMARY = "Example recipe for using inherit useradd"
2DESCRIPTION = "This recipe serves as an example for using features from useradd.bbclass"
3SECTION = "examples"
4PR = "r1"
5LICENSE = "MIT"
6LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58 \
7 file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
8
9SRC_URI = "file://file1 \
10 file://file2 \
11 file://file3 \
12 file://file4"
13
14S = "${WORKDIR}"
15
16PACKAGES =+ "${PN}-user3"
17
18inherit useradd
19
20# You must set USERADD_PACKAGES when you inherit useradd. This
21# lists which output packages will include the user/group
22# creation code.
23USERADD_PACKAGES = "${PN} ${PN}-user3"
24
25# You must also set USERADD_PARAM and/or GROUPADD_PARAM when
26# you inherit useradd.
27
28# USERADD_PARAM specifies command line options to pass to the
29# useradd command. Multiple users can be created by separating
30# the commands with a semicolon. Here we'll create two users,
31# user1 and user2:
32USERADD_PARAM_${PN} = "-u 1200 -d /home/user1 -r -s /bin/bash user1; -u 1201 -d /home/user2 -r -s /bin/bash user2"
33
34# user3 will be managed in the useradd-example-user3 pacakge:
35USERADD_PARAM_${PN}-user3 = "-u 1202 -d /home/user3 -r -s /bin/bash user3"
36
37# GROUPADD_PARAM works the same way, which you set to the options
38# you'd normally pass to the groupadd command. This will create
39# groups group1 and group2:
40GROUPADD_PARAM_${PN} = "-g 880 group1; -g 890 group2"
41
42# Likewise, we'll manage group3 in the useradd-example-user3 package:
43GROUPADD_PARAM_${PN}-user3 = "-g 900 group3"
44
45do_install () {
46 install -d -m 755 ${D}${datadir}/user1
47 install -d -m 755 ${D}${datadir}/user2
48 install -d -m 755 ${D}${datadir}/user3
49
50 install -p -m 644 file1 ${D}${datadir}/user1/
51 install -p -m 644 file2 ${D}${datadir}/user1/
52
53 install -p -m 644 file2 ${D}${datadir}/user2/
54 install -p -m 644 file3 ${D}${datadir}/user2/
55
56 install -p -m 644 file3 ${D}${datadir}/user3/
57 install -p -m 644 file4 ${D}${datadir}/user3/
58
59 # The new users and groups are created before the do_install
60 # step, so you are now free to make use of them:
61 chown -R user1 ${D}${datadir}/user1
62 chown -R user2 ${D}${datadir}/user2
63 chown -R user3 ${D}${datadir}/user3
64
65 chgrp -R group1 ${D}${datadir}/user1
66 chgrp -R group2 ${D}${datadir}/user2
67 chgrp -R group3 ${D}${datadir}/user3
68}
69
70FILES_${PN} = "${datadir}/user1/* ${datadir}/user2/*"
71FILES_${PN}-user3 = "${datadir}/user3/*"
72
73# Prevents do_package failures with:
74# debugsources.list: No such file or directory:
75INHIBIT_PACKAGE_DEBUG_SPLIT = "1"