aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/rpm/rpm/0001-rpm-Fix-build-on-musl.patch
blob: 70dd4ff532cb0d75d904b56105c6c1cdb4994d91 (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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
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>

Updated to 5.4.16 (CVS)

The patch will likely need additional rework before it can be accepted upsteam
due to the way MUSL changes are patched in.

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>

---
Upstream-Status: Pending

 lib/poptALL.c          |    2 ++
 rpmio/fts.c            |    4 ++++
 rpmio/poptIO.c         |    2 ++
 rpmqv.c                |    2 ++
 system.h               |   13 ++++++-------
 tools/debugedit.c      |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 tools/rpm2cpio.c       |    2 ++
 tools/rpmcache.c       |    2 ++
 tools/rpmcmp.c         |    2 ++
 tools/rpmdeps-oecore.c |    2 ++
 tools/rpmdeps.c        |    2 ++
 tools/rpmdigest.c      |    2 ++
 tools/rpmfind.c        |    6 +++---
 13 files changed, 78 insertions(+), 10 deletions(-)

Index: rpm-5.4.15/rpmio/fts.c
===================================================================
--- rpm-5.4.15.orig/rpmio/fts.c
+++ rpm-5.4.15/rpmio/fts.c
@@ -124,6 +124,10 @@ static char sccsid[] = "@(#)fts.c	8.6 (B
 #   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
Index: rpm-5.4.15/tools/debugedit.c
===================================================================
--- rpm-5.4.15.orig/tools/debugedit.c
+++ rpm-5.4.15/tools/debugedit.c
@@ -22,7 +22,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>
@@ -1535,6 +1540,48 @@ handle_build_id (DSO *dso, Elf_Data *bui
     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
Index: rpm-5.4.15/tools/rpmfind.c
===================================================================
--- rpm-5.4.15.orig/tools/rpmfind.c
+++ rpm-5.4.15/tools/rpmfind.c
@@ -1175,7 +1175,7 @@ find_parsenum(PLAN *plan, const char *op
      * 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);
@@ -1215,7 +1215,7 @@ find_parsetime(PLAN *plan, const char *o
 	break;
     }
 
-#if defined(__sun)
+#if defined(__sun) || !defined(__GLIBC_)
     value = strtoll(str, &unit, 10);
 #else
     value = strtoq(str, &unit, 10);
@@ -1253,7 +1253,7 @@ find_parsetime(PLAN *plan, const char *o
 	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);
Index: rpm-5.4.15/system.h
===================================================================
--- rpm-5.4.15.orig/system.h
+++ rpm-5.4.15/system.h
@@ -372,16 +372,15 @@ extern int _tolower(int) __THROW	/*@*/;
 #define	__progname	__assert_program_name
 #endif
 #define	setprogname(pn)
+/*@unchecked@*/
+extern const char *__progname;
 #else
-#define	__progname	program_name
-#define	setprogname(pn)	\
-  { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \
-    else __progname = pn;		\
-  }
-#endif
+#define	setprogname(pn)
+#define	progname	__progname
 
 /*@unchecked@*/
-extern const char *__progname;
+extern char *__progname;
+#endif
 
 /* -- Retrofit missing prototypes (if needed). */
 #ifdef __cplusplus
Index: rpm-5.4.15/rpmio/poptIO.c
===================================================================
--- rpm-5.4.15.orig/rpmio/poptIO.c
+++ rpm-5.4.15/rpmio/poptIO.c
@@ -65,7 +65,9 @@ extern int _rpmsvn_debug;
 GENfree(rpmioP)
 #endif	/* __cplusplus */
 
+#ifdef __GLIBC__
 const char *__progname;
+#endif
 
 #if !defined(POPT_ARGFLAG_TOGGLE)	/* XXX compat with popt < 1.15 */
 #define	POPT_ARGFLAG_TOGGLE	0
Index: rpm-5.4.15/lib/poptALL.c
===================================================================
--- rpm-5.4.15.orig/lib/poptALL.c
+++ rpm-5.4.15/lib/poptALL.c
@@ -4,7 +4,9 @@
  */
 
 #include "system.h"
+#ifdef __GLIBC__
 extern const char *__progname;
+#endif
 
 #if defined(RPM_VENDOR_WINDRIVER)
 const char *__usrlibrpm = USRLIBRPM;
Index: rpm-5.4.15/tools/rpm2cpio.c
===================================================================
--- rpm-5.4.15.orig/tools/rpm2cpio.c
+++ rpm-5.4.15/tools/rpm2cpio.c
@@ -1,7 +1,9 @@
 /* rpmarchive: spit out the main archive portion of a package */
 
 #include "system.h"
+#ifdef __GLIBC__
 const char *__progname;
+#endif
 
 #include <rpmio.h>
 #include <rpmiotypes.h>	/* XXX fnpyKey */
Index: rpm-5.4.15/tools/rpmcache.c
===================================================================
--- rpm-5.4.15.orig/tools/rpmcache.c
+++ rpm-5.4.15/tools/rpmcache.c
@@ -3,7 +3,9 @@
  */
 
 #include "system.h"
+#ifdef __GLIBC__
 const char *__progname;
+#endif
 
 #include <fnmatch.h>
 #include <fts.h>
Index: rpm-5.4.15/tools/rpmdeps-oecore.c
===================================================================
--- rpm-5.4.15.orig/tools/rpmdeps-oecore.c
+++ rpm-5.4.15/tools/rpmdeps-oecore.c
@@ -1,5 +1,7 @@
 #include "system.h"
+#ifdef __GLIBC__
 const char *__progname;
+#endif
 
 #include <rpmio.h>
 #include <rpmiotypes.h>
Index: rpm-5.4.15/tools/rpmdeps.c
===================================================================
--- rpm-5.4.15.orig/tools/rpmdeps.c
+++ rpm-5.4.15/tools/rpmdeps.c
@@ -1,5 +1,7 @@
 #include "system.h"
+#ifdef __GLIBC__
 const char *__progname;
+#endif
 
 #include <rpmio.h>
 #include <rpmiotypes.h>
Index: rpm-5.4.15/tools/rpmdigest.c
===================================================================
--- rpm-5.4.15.orig/tools/rpmdigest.c
+++ rpm-5.4.15/tools/rpmdigest.c
@@ -1,6 +1,8 @@
 #include "system.h"
+#ifdef __GLIBC__
 /*@unchecked@*/
 extern const char * __progname;
+#endif
 
 #define	_RPMIOB_INTERNAL
 #include <rpmiotypes.h>
Index: rpm-5.4.15/tools/rpmcmp.c
===================================================================
--- rpm-5.4.15.orig/tools/rpmcmp.c
+++ rpm-5.4.15/tools/rpmcmp.c
@@ -13,8 +13,10 @@
 
 #include "debug.h"
 
+#ifdef __GLIBC__
 const char *__progname;
 #define	progname	__progname
+#endif
 
 static int pointRpmEVR(ARGV_t av)
 {
Index: rpm-5.4.15/rpmqv.c
===================================================================
--- rpm-5.4.15.orig/rpmqv.c
+++ rpm-5.4.15/rpmqv.c
@@ -1,5 +1,7 @@
 #include "system.h"
+#ifdef __GLIBC__
 extern const char *__progname;
+#endif
 
 /* Copyright (C) 1998-2002 - Red Hat, Inc. */