diff options
Diffstat (limited to 'meta/recipes-devtools/rpm/files/0001-tools-Add-error.h-for-non-glibc-case.patch')
-rw-r--r-- | meta/recipes-devtools/rpm/files/0001-tools-Add-error.h-for-non-glibc-case.patch | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/meta/recipes-devtools/rpm/files/0001-tools-Add-error.h-for-non-glibc-case.patch b/meta/recipes-devtools/rpm/files/0001-tools-Add-error.h-for-non-glibc-case.patch new file mode 100644 index 0000000000..e78514b814 --- /dev/null +++ b/meta/recipes-devtools/rpm/files/0001-tools-Add-error.h-for-non-glibc-case.patch | |||
@@ -0,0 +1,118 @@ | |||
1 | From b3952bd5e28f2a4d86c7377de239db8fa7237e14 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sat, 31 Oct 2020 22:14:05 -0700 | ||
4 | Subject: [PATCH] tools: Add error.h for non-glibc case | ||
5 | |||
6 | error is glibc specific API, so this patch will mostly not accepted | ||
7 | upstream given that elfutils has been closely tied to glibc | ||
8 | |||
9 | Upstream-Status: Inappropriate [workaround for musl] | ||
10 | |||
11 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
12 | --- | ||
13 | tools/debugedit.c | 6 +++++- | ||
14 | tools/elfdeps.c | 6 +++++- | ||
15 | tools/error.h | 27 +++++++++++++++++++++++++++ | ||
16 | tools/sepdebugcrcfix.c | 6 +++++- | ||
17 | 4 files changed, 42 insertions(+), 3 deletions(-) | ||
18 | create mode 100644 tools/error.h | ||
19 | |||
20 | diff --git a/tools/debugedit.c b/tools/debugedit.c | ||
21 | index 9f8dcd0fb..852f46073 100644 | ||
22 | --- a/tools/debugedit.c | ||
23 | +++ b/tools/debugedit.c | ||
24 | @@ -26,7 +26,6 @@ | ||
25 | #include <byteswap.h> | ||
26 | #include <endian.h> | ||
27 | #include <errno.h> | ||
28 | -#include <error.h> | ||
29 | #include <limits.h> | ||
30 | #include <string.h> | ||
31 | #include <stdlib.h> | ||
32 | @@ -40,6 +39,11 @@ | ||
33 | |||
34 | #include <gelf.h> | ||
35 | #include <dwarf.h> | ||
36 | +#ifdef __GLIBC__ | ||
37 | +#include <error.h> | ||
38 | +#else | ||
39 | +#include "error.h" | ||
40 | +#endif | ||
41 | |||
42 | |||
43 | /* Unfortunately strtab manipulation functions were only officially added | ||
44 | diff --git a/tools/elfdeps.c b/tools/elfdeps.c | ||
45 | index 6d9094874..f69e60997 100644 | ||
46 | --- a/tools/elfdeps.c | ||
47 | +++ b/tools/elfdeps.c | ||
48 | @@ -5,10 +5,14 @@ | ||
49 | #include <unistd.h> | ||
50 | #include <stdlib.h> | ||
51 | #include <fcntl.h> | ||
52 | -#include <error.h> | ||
53 | #include <errno.h> | ||
54 | #include <popt.h> | ||
55 | #include <gelf.h> | ||
56 | +#ifdef __GLIBC__ | ||
57 | +#include <error.h> | ||
58 | +#else | ||
59 | +#include "error.h" | ||
60 | +#endif | ||
61 | |||
62 | #include <rpm/rpmstring.h> | ||
63 | #include <rpm/argv.h> | ||
64 | diff --git a/tools/error.h b/tools/error.h | ||
65 | new file mode 100644 | ||
66 | index 000000000..ef06827a0 | ||
67 | --- /dev/null | ||
68 | +++ b/tools/error.h | ||
69 | @@ -0,0 +1,27 @@ | ||
70 | +#ifndef _ERROR_H_ | ||
71 | +#define _ERROR_H_ | ||
72 | + | ||
73 | +#include <stdarg.h> | ||
74 | +#include <stdio.h> | ||
75 | +#include <stdlib.h> | ||
76 | +#include <string.h> | ||
77 | +#include <errno.h> | ||
78 | + | ||
79 | +static unsigned int error_message_count = 0; | ||
80 | + | ||
81 | +static inline void error(int status, int errnum, const char* format, ...) | ||
82 | +{ | ||
83 | + va_list ap; | ||
84 | + fprintf(stderr, "%s: ", program_invocation_name); | ||
85 | + va_start(ap, format); | ||
86 | + vfprintf(stderr, format, ap); | ||
87 | + va_end(ap); | ||
88 | + if (errnum) | ||
89 | + fprintf(stderr, ": %s", strerror(errnum)); | ||
90 | + fprintf(stderr, "\n"); | ||
91 | + error_message_count++; | ||
92 | + if (status) | ||
93 | + exit(status); | ||
94 | +} | ||
95 | + | ||
96 | +#endif /* _ERROR_H_ */ | ||
97 | diff --git a/tools/sepdebugcrcfix.c b/tools/sepdebugcrcfix.c | ||
98 | index fba460014..2be9c1fd8 100644 | ||
99 | --- a/tools/sepdebugcrcfix.c | ||
100 | +++ b/tools/sepdebugcrcfix.c | ||
101 | @@ -29,9 +29,13 @@ | ||
102 | #include <endian.h> | ||
103 | #include <stdio.h> | ||
104 | #include <stdlib.h> | ||
105 | -#include <error.h> | ||
106 | #include <libelf.h> | ||
107 | #include <gelf.h> | ||
108 | +#ifdef __GLIBC__ | ||
109 | +#include <error.h> | ||
110 | +#else | ||
111 | +#include "error.h" | ||
112 | +#endif | ||
113 | |||
114 | #ifndef _ | ||
115 | #define _(x) x | ||
116 | -- | ||
117 | 2.29.2 | ||
118 | |||