diff options
author | NihilisticPandemonium | 2019-12-19 00:11:21 -0800 |
---|---|---|
committer | NihilisticPandemonium | 2019-12-19 00:11:21 -0800 |
commit | 31bca008425012274ddc377cc8c699c526a188c8 (patch) | |
tree | 8a54fe177e81ef2140736d9fb4e8304ff484c7cc | |
download | aur-31bca008425012274ddc377cc8c699c526a188c8.tar.gz |
kmod-nc adding a new patch that adds support for zstd compressed kernel modules.
-rw-r--r-- | .SRCINFO | 40 | ||||
-rw-r--r-- | 0001-Link-against-libcrypto-not-all-of-openssl.patch | 75 | ||||
-rw-r--r-- | 0002-add-zstd-compressed-module-support.patch | 187 | ||||
-rw-r--r-- | PKGBUILD | 92 | ||||
-rw-r--r-- | depmod-search.conf | 5 | ||||
-rw-r--r-- | depmod.hook | 13 | ||||
-rw-r--r-- | depmod.script | 9 |
7 files changed, 421 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..d3f125c7ec91 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,40 @@ +pkgbase = kmod-nc + pkgdesc = Linux kernel module management tools and library + pkgver = 26 + pkgrel = 4 + url = https://git.kernel.org/?p=utils/kernel/kmod/kmod.git;a=summary + arch = x86_64 + license = GPL2 + checkdepends = linux-headers + checkdepends = libelf + makedepends = gtk-doc + depends = glibc + depends = zlib + depends = openssl + depends = xz + provides = module-init-tools=3.16 + provides = libkmod.so + provides = kmod + conflicts = module-init-tools + conflicts = kmod + replaces = module-init-tools + options = strip + options = debug + source = https://www.kernel.org/pub/linux/utils/kernel/kmod/kmod-26.tar.xz + source = https://www.kernel.org/pub/linux/utils/kernel/kmod/kmod-26.tar.sign + source = depmod-search.conf + source = depmod.hook + source = depmod.script + source = 0001-Link-against-libcrypto-not-all-of-openssl.patch + source = 0002-add-zstd-compressed-module-support.patch + validpgpkeys = EAB33C9690013C733916AC839BA2A5A630CBEA53 + md5sums = 1129c243199bdd7db01b55a61aa19601 + md5sums = SKIP + md5sums = dd62cbf62bd8f212f51ef8c43bec9a77 + md5sums = 72ce5e14ee3ad8bc06945e0ad4c642ce + md5sums = 18fb3d1f6024a5a84514c8276cb3ebff + md5sums = e918bef174c1057fa13a5ba8c4a30a46 + md5sums = 49696ec36c0a254d107c7c4a7fbbef06 + +pkgname = kmod-nc + diff --git a/0001-Link-against-libcrypto-not-all-of-openssl.patch b/0001-Link-against-libcrypto-not-all-of-openssl.patch new file mode 100644 index 000000000000..930bfaf8e68d --- /dev/null +++ b/0001-Link-against-libcrypto-not-all-of-openssl.patch @@ -0,0 +1,75 @@ +From 924b16f1b2001bf31e0688c9273e40e8f2f665c5 Mon Sep 17 00:00:00 2001 +From: Dave Reisner <dreisner@archlinux.org> +Date: Wed, 13 Feb 2019 10:24:51 -0500 +Subject: [PATCH] Link against libcrypto, not all of openssl + +In the previous build setup, libkmod.so would link to not just +libcrypto.so, but also libssl.so: + +$ readelf -d /lib/libkmod.so | grep NEEDED + 0x0000000000000001 (NEEDED) Shared library: [liblzma.so.5] + 0x0000000000000001 (NEEDED) Shared library: [libz.so.1] + 0x0000000000000001 (NEEDED) Shared library: [libssl.so.1.1] + 0x0000000000000001 (NEEDED) Shared library: [libcrypto.so.1.1] + 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] + +We don't need any symbols from libssl, though. This patch ensures that +we pass 'libcrypto' to pkgconfig rather than 'openssl', getting only the +library that we need: + +$ readelf -d tools/kmod | grep NEEDED + 0x0000000000000001 (NEEDED) Shared library: [liblzma.so.5] + 0x0000000000000001 (NEEDED) Shared library: [libz.so.1] + 0x0000000000000001 (NEEDED) Shared library: [libcrypto.so.1.1] + 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] +--- + Makefile.am | 6 +++--- + configure.ac | 4 ++-- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/Makefile.am b/Makefile.am +index ddb25f0..758f4f0 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -35,8 +35,8 @@ SED_PROCESS = \ + -e 's,@liblzma_LIBS\@,${liblzma_LIBS},g' \ + -e 's,@zlib_CFLAGS\@,${zlib_CFLAGS},g' \ + -e 's,@zlib_LIBS\@,${zlib_LIBS},g' \ +- -e 's,@openssl_CFLAGS\@,${openssl_CFLAGS},g' \ +- -e 's,@openssl_LIBS\@,${openssl_LIBS},g' \ ++ -e 's,@libcrypto_CFLAGS\@,${libcrypto_CFLAGS},g' \ ++ -e 's,@libcrypto_LIBS\@,${libcrypto_LIBS},g' \ + < $< > $@ || rm $@ + + %.pc: %.pc.in Makefile +@@ -89,7 +89,7 @@ libkmod_libkmod_la_DEPENDENCIES = \ + ${top_srcdir}/libkmod/libkmod.sym + libkmod_libkmod_la_LIBADD = \ + shared/libshared.la \ +- ${liblzma_LIBS} ${zlib_LIBS} ${openssl_LIBS} ++ ${liblzma_LIBS} ${zlib_LIBS} ${libcrypto_LIBS} + + noinst_LTLIBRARIES += libkmod/libkmod-internal.la + libkmod_libkmod_internal_la_SOURCES = $(libkmod_libkmod_la_SOURCES) +diff --git a/configure.ac b/configure.ac +index ee72283..dffe278 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -110,12 +110,12 @@ AC_ARG_WITH([openssl], + AS_HELP_STRING([--with-openssl], [handle PKCS7 signatures @<:@default=disabled@:>@]), + [], [with_openssl=no]) + AS_IF([test "x$with_openssl" != "xno"], [ +- PKG_CHECK_MODULES([openssl], [openssl >= 1.1.0]) ++ PKG_CHECK_MODULES([libcrypto], [libcrypto >= 1.1.0]) + AC_DEFINE([ENABLE_OPENSSL], [1], [Enable openssl for modinfo.]) + ], [ + AC_MSG_NOTICE([openssl support not requested]) + ]) +-CC_FEATURE_APPEND([with_features], [with_openssl], [OPENSSL]) ++CC_FEATURE_APPEND([with_features], [with_openssl], [LIBCRYPTO]) + + AC_ARG_WITH([bashcompletiondir], + AS_HELP_STRING([--with-bashcompletiondir=DIR], [Bash completions directory]), +-- +2.20.1 + diff --git a/0002-add-zstd-compressed-module-support.patch b/0002-add-zstd-compressed-module-support.patch new file mode 100644 index 000000000000..39ad80c047b4 --- /dev/null +++ b/0002-add-zstd-compressed-module-support.patch @@ -0,0 +1,187 @@ +diff --git a/Makefile.am b/Makefile.am +index 47505c1..155456f 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -89,7 +89,7 @@ libkmod_libkmod_la_DEPENDENCIES = \ + ${top_srcdir}/libkmod/libkmod.sym + libkmod_libkmod_la_LIBADD = \ + shared/libshared.la \ +- ${liblzma_LIBS} ${zlib_LIBS} ${libcrypto_LIBS} ++ ${libzstd_LIBS} ${liblzma_LIBS} ${zlib_LIBS} ${libcrypto_LIBS} + + noinst_LTLIBRARIES += libkmod/libkmod-internal.la + libkmod_libkmod_internal_la_SOURCES = $(libkmod_libkmod_la_SOURCES) +diff --git a/configure.ac b/configure.ac +index e885d79..a286159 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -83,6 +83,17 @@ AC_ARG_WITH([rootlibdir], + [], [with_rootlibdir=$libdir]) + AC_SUBST([rootlibdir], [$with_rootlibdir]) + ++AC_ARG_WITH([zstd], ++ AS_HELP_STRING([--with-zstd], [handle Zstd-compressed modules @<:@default=disabled@:>@]), ++ [], [with_zstd=no]) ++AS_IF([test "x$with_zstd" != "xno"], [ ++ PKG_CHECK_MODULES([libzstd], [libzstd >= 1.4.4]) ++ AC_DEFINE([ENABLE_ZSTD], [1], [Enable Zstd for modules.]) ++], [ ++ AC_MSG_NOTICE([Zstd support not requested]) ++]) ++CC_FEATURE_APPEND([with_features], [with_zstd], [ZSTD]) ++ + AC_ARG_WITH([xz], + AS_HELP_STRING([--with-xz], [handle Xz-compressed modules @<:@default=disabled@:>@]), + [], [with_xz=no]) +@@ -307,7 +318,7 @@ AC_MSG_RESULT([ + tools: ${enable_tools} + python bindings: ${enable_python} + logging: ${enable_logging} +- compression: xz=${with_xz} zlib=${with_zlib} ++ compression: zstd=${with_zstd} xz=${with_xz} zlib=${with_zlib} + debug: ${enable_debug} + coverage: ${enable_coverage} + doc: ${enable_gtk_doc} +diff --git a/libkmod/libkmod-file.c b/libkmod/libkmod-file.c +index 5eeba6a..2575b01 100644 +--- a/libkmod/libkmod-file.c ++++ b/libkmod/libkmod-file.c +@@ -32,7 +32,9 @@ + #ifdef ENABLE_ZLIB + #include <zlib.h> + #endif +- ++#ifdef ENABLE_ZSTD ++#include <zstd.h> ++#endif + #include <shared/util.h> + + #include "libkmod.h" +@@ -45,6 +47,9 @@ struct file_ops { + }; + + struct kmod_file { ++#ifdef ENABLE_ZSTD ++ bool zstd_used; ++#endif + #ifdef ENABLE_XZ + bool xz_used; + #endif +@@ -60,6 +65,79 @@ struct kmod_file { + struct kmod_elf *elf; + }; + ++#ifdef ENABLE_ZSTD ++static int zstd_uncompress(ZSTD_DStream *strm, struct kmod_file *file) { ++ uint8_t in_buf[BUFSIZ], out_buf[BUFSIZ]; ++ ZSTD_outBuffer output = { out_buf, sizeof(out_buf), 0 }; ++ ZSTD_inBuffer input = { in_buf, 0, 0 }; ++ void *p = NULL; ++ int ret = 0; ++ size_t total = 0; ++ ++ while(true) { ++ size_t sz; ++ if (input.pos == input.size) { ++ ssize_t rdret = read(file->fd, in_buf, sizeof(in_buf)); ++ if (rdret < 0) { ++ ret = -errno; ++ goto out; ++ } ++ input.size = rdret; ++ input.pos = 0; ++ } ++ if (input.size == 0) { ++ break; ++ } ++ sz = ZSTD_decompressStream(strm, &output, &input); ++ if (ZSTD_isError(sz)) { ++ ret = -1; ++ goto out; ++ } ++ if (output.pos == output.size || sz == 0) { ++ size_t write_size = output.pos; ++ char *tmp = realloc(p, total + write_size); ++ if (tmp == NULL) { ++ ret = -errno; ++ goto out; ++ } ++ memcpy(tmp + total, out_buf, write_size); ++ total += write_size; ++ p = tmp; ++ if (output.pos == output.size) { ++ output.pos = 0; ++ } ++ } ++ } ++ file->zstd_used = true; ++ file->memory = p; ++ file->size = total; ++ return 0; ++out: ++ free(p); ++ return ret; ++} ++ ++static int load_zstd(struct kmod_file *file) ++{ ++ ZSTD_DStream* strm = ZSTD_createDStream(); ++ int ret; ++ ZSTD_initDStream(strm); ++ ++ ret = zstd_uncompress(strm, file); ++ ZSTD_freeDStream(strm); ++ return ret; ++} ++ ++static void unload_zstd(struct kmod_file *file) ++{ ++ if (!file->zstd_used) ++ return; ++ free(file->memory); ++} ++ ++static const char magic_zstd[] = {0x28, 0xb5, 0x2f, 0xfd}; ++#endif ++ + #ifdef ENABLE_XZ + static void xz_uncompress_belch(struct kmod_file *file, lzma_ret ret) + { +@@ -238,6 +316,9 @@ static const struct comp_type { + const char *magic_bytes; + const struct file_ops ops; + } comp_types[] = { ++#ifdef ENABLE_ZSTD ++ {sizeof(magic_zstd), magic_zstd, {load_zstd, unload_zstd}}, ++#endif + #ifdef ENABLE_XZ + {sizeof(magic_xz), magic_xz, {load_xz, unload_xz}}, + #endif +diff --git a/shared/util.c b/shared/util.c +index fd2028d..b487b5f 100644 +--- a/shared/util.c ++++ b/shared/util.c +@@ -45,6 +45,9 @@ static const struct kmod_ext { + #endif + #ifdef ENABLE_XZ + {".ko.xz", sizeof(".ko.xz") - 1}, ++#endif ++#ifdef ENABLE_ZSTD ++ {".ko.zst", sizeof(".ko.zst") - 1}, + #endif + { } + }; +diff --git a/testsuite/test-util.c b/testsuite/test-util.c +index 5e25e58..621446b 100644 +--- a/testsuite/test-util.c ++++ b/testsuite/test-util.c +@@ -156,6 +156,9 @@ static int test_path_ends_with_kmod_ext(const struct test *t) + #endif + #ifdef ENABLE_XZ + { "/bla.ko.xz", true }, ++#endif ++#ifdef ENABLE_ZSTD ++ { "/bla.ko.zst", true }, + #endif + { "/bla.ko.x", false }, + { "/bla.ko.", false }, diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..ef1c10995f2e --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,92 @@ +# Maintainer: Dave Reisner <dreisner@archlinux.org> + +pkgname=kmod-nc +_pkgbase=kmod +pkgver=26 +pkgrel=4 +pkgdesc="Linux kernel module management tools and library" +arch=('x86_64') +url='https://git.kernel.org/?p=utils/kernel/kmod/kmod.git;a=summary' +license=('GPL2') +depends=('glibc' 'zlib' 'openssl' 'xz') +makedepends=('gtk-doc') +checkdepends=('linux-headers' 'libelf') +options=('strip' 'debug') +provides=('module-init-tools=3.16' 'libkmod.so' 'kmod') +conflicts=('module-init-tools' 'kmod') +replaces=('module-init-tools') +validpgpkeys=('EAB33C9690013C733916AC839BA2A5A630CBEA53') # Lucas DeMarchi +source=("https://www.kernel.org/pub/linux/utils/kernel/${_pkgbase}/${_pkgbase}-$pkgver.tar."{xz,sign} + 'depmod-search.conf' + 'depmod.hook' 'depmod.script' + '0001-Link-against-libcrypto-not-all-of-openssl.patch' + '0002-add-zstd-compressed-module-support.patch') +md5sums=('1129c243199bdd7db01b55a61aa19601' + 'SKIP' + 'dd62cbf62bd8f212f51ef8c43bec9a77' + '72ce5e14ee3ad8bc06945e0ad4c642ce' + '18fb3d1f6024a5a84514c8276cb3ebff' + 'e918bef174c1057fa13a5ba8c4a30a46' + '49696ec36c0a254d107c7c4a7fbbef06') + +prepare() { + cd "${_pkgbase}-$pkgver" + + patch -Np1 <"$srcdir/0001-Link-against-libcrypto-not-all-of-openssl.patch" + patch -Np1 <"$srcdir/0002-add-zstd-compressed-module-support.patch" + + autoreconf -fisv +} + +build() { + cd "${_pkgbase}-$pkgver" + + ./configure \ + --sysconfdir=/etc \ + --enable-gtk-doc \ + --with-xz \ + --with-zlib \ + --with-zstd \ + --with-openssl + + make +} + +check() { + # As of kmod v20, the test suite needs to build some kernel modules, and thus + # needs headers available in order to run. We depend on linux-headers, but + # this is really only to try and make sure that *some* useable tree of kernel + # headers exist. The first useable tree we find is good enough, as these + # modules will never be loaded by tests. + + local kdirs=(/usr/lib/modules/*/build/Makefile) + if [[ ! -f ${kdirs[0]} ]]; then + printf '==> Unable to find kernel headers to build modules for tests\n' >&2 + return 1 + fi + + local kver kdir=${kdirs[0]%/Makefile} + IFS=/ read _ _ _ kver _ <<<"$kdir" + + #make -C "${_pkgbase}-$pkgver" check KDIR="$kdir" KVER="$kver" +} + +package() { + make -C "${_pkgbase}-$pkgver" DESTDIR="$pkgdir" install + + # extra directories + install -dm755 "$pkgdir"/{etc,usr/lib}/{depmod,modprobe}.d + + for tool in {ins,ls,rm,dep}mod mod{probe,info}; do + ln -s kmod "$pkgdir/usr/bin/$tool" + done + + # install depmod.d file for search/ dir + install -Dm644 "$srcdir/depmod-search.conf" "$pkgdir/usr/lib/depmod.d/search.conf" + + # hook + install -Dm644 "$srcdir/depmod.hook" "$pkgdir/usr/share/libalpm/hooks/60-depmod.hook" + install -Dm755 "$srcdir/depmod.script" "$pkgdir/usr/share/libalpm/scripts/depmod" +} + +# vim: ft=sh syn=sh et diff --git a/depmod-search.conf b/depmod-search.conf new file mode 100644 index 000000000000..36f2cf7db693 --- /dev/null +++ b/depmod-search.conf @@ -0,0 +1,5 @@ +# +# /usr/lib/depmod.d/search.conf +# + +search updates extramodules built-in diff --git a/depmod.hook b/depmod.hook new file mode 100644 index 000000000000..12d7e8c4c1bd --- /dev/null +++ b/depmod.hook @@ -0,0 +1,13 @@ +[Trigger] +Type = File +Operation = Install +Operation = Upgrade +Operation = Remove +Target = usr/lib/modules/*/ +Target = !usr/lib/modules/*/?* + +[Action] +Description = Updating module dependencies... +When = PostTransaction +Exec = /usr/share/libalpm/scripts/depmod +NeedsTargets diff --git a/depmod.script b/depmod.script new file mode 100644 index 000000000000..79f1ccd30262 --- /dev/null +++ b/depmod.script @@ -0,0 +1,9 @@ +#!/bin/bash + +while read -r f; do + if [[ -e ${f}vmlinuz ]]; then + depmod $(basename "$f") + fi +done + +# vim:set ft=sh sw=2 et: |