All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Yang <liezhi.yang@windriver.com>
To: Saul Wold <sgw@linux.intel.com>,
	<openembedded-core@lists.openembedded.org>
Subject: Re: [PATCH 1/1] useradd_base.bbclass: sleep more and more seconds (up to 10)
Date: Fri, 4 Apr 2014 15:33:08 +0800	[thread overview]
Message-ID: <533E6034.4060906@windriver.com> (raw)
In-Reply-To: <533DC7B3.3060108@linux.intel.com>



On 04/04/2014 04:42 AM, Saul Wold wrote:
> On 04/03/2014 02:59 AM, Robert Yang wrote:
>>
>> Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
>> ---
>>   meta/classes/useradd_base.bbclass | 14 +++++++-------
>>   1 file changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/meta/classes/useradd_base.bbclass
>> b/meta/classes/useradd_base.bbclass
>> index 7aafe29..01d2e99 100644
>> --- a/meta/classes/useradd_base.bbclass
>> +++ b/meta/classes/useradd_base.bbclass
>> @@ -24,7 +24,7 @@ perform_groupadd () {
>>               group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
>>               if test "x$group_exists" = "x"; then
>>                   bbwarn "groupadd command did not succeed. Retrying..."
>> -                sleep 1
>> +                sleep `expr $count + 1`
>
> Why not move the count assignment that is below the fi (not visible in this
> diff) to above the test and then check for count > retries, this will save one
> call to expr.
>

Ah, yes, thanks, we can move the sleep after the bbfatal so that we don't
need the extra "expr" or check count > retries.

Updated:

   git://git.openembedded.org/openembedded-core-contrib rbt/sleep
   http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=rbt/sleep


diff --git a/meta/classes/useradd_base.bbclass b/meta/classes/useradd_base.bbclass
index 7aafe29..c47b1eb 100644
--- a/meta/classes/useradd_base.bbclass
+++ b/meta/classes/useradd_base.bbclass
@@ -24,7 +24,6 @@ perform_groupadd () {
  			group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
  			if test "x$group_exists" = "x"; then
  				bbwarn "groupadd command did not succeed. Retrying..."
-				sleep 1
  			else
  				break
  			fi
@@ -32,6 +31,7 @@ perform_groupadd () {
  			if test $count = $retries; then
  				bbfatal "Tried running groupadd command $retries times without scucess, 
giving up"
  			fi
+                        sleep $count
  		done
  	else
  		bbwarn "group $groupname already exists, not re-creating it"
@@ -52,7 +52,6 @@ perform_useradd () {
  		       user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
  		       if test "x$user_exists" = "x"; then
  			       bbwarn "useradd command did not succeed. Retrying..."
-			       sleep 1
  		       else
  			       break
  		       fi
@@ -60,6 +59,7 @@ perform_useradd () {
  		       if test $count = $retries; then
  				bbfatal "Tried running useradd command $retries times without scucess, 
giving up"
  		       fi
+		       sleep $count
  	       done
  	else
  		bbwarn "user $username already exists, not re-creating it"
@@ -90,7 +90,6 @@ perform_groupmems () {
  			mem_exists="`grep "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" 
$rootdir/etc/group || true`"
  			if test "x$mem_exists" = "x"; then
  				bbwarn "groupmems command did not succeed. Retrying..."
-				sleep 1
  			else
  				break
  			fi
@@ -102,6 +101,7 @@ perform_groupmems () {
  				fi
  				bbfatal "Tried running groupmems command $retries times without scucess, 
giving up"
  			fi
+			sleep $count
  		done
  	else
  		bbwarn "group $groupname already contains $username, not re-adding it"
@@ -126,7 +126,6 @@ perform_groupdel () {
  			group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
  			if test "x$group_exists" != "x"; then
  				bbwarn "groupdel command did not succeed. Retrying..."
-				sleep 1
  			else
  				break
  			fi
@@ -134,6 +133,7 @@ perform_groupdel () {
  			if test $count = $retries; then
  				bbfatal "Tried running groupdel command $retries times without scucess, 
giving up"
  			fi
+			sleep $count
  		done
  	else
  		bbwarn "group $groupname doesn't exist, not removing it"
@@ -154,7 +154,6 @@ perform_userdel () {
  		       user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
  		       if test "x$user_exists" != "x"; then
  			       bbwarn "userdel command did not succeed. Retrying..."
-			       sleep 1
  		       else
  			       break
  		       fi
@@ -162,6 +161,7 @@ perform_userdel () {
  		       if test $count = $retries; then
  				bbfatal "Tried running userdel command $retries times without scucess, 
giving up"
  		       fi
+		       sleep $count
  	       done
  	else
  		bbwarn "user $username doesn't exist, not removing it"
@@ -184,7 +184,6 @@ perform_groupmod () {
  			eval $PSEUDO groupmod $opts
  			if test $? != 0; then
  				bbwarn "groupmod command did not succeed. Retrying..."
-				sleep 1
  			else
  				break
  			fi
@@ -192,6 +191,7 @@ perform_groupmod () {
  			if test $count = $retries; then
  				bbfatal "Tried running groupmod command $retries times without scucess, 
giving up"
  			fi
+			sleep $count
  		done
  	else
  		bbwarn "group $groupname doesn't exist, unable to modify it"
@@ -214,7 +214,6 @@ perform_usermod () {
  		       eval $PSEUDO usermod $opts
  		       if test $? != 0; then
  			       bbwarn "usermod command did not succeed. Retrying..."
-			       sleep 1
  		       else
  			       break
  		       fi
@@ -222,6 +221,7 @@ perform_usermod () {
  		       if test $count = $retries; then
  				bbfatal "Tried running usermod command $retries times without scucess, 
giving up"
  		       fi
+		       sleep $count
  	       done
  	else
  		bbwarn "user $username doesn't exist, unable to modify it"

// Robert

> Sau!
>
>>               else
>>                   break
>>               fi
>> @@ -52,7 +52,7 @@ perform_useradd () {
>>                  user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
>>                  if test "x$user_exists" = "x"; then
>>                      bbwarn "useradd command did not succeed. Retrying..."
>> -                   sleep 1
>> +                   sleep `expr $count + 1`
>>                  else
>>                      break
>>                  fi
>> @@ -90,7 +90,7 @@ perform_groupmems () {
>>               mem_exists="`grep
>> "^$groupname:[^:]*:[^:]*:\([^,]*,\)*$username\(,[^,]*\)*" $rootdir/etc/group
>> || true`"
>>               if test "x$mem_exists" = "x"; then
>>                   bbwarn "groupmems command did not succeed. Retrying..."
>> -                sleep 1
>> +                sleep `expr $count + 1`
>>               else
>>                   break
>>               fi
>> @@ -126,7 +126,7 @@ perform_groupdel () {
>>               group_exists="`grep "^$groupname:" $rootdir/etc/group || true`"
>>               if test "x$group_exists" != "x"; then
>>                   bbwarn "groupdel command did not succeed. Retrying..."
>> -                sleep 1
>> +                sleep `expr $count + 1`
>>               else
>>                   break
>>               fi
>> @@ -154,7 +154,7 @@ perform_userdel () {
>>                  user_exists="`grep "^$username:" $rootdir/etc/passwd || true`"
>>                  if test "x$user_exists" != "x"; then
>>                      bbwarn "userdel command did not succeed. Retrying..."
>> -                   sleep 1
>> +                   sleep `expr $count + 1`
>>                  else
>>                      break
>>                  fi
>> @@ -184,7 +184,7 @@ perform_groupmod () {
>>               eval $PSEUDO groupmod $opts
>>               if test $? != 0; then
>>                   bbwarn "groupmod command did not succeed. Retrying..."
>> -                sleep 1
>> +                sleep `expr $count + 1`
>>               else
>>                   break
>>               fi
>> @@ -214,7 +214,7 @@ perform_usermod () {
>>                  eval $PSEUDO usermod $opts
>>                  if test $? != 0; then
>>                      bbwarn "usermod command did not succeed. Retrying..."
>> -                   sleep 1
>> +                   sleep `expr $count + 1`
>>                  else
>>                      break
>>                  fi
>>
>
>


      reply	other threads:[~2014-04-04  7:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-03  9:59 [PATCH 0/1] useradd_base.bbclass: sleep more and more seconds (up to 10) Robert Yang
2014-04-03  9:59 ` [PATCH 1/1] " Robert Yang
2014-04-03 20:42   ` Saul Wold
2014-04-04  7:33     ` Robert Yang [this message]

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=533E6034.4060906@windriver.com \
    --to=liezhi.yang@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=sgw@linux.intel.com \
    /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.