[oe-commits] [meta-openembedded] 12/15: emlog: Add recipe

git at git.openembedded.org git at git.openembedded.org
Thu Nov 28 04:08:14 UTC 2019


This is an automated email from the git hooks/post-receive script.

khem pushed a commit to branch master-next
in repository meta-openembedded.

commit 027c7c1ebf6b1bdd40fe75b32ef67f730850b54f
Author: Fabio Berton <fabio.berton at ossystems.com.br>
AuthorDate: Wed Nov 27 10:03:05 2019 -0300

    emlog: Add recipe
    
    Signed-off-by: Fabio Berton <fabio.berton at ossystems.com.br>
    Signed-off-by: Khem Raj <raj.khem at gmail.com>
---
 meta-oe/recipes-core/emlog/emlog.inc               |  13 +++
 .../emlog/emlog/Drop-use-of-error-h.patch          | 113 +++++++++++++++++++++
 meta-oe/recipes-core/emlog/emlog/emlog.initd       |  25 +++++
 meta-oe/recipes-core/emlog/emlog_git.bb            |  22 ++++
 .../recipes-core/emlog/kernel-module-emlog_git.bb  |  12 +++
 5 files changed, 185 insertions(+)

diff --git a/meta-oe/recipes-core/emlog/emlog.inc b/meta-oe/recipes-core/emlog/emlog.inc
new file mode 100644
index 0000000..9a0f9ba
--- /dev/null
+++ b/meta-oe/recipes-core/emlog/emlog.inc
@@ -0,0 +1,13 @@
+DESCRIPTION = "emlog is a Linux kernel module that makes it easy to access the \
+most recent (and only the most recent) output from a process"
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f"
+
+SRC_URI = "git://github.com/nicupavel/emlog.git;protocol=http"
+SRCREV = "aee53e8dee862f35291242ba41b0ca88010f6c71"
+
+S = "${WORKDIR}/git"
+
+EXTRA_OEMAKE += " \
+    CFLAGS='${TARGET_CFLAGS}' \
+"
diff --git a/meta-oe/recipes-core/emlog/emlog/Drop-use-of-error-h.patch b/meta-oe/recipes-core/emlog/emlog/Drop-use-of-error-h.patch
new file mode 100644
index 0000000..6bfc44c
--- /dev/null
+++ b/meta-oe/recipes-core/emlog/emlog/Drop-use-of-error-h.patch
@@ -0,0 +1,113 @@
+From 41de28a92297f4cb0c5a8d7356cde9190176947b Mon Sep 17 00:00:00 2001
+From: Fabio Berton <fabio.berton at ossystems.com.br>
+Date: Thu, 14 Mar 2019 19:54:27 -0300
+Subject: [PATCH] Drop use of error.h
+Organization: O.S. Systems Software LTDA.
+
+The error.h does not work with musl and this project being embedded
+friendly it makes sense to avoid glibc-specific code.
+
+Signed-off-by: Otavio Salvador <otavio at ossystems.com.br>
+Signed-off-by: Fabio Berton <fabio.berton at ossystems.com.br>
+---
+ mkemlog.c | 29 ++++++++++++++---------------
+ 1 file changed, 14 insertions(+), 15 deletions(-)
+
+diff --git a/mkemlog.c b/mkemlog.c
+index e3354ed..7bcdfce 100644
+--- a/mkemlog.c
++++ b/mkemlog.c
+@@ -21,7 +21,6 @@
+ #include <unistd.h>
+ #include <fcntl.h>
+ #include <stdlib.h>
+-#include <error.h>
+ #include <errno.h>
+
+ #define EMLOG_DEVICE "/dev/emlog"
+@@ -40,16 +39,16 @@ int main(int argc, char** argv) {
+     FILE *max_size_file = NULL;
+     uid_t uid = -1;
+     if (argc < 2 || argc > 5) {
+-        error(1 ,0, USAGE);
++        fprintf(stderr, USAGE);
+     }
+     file = argv[1];
+
+     max_size_file = fopen("/sys/module/emlog/parameters/emlog_max_size", "r");
+     if (max_size_file == NULL)
+-        error(1, errno, "Emlog module not loaded\n");
++        fprintf(stderr, "Emlog module not loaded\n");
+     rc = fscanf(max_size_file, "%d", &emlog_max_size);
+     if (rc != 1)
+-        error(1, errno, "Unable to get emlog max size\n");
++        fprintf(stderr, "Unable to get emlog max size\n");
+     fclose(max_size_file);
+     max_size_file = NULL;
+     if (argc > 2 ) {
+@@ -57,13 +56,13 @@ int main(int argc, char** argv) {
+         number = argv[2];
+         size_of_buffer = strtol(number, &end_of_number, 10);
+         if (errno) {
+-            error(1, errno, "Invalid size provided\n" USAGE);
++            fprintf(stderr, "Invalid size provided\n" USAGE);
+         }
+         if (end_of_number == number) {
+-            error(1, 0, "Invalid size provided\n" USAGE);
++            fprintf(stderr, "Invalid size provided\n" USAGE);
+         }
+         if (size_of_buffer < 1 || size_of_buffer > emlog_max_size) {
+-            error(1, 0, "Invalid size provided must be a value between 1 and %d\n" USAGE, emlog_max_size);
++            fprintf(stderr, "Invalid size provided must be a value between 1 and %d\n" USAGE, emlog_max_size);
+         }
+     }
+     if (argc > 3 ) {
+@@ -71,10 +70,10 @@ int main(int argc, char** argv) {
+         number = argv[3];
+         mode = strtol(number, &end_of_number, 8);
+         if (errno) {
+-            error(1, errno, "Invalid mode provided\n" USAGE);
++            fprintf(stderr, "Invalid mode provided\n" USAGE);
+         }
+         if (end_of_number == number || S_IFMT & mode) {
+-            error(1, 0, "Invalid mode provided\n" USAGE);
++            fprintf(stderr, "Invalid mode provided\n" USAGE);
+         }
+     }
+     if (argc > 4 ) {
+@@ -82,27 +81,27 @@ int main(int argc, char** argv) {
+         number = argv[4];
+         uid = strtol(number, &end_of_number, 10);
+         if (errno) {
+-            error(1, errno, "Invalid uid provided\n" USAGE);
++            fprintf(stderr, "Invalid uid provided\n" USAGE);
+         }
+         if (end_of_number == number) {
+-            error(1, 0, "Invalid uid provided\n" USAGE);
++            fprintf(stderr, "Invalid uid provided\n" USAGE);
+         }
+     }
+     rc = stat(EMLOG_DEVICE, &emlog_stat);
+     if (rc == -1) {
+-        error(1, errno, "stat: " EMLOG_DEVICE);
++        fprintf(stderr, "stat: " EMLOG_DEVICE);
+     }
+     if (!S_ISCHR(emlog_stat.st_mode)) {
+-        error(1, 0, EMLOG_DEVICE " is not a valid emlog device\n");
++        fprintf(stderr, EMLOG_DEVICE " is not a valid emlog device\n");
+     }
+     rc = mknod(file, mode | S_IFCHR, makedev(major(emlog_stat.st_rdev),size_of_buffer));
+     if (rc == -1) {
+-        error(1, errno, "mknod: %s", file);
++        fprintf(stderr, "mknod: %s", file);
+     }
+     if (uid != -1) {
+         rc = chown(file, uid, -1);
+         if (rc == -1) {
+-            error(1, errno, "chown: %s", file);
++            fprintf(stderr, "chown: %s", file);
+         }
+     }
+     printf("Log device %s created with buffer size of %d KiB\n", file, size_of_buffer);
+--
+2.20.1
diff --git a/meta-oe/recipes-core/emlog/emlog/emlog.initd b/meta-oe/recipes-core/emlog/emlog/emlog.initd
new file mode 100644
index 0000000..361cf80
--- /dev/null
+++ b/meta-oe/recipes-core/emlog/emlog/emlog.initd
@@ -0,0 +1,25 @@
+#!/bin/sh
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+
+[ -r /etc/default/emlog ] && . /etc/default/emlog
+
+do_start() {
+    :
+}
+
+do_stop() {
+    nbcat /dev/emlog > /data/emlog
+}
+
+case "$1" in
+    start)
+	    do_start || exit $?
+	    ;;
+    stop)
+	    do_stop || exit $?
+	    ;;
+    *)
+	    echo "Usage: $0 {stop}" >&2
+	    exit 3
+	    ;;
+esac
diff --git a/meta-oe/recipes-core/emlog/emlog_git.bb b/meta-oe/recipes-core/emlog/emlog_git.bb
new file mode 100644
index 0000000..63d1247
--- /dev/null
+++ b/meta-oe/recipes-core/emlog/emlog_git.bb
@@ -0,0 +1,22 @@
+require ${BPN}.inc
+
+SRC_URI += "file://${BPN}.initd"
+
+SRC_URI_append_libc-musl = " file://Drop-use-of-error-h.patch"
+
+inherit update-rc.d
+
+INITSCRIPT_NAME = "${BPN}"
+
+do_compile() {
+    oe_runmake nbcat
+    oe_runmake mkemlog
+}
+
+do_install() {
+   install -Dm 0755 ${WORKDIR}/${BPN}.initd ${D}${sysconfdir}/init.d/${BPN}
+   install -Dm 0755 ${S}/nbcat ${D}${bindir}/nbcat
+   install -Dm 0755 ${S}/mkemlog ${D}${bindir}/mkemlog
+}
+
+RDEPENDS_${PN} += "kernel-module-emlog"
diff --git a/meta-oe/recipes-core/emlog/kernel-module-emlog_git.bb b/meta-oe/recipes-core/emlog/kernel-module-emlog_git.bb
new file mode 100644
index 0000000..51f7226
--- /dev/null
+++ b/meta-oe/recipes-core/emlog/kernel-module-emlog_git.bb
@@ -0,0 +1,12 @@
+require emlog.inc
+
+inherit module
+
+EXTRA_OEMAKE += " \
+    KDIR=${STAGING_KERNEL_DIR} \
+    KVER=${KERNEL_VERSION} \
+"
+
+do_compile() {
+    oe_runmake modules
+}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list