diff options
-rw-r--r-- | meta-oe/recipes-core/emlog/emlog.inc | 13 | ||||
-rw-r--r-- | meta-oe/recipes-core/emlog/emlog/Drop-use-of-error-h.patch | 113 | ||||
-rw-r--r-- | meta-oe/recipes-core/emlog/emlog/emlog.initd | 25 | ||||
-rw-r--r-- | meta-oe/recipes-core/emlog/emlog_git.bb | 22 | ||||
-rw-r--r-- | meta-oe/recipes-core/emlog/kernel-module-emlog_git.bb | 12 |
5 files changed, 185 insertions, 0 deletions
diff --git a/meta-oe/recipes-core/emlog/emlog.inc b/meta-oe/recipes-core/emlog/emlog.inc new file mode 100644 index 0000000000..9a0f9ba928 --- /dev/null +++ b/meta-oe/recipes-core/emlog/emlog.inc | |||
@@ -0,0 +1,13 @@ | |||
1 | DESCRIPTION = "emlog is a Linux kernel module that makes it easy to access the \ | ||
2 | most recent (and only the most recent) output from a process" | ||
3 | LICENSE = "GPLv2" | ||
4 | LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f" | ||
5 | |||
6 | SRC_URI = "git://github.com/nicupavel/emlog.git;protocol=http" | ||
7 | SRCREV = "aee53e8dee862f35291242ba41b0ca88010f6c71" | ||
8 | |||
9 | S = "${WORKDIR}/git" | ||
10 | |||
11 | EXTRA_OEMAKE += " \ | ||
12 | CFLAGS='${TARGET_CFLAGS}' \ | ||
13 | " | ||
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 0000000000..6bfc44cb85 --- /dev/null +++ b/meta-oe/recipes-core/emlog/emlog/Drop-use-of-error-h.patch | |||
@@ -0,0 +1,113 @@ | |||
1 | From 41de28a92297f4cb0c5a8d7356cde9190176947b Mon Sep 17 00:00:00 2001 | ||
2 | From: Fabio Berton <fabio.berton@ossystems.com.br> | ||
3 | Date: Thu, 14 Mar 2019 19:54:27 -0300 | ||
4 | Subject: [PATCH] Drop use of error.h | ||
5 | Organization: O.S. Systems Software LTDA. | ||
6 | |||
7 | The error.h does not work with musl and this project being embedded | ||
8 | friendly it makes sense to avoid glibc-specific code. | ||
9 | |||
10 | Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> | ||
11 | Signed-off-by: Fabio Berton <fabio.berton@ossystems.com.br> | ||
12 | --- | ||
13 | mkemlog.c | 29 ++++++++++++++--------------- | ||
14 | 1 file changed, 14 insertions(+), 15 deletions(-) | ||
15 | |||
16 | diff --git a/mkemlog.c b/mkemlog.c | ||
17 | index e3354ed..7bcdfce 100644 | ||
18 | --- a/mkemlog.c | ||
19 | +++ b/mkemlog.c | ||
20 | @@ -21,7 +21,6 @@ | ||
21 | #include <unistd.h> | ||
22 | #include <fcntl.h> | ||
23 | #include <stdlib.h> | ||
24 | -#include <error.h> | ||
25 | #include <errno.h> | ||
26 | |||
27 | #define EMLOG_DEVICE "/dev/emlog" | ||
28 | @@ -40,16 +39,16 @@ int main(int argc, char** argv) { | ||
29 | FILE *max_size_file = NULL; | ||
30 | uid_t uid = -1; | ||
31 | if (argc < 2 || argc > 5) { | ||
32 | - error(1 ,0, USAGE); | ||
33 | + fprintf(stderr, USAGE); | ||
34 | } | ||
35 | file = argv[1]; | ||
36 | |||
37 | max_size_file = fopen("/sys/module/emlog/parameters/emlog_max_size", "r"); | ||
38 | if (max_size_file == NULL) | ||
39 | - error(1, errno, "Emlog module not loaded\n"); | ||
40 | + fprintf(stderr, "Emlog module not loaded\n"); | ||
41 | rc = fscanf(max_size_file, "%d", &emlog_max_size); | ||
42 | if (rc != 1) | ||
43 | - error(1, errno, "Unable to get emlog max size\n"); | ||
44 | + fprintf(stderr, "Unable to get emlog max size\n"); | ||
45 | fclose(max_size_file); | ||
46 | max_size_file = NULL; | ||
47 | if (argc > 2 ) { | ||
48 | @@ -57,13 +56,13 @@ int main(int argc, char** argv) { | ||
49 | number = argv[2]; | ||
50 | size_of_buffer = strtol(number, &end_of_number, 10); | ||
51 | if (errno) { | ||
52 | - error(1, errno, "Invalid size provided\n" USAGE); | ||
53 | + fprintf(stderr, "Invalid size provided\n" USAGE); | ||
54 | } | ||
55 | if (end_of_number == number) { | ||
56 | - error(1, 0, "Invalid size provided\n" USAGE); | ||
57 | + fprintf(stderr, "Invalid size provided\n" USAGE); | ||
58 | } | ||
59 | if (size_of_buffer < 1 || size_of_buffer > emlog_max_size) { | ||
60 | - error(1, 0, "Invalid size provided must be a value between 1 and %d\n" USAGE, emlog_max_size); | ||
61 | + fprintf(stderr, "Invalid size provided must be a value between 1 and %d\n" USAGE, emlog_max_size); | ||
62 | } | ||
63 | } | ||
64 | if (argc > 3 ) { | ||
65 | @@ -71,10 +70,10 @@ int main(int argc, char** argv) { | ||
66 | number = argv[3]; | ||
67 | mode = strtol(number, &end_of_number, 8); | ||
68 | if (errno) { | ||
69 | - error(1, errno, "Invalid mode provided\n" USAGE); | ||
70 | + fprintf(stderr, "Invalid mode provided\n" USAGE); | ||
71 | } | ||
72 | if (end_of_number == number || S_IFMT & mode) { | ||
73 | - error(1, 0, "Invalid mode provided\n" USAGE); | ||
74 | + fprintf(stderr, "Invalid mode provided\n" USAGE); | ||
75 | } | ||
76 | } | ||
77 | if (argc > 4 ) { | ||
78 | @@ -82,27 +81,27 @@ int main(int argc, char** argv) { | ||
79 | number = argv[4]; | ||
80 | uid = strtol(number, &end_of_number, 10); | ||
81 | if (errno) { | ||
82 | - error(1, errno, "Invalid uid provided\n" USAGE); | ||
83 | + fprintf(stderr, "Invalid uid provided\n" USAGE); | ||
84 | } | ||
85 | if (end_of_number == number) { | ||
86 | - error(1, 0, "Invalid uid provided\n" USAGE); | ||
87 | + fprintf(stderr, "Invalid uid provided\n" USAGE); | ||
88 | } | ||
89 | } | ||
90 | rc = stat(EMLOG_DEVICE, &emlog_stat); | ||
91 | if (rc == -1) { | ||
92 | - error(1, errno, "stat: " EMLOG_DEVICE); | ||
93 | + fprintf(stderr, "stat: " EMLOG_DEVICE); | ||
94 | } | ||
95 | if (!S_ISCHR(emlog_stat.st_mode)) { | ||
96 | - error(1, 0, EMLOG_DEVICE " is not a valid emlog device\n"); | ||
97 | + fprintf(stderr, EMLOG_DEVICE " is not a valid emlog device\n"); | ||
98 | } | ||
99 | rc = mknod(file, mode | S_IFCHR, makedev(major(emlog_stat.st_rdev),size_of_buffer)); | ||
100 | if (rc == -1) { | ||
101 | - error(1, errno, "mknod: %s", file); | ||
102 | + fprintf(stderr, "mknod: %s", file); | ||
103 | } | ||
104 | if (uid != -1) { | ||
105 | rc = chown(file, uid, -1); | ||
106 | if (rc == -1) { | ||
107 | - error(1, errno, "chown: %s", file); | ||
108 | + fprintf(stderr, "chown: %s", file); | ||
109 | } | ||
110 | } | ||
111 | printf("Log device %s created with buffer size of %d KiB\n", file, size_of_buffer); | ||
112 | -- | ||
113 | 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 0000000000..361cf8029e --- /dev/null +++ b/meta-oe/recipes-core/emlog/emlog/emlog.initd | |||
@@ -0,0 +1,25 @@ | |||
1 | #!/bin/sh | ||
2 | PATH=/sbin:/usr/sbin:/bin:/usr/bin | ||
3 | |||
4 | [ -r /etc/default/emlog ] && . /etc/default/emlog | ||
5 | |||
6 | do_start() { | ||
7 | : | ||
8 | } | ||
9 | |||
10 | do_stop() { | ||
11 | nbcat /dev/emlog > /data/emlog | ||
12 | } | ||
13 | |||
14 | case "$1" in | ||
15 | start) | ||
16 | do_start || exit $? | ||
17 | ;; | ||
18 | stop) | ||
19 | do_stop || exit $? | ||
20 | ;; | ||
21 | *) | ||
22 | echo "Usage: $0 {stop}" >&2 | ||
23 | exit 3 | ||
24 | ;; | ||
25 | 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 0000000000..63d12477bf --- /dev/null +++ b/meta-oe/recipes-core/emlog/emlog_git.bb | |||
@@ -0,0 +1,22 @@ | |||
1 | require ${BPN}.inc | ||
2 | |||
3 | SRC_URI += "file://${BPN}.initd" | ||
4 | |||
5 | SRC_URI_append_libc-musl = " file://Drop-use-of-error-h.patch" | ||
6 | |||
7 | inherit update-rc.d | ||
8 | |||
9 | INITSCRIPT_NAME = "${BPN}" | ||
10 | |||
11 | do_compile() { | ||
12 | oe_runmake nbcat | ||
13 | oe_runmake mkemlog | ||
14 | } | ||
15 | |||
16 | do_install() { | ||
17 | install -Dm 0755 ${WORKDIR}/${BPN}.initd ${D}${sysconfdir}/init.d/${BPN} | ||
18 | install -Dm 0755 ${S}/nbcat ${D}${bindir}/nbcat | ||
19 | install -Dm 0755 ${S}/mkemlog ${D}${bindir}/mkemlog | ||
20 | } | ||
21 | |||
22 | 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 0000000000..51f7226ebd --- /dev/null +++ b/meta-oe/recipes-core/emlog/kernel-module-emlog_git.bb | |||
@@ -0,0 +1,12 @@ | |||
1 | require emlog.inc | ||
2 | |||
3 | inherit module | ||
4 | |||
5 | EXTRA_OEMAKE += " \ | ||
6 | KDIR=${STAGING_KERNEL_DIR} \ | ||
7 | KVER=${KERNEL_VERSION} \ | ||
8 | " | ||
9 | |||
10 | do_compile() { | ||
11 | oe_runmake modules | ||
12 | } | ||