Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1 | From 0af17c2ae86c1e8e42b96f6dface08f535bb55ad Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Sun, 14 Feb 2016 08:33:24 +0000 |
| 4 | Subject: [PATCH] rpm: Fix build on musl |
| 5 | |
| 6 | Provide alternatives to assumptions about glibc |
| 7 | on linux |
| 8 | |
| 9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 10 | |
| 11 | Updated to 5.4.16 (CVS) |
| 12 | |
| 13 | The patch will likely need additional rework before it can be accepted upsteam |
| 14 | due to the way MUSL changes are patched in. |
| 15 | |
| 16 | Signed-off-by: Mark Hatle <mark.hatle@windriver.com> |
| 17 | |
| 18 | --- |
| 19 | Upstream-Status: Pending |
| 20 | |
| 21 | lib/poptALL.c | 2 ++ |
| 22 | rpmio/fts.c | 4 ++++ |
| 23 | rpmio/poptIO.c | 2 ++ |
| 24 | rpmqv.c | 2 ++ |
| 25 | system.h | 13 ++++++------- |
| 26 | tools/debugedit.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ |
| 27 | tools/rpm2cpio.c | 2 ++ |
| 28 | tools/rpmcache.c | 2 ++ |
| 29 | tools/rpmcmp.c | 2 ++ |
| 30 | tools/rpmdeps-oecore.c | 2 ++ |
| 31 | tools/rpmdeps.c | 2 ++ |
| 32 | tools/rpmdigest.c | 2 ++ |
| 33 | tools/rpmfind.c | 6 +++--- |
| 34 | 13 files changed, 78 insertions(+), 10 deletions(-) |
| 35 | |
| 36 | Index: rpm-5.4.15/rpmio/fts.c |
| 37 | =================================================================== |
| 38 | --- rpm-5.4.15.orig/rpmio/fts.c |
| 39 | +++ rpm-5.4.15/rpmio/fts.c |
| 40 | @@ -124,6 +124,10 @@ static char sccsid[] = "@(#)fts.c 8.6 (B |
| 41 | # define __fxstat64(_stat_ver, _fd, _sbp) fstat((_fd), (_sbp)) |
| 42 | #endif |
| 43 | |
| 44 | +#ifndef _STAT_VER |
| 45 | +# define _STAT_VER 0 |
| 46 | +#endif |
| 47 | + |
| 48 | #if !defined(_D_EXACT_NAMLEN) |
| 49 | # define _D_EXACT_NAMLEN(d) (strlen((d)->d_name)) |
| 50 | #endif |
| 51 | Index: rpm-5.4.15/tools/debugedit.c |
| 52 | =================================================================== |
| 53 | --- rpm-5.4.15.orig/tools/debugedit.c |
| 54 | +++ rpm-5.4.15/tools/debugedit.c |
| 55 | @@ -22,7 +22,12 @@ |
| 56 | #include <byteswap.h> |
| 57 | #include <endian.h> |
| 58 | #include <errno.h> |
| 59 | +#ifdef __GLIBC__ |
| 60 | #include <error.h> |
| 61 | +#else |
| 62 | +#include <stdarg.h> |
| 63 | +void error(int, int, const char *, ...); |
| 64 | +#endif |
| 65 | #include <limits.h> |
| 66 | #include <string.h> |
| 67 | #include <stdlib.h> |
| 68 | @@ -1535,6 +1540,48 @@ handle_build_id (DSO *dso, Elf_Data *bui |
| 69 | puts (hex); |
| 70 | } |
| 71 | } |
| 72 | +#ifndef __GLIBC__ |
| 73 | +extern char *__progname; |
| 74 | + |
| 75 | +void (*error_print_progname)(void) = 0; |
| 76 | +unsigned int error_message_count = 0; |
| 77 | +int error_one_per_line = 0; |
| 78 | + |
| 79 | +static void eprint(int status, int e, const char *file, unsigned int line, const char *fmt, va_list ap) |
| 80 | +{ |
| 81 | + if (file && error_one_per_line) { |
| 82 | + static const char *oldfile; |
| 83 | + static unsigned int oldline; |
| 84 | + if (line == oldline && strcmp(file, oldfile) == 0) |
| 85 | + return; |
| 86 | + oldfile = file; |
| 87 | + oldline = line; |
| 88 | + } |
| 89 | + if (error_print_progname) |
| 90 | + error_print_progname(); |
| 91 | + else |
| 92 | + fprintf(stderr, "%s: ", __progname); |
| 93 | + if (file) |
| 94 | + fprintf(stderr, "%s:%u: ", file, line); |
| 95 | + vfprintf(stderr, fmt, ap); |
| 96 | + if (e) |
| 97 | + fprintf(stderr, ": %s", strerror(e)); |
| 98 | + putc('\n', stderr); |
| 99 | + fflush(stderr); |
| 100 | + error_message_count++; |
| 101 | + if (status) |
| 102 | + exit(status); |
| 103 | +} |
| 104 | + |
| 105 | +void error(int status, int e, const char *fmt, ...) |
| 106 | +{ |
| 107 | + va_list ap; |
| 108 | + va_start(ap,fmt); |
| 109 | + eprint(status, e, 0, 0, fmt, ap); |
| 110 | + va_end(ap); |
| 111 | +} |
| 112 | + |
| 113 | +#endif |
| 114 | |
| 115 | /* It avoided the segment fault while file's bss offset have a large number. |
| 116 | See https://bugzilla.redhat.com/show_bug.cgi?id=1019707 |
| 117 | Index: rpm-5.4.15/tools/rpmfind.c |
| 118 | =================================================================== |
| 119 | --- rpm-5.4.15.orig/tools/rpmfind.c |
| 120 | +++ rpm-5.4.15/tools/rpmfind.c |
| 121 | @@ -1175,7 +1175,7 @@ find_parsenum(PLAN *plan, const char *op |
| 122 | * and endchar points to the beginning of the string we know we have |
| 123 | * a syntax error. |
| 124 | */ |
| 125 | -#if defined(__sun) |
| 126 | +#if defined(__sun) || !defined(__GLIBC_) |
| 127 | value = strtoll(str, &endchar, 10); |
| 128 | #else |
| 129 | value = strtoq(str, &endchar, 10); |
| 130 | @@ -1215,7 +1215,7 @@ find_parsetime(PLAN *plan, const char *o |
| 131 | break; |
| 132 | } |
| 133 | |
| 134 | -#if defined(__sun) |
| 135 | +#if defined(__sun) || !defined(__GLIBC_) |
| 136 | value = strtoll(str, &unit, 10); |
| 137 | #else |
| 138 | value = strtoq(str, &unit, 10); |
| 139 | @@ -1253,7 +1253,7 @@ find_parsetime(PLAN *plan, const char *o |
| 140 | str = unit + 1; |
| 141 | if (*str == '\0') /* EOS */ |
| 142 | break; |
| 143 | -#if defined(__sun) |
| 144 | +#if defined(__sun) || !defined(__GLIBC_) |
| 145 | value = strtoll(str, &unit, 10); |
| 146 | #else |
| 147 | value = strtoq(str, &unit, 10); |
| 148 | Index: rpm-5.4.15/system.h |
| 149 | =================================================================== |
| 150 | --- rpm-5.4.15.orig/system.h |
| 151 | +++ rpm-5.4.15/system.h |
| 152 | @@ -372,16 +372,15 @@ extern int _tolower(int) __THROW /*@*/; |
| 153 | #define __progname __assert_program_name |
| 154 | #endif |
| 155 | #define setprogname(pn) |
| 156 | +/*@unchecked@*/ |
| 157 | +extern const char *__progname; |
| 158 | #else |
| 159 | -#define __progname program_name |
| 160 | -#define setprogname(pn) \ |
| 161 | - { if ((__progname = strrchr(pn, '/')) != NULL) __progname++; \ |
| 162 | - else __progname = pn; \ |
| 163 | - } |
| 164 | -#endif |
| 165 | +#define setprogname(pn) |
| 166 | +#define progname __progname |
| 167 | |
| 168 | /*@unchecked@*/ |
| 169 | -extern const char *__progname; |
| 170 | +extern char *__progname; |
| 171 | +#endif |
| 172 | |
| 173 | /* -- Retrofit missing prototypes (if needed). */ |
| 174 | #ifdef __cplusplus |
| 175 | Index: rpm-5.4.15/rpmio/poptIO.c |
| 176 | =================================================================== |
| 177 | --- rpm-5.4.15.orig/rpmio/poptIO.c |
| 178 | +++ rpm-5.4.15/rpmio/poptIO.c |
| 179 | @@ -65,7 +65,9 @@ extern int _rpmsvn_debug; |
| 180 | GENfree(rpmioP) |
| 181 | #endif /* __cplusplus */ |
| 182 | |
| 183 | +#ifdef __GLIBC__ |
| 184 | const char *__progname; |
| 185 | +#endif |
| 186 | |
| 187 | #if !defined(POPT_ARGFLAG_TOGGLE) /* XXX compat with popt < 1.15 */ |
| 188 | #define POPT_ARGFLAG_TOGGLE 0 |
| 189 | Index: rpm-5.4.15/lib/poptALL.c |
| 190 | =================================================================== |
| 191 | --- rpm-5.4.15.orig/lib/poptALL.c |
| 192 | +++ rpm-5.4.15/lib/poptALL.c |
| 193 | @@ -4,7 +4,9 @@ |
| 194 | */ |
| 195 | |
| 196 | #include "system.h" |
| 197 | +#ifdef __GLIBC__ |
| 198 | extern const char *__progname; |
| 199 | +#endif |
| 200 | |
| 201 | #if defined(RPM_VENDOR_WINDRIVER) |
| 202 | const char *__usrlibrpm = USRLIBRPM; |
| 203 | Index: rpm-5.4.15/tools/rpm2cpio.c |
| 204 | =================================================================== |
| 205 | --- rpm-5.4.15.orig/tools/rpm2cpio.c |
| 206 | +++ rpm-5.4.15/tools/rpm2cpio.c |
| 207 | @@ -1,7 +1,9 @@ |
| 208 | /* rpmarchive: spit out the main archive portion of a package */ |
| 209 | |
| 210 | #include "system.h" |
| 211 | +#ifdef __GLIBC__ |
| 212 | const char *__progname; |
| 213 | +#endif |
| 214 | |
| 215 | #include <rpmio.h> |
| 216 | #include <rpmiotypes.h> /* XXX fnpyKey */ |
| 217 | Index: rpm-5.4.15/tools/rpmcache.c |
| 218 | =================================================================== |
| 219 | --- rpm-5.4.15.orig/tools/rpmcache.c |
| 220 | +++ rpm-5.4.15/tools/rpmcache.c |
| 221 | @@ -3,7 +3,9 @@ |
| 222 | */ |
| 223 | |
| 224 | #include "system.h" |
| 225 | +#ifdef __GLIBC__ |
| 226 | const char *__progname; |
| 227 | +#endif |
| 228 | |
| 229 | #include <fnmatch.h> |
| 230 | #include <fts.h> |
| 231 | Index: rpm-5.4.15/tools/rpmdeps-oecore.c |
| 232 | =================================================================== |
| 233 | --- rpm-5.4.15.orig/tools/rpmdeps-oecore.c |
| 234 | +++ rpm-5.4.15/tools/rpmdeps-oecore.c |
| 235 | @@ -1,5 +1,7 @@ |
| 236 | #include "system.h" |
| 237 | +#ifdef __GLIBC__ |
| 238 | const char *__progname; |
| 239 | +#endif |
| 240 | |
| 241 | #include <rpmio.h> |
| 242 | #include <rpmiotypes.h> |
| 243 | Index: rpm-5.4.15/tools/rpmdeps.c |
| 244 | =================================================================== |
| 245 | --- rpm-5.4.15.orig/tools/rpmdeps.c |
| 246 | +++ rpm-5.4.15/tools/rpmdeps.c |
| 247 | @@ -1,5 +1,7 @@ |
| 248 | #include "system.h" |
| 249 | +#ifdef __GLIBC__ |
| 250 | const char *__progname; |
| 251 | +#endif |
| 252 | |
| 253 | #include <rpmio.h> |
| 254 | #include <rpmiotypes.h> |
| 255 | Index: rpm-5.4.15/tools/rpmdigest.c |
| 256 | =================================================================== |
| 257 | --- rpm-5.4.15.orig/tools/rpmdigest.c |
| 258 | +++ rpm-5.4.15/tools/rpmdigest.c |
| 259 | @@ -1,6 +1,8 @@ |
| 260 | #include "system.h" |
| 261 | +#ifdef __GLIBC__ |
| 262 | /*@unchecked@*/ |
| 263 | extern const char * __progname; |
| 264 | +#endif |
| 265 | |
| 266 | #define _RPMIOB_INTERNAL |
| 267 | #include <rpmiotypes.h> |
| 268 | Index: rpm-5.4.15/tools/rpmcmp.c |
| 269 | =================================================================== |
| 270 | --- rpm-5.4.15.orig/tools/rpmcmp.c |
| 271 | +++ rpm-5.4.15/tools/rpmcmp.c |
| 272 | @@ -13,8 +13,10 @@ |
| 273 | |
| 274 | #include "debug.h" |
| 275 | |
| 276 | +#ifdef __GLIBC__ |
| 277 | const char *__progname; |
| 278 | #define progname __progname |
| 279 | +#endif |
| 280 | |
| 281 | static int pointRpmEVR(ARGV_t av) |
| 282 | { |
| 283 | Index: rpm-5.4.15/rpmqv.c |
| 284 | =================================================================== |
| 285 | --- rpm-5.4.15.orig/rpmqv.c |
| 286 | +++ rpm-5.4.15/rpmqv.c |
| 287 | @@ -1,5 +1,7 @@ |
| 288 | #include "system.h" |
| 289 | +#ifdef __GLIBC__ |
| 290 | extern const char *__progname; |
| 291 | +#endif |
| 292 | |
| 293 | /* Copyright (C) 1998-2002 - Red Hat, Inc. */ |
| 294 | |