diff --git a/Documentation/BUILDING.md b/Documentation/BUILDING.md index dfeb0037f0..268b92d213 100644 --- a/Documentation/BUILDING.md +++ b/Documentation/BUILDING.md @@ -45,7 +45,7 @@ the default is `auto` (use if found) unless noted otherwise. | `libkmod` | `auto` | 5 | Loading the nvme-fabrics module when needed. On Linux, nvme loads `libkmod.so.2` before it connects or discovers and doesn't link it, so nvme doesn't depend on libkmod; packages can make it a weak dependency. Without it, nvme doesn't load the module, which then has to be loaded beforehand | | `libdbus` | `disabled` | | End-point discovery for NVMe-MI | | `liburing` | `disabled` | 2.2 | Asynchronous admin and I/O passthrough commands through io_uring | -| `libarchive` | `auto` | | Archiving vendor plugin log captures (WDC, SanDisk, Micron, Samsung, Solidigm) as `.tar`/`.tar.gz`/`.zip`, without spawning an external `tar`/`zip` process. On Linux, nvme loads `libarchive.so.13` when it creates an archive and doesn't link it, so nvme and an initrd that carries it don't depend on libarchive; packages can make it a weak dependency. Without it, those capture subcommands fail with a clear error instead | +| `libarchive` | `auto` | | Archiving vendor plugin log captures (WDC, SanDisk, Micron, Samsung, Solidigm) as `.tar`/`.tar.gz`/`.zip`, without spawning an external `tar`/`zip` process. On Linux, nvme loads `libarchive.so.13` when it creates an archive and doesn't link it, so nvme and an initrd that carries it don't depend on libarchive; packages can make it a weak dependency. Without it, those capture subcommands fail with a clear error instead. A static build with `-Dlibarchive=enabled` builds libarchive from its wrap with zlib support only, rather than linking a system libarchive and everything it was built with; the Windows static build (`scripts/build.sh static_windows`) enables it | | `python` | `auto` | 3.6 | Python bindings for libnvme | | `nvme-discoverd` | `auto` | libsystemd 253 | The nvme-discoverd daemon; see [Daemons and systemd](#daemons-and-systemd) | | `mdns` | `auto` | libsystemd 258 | mDNS discovery in nvme-discoverd; see [Daemons and systemd](#daemons-and-systemd) | diff --git a/meson.build b/meson.build index f7e54b7a14..4b32d0a6fb 100644 --- a/meson.build +++ b/meson.build @@ -472,8 +472,37 @@ conf.set('CONFIG_KEYUTILS', keyutils_dep.found(), description: 'Is libkeyutils a if get_option('libarchive').disabled() libarchive_dep = dependency('', required: false) +elif is_static and get_option('libarchive').enabled() + # A static link embeds everything a system libarchive was built with, + # OpenSSL and libiconv included. Build the wrap with zlib alone (the + # plugins only write zip, tar and tar.gz); the subprojects override the + # libarchive and zlib dependencies. + subproject('zlib', default_options: ['werror=false']) + subproject('libarchive', default_options: [ + 'progs=[]', + 'zlib=enabled', + 'bz2lib=disabled', + 'libb2=disabled', + 'iconv=disabled', + 'lz4=disabled', + 'zstd=disabled', + 'lzma=disabled', + 'lzo2=disabled', + 'cng=disabled', + 'openssl=disabled', + 'xml2=disabled', + 'expat=disabled', + 'regex=disabled', + 'xattr=disabled', + 'acl=disabled', + 'tests=disabled', + 'werror=false', + ]) + libarchive_dep = dependency('libarchive') else - libarchive_dep = dependency('libarchive', required: get_option('libarchive')) + # Only static builds with libarchive enabled use the wraps. + libarchive_dep = dependency('libarchive', required: get_option('libarchive'), + allow_fallback: false) endif conf.set('CONFIG_LIBARCHIVE', libarchive_dep.found(), description: 'Is libarchive available?') # Load libarchive at runtime, so that nvme, and with it every initrd that diff --git a/scripts/build.sh b/scripts/build.sh index 69357bfc82..8c88d0f5aa 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -433,7 +433,7 @@ config_meson_static_windows() { --buildtype=release \ --default-library=static \ -Dc_link_args="-static" \ - -Dlibarchive=disabled \ + -Dlibarchive=enabled \ -Dpython=disabled \ -Dopenssl=disabled \ -Dtests=false \ @@ -672,6 +672,7 @@ config_muon_default() { -Dkeyutils=disabled \ -Djson-c=disabled \ -Dnvme-discoverd=disabled \ + -Dlibarchive=disabled \ "${BUILDDIR}" } diff --git a/subprojects/libarchive.wrap b/subprojects/libarchive.wrap new file mode 100644 index 0000000000..0c6255c1d4 --- /dev/null +++ b/subprojects/libarchive.wrap @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# This file is part of nvme. +# Copyright (c) 2026 Micron Technology, Inc. + +[wrap-file] +directory = libarchive-3.8.9 +source_url = https://github.com/libarchive/libarchive/releases/download/v3.8.9/libarchive-3.8.9.tar.xz +source_filename = libarchive-3.8.9.tar.xz +source_hash = 888c934f9d95648ecb9163dc8e23ab80a476ecb81a8f1154704a227b5b676dde +source_fallback_url = https://wrapdb.mesonbuild.com/v2/libarchive_3.8.9-1/get_source/libarchive-3.8.9.tar.xz +patch_filename = libarchive_3.8.9-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/libarchive_3.8.9-1/get_patch +patch_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/libarchive_3.8.9-1/libarchive_3.8.9-1_patch.zip +patch_hash = 78f21d8e126616c803acc228ae9251e91486e5f8016e3954541e883772342a69 +wrapdb_version = 3.8.9-1 + +[provide] +dependency_names = libarchive +program_names = bsdcat, bsdcpio, bsdtar diff --git a/subprojects/zlib.wrap b/subprojects/zlib.wrap new file mode 100644 index 0000000000..2cc8f1f6b8 --- /dev/null +++ b/subprojects/zlib.wrap @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# This file is part of nvme. +# Copyright (c) 2026 Micron Technology, Inc. + +[wrap-file] +directory = zlib-1.3.2 +source_url = https://zlib.net/zlib-1.3.2.tar.xz +source_fallback_url = https://wrapdb.mesonbuild.com/v2/zlib_1.3.2-1/get_source/zlib-1.3.2.tar.xz +source_filename = zlib-1.3.2.tar.xz +source_hash = d7a0654783a4da529d1bb793b7ad9c3318020af77667bcae35f95d0e42a792f3 +patch_filename = zlib_1.3.2-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/zlib_1.3.2-1/get_patch +patch_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/zlib_1.3.2-1/zlib_1.3.2-1_patch.zip +patch_hash = 5ae7a2e92f823df118cfb8c1b23d94e3117864392b3446581d669049b2fba6dd +wrapdb_version = 1.3.2-1 + +[provide] +dependency_names = zlib