recipes: x-apps/feh: upgraded to version 3.1.1
[dragora.git] / patches / kmod / kmod-25_lzip-0.diff
blob381c3625e02630f438676a79978f5a97c76ff7bc
1 diff -urdN kmod-25.orig/Makefile.am kmod-25/Makefile.am
2 --- kmod-25.orig/Makefile.am 2018-01-08 22:51:26.000000000 +0100
3 +++ kmod-25/Makefile.am 2018-04-17 23:55:35.000000000 +0200
4 @@ -19,7 +19,7 @@
5 -include $(top_builddir)/config.h \
6 -I$(top_srcdir) \
7 -DSYSCONFDIR=\""$(sysconfdir)"\" \
8 - ${zlib_CFLAGS}
9 + ${lzlib_CFLAGS} ${zlib_CFLAGS}
11 AM_CFLAGS = $(OUR_CFLAGS)
12 AM_LDFLAGS = $(OUR_LDFLAGS)
13 @@ -33,6 +33,8 @@
14 -e 's,@includedir\@,$(includedir),g' \
15 -e 's,@liblzma_CFLAGS\@,${liblzma_CFLAGS},g' \
16 -e 's,@liblzma_LIBS\@,${liblzma_LIBS},g' \
17 + -e 's,@lzlib_CFLAGS\@,${lzlib_CFLAGS},g' \
18 + -e 's,@lzlib_LIBS\@,${lzlib_LIBS},g' \
19 -e 's,@zlib_CFLAGS\@,${zlib_CFLAGS},g' \
20 -e 's,@zlib_LIBS\@,${zlib_LIBS},g' \
21 < $< > $@ || rm $@
22 @@ -87,7 +89,7 @@
23 ${top_srcdir}/libkmod/libkmod.sym
24 libkmod_libkmod_la_LIBADD = \
25 shared/libshared.la \
26 - ${liblzma_LIBS} ${zlib_LIBS}
27 + ${liblzma_LIBS} ${lzlib_LIBS} ${zlib_LIBS}
29 noinst_LTLIBRARIES += libkmod/libkmod-internal.la
30 libkmod_libkmod_internal_la_SOURCES = $(libkmod_libkmod_la_SOURCES)
31 diff -urdN kmod-25.orig/Makefile.in kmod-25/Makefile.in
32 --- kmod-25.orig/Makefile.in 2018-01-09 02:26:05.000000000 +0100
33 +++ kmod-25/Makefile.in 2018-04-17 23:55:35.000000000 +0200
34 @@ -884,6 +884,8 @@
35 top_build_prefix = @top_build_prefix@
36 top_builddir = @top_builddir@
37 top_srcdir = @top_srcdir@
38 +lzlib_CFLAGS = @lzlib_CFLAGS@
39 +lzlib_LIBS = @lzlib_LIBS@
40 zlib_CFLAGS = @zlib_CFLAGS@
41 zlib_LIBS = @zlib_LIBS@
42 SUBDIRS = . libkmod/docs $(am__append_1)
43 @@ -933,7 +935,7 @@
44 -include $(top_builddir)/config.h \
45 -I$(top_srcdir) \
46 -DSYSCONFDIR=\""$(sysconfdir)"\" \
47 - ${zlib_CFLAGS}
48 + ${lzlib_CFLAGS} ${zlib_CFLAGS}
50 AM_CFLAGS = $(OUR_CFLAGS)
51 AM_LDFLAGS = $(OUR_LDFLAGS)
52 @@ -946,6 +948,8 @@
53 -e 's,@includedir\@,$(includedir),g' \
54 -e 's,@liblzma_CFLAGS\@,${liblzma_CFLAGS},g' \
55 -e 's,@liblzma_LIBS\@,${liblzma_LIBS},g' \
56 + -e 's,@lzlib_CFLAGS\@,${lzlib_CFLAGS},g' \
57 + -e 's,@lzlib_LIBS\@,${lzlib_LIBS},g' \
58 -e 's,@zlib_CFLAGS\@,${zlib_CFLAGS},g' \
59 -e 's,@zlib_LIBS\@,${zlib_LIBS},g' \
60 < $< > $@ || rm $@
61 @@ -993,7 +997,7 @@
63 libkmod_libkmod_la_LIBADD = \
64 shared/libshared.la \
65 - ${liblzma_LIBS} ${zlib_LIBS}
66 + ${liblzma_LIBS} ${lzlib_LIBS} ${zlib_LIBS}
68 libkmod_libkmod_internal_la_SOURCES = $(libkmod_libkmod_la_SOURCES)
69 libkmod_libkmod_internal_la_LDFLAGS = $(AM_LDFLAGS) \
70 diff -urdN kmod-25.orig/README kmod-25/README
71 --- kmod-25.orig/README 2017-12-07 23:05:47.000000000 +0100
72 +++ kmod-25/README 2018-04-17 23:55:35.000000000 +0200
73 @@ -51,6 +51,7 @@
75 Optional dependencies:
76 - ZLIB library
77 + - LZLIB library
78 - LZMA library
80 Typical configuration:
81 diff -urdN kmod-25.orig/config.h.in kmod-25/config.h.in
82 --- kmod-25.orig/config.h.in 2018-01-09 02:31:04.000000000 +0100
83 +++ kmod-25/config.h.in 2018-04-17 23:55:35.000000000 +0200
84 @@ -12,6 +12,9 @@
85 /* Enable Xz for modules. */
86 #undef ENABLE_XZ
88 +/* Enable lzlib for modules. */
89 +#undef ENABLE_LZLIB
91 /* Enable zlib for modules. */
92 #undef ENABLE_ZLIB
94 diff -urdN kmod-25.orig/configure kmod-25/configure
95 --- kmod-25.orig/configure 2018-01-09 02:26:04.000000000 +0100
96 +++ kmod-25/configure 2018-04-17 23:55:35.000000000 +0200
97 @@ -688,6 +688,8 @@
98 bashcompletiondir
99 zlib_LIBS
100 zlib_CFLAGS
101 +lzlib_LIBS
102 +lzlib_CFLAGS
103 liblzma_LIBS
104 liblzma_CFLAGS
105 rootlibdir
106 @@ -833,6 +835,7 @@
107 enable_libtool_lock
108 with_rootlibdir
109 with_xz
110 +with_lzlib
111 with_zlib
112 with_bashcompletiondir
113 enable_experimental
114 @@ -863,6 +866,8 @@
115 PKG_CONFIG_LIBDIR
116 liblzma_CFLAGS
117 liblzma_LIBS
118 +lzlib_CFLAGS
119 +lzlib_LIBS
120 zlib_CFLAGS
121 zlib_LIBS
122 PYTHON
123 @@ -1532,6 +1537,7 @@
124 compiler's sysroot if not specified).
125 --with-rootlibdir=DIR rootfs directory to install shared libraries
126 --with-xz handle Xz-compressed modules [default=disabled]
127 + --with-lzlib handle lzipped modules [default=disabled]
128 --with-zlib handle gzipped modules [default=disabled]
129 --with-bashcompletiondir=DIR
130 Bash completions directory
131 @@ -1557,6 +1563,9 @@
132 C compiler flags for liblzma, overriding pkg-config
133 liblzma_LIBS
134 linker flags for liblzma, overriding pkg-config
135 + lzlib_CFLAGS
136 + C compiler flags for lzlib, overriding pkg-config
137 + lzlib_LIBS linker flags for lzlib, overriding pkg-config
138 zlib_CFLAGS C compiler flags for zlib, overriding pkg-config
139 zlib_LIBS linker flags for zlib, overriding pkg-config
140 PYTHON the Python interpreter
141 @@ -13751,6 +13760,142 @@
145 +# Check whether --with-lzlib was given.
146 +if test "${with_lzlib+set}" = set; then :
147 + withval=$with_lzlib;
148 +else
149 + with_lzlib=no
152 +if test "x$with_lzlib" != "xno"; then :
155 +pkg_failed=no
156 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for lzlib" >&5
157 +$as_echo_n "checking for lzlib... " >&6; }
159 +if test -n "$lzlib_CFLAGS"; then
160 + pkg_cv_lzlib_CFLAGS="$lzlib_CFLAGS"
161 + elif test -n "$PKG_CONFIG"; then
162 + if test -n "$PKG_CONFIG" && \
163 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"lzlib\""; } >&5
164 + ($PKG_CONFIG --exists --print-errors "lzlib") 2>&5
165 + ac_status=$?
166 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
167 + test $ac_status = 0; }; then
168 + pkg_cv_lzlib_CFLAGS=`$PKG_CONFIG --cflags "lzlib" 2>/dev/null`
169 + test "x$?" != "x0" && pkg_failed=yes
170 +else
171 + pkg_failed=yes
173 + else
174 + pkg_failed=untried
176 +if test -n "$lzlib_LIBS"; then
177 + pkg_cv_lzlib_LIBS="$lzlib_LIBS"
178 + elif test -n "$PKG_CONFIG"; then
179 + if test -n "$PKG_CONFIG" && \
180 + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"lzlib\""; } >&5
181 + ($PKG_CONFIG --exists --print-errors "lzlib") 2>&5
182 + ac_status=$?
183 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
184 + test $ac_status = 0; }; then
185 + pkg_cv_lzlib_LIBS=`$PKG_CONFIG --libs "lzlib" 2>/dev/null`
186 + test "x$?" != "x0" && pkg_failed=yes
187 +else
188 + pkg_failed=yes
190 + else
191 + pkg_failed=untried
196 +if test $pkg_failed = yes; then
197 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
198 +$as_echo "no" >&6; }
200 +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
201 + _pkg_short_errors_supported=yes
202 +else
203 + _pkg_short_errors_supported=no
205 + if test $_pkg_short_errors_supported = yes; then
206 + lzlib_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "lzlib" 2>&1`
207 + else
208 + lzlib_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "lzlib" 2>&1`
209 + fi
210 + # Put the nasty error message in config.log where it belongs
211 + echo "$lzlib_PKG_ERRORS" >&5
213 + as_fn_error $? "Package requirements (lzlib) were not met:
215 +$lzlib_PKG_ERRORS
217 +Consider adjusting the PKG_CONFIG_PATH environment variable if you
218 +installed software in a non-standard prefix.
220 +Alternatively, you may set the environment variables lzlib_CFLAGS
221 +and lzlib_LIBS to avoid the need to call pkg-config.
222 +See the pkg-config man page for more details." "$LINENO" 5
223 +elif test $pkg_failed = untried; then
224 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
225 +$as_echo "no" >&6; }
226 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
227 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
228 +as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it
229 +is in your PATH or set the PKG_CONFIG environment variable to the full
230 +path to pkg-config.
232 +Alternatively, you may set the environment variables lzlib_CFLAGS
233 +and lzlib_LIBS to avoid the need to call pkg-config.
234 +See the pkg-config man page for more details.
236 +To get pkg-config, see <http://pkg-config.freedesktop.org/>.
237 +See \`config.log' for more details" "$LINENO" 5; }
238 +else
239 + lzlib_CFLAGS=$pkg_cv_lzlib_CFLAGS
240 + lzlib_LIBS=$pkg_cv_lzlib_LIBS
241 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
242 +$as_echo "yes" >&6; }
246 +$as_echo "#define ENABLE_LZLIB 1" >>confdefs.h
249 +else
251 + { $as_echo "$as_me:${as_lineno-$LINENO}: lzlib support not requested" >&5
252 +$as_echo "$as_me: lzlib support not requested" >&6;}
257 + case " $with_features " in #(
258 + *" LZLIB "*) :
259 + { { $as_echo "$as_me:${as_lineno-$LINENO}: : with_features already contains LZLIB"; } >&5
260 + (: with_features already contains LZLIB) 2>&5
261 + ac_status=$?
262 + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
263 + test $ac_status = 0; } ;; #(
264 + *) :
266 + if test "x$with_features" != "x"; then :
267 + as_fn_append with_features " "
269 + if test "x$with_lzlib" = "xyes"; then :
270 + as_fn_append with_features "+LZLIB"
271 +else
272 + as_fn_append with_features "-LZLIB"
275 + ;;
276 +esac
281 # Check whether --with-zlib was given.
282 if test "${with_zlib+set}" = set; then :
283 withval=$with_zlib;
284 @@ -17499,7 +17644,7 @@
285 tools: ${enable_tools}
286 python bindings: ${enable_python}
287 logging: ${enable_logging}
288 - compression: xz=${with_xz} zlib=${with_zlib}
289 + compression: xz=${with_xz} lzlib=${with_lzlib} zlib=${with_zlib}
290 debug: ${enable_debug}
291 coverage: ${enable_coverage}
292 doc: ${enable_gtk_doc}
293 @@ -17528,7 +17673,7 @@
294 tools: ${enable_tools}
295 python bindings: ${enable_python}
296 logging: ${enable_logging}
297 - compression: xz=${with_xz} zlib=${with_zlib}
298 + compression: xz=${with_xz} lzlib=${with_lzlib} zlib=${with_zlib}
299 debug: ${enable_debug}
300 coverage: ${enable_coverage}
301 doc: ${enable_gtk_doc}
302 diff -urdN kmod-25.orig/configure.ac kmod-25/configure.ac
303 --- kmod-25.orig/configure.ac 2018-01-08 22:51:04.000000000 +0100
304 +++ kmod-25/configure.ac 2018-04-17 23:55:35.000000000 +0200
305 @@ -95,6 +95,17 @@
307 CC_FEATURE_APPEND([with_features], [with_xz], [XZ])
309 +AC_ARG_WITH([lzlib],
310 + AS_HELP_STRING([--with-lzlib], [handle lzipped modules @<:@default=disabled@:>@]),
311 + [], [with_lzlib=no])
312 +AS_IF([test "x$with_lzlib" != "xno"], [
313 + PKG_CHECK_MODULES([lzlib], [lzlib])
314 + AC_DEFINE([ENABLE_LZLIB], [1], [Enable lzlib for modules.])
315 +], [
316 + AC_MSG_NOTICE([lzlib support not requested])
318 +CC_FEATURE_APPEND([with_features], [with_lzlib], [LZLIB])
320 AC_ARG_WITH([zlib],
321 AS_HELP_STRING([--with-zlib], [handle gzipped modules @<:@default=disabled@:>@]),
322 [], [with_zlib=no])
323 @@ -297,7 +308,7 @@
324 tools: ${enable_tools}
325 python bindings: ${enable_python}
326 logging: ${enable_logging}
327 - compression: xz=${with_xz} zlib=${with_zlib}
328 + compression: xz=${with_xz} lzlib=${with_lzlib} zlib=${with_zlib}
329 debug: ${enable_debug}
330 coverage: ${enable_coverage}
331 doc: ${enable_gtk_doc}
332 diff -urdN kmod-25.orig/libkmod/docs/Makefile.in kmod-25/libkmod/docs/Makefile.in
333 --- kmod-25.orig/libkmod/docs/Makefile.in 2018-01-09 02:26:05.000000000 +0100
334 +++ kmod-25/libkmod/docs/Makefile.in 2018-04-18 22:57:17.000000000 +0200
335 @@ -304,6 +304,8 @@
336 top_build_prefix = @top_build_prefix@
337 top_builddir = @top_builddir@
338 top_srcdir = @top_srcdir@
339 +lzlib_CFLAGS = @lzlib_CFLAGS@
340 +lzlib_LIBS = @lzlib_LIBS@
341 zlib_CFLAGS = @zlib_CFLAGS@
342 zlib_LIBS = @zlib_LIBS@
343 AUTOMAKE_OPTIONS = 1.11
344 diff -urdN kmod-25.orig/libkmod/libkmod-file.c kmod-25/libkmod/libkmod-file.c
345 --- kmod-25.orig/libkmod/libkmod-file.c 2017-12-07 23:05:47.000000000 +0100
346 +++ kmod-25/libkmod/libkmod-file.c 2018-04-18 23:14:10.000000000 +0200
347 @@ -34,6 +34,9 @@
348 #endif
350 #include <shared/util.h>
351 +#ifdef ENABLE_LZLIB
352 +#include <lzlib.h>
353 +#endif
355 #include "libkmod.h"
356 #include "libkmod-internal.h"
357 @@ -48,6 +51,9 @@
358 #ifdef ENABLE_XZ
359 bool xz_used;
360 #endif
361 +#ifdef ENABLE_LZLIB
362 + bool lz_used;
363 +#endif
364 #ifdef ENABLE_ZLIB
365 gzFile gzf;
366 #endif
367 @@ -169,6 +175,88 @@
368 static const char magic_xz[] = {0xfd, '7', 'z', 'X', 'Z', 0};
369 #endif
371 +#ifdef ENABLE_LZLIB
372 +#ifndef min
373 + #define min(x,y) ((x) <= (y) ? (x) : (y))
374 +#endif
376 +static int load_lzlib(struct kmod_file *file)
378 + uint8_t in_buf[16384];
379 + int err = 0;
380 + off_t did = 0, total = 0;
381 + _cleanup_free_ unsigned char *p = NULL;
383 + struct LZ_Decoder *lzd = LZ_decompress_open();
384 + if (!lzd || LZ_decompress_errno( lzd ) != LZ_ok)
385 + { LZ_decompress_close(lzd); return -ENOMEM; }
387 + for (;;) {
388 + int rd;
389 + const int size = min(LZ_decompress_write_size(lzd),
390 + (int)sizeof in_buf);
392 + if (did == total) {
393 + const int realloc_step = 4 * 1024 * 1024;
394 + void *tmp = realloc(p, total + realloc_step);
395 + if (tmp == NULL) {
396 + err = -ENOMEM;
397 + goto error;
399 + total += realloc_step;
400 + p = tmp;
403 + if (size > 0) {
404 + rd = read(file->fd, in_buf, size);
405 + if (rd < 0) {
406 + err = -errno;
407 + goto error;
409 + if (rd == 0)
410 + LZ_decompress_finish(lzd);
411 + else if (LZ_decompress_write(lzd, in_buf, rd) != rd) {
412 + err = -EINVAL;
413 + goto error;
416 + rd = LZ_decompress_read(lzd, p + did, total - did);
417 + if (rd < 0) {
418 + const char *lz_errmsg =
419 + LZ_strerror(LZ_decompress_errno(lzd));
421 + ERR(file->ctx, "lzip: %s\n", lz_errmsg);
422 + err = -EINVAL;
423 + goto error;
425 + did += rd;
426 + if (LZ_decompress_finished(lzd) == 1)
427 + break;
430 + if (LZ_decompress_close(lzd) < 0)
431 + return -EINVAL;
432 + file->lz_used = true;
433 + file->memory = p;
434 + file->size = did;
435 + p = NULL;
436 + return 0;
438 +error:
439 + LZ_decompress_close(lzd);
440 + return err;
443 +static void unload_lzlib(struct kmod_file *file)
445 + if (!file->lz_used)
446 + return;
447 + free(file->memory);
450 +static const char magic_lzlib[] = { 0x4C, 0x5A, 0x49, 0x50 }; /* "LZIP" */
451 +#endif
453 #ifdef ENABLE_ZLIB
454 #define READ_STEP (4 * 1024 * 1024)
455 static int load_zlib(struct kmod_file *file)
456 @@ -241,6 +329,9 @@
457 #ifdef ENABLE_XZ
458 {sizeof(magic_xz), magic_xz, {load_xz, unload_xz}},
459 #endif
460 +#ifdef ENABLE_LZLIB
461 + {sizeof(magic_lzlib), magic_lzlib, {load_lzlib, unload_lzlib}},
462 +#endif
463 #ifdef ENABLE_ZLIB
464 {sizeof(magic_zlib), magic_zlib, {load_zlib, unload_zlib}},
465 #endif
466 diff -urdN kmod-25.orig/libkmod/libkmod.pc.in kmod-25/libkmod/libkmod.pc.in
467 --- kmod-25.orig/libkmod/libkmod.pc.in 2013-04-24 22:02:37.000000000 +0200
468 +++ kmod-25/libkmod/libkmod.pc.in 2018-04-18 22:57:17.000000000 +0200
469 @@ -7,5 +7,5 @@
470 Description: Library to deal with kernel modules
471 Version: @VERSION@
472 Libs: -L${libdir} -lkmod
473 -Libs.private: @liblzma_LIBS@ @zlib_LIBS@
474 +Libs.private: @liblzma_LIBS@ @lzlib_LIBS@ @zlib_LIBS@
475 Cflags: -I${includedir}
476 diff -urdN kmod-25.orig/man/Makefile.in kmod-25/man/Makefile.in
477 --- kmod-25.orig/man/Makefile.in 2018-01-09 02:26:05.000000000 +0100
478 +++ kmod-25/man/Makefile.in 2018-04-18 22:57:17.000000000 +0200
479 @@ -307,6 +307,8 @@
480 top_build_prefix = @top_build_prefix@
481 top_builddir = @top_builddir@
482 top_srcdir = @top_srcdir@
483 +lzlib_CFLAGS = @lzlib_CFLAGS@
484 +lzlib_LIBS = @lzlib_LIBS@
485 zlib_CFLAGS = @zlib_CFLAGS@
486 zlib_LIBS = @zlib_LIBS@
487 MAN5 = depmod.d.5 modprobe.d.5 modules.dep.5
488 diff -urdN kmod-25.orig/shared/util.c kmod-25/shared/util.c
489 --- kmod-25.orig/shared/util.c 2017-12-07 23:05:47.000000000 +0100
490 +++ kmod-25/shared/util.c 2018-04-18 22:57:17.000000000 +0200
491 @@ -43,6 +43,9 @@
492 #ifdef ENABLE_ZLIB
493 {".ko.gz", sizeof(".ko.gz") - 1},
494 #endif
495 +#ifdef ENABLE_LZLIB
496 + {".ko.lz", sizeof(".ko.lz") - 1},
497 +#endif
498 #ifdef ENABLE_XZ
499 {".ko.xz", sizeof(".ko.xz") - 1},
500 #endif
501 diff -urdN kmod-25.orig/testsuite/test-util.c kmod-25/testsuite/test-util.c
502 --- kmod-25.orig/testsuite/test-util.c 2017-12-07 23:05:47.000000000 +0100
503 +++ kmod-25/testsuite/test-util.c 2018-04-18 22:57:17.000000000 +0200
504 @@ -154,6 +154,9 @@
505 #ifdef ENABLE_ZLIB
506 { "/bla.ko.gz", true },
507 #endif
508 +#ifdef ENABLE_LZLIB
509 + { "/bla.ko.lz", true },
510 +#endif
511 #ifdef ENABLE_XZ
512 { "/bla.ko.xz", true },
513 #endif