summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2015-07-28 02:03:32 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-01 22:24:16 +0100
commitfd921429958a726825759748900f22b4389c1d05 (patch)
treedd2c7903c870a176fc1780fc1c974f3bf23aec32 /meta
parentb741780d43ad412f6a1ae91d8489ec3522447ea2 (diff)
downloadpoky-fd921429958a726825759748900f22b4389c1d05.tar.gz
useradd_base.bbclass: print PN when bbnote/bbwarn/bbfatal
Print PN will help debug: WARNING: openssh: user sshd already exists, not re-creating it Which is better than: WARNING: user sshd already exists, not re-creating it (From OE-Core rev: cfde8621d18967dee71042e02b8d6db5661df3da) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/useradd_base.bbclass58
1 files changed, 29 insertions, 29 deletions
diff --git a/meta/classes/useradd_base.bbclass b/meta/classes/useradd_base.bbclass
index 4398a25154..7fe83a7653 100644
--- a/meta/classes/useradd_base.bbclass
+++ b/meta/classes/useradd_base.bbclass
@@ -14,7 +14,7 @@ perform_groupadd () {
14 local rootdir="$1" 14 local rootdir="$1"
15 local opts="$2" 15 local opts="$2"
16 local retries="$3" 16 local retries="$3"
17 bbnote "Performing groupadd with [$opts] and $retries times of retry" 17 bbnote "${PN}: Performing groupadd with [$opts] and $retries times of retry"
18 local groupname=`echo "$opts" | awk '{ print $NF }'` 18 local groupname=`echo "$opts" | awk '{ print $NF }'`
19 local group_exists="`grep "^$groupname:" $rootdir/etc/group || true`" 19 local group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
20 if test "x$group_exists" = "x"; then 20 if test "x$group_exists" = "x"; then
@@ -23,18 +23,18 @@ perform_groupadd () {
23 eval $PSEUDO groupadd $opts || true 23 eval $PSEUDO groupadd $opts || true
24 group_exists="`grep "^$groupname:" $rootdir/etc/group || true`" 24 group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
25 if test "x$group_exists" = "x"; then 25 if test "x$group_exists" = "x"; then
26 bbwarn "groupadd command did not succeed. Retrying..." 26 bbwarn "${PN}: groupadd command did not succeed. Retrying..."
27 else 27 else
28 break 28 break
29 fi 29 fi
30 count=`expr $count + 1` 30 count=`expr $count + 1`
31 if test $count = $retries; then 31 if test $count = $retries; then
32 bbfatal "Tried running groupadd command $retries times without success, giving up" 32 bbfatal "${PN}: Tried running groupadd command $retries times without success, giving up"
33 fi 33 fi
34 sleep $count 34 sleep $count
35 done 35 done
36 else 36 else
37 bbwarn "group $groupname already exists, not re-creating it" 37 bbwarn "${PN}: group $groupname already exists, not re-creating it"
38 fi 38 fi
39} 39}
40 40
@@ -42,7 +42,7 @@ perform_useradd () {
42 local rootdir="$1" 42 local rootdir="$1"
43 local opts="$2" 43 local opts="$2"
44 local retries="$3" 44 local retries="$3"
45 bbnote "Performing useradd with [$opts] and $retries times of retry" 45 bbnote "${PN}: Performing useradd with [$opts] and $retries times of retry"
46 local username=`echo "$opts" | awk '{ print $NF }'` 46 local username=`echo "$opts" | awk '{ print $NF }'`
47 local user_exists="`grep "^$username:" $rootdir/etc/passwd || true`" 47 local user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
48 if test "x$user_exists" = "x"; then 48 if test "x$user_exists" = "x"; then
@@ -51,18 +51,18 @@ perform_useradd () {
51 eval $PSEUDO useradd $opts || true 51 eval $PSEUDO useradd $opts || true
52 user_exists="`grep "^$username:" $rootdir/etc/passwd || true`" 52 user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
53 if test "x$user_exists" = "x"; then 53 if test "x$user_exists" = "x"; then
54 bbwarn "useradd command did not succeed. Retrying..." 54 bbwarn "${PN}: useradd command did not succeed. Retrying..."
55 else 55 else
56 break 56 break
57 fi 57 fi
58 count=`expr $count + 1` 58 count=`expr $count + 1`
59 if test $count = $retries; then 59 if test $count = $retries; then
60 bbfatal "Tried running useradd command $retries times without success, giving up" 60 bbfatal "${PN}: Tried running useradd command $retries times without success, giving up"
61 fi 61 fi
62 sleep $count 62 sleep $count
63 done 63 done
64 else 64 else
65 bbwarn "user $username already exists, not re-creating it" 65 bbwarn "${PN}: user $username already exists, not re-creating it"
66 fi 66 fi
67} 67}
68 68
@@ -70,10 +70,10 @@ perform_groupmems () {
70 local rootdir="$1" 70 local rootdir="$1"
71 local opts="$2" 71 local opts="$2"
72 local retries="$3" 72 local retries="$3"
73 bbnote "Performing groupmems with [$opts] and $retries times of retry" 73 bbnote "${PN}: Performing groupmems with [$opts] and $retries times of retry"
74 local groupname=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-g" || $i == "--group") print $(i+1) }'` 74 local groupname=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-g" || $i == "--group") print $(i+1) }'`
75 local username=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-a" || $i == "--add") print $(i+1) }'` 75 local username=`echo "$opts" | awk '{ for (i = 1; i < NF; i++) if ($i == "-a" || $i == "--add") print $(i+1) }'`
76 bbnote "Running groupmems command with group $groupname and user $username" 76 bbnote "${PN}: Running groupmems command with group $groupname and user $username"
77 # groupmems fails if /etc/gshadow does not exist 77 # groupmems fails if /etc/gshadow does not exist
78 local gshadow="" 78 local gshadow=""
79 if [ -f $rootdir${sysconfdir}/gshadow ]; then 79 if [ -f $rootdir${sysconfdir}/gshadow ]; then
@@ -89,7 +89,7 @@ perform_groupmems () {
89 eval $PSEUDO groupmems $opts || true 89 eval $PSEUDO groupmems $opts || true
90 mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" $rootdir/etc/group || true`" 90 mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" $rootdir/etc/group || true`"
91 if test "x$mem_exists" = "x"; then 91 if test "x$mem_exists" = "x"; then
92 bbwarn "groupmems command did not succeed. Retrying..." 92 bbwarn "${PN}: groupmems command did not succeed. Retrying..."
93 else 93 else
94 break 94 break
95 fi 95 fi
@@ -99,12 +99,12 @@ perform_groupmems () {
99 rm -f $rootdir${sysconfdir}/gshadow 99 rm -f $rootdir${sysconfdir}/gshadow
100 rm -f $rootdir${sysconfdir}/gshadow- 100 rm -f $rootdir${sysconfdir}/gshadow-
101 fi 101 fi
102 bbfatal "Tried running groupmems command $retries times without success, giving up" 102 bbfatal "${PN}: Tried running groupmems command $retries times without success, giving up"
103 fi 103 fi
104 sleep $count 104 sleep $count
105 done 105 done
106 else 106 else
107 bbwarn "group $groupname already contains $username, not re-adding it" 107 bbwarn "${PN}: group $groupname already contains $username, not re-adding it"
108 fi 108 fi
109 if test "x$gshadow" = "xno"; then 109 if test "x$gshadow" = "xno"; then
110 rm -f $rootdir${sysconfdir}/gshadow 110 rm -f $rootdir${sysconfdir}/gshadow
@@ -116,7 +116,7 @@ perform_groupdel () {
116 local rootdir="$1" 116 local rootdir="$1"
117 local opts="$2" 117 local opts="$2"
118 local retries="$3" 118 local retries="$3"
119 bbnote "Performing groupdel with [$opts] and $retries times of retry" 119 bbnote "${PN}: Performing groupdel with [$opts] and $retries times of retry"
120 local groupname=`echo "$opts" | awk '{ print $NF }'` 120 local groupname=`echo "$opts" | awk '{ print $NF }'`
121 local group_exists="`grep "^$groupname:" $rootdir/etc/group || true`" 121 local group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
122 if test "x$group_exists" != "x"; then 122 if test "x$group_exists" != "x"; then
@@ -125,18 +125,18 @@ perform_groupdel () {
125 eval $PSEUDO groupdel $opts || true 125 eval $PSEUDO groupdel $opts || true
126 group_exists="`grep "^$groupname:" $rootdir/etc/group || true`" 126 group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
127 if test "x$group_exists" != "x"; then 127 if test "x$group_exists" != "x"; then
128 bbwarn "groupdel command did not succeed. Retrying..." 128 bbwarn "${PN}: groupdel command did not succeed. Retrying..."
129 else 129 else
130 break 130 break
131 fi 131 fi
132 count=`expr $count + 1` 132 count=`expr $count + 1`
133 if test $count = $retries; then 133 if test $count = $retries; then
134 bbfatal "Tried running groupdel command $retries times without success, giving up" 134 bbfatal "${PN}: Tried running groupdel command $retries times without success, giving up"
135 fi 135 fi
136 sleep $count 136 sleep $count
137 done 137 done
138 else 138 else
139 bbwarn "group $groupname doesn't exist, not removing it" 139 bbwarn "${PN}: group $groupname doesn't exist, not removing it"
140 fi 140 fi
141} 141}
142 142
@@ -144,7 +144,7 @@ perform_userdel () {
144 local rootdir="$1" 144 local rootdir="$1"
145 local opts="$2" 145 local opts="$2"
146 local retries="$3" 146 local retries="$3"
147 bbnote "Performing userdel with [$opts] and $retries times of retry" 147 bbnote "${PN}: Performing userdel with [$opts] and $retries times of retry"
148 local username=`echo "$opts" | awk '{ print $NF }'` 148 local username=`echo "$opts" | awk '{ print $NF }'`
149 local user_exists="`grep "^$username:" $rootdir/etc/passwd || true`" 149 local user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
150 if test "x$user_exists" != "x"; then 150 if test "x$user_exists" != "x"; then
@@ -153,18 +153,18 @@ perform_userdel () {
153 eval $PSEUDO userdel $opts || true 153 eval $PSEUDO userdel $opts || true
154 user_exists="`grep "^$username:" $rootdir/etc/passwd || true`" 154 user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
155 if test "x$user_exists" != "x"; then 155 if test "x$user_exists" != "x"; then
156 bbwarn "userdel command did not succeed. Retrying..." 156 bbwarn "${PN}: userdel command did not succeed. Retrying..."
157 else 157 else
158 break 158 break
159 fi 159 fi
160 count=`expr $count + 1` 160 count=`expr $count + 1`
161 if test $count = $retries; then 161 if test $count = $retries; then
162 bbfatal "Tried running userdel command $retries times without success, giving up" 162 bbfatal "${PN}: Tried running userdel command $retries times without success, giving up"
163 fi 163 fi
164 sleep $count 164 sleep $count
165 done 165 done
166 else 166 else
167 bbwarn "user $username doesn't exist, not removing it" 167 bbwarn "${PN}: user $username doesn't exist, not removing it"
168 fi 168 fi
169} 169}
170 170
@@ -175,7 +175,7 @@ perform_groupmod () {
175 local rootdir="$1" 175 local rootdir="$1"
176 local opts="$2" 176 local opts="$2"
177 local retries="$3" 177 local retries="$3"
178 bbnote "Performing groupmod with [$opts] and $retries times of retry" 178 bbnote "${PN}: Performing groupmod with [$opts] and $retries times of retry"
179 local groupname=`echo "$opts" | awk '{ print $NF }'` 179 local groupname=`echo "$opts" | awk '{ print $NF }'`
180 local group_exists="`grep "^$groupname:" $rootdir/etc/group || true`" 180 local group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
181 if test "x$group_exists" != "x"; then 181 if test "x$group_exists" != "x"; then
@@ -183,18 +183,18 @@ perform_groupmod () {
183 while true; do 183 while true; do
184 eval $PSEUDO groupmod $opts 184 eval $PSEUDO groupmod $opts
185 if test $? != 0; then 185 if test $? != 0; then
186 bbwarn "groupmod command did not succeed. Retrying..." 186 bbwarn "${PN}: groupmod command did not succeed. Retrying..."
187 else 187 else
188 break 188 break
189 fi 189 fi
190 count=`expr $count + 1` 190 count=`expr $count + 1`
191 if test $count = $retries; then 191 if test $count = $retries; then
192 bbfatal "Tried running groupmod command $retries times without success, giving up" 192 bbfatal "${PN}: Tried running groupmod command $retries times without success, giving up"
193 fi 193 fi
194 sleep $count 194 sleep $count
195 done 195 done
196 else 196 else
197 bbwarn "group $groupname doesn't exist, unable to modify it" 197 bbwarn "${PN}: group $groupname doesn't exist, unable to modify it"
198 fi 198 fi
199 set -e 199 set -e
200} 200}
@@ -205,7 +205,7 @@ perform_usermod () {
205 local rootdir="$1" 205 local rootdir="$1"
206 local opts="$2" 206 local opts="$2"
207 local retries="$3" 207 local retries="$3"
208 bbnote "Performing usermod with [$opts] and $retries times of retry" 208 bbnote "${PN}: Performing usermod with [$opts] and $retries times of retry"
209 local username=`echo "$opts" | awk '{ print $NF }'` 209 local username=`echo "$opts" | awk '{ print $NF }'`
210 local user_exists="`grep "^$username:" $rootdir/etc/passwd || true`" 210 local user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
211 if test "x$user_exists" != "x"; then 211 if test "x$user_exists" != "x"; then
@@ -213,18 +213,18 @@ perform_usermod () {
213 while true; do 213 while true; do
214 eval $PSEUDO usermod $opts 214 eval $PSEUDO usermod $opts
215 if test $? != 0; then 215 if test $? != 0; then
216 bbwarn "usermod command did not succeed. Retrying..." 216 bbwarn "${PN}: usermod command did not succeed. Retrying..."
217 else 217 else
218 break 218 break
219 fi 219 fi
220 count=`expr $count + 1` 220 count=`expr $count + 1`
221 if test $count = $retries; then 221 if test $count = $retries; then
222 bbfatal "Tried running usermod command $retries times without success, giving up" 222 bbfatal "${PN}: Tried running usermod command $retries times without success, giving up"
223 fi 223 fi
224 sleep $count 224 sleep $count
225 done 225 done
226 else 226 else
227 bbwarn "user $username doesn't exist, unable to modify it" 227 bbwarn "${PN}: user $username doesn't exist, unable to modify it"
228 fi 228 fi
229 set -e 229 set -e
230} 230}