aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/rpm/rpm/0001-rpm-Fix-build-on-musl.patch
blob: 763dc576526b7a2557d2e4b43e1667348417e465 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
From 0af17c2ae86c1e8e42b96f6dface08f535bb55ad Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sun, 14 Feb 2016 08:33:24 +0000
Subject: [PATCH] rpm: Fix build on musl

Provide alternatives to assumptions about glibc
on linux

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Upstream-Status: Pending

 rpmio/fts.c       |  4 ++++
 rpmqv.c           |  6 +++++-
 system.h          |  2 +-
 tools/debugedit.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 tools/rpmfind.c   |  6 +++---
 5 files changed, 60 insertions(+), 5 deletions(-)

diff --git a/rpmio/fts.c b/rpmio/fts.c
index 2d7594c..b7aa9b8 100644
--- a/rpmio/fts.c
+++ b/rpmio/fts.c
@@ -124,6 +124,10 @@ static char sccsid[] = "@(#)fts.c	8.6 (Berkeley) 8/14/94";
 #   define __fxstat64(_stat_ver, _fd, _sbp)    fstat((_fd), (_sbp))
 #endif
 
+#ifndef _STAT_VER
+#   define _STAT_VER      0
+#endif
+
 #if !defined(_D_EXACT_NAMLEN)
 #   define _D_EXACT_NAMLEN(d) (strlen((d)->d_name))
 #endif
diff --git a/rpmqv.c b/rpmqv.c
index 14c73e2..b2d3e24 100644
--- a/rpmqv.c
+++ b/rpmqv.c
@@ -523,7 +523,11 @@ int main(int argc, const char ** argv)
     (void) initproctitle(argc, (char **)argv, environ);
 #endif
 #endif  
-
+    /* XXX glibc churn sanity */
+    if (__progname == NULL) {
+        if ((__progname = strrchr(argv[0], '/')) != NULL) __progname++;
+        else __progname = argv[0];
+    }
     /* Set the major mode based on argv[0] */
     /*@-nullpass@*/
 #ifdef	IAM_RPMBT
diff --git a/system.h b/system.h
index 72851c0..05f7553 100644
--- a/system.h
+++ b/system.h
@@ -791,5 +791,5 @@ static inline const char *rcsid(const char *p) { \
  * Permit ar(1) payloads. Disabled while rpmio/iosm.c is under development.
  */
 #undef	SUPPORT_AR_PAYLOADS
-
 #endif	/* H_SYSTEM */
+const char *program_name;
diff --git a/tools/debugedit.c b/tools/debugedit.c
index 29e8ee9..b2a8918 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -23,7 +23,12 @@
 #include <byteswap.h>
 #include <endian.h>
 #include <errno.h>
+#ifdef __GLIBC__
 #include <error.h>
+#else
+#include <stdarg.h>
+void error(int, int, const char *, ...);
+#endif
 #include <limits.h>
 #include <string.h>
 #include <stdlib.h>
@@ -1531,6 +1536,48 @@ handle_build_id (DSO *dso, Elf_Data *build_id,
     puts (hex);
   }
 }
+#ifndef __GLIBC__
+extern char *__progname;
+
+void (*error_print_progname)(void) = 0;
+unsigned int error_message_count = 0;
+int error_one_per_line = 0;
+
+static void eprint(int status, int e, const char *file, unsigned int line, const char *fmt, va_list ap)
+{
+       if (file && error_one_per_line) {
+               static const char *oldfile;
+               static unsigned int oldline;
+               if (line == oldline && strcmp(file, oldfile) == 0)
+                       return;
+               oldfile = file;
+               oldline = line;
+       }
+       if (error_print_progname)
+               error_print_progname();
+       else
+               fprintf(stderr, "%s: ", __progname);
+       if (file)
+               fprintf(stderr, "%s:%u: ", file, line);
+       vfprintf(stderr, fmt, ap);
+      if (e)
+               fprintf(stderr, ": %s", strerror(e));
+       putc('\n', stderr);
+       fflush(stderr);
+       error_message_count++;
+       if (status)
+               exit(status);
+}
+
+void error(int status, int e, const char *fmt, ...)
+{
+       va_list ap;
+       va_start(ap,fmt);
+       eprint(status, e, 0, 0, fmt, ap);
+       va_end(ap);
+}
+
+#endif
 
 /* It avoided the segment fault while file's bss offset have a large number.
    See https://bugzilla.redhat.com/show_bug.cgi?id=1019707
diff --git a/tools/rpmfind.c b/tools/rpmfind.c
index 816aeef..327fab0 100644
--- a/tools/rpmfind.c
+++ b/tools/rpmfind.c
@@ -1174,7 +1174,7 @@ find_parsenum(PLAN *plan, const char *option, char *vp, char *endch)
      * and endchar points to the beginning of the string we know we have
      * a syntax error.
      */
-#if defined(__sun)
+#if defined(__sun) || !defined(__GLIBC_)
     value = strtoll(str, &endchar, 10);
 #else
     value = strtoq(str, &endchar, 10);
@@ -1214,7 +1214,7 @@ find_parsetime(PLAN *plan, const char *option, char *vp)
 	break;
     }
 
-#if defined(__sun)
+#if defined(__sun) || !defined(__GLIBC_)
     value = strtoll(str, &unit, 10);
 #else
     value = strtoq(str, &unit, 10);
@@ -1252,7 +1252,7 @@ find_parsetime(PLAN *plan, const char *option, char *vp)
 	str = unit + 1;
 	if (*str == '\0')	/* EOS */
 	    break;
-#if defined(__sun)
+#if defined(__sun) || !defined(__GLIBC_)
 	value = strtoll(str, &unit, 10);
 #else
 	value = strtoq(str, &unit, 10);
-- 
2.7.1