All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] initscripts: add usleep support from RHEL
@ 2014-07-02  7:33 Ming Liu
  2014-07-02 17:37 ` Christopher Larson
  0 siblings, 1 reply; 7+ messages in thread
From: Ming Liu @ 2014-07-02  7:33 UTC (permalink / raw)
  To: openembedded-core

Add usleep in to support sleeping some number of microseconds.

Signed-off-by: Ming Liu <ming.liu@windriver.com>
---
 .../initscripts/initscripts-1.0/usleep.1           | 25 +++++++
 .../initscripts/initscripts-1.0/usleep.c           | 82 ++++++++++++++++++++++
 meta/recipes-core/initscripts/initscripts_1.0.bb   | 13 +++-
 3 files changed, 119 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-core/initscripts/initscripts-1.0/usleep.1
 create mode 100644 meta/recipes-core/initscripts/initscripts-1.0/usleep.c

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/usleep.1 b/meta/recipes-core/initscripts/initscripts-1.0/usleep.1
new file mode 100644
index 0000000..2d7520f
--- /dev/null
+++ b/meta/recipes-core/initscripts/initscripts-1.0/usleep.1
@@ -0,0 +1,25 @@
+.TH USLEEP 1 "Red Hat, Inc" \" -*- nroff -*-
+.SH NAME
+usleep \- sleep some number of microseconds
+.SH SYNOPSIS
+.B usleep
+[\fInumber\fP]
+.SH DESCRIPTION
+.B usleep
+sleeps some number of microseconds.  The default is 1.
+.SH OPTIONS
+\fI--usage\fP
+Show short usage message.
+.TP
+\fI--help, -?\fP
+Print help information.
+.TP
+\fI-v, --version\fP
+Print version information.
+.SH BUGS
+Probably not accurate on many machines down to the microsecond.  Count
+on precision only to -4 or maybe -5.
+.SH AUTHOR
+Donald Barnes <djb@redhat.com>
+.br
+Erik Troan <ewt@redhat.com>
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/usleep.c b/meta/recipes-core/initscripts/initscripts-1.0/usleep.c
new file mode 100644
index 0000000..a5e7d9d
--- /dev/null
+++ b/meta/recipes-core/initscripts/initscripts-1.0/usleep.c
@@ -0,0 +1,82 @@
+/* 
+ * usleep
+ * 
+ * Written by Donald Barnes <djb@redhat.com> for Red Hat, Inc.
+ * 
+ * Copyright (c) 1997-2003 Red Hat, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "popt.h"
+
+int main(int argc, char **argv) {
+  unsigned long count;
+  poptContext optCon;
+  int showVersion = 0;
+  int showOot = 0;
+  int rc;
+  char * countStr = NULL;
+  struct poptOption options[] = {
+            { "version", 'v', POPT_ARG_NONE, &showVersion, 0, 
+			"Display the version of this program, and exit" },
+            { "oot", 'o', POPT_ARG_NONE, &showOot, 0, 
+			"oot says hey!" },
+	    POPT_AUTOHELP
+            { 0, 0, 0, 0, 0 }
+        };
+
+  optCon = poptGetContext("usleep", argc, argv, options,0);
+  /*poptReadDefaultConfig(optCon, 1);*/
+  poptSetOtherOptionHelp(optCon, "[microseconds]");
+
+  if ((rc = poptGetNextOpt(optCon)) < -1) {
+	fprintf(stderr, "usleep: bad argument %s: %s\n", 
+		poptBadOption(optCon, POPT_BADOPTION_NOALIAS), 
+		poptStrerror(rc));
+	return 2;
+  }
+
+  if (showVersion) {
+      printf("usleep version 1.2\n	usleep --help for more info\n");
+      return 0;
+  }
+
+  if (showOot) {
+      printf("oot says hey!\n");
+      return 0;
+  }
+
+  countStr = poptGetArg(optCon);
+
+  if (countStr == NULL) count = 1;
+
+  else if (countStr && poptGetArg(optCon)) {
+      fprintf(stderr, "%s: exactly one argument (number of microseconds) "
+      		"must be used\n", argv[0]);
+      return 2;
+  }
+
+  else count = strtoul(countStr, NULL, 0); 
+
+  usleep(count);
+  return 0;
+} 
diff --git a/meta/recipes-core/initscripts/initscripts_1.0.bb b/meta/recipes-core/initscripts/initscripts_1.0.bb
index 7273a82..456aed4 100644
--- a/meta/recipes-core/initscripts/initscripts_1.0.bb
+++ b/meta/recipes-core/initscripts/initscripts_1.0.bb
@@ -5,7 +5,7 @@ LICENSE = "GPLv2"
 LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
 PR = "r155"
 
-INHIBIT_DEFAULT_DEPS = "1"
+S = "${WORKDIR}"
 
 SRC_URI = "file://functions \
            file://halt \
@@ -33,6 +33,8 @@ SRC_URI = "file://functions \
            file://GPLv2.patch \
            file://dmesg.sh \
            file://logrotate-dmesg.conf \
+           file://usleep.c \
+           file://usleep.1 \
 "
 
 SRC_URI_append_arm = " file://alignment.sh"
@@ -42,6 +44,7 @@ KERNEL_VERSION = ""
 inherit update-alternatives
 DEPENDS_append = " update-rc.d-native"
 DEPENDS_append = " ${@bb.utils.contains('DISTRO_FEATURES','systemd','systemd-systemctl-native','',d)}"
+DEPENDS_append = " popt"
 
 PACKAGES =+ "${PN}-functions"
 RDEPENDS_${PN} = "${PN}-functions"
@@ -58,6 +61,10 @@ do_configure() {
 	sed -i -e "s:SED_HALTARGS:${HALTARGS}:g" ${WORKDIR}/reboot
 }
 
+do_compile() {
+	${CC} ${CFLAGS} ${LDFLAGS} usleep.c -o usleep -lpopt
+}
+
 do_install () {
 #
 # Create directories and install device independent scripts
@@ -75,6 +82,8 @@ do_install () {
 	install -d ${D}${sysconfdir}/default/volatiles
 	# Holds state information pertaining to urandom
 	install -d ${D}/var/lib/urandom
+	install -d ${D}${base_bindir}
+	install -d ${D}${mandir}/man1
 
 	install -m 0644    ${WORKDIR}/functions		${D}${sysconfdir}/init.d
 	install -m 0755    ${WORKDIR}/bootmisc.sh	${D}${sysconfdir}/init.d
@@ -98,6 +107,8 @@ do_install () {
 	install -m 0644    ${WORKDIR}/volatiles		${D}${sysconfdir}/default/volatiles/00_core
 	install -m 0755    ${WORKDIR}/dmesg.sh		${D}${sysconfdir}/init.d
 	install -m 0644    ${WORKDIR}/logrotate-dmesg.conf ${D}${sysconfdir}/
+	install -m 0755    ${WORKDIR}/usleep            ${D}${base_bindir}
+	install -m 0644    ${WORKDIR}/usleep.1          ${D}${mandir}/man1
 
 	if [ "${TARGET_ARCH}" = "arm" ]; then
 		install -m 0755 ${WORKDIR}/alignment.sh	${D}${sysconfdir}/init.d
-- 
1.8.4.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] initscripts: add usleep support from RHEL
  2014-07-02  7:33 [PATCH] initscripts: add usleep support from RHEL Ming Liu
@ 2014-07-02 17:37 ` Christopher Larson
  2014-07-02 19:08   ` Burton, Ross
  2014-07-02 19:39   ` Saul Wold
  0 siblings, 2 replies; 7+ messages in thread
From: Christopher Larson @ 2014-07-02 17:37 UTC (permalink / raw)
  To: Ming Liu; +Cc: Patches and discussions about the oe-core layer

[-- Attachment #1: Type: text/plain, Size: 442 bytes --]

On Wed, Jul 2, 2014 at 12:33 AM, Ming Liu <ming.liu@windriver.com> wrote:

> Add usleep in to support sleeping some number of microseconds.
>
> Signed-off-by: Ming Liu <ming.liu@windriver.com>
>

Maybe it's just me, but initscripts seems like a horrible place to put this.
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics

[-- Attachment #2: Type: text/html, Size: 897 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] initscripts: add usleep support from RHEL
  2014-07-02 17:37 ` Christopher Larson
@ 2014-07-02 19:08   ` Burton, Ross
  2014-07-02 19:39   ` Saul Wold
  1 sibling, 0 replies; 7+ messages in thread
From: Burton, Ross @ 2014-07-02 19:08 UTC (permalink / raw)
  To: Christopher Larson; +Cc: Patches and discussions about the oe-core layer

On 2 July 2014 18:37, Christopher Larson <clarson@kergoth.com> wrote:
>> Add usleep in to support sleeping some number of microseconds.
>>
>> Signed-off-by: Ming Liu <ming.liu@windriver.com>
>
>
> Maybe it's just me, but initscripts seems like a horrible place to put this.

Agreed.  Also is there a rationale for adding this?

Ross


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] initscripts: add usleep support from RHEL
  2014-07-02 17:37 ` Christopher Larson
  2014-07-02 19:08   ` Burton, Ross
@ 2014-07-02 19:39   ` Saul Wold
  2014-07-03  2:26     ` Ming Liu
  1 sibling, 1 reply; 7+ messages in thread
From: Saul Wold @ 2014-07-02 19:39 UTC (permalink / raw)
  To: Christopher Larson, Ming Liu
  Cc: Patches and discussions about the oe-core layer

On 07/02/2014 10:37 AM, Christopher Larson wrote:
> On Wed, Jul 2, 2014 at 12:33 AM, Ming Liu <ming.liu@windriver.com> wrote:
>
>> Add usleep in to support sleeping some number of microseconds.
>>
>> Signed-off-by: Ming Liu <ming.liu@windriver.com>
>>
>
> Maybe it's just me, but initscripts seems like a horrible place to put this.
>
>
>
It's not just you!  Not sure why it's being added here and I don't see 
any usage of it, so more information is required.

Sau!


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] initscripts: add usleep support from RHEL
  2014-07-02 19:39   ` Saul Wold
@ 2014-07-03  2:26     ` Ming Liu
  2014-07-03  3:45       ` Christopher Larson
  0 siblings, 1 reply; 7+ messages in thread
From: Ming Liu @ 2014-07-03  2:26 UTC (permalink / raw)
  To: Saul Wold
  Cc: Christopher Larson, Patches and discussions about the oe-core layer

On 07/03/2014 03:39 AM, Saul Wold wrote:
> On 07/02/2014 10:37 AM, Christopher Larson wrote:
>> On Wed, Jul 2, 2014 at 12:33 AM, Ming Liu <ming.liu@windriver.com> 
>> wrote:
>>
>>> Add usleep in to support sleeping some number of microseconds.
>>>
>>> Signed-off-by: Ming Liu <ming.liu@windriver.com>
>>>
>>
>> Maybe it's just me, but initscripts seems like a horrible place to 
>> put this.
>>
>>
>>
> It's not just you!  Not sure why it's being added here and I don't see 
> any usage of it, so more information is required.
Why I've sent this is because I noticed there was no usleep binary in 
any of the packages in oe repositories, and I assumed that the end user 
might like to use it in their rootfs, so I migrated it from initscripts 
package of RHEL. Anyway, if all you guys think it's not necessary and 
not appropriate, I will not insist it, we could just ignore my proposal. :)

the best,
thank you
>
> Sau!
>
>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] initscripts: add usleep support from RHEL
  2014-07-03  2:26     ` Ming Liu
@ 2014-07-03  3:45       ` Christopher Larson
  2014-07-04  2:30         ` Ming Liu
  0 siblings, 1 reply; 7+ messages in thread
From: Christopher Larson @ 2014-07-03  3:45 UTC (permalink / raw)
  To: Ming Liu; +Cc: Patches and discussions about the oe-core layer

[-- Attachment #1: Type: text/plain, Size: 1339 bytes --]

On Wed, Jul 2, 2014 at 7:26 PM, Ming Liu <ming.liu@windriver.com> wrote:

> On 07/03/2014 03:39 AM, Saul Wold wrote:
>
>> On 07/02/2014 10:37 AM, Christopher Larson wrote:
>>
>>> On Wed, Jul 2, 2014 at 12:33 AM, Ming Liu <ming.liu@windriver.com>
>>> wrote:
>>>
>>>  Add usleep in to support sleeping some number of microseconds.
>>>>
>>>> Signed-off-by: Ming Liu <ming.liu@windriver.com>
>>>>
>>>>
>>> Maybe it's just me, but initscripts seems like a horrible place to put
>>> this.
>>>
>>>
>>>
>>>  It's not just you!  Not sure why it's being added here and I don't see
>> any usage of it, so more information is required.
>>
> Why I've sent this is because I noticed there was no usleep binary in any
> of the packages in oe repositories, and I assumed that the end user might
> like to use it in their rootfs, so I migrated it from initscripts package
> of RHEL. Anyway, if all you guys think it's not necessary and not
> appropriate, I will not insist it, we could just ignore my proposal. :)


The tool itself sounds like it could be of use, but it should likely get
its own recipe in meta-oe until/if something in oe-core actually needs it.
-- 
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics

[-- Attachment #2: Type: text/html, Size: 2215 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] initscripts: add usleep support from RHEL
  2014-07-03  3:45       ` Christopher Larson
@ 2014-07-04  2:30         ` Ming Liu
  0 siblings, 0 replies; 7+ messages in thread
From: Ming Liu @ 2014-07-04  2:30 UTC (permalink / raw)
  To: Christopher Larson; +Cc: Patches and discussions about the oe-core layer

[-- Attachment #1: Type: text/plain, Size: 1728 bytes --]

On 07/03/2014 11:45 AM, Christopher Larson wrote:
>
> On Wed, Jul 2, 2014 at 7:26 PM, Ming Liu <ming.liu@windriver.com 
> <mailto:ming.liu@windriver.com>> wrote:
>
>     On 07/03/2014 03:39 AM, Saul Wold wrote:
>
>         On 07/02/2014 10:37 AM, Christopher Larson wrote:
>
>             On Wed, Jul 2, 2014 at 12:33 AM, Ming Liu
>             <ming.liu@windriver.com <mailto:ming.liu@windriver.com>>
>             wrote:
>
>                 Add usleep in to support sleeping some number of
>                 microseconds.
>
>                 Signed-off-by: Ming Liu <ming.liu@windriver.com
>                 <mailto:ming.liu@windriver.com>>
>
>
>             Maybe it's just me, but initscripts seems like a horrible
>             place to put this.
>
>
>
>         It's not just you!  Not sure why it's being added here and I
>         don't see any usage of it, so more information is required.
>
>     Why I've sent this is because I noticed there was no usleep binary
>     in any of the packages in oe repositories, and I assumed that the
>     end user might like to use it in their rootfs, so I migrated it
>     from initscripts package of RHEL. Anyway, if all you guys think
>     it's not necessary and not appropriate, I will not insist it, we
>     could just ignore my proposal. :)
>
>
> The tool itself sounds like it could be of use, but it should likely 
> get its own recipe in meta-oe until/if something in oe-core actually 
> needs it.
Got it, thanks! I will do that.

the best,
thank you
> -- 
> Christopher Larson
> clarson at kergoth dot com
> Founder - BitBake, OpenEmbedded, OpenZaurus
> Maintainer - Tslib
> Senior Software Engineer, Mentor Graphics


[-- Attachment #2: Type: text/html, Size: 3850 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-07-04  2:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-02  7:33 [PATCH] initscripts: add usleep support from RHEL Ming Liu
2014-07-02 17:37 ` Christopher Larson
2014-07-02 19:08   ` Burton, Ross
2014-07-02 19:39   ` Saul Wold
2014-07-03  2:26     ` Ming Liu
2014-07-03  3:45       ` Christopher Larson
2014-07-04  2:30         ` Ming Liu

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.