diff options
Diffstat (limited to 'meta/recipes-extended/libsolv')
-rw-r--r-- | meta/recipes-extended/libsolv/libsolv/0001-Add-fallback-fopencookie-implementation.patch | 254 | ||||
-rw-r--r-- | meta/recipes-extended/libsolv/libsolv_git.bb | 8 |
2 files changed, 259 insertions, 3 deletions
diff --git a/meta/recipes-extended/libsolv/libsolv/0001-Add-fallback-fopencookie-implementation.patch b/meta/recipes-extended/libsolv/libsolv/0001-Add-fallback-fopencookie-implementation.patch new file mode 100644 index 0000000000..24e2228b74 --- /dev/null +++ b/meta/recipes-extended/libsolv/libsolv/0001-Add-fallback-fopencookie-implementation.patch | |||
@@ -0,0 +1,254 @@ | |||
1 | From 5b6e113f548bd8a2b100267bc5d54cee861a4b98 Mon Sep 17 00:00:00 2001 | ||
2 | From: =?UTF-8?q?Neal=20Gompa=20=28=E3=83=8B=E3=83=BC=E3=83=AB=E3=83=BB?= | ||
3 | =?UTF-8?q?=E3=82=B3=E3=82=99=E3=83=B3=E3=83=8F=E3=82=9A=29?= | ||
4 | <ngompa13@gmail.com> | ||
5 | Date: Wed, 11 Nov 2015 20:32:17 -0500 | ||
6 | Subject: [PATCH] Add fallback fopencookie() implementation | ||
7 | MIME-Version: 1.0 | ||
8 | Content-Type: text/plain; charset=UTF-8 | ||
9 | Content-Transfer-Encoding: 8bit | ||
10 | |||
11 | In environments where neither fopencookie() nor funopen() | ||
12 | are implemented, we need to provide a suitable implementation | ||
13 | of fopencookie() that we can use. | ||
14 | |||
15 | Upstream-Status: Submitted [ https://github.com/openSUSE/libsolv/pull/112 ] | ||
16 | |||
17 | Signed-off-by: Neal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>com> | ||
18 | Signed-off-by: Maxin B. John <maxin.john@intel.com> | ||
19 | --- | ||
20 | ext/CMakeLists.txt | 7 ++ | ||
21 | ext/solv_xfopen.c | 10 +-- | ||
22 | ext/solv_xfopen_fallback_fopencookie.c | 124 +++++++++++++++++++++++++++++++++ | ||
23 | ext/solv_xfopen_fallback_fopencookie.h | 28 ++++++++ | ||
24 | 4 files changed, 165 insertions(+), 4 deletions(-) | ||
25 | create mode 100644 ext/solv_xfopen_fallback_fopencookie.c | ||
26 | create mode 100644 ext/solv_xfopen_fallback_fopencookie.h | ||
27 | |||
28 | diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt | ||
29 | index ad52495..4f282ce 100644 | ||
30 | --- a/ext/CMakeLists.txt | ||
31 | +++ b/ext/CMakeLists.txt | ||
32 | @@ -4,6 +4,13 @@ SET (libsolvext_SRCS | ||
33 | SET (libsolvext_HEADERS | ||
34 | tools_util.h solv_xfopen.h testcase.h) | ||
35 | |||
36 | +IF (NOT HAVE_FOPENCOOKIE AND NOT HAVE_FUNOPEN) | ||
37 | + SET (libsolvext_SRCS ${libsolvext_SRCS} | ||
38 | + solv_xfopen_fallback_fopencookie.c) | ||
39 | + SET (libsolvext_HEADERS ${libsolvext_HEADERS} | ||
40 | + solv_xfopen_fallback_fopencookie.h) | ||
41 | +ENDIF (NOT HAVE_FOPENCOOKIE AND NOT HAVE_FUNOPEN) | ||
42 | + | ||
43 | IF (ENABLE_RPMDB) | ||
44 | SET (libsolvext_SRCS ${libsolvext_SRCS} | ||
45 | pool_fileconflicts.c repo_rpmdb.c) | ||
46 | diff --git a/ext/solv_xfopen.c b/ext/solv_xfopen.c | ||
47 | index b0421bf..31345dd 100644 | ||
48 | --- a/ext/solv_xfopen.c | ||
49 | +++ b/ext/solv_xfopen.c | ||
50 | @@ -13,6 +13,10 @@ | ||
51 | #include <zlib.h> | ||
52 | #include <fcntl.h> | ||
53 | |||
54 | +#if !defined(HAVE_FUNOPEN) && !defined(HAVE_FOPENCOOKIE) | ||
55 | +#include "solv_xfopen_fallback_fopencookie.h" | ||
56 | +#endif | ||
57 | + | ||
58 | #include "solv_xfopen.h" | ||
59 | #include "util.h" | ||
60 | |||
61 | @@ -39,7 +43,7 @@ static FILE *cookieopen(void *cookie, const char *mode, | ||
62 | ssize_t (*cwrite)(void *, const char *, size_t), | ||
63 | int (*cclose)(void *)) | ||
64 | { | ||
65 | -#ifdef HAVE_FUNOPEN | ||
66 | +#if defined(HAVE_FUNOPEN) && !defined(HAVE_FOPENCOOKIE) | ||
67 | if (!cookie) | ||
68 | return 0; | ||
69 | return funopen(cookie, | ||
70 | @@ -48,7 +52,7 @@ static FILE *cookieopen(void *cookie, const char *mode, | ||
71 | (fpos_t (*)(void *, fpos_t, int))NULL, /* seekfn */ | ||
72 | cclose | ||
73 | ); | ||
74 | -#elif defined(HAVE_FOPENCOOKIE) | ||
75 | +#else | ||
76 | cookie_io_functions_t cio; | ||
77 | |||
78 | if (!cookie) | ||
79 | @@ -60,8 +64,6 @@ static FILE *cookieopen(void *cookie, const char *mode, | ||
80 | cio.write = cwrite; | ||
81 | cio.close = cclose; | ||
82 | return fopencookie(cookie, *mode == 'w' ? "w" : "r", cio); | ||
83 | -#else | ||
84 | -# error Need to implement custom I/O | ||
85 | #endif | ||
86 | } | ||
87 | |||
88 | diff --git a/ext/solv_xfopen_fallback_fopencookie.c b/ext/solv_xfopen_fallback_fopencookie.c | ||
89 | new file mode 100644 | ||
90 | index 0000000..89426a9 | ||
91 | --- /dev/null | ||
92 | +++ b/ext/solv_xfopen_fallback_fopencookie.c | ||
93 | @@ -0,0 +1,124 @@ | ||
94 | +/* | ||
95 | + * Provides a very limited fopencookie() for environments with a libc | ||
96 | + * that lacks it. | ||
97 | + * | ||
98 | + * Authors: zhasha & nsz | ||
99 | + * Modified for libsolv by Neal Gompa | ||
100 | + * | ||
101 | + * This program is licensed under the BSD license, read LICENSE.BSD | ||
102 | + * for further information. | ||
103 | + * | ||
104 | + */ | ||
105 | + | ||
106 | +#define _LARGEFILE64_SOURCE 1 | ||
107 | +#include <pthread.h> | ||
108 | +#include <stdio.h> | ||
109 | +#include <stdlib.h> | ||
110 | +#include <unistd.h> | ||
111 | +#include <fcntl.h> | ||
112 | +#include <sys/types.h> | ||
113 | +#include <errno.h> | ||
114 | +#include "solv_xfopen_fallback_fopencookie.h" | ||
115 | + | ||
116 | +extern int pipe2(int[2], int); | ||
117 | + | ||
118 | +struct ctx { | ||
119 | + int fd; | ||
120 | + void *cookie; | ||
121 | + struct cookie_io_functions_t io; | ||
122 | + char buf[1024]; | ||
123 | +}; | ||
124 | + | ||
125 | +static void *proxy(void *arg) | ||
126 | +{ | ||
127 | + struct ctx *ctx = arg; | ||
128 | + ssize_t r; | ||
129 | + size_t n, k; | ||
130 | + | ||
131 | + pthread_detach(pthread_self()); | ||
132 | + | ||
133 | + while (1) { | ||
134 | + r = ctx->io.read ? | ||
135 | + (ctx->io.read)(ctx->cookie, ctx->buf, sizeof(ctx->buf)) : | ||
136 | + read(ctx->fd, ctx->buf, sizeof(ctx->buf)); | ||
137 | + if (r < 0) { | ||
138 | + if (errno != EINTR) { break; } | ||
139 | + continue; | ||
140 | + } | ||
141 | + if (r == 0) { break; } | ||
142 | + | ||
143 | + n = r, k = 0; | ||
144 | + while (n > 0) { | ||
145 | + r = ctx->io.write ? | ||
146 | + (ctx->io.write)(ctx->cookie, ctx->buf + k, n) : | ||
147 | + write(ctx->fd, ctx->buf + k, n); | ||
148 | + if (r < 0) { | ||
149 | + if (errno != EINTR) { break; } | ||
150 | + continue; | ||
151 | + } | ||
152 | + if (r == 0) { break; } | ||
153 | + | ||
154 | + n -= r, k += r; | ||
155 | + } | ||
156 | + if (n > 0) { break; } | ||
157 | + } | ||
158 | + | ||
159 | + if (ctx->io.close) { (ctx->io.close)(ctx->cookie); } | ||
160 | + close(ctx->fd); | ||
161 | + return NULL; | ||
162 | +} | ||
163 | + | ||
164 | +FILE *fopencookie(void *cookie, const char *mode, struct cookie_io_functions_t io) | ||
165 | +{ | ||
166 | + struct ctx *ctx = NULL; | ||
167 | + int rd = 0, wr = 0; | ||
168 | + int p[2] = { -1, -1 }; | ||
169 | + FILE *f = NULL; | ||
170 | + pthread_t dummy; | ||
171 | + | ||
172 | + switch (mode[0]) { | ||
173 | + case 'a': | ||
174 | + case 'w': wr = 1; break; | ||
175 | + case 'r': rd = 1; break; | ||
176 | + default: | ||
177 | + errno = EINVAL; | ||
178 | + return NULL; | ||
179 | + } | ||
180 | + switch (mode[1]) { | ||
181 | + case '\0': break; | ||
182 | + case '+': | ||
183 | + if (mode[2] == '\0') { | ||
184 | + errno = ENOTSUP; | ||
185 | + return NULL; | ||
186 | + } | ||
187 | + default: | ||
188 | + errno = EINVAL; | ||
189 | + return NULL; | ||
190 | + } | ||
191 | + if (io.seek) { | ||
192 | + errno = ENOTSUP; | ||
193 | + return NULL; | ||
194 | + } | ||
195 | + | ||
196 | + ctx = malloc(sizeof(*ctx)); | ||
197 | + if (!ctx) { return NULL; } | ||
198 | + if (pipe2(p, O_CLOEXEC) != 0) { goto err; } | ||
199 | + if ((f = fdopen(p[wr], mode)) == NULL) { goto err; } | ||
200 | + p[wr] = -1; | ||
201 | + ctx->fd = p[rd]; | ||
202 | + ctx->cookie = cookie; | ||
203 | + ctx->io.read = rd ? io.read : NULL; | ||
204 | + ctx->io.write = wr ? io.write : NULL; | ||
205 | + ctx->io.seek = NULL; | ||
206 | + ctx->io.close = io.close; | ||
207 | + if (pthread_create(&dummy, NULL, proxy, ctx) != 0) { goto err; } | ||
208 | + | ||
209 | + return f; | ||
210 | + | ||
211 | +err: | ||
212 | + if (p[0] >= 0) { close(p[0]); } | ||
213 | + if (p[1] >= 0) { close(p[1]); } | ||
214 | + if (f) { fclose(f); } | ||
215 | + free(ctx); | ||
216 | + return NULL; | ||
217 | +} | ||
218 | diff --git a/ext/solv_xfopen_fallback_fopencookie.h b/ext/solv_xfopen_fallback_fopencookie.h | ||
219 | new file mode 100644 | ||
220 | index 0000000..7223e3f | ||
221 | --- /dev/null | ||
222 | +++ b/ext/solv_xfopen_fallback_fopencookie.h | ||
223 | @@ -0,0 +1,28 @@ | ||
224 | +/* | ||
225 | + * Provides a very limited fopencookie() for environments with a libc | ||
226 | + * that lacks it. | ||
227 | + * | ||
228 | + * Authors: zhasha & nsz | ||
229 | + * Modified for libsolv by Neal Gompa | ||
230 | + * | ||
231 | + * This program is licensed under the BSD license, read LICENSE.BSD | ||
232 | + * for further information. | ||
233 | + * | ||
234 | + */ | ||
235 | + | ||
236 | +#ifndef SOLV_XFOPEN_FALLBACK_FOPENCOOKIE_H | ||
237 | +#define SOLV_XFOPEN_FALLBACK_FOPENCOOKIE_H | ||
238 | + | ||
239 | +#include <stdio.h> | ||
240 | +#include <stdint.h> | ||
241 | + | ||
242 | +typedef struct cookie_io_functions_t { | ||
243 | + ssize_t (*read)(void *, char *, size_t); | ||
244 | + ssize_t (*write)(void *, const char *, size_t); | ||
245 | + int (*seek)(void *, off64_t, int); | ||
246 | + int (*close)(void *); | ||
247 | +} cookie_io_functions_t; | ||
248 | + | ||
249 | +FILE *fopencookie(void *cookie, const char *mode, struct cookie_io_functions_t io); | ||
250 | + | ||
251 | +#endif | ||
252 | -- | ||
253 | 2.4.0 | ||
254 | |||
diff --git a/meta/recipes-extended/libsolv/libsolv_git.bb b/meta/recipes-extended/libsolv/libsolv_git.bb index fb81c8a5fa..a16897e7d6 100644 --- a/meta/recipes-extended/libsolv/libsolv_git.bb +++ b/meta/recipes-extended/libsolv/libsolv_git.bb | |||
@@ -7,12 +7,14 @@ LIC_FILES_CHKSUM = "file://LICENSE.BSD;md5=62272bd11c97396d4aaf1c41bc11f7d8" | |||
7 | 7 | ||
8 | DEPENDS = "expat zlib" | 8 | DEPENDS = "expat zlib" |
9 | 9 | ||
10 | PV = "0.6.19" | 10 | PV = "0.6.20" |
11 | 11 | ||
12 | SRC_URI = "git://github.com/openSUSE/libsolv.git \ | 12 | SRC_URI = "git://github.com/openSUSE/libsolv.git \ |
13 | file://0001-CMakeLists.txt-fix-MAN_INSTALL_DIR.patch \ | 13 | file://0001-CMakeLists.txt-fix-MAN_INSTALL_DIR.patch \ |
14 | " | 14 | " |
15 | SRCREV = "4c5af401a89858d4cebbfe40c59a0031ff9db5b0" | 15 | SRC_URI_append_libc-musl = " file://0001-Add-fallback-fopencookie-implementation.patch" |
16 | |||
17 | SRCREV = "513c572b10e18bea5ac78709267de4b739cb31e7" | ||
16 | UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>\d+(\.\d+)+)" | 18 | UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>\d+(\.\d+)+)" |
17 | 19 | ||
18 | S = "${WORKDIR}/git" | 20 | S = "${WORKDIR}/git" |