Skip to content

Commit

Permalink
feat: add nvme cli
Browse files Browse the repository at this point in the history
Add nvme cli.

Fixes: #562

Signed-off-by: Noel Georgi <[email protected]>
  • Loading branch information
frezbo committed Jan 20, 2025
1 parent 4a2e536 commit 08b7478
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@
"containers/crun",
"git://git.kernel.org/pub/scm/libs/libcap/libcap.git",
"git://sourceware.org/git/elfutils.git",
"git://git.kernel.org/pub/scm/utils/mdadm/mdadm.git"
"git://git.kernel.org/pub/scm/utils/mdadm/mdadm.git",
"linux-nvme/libnvme",
"linux-nvme/nvme-cli"
]
},
{
Expand Down
3 changes: 3 additions & 0 deletions .kres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ spec:
- nvidia-fabricmanager-production
- nvidia-open-gpu-kernel-modules-lts
- nvidia-open-gpu-kernel-modules-production
- nvme-cli
- qemu-guest-agent
- qlogic-firmware
- realtek-firmware
Expand Down Expand Up @@ -178,6 +179,8 @@ spec:
- git://git.kernel.org/pub/scm/libs/libcap/libcap.git
- git://sourceware.org/git/elfutils.git
- git://git.kernel.org/pub/scm/utils/mdadm/mdadm.git
- linux-nvme/libnvme
- linux-nvme/nvme-cli
versioning: 'regex:^(?<major>\d+)\.(?<minor>\d+)\.?(?<patch>\d+)?$'
- matchPackageNames:
- https://sourceware.org/git/glibc.git
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ TARGETS += nvidia-fabricmanager-lts
TARGETS += nvidia-fabricmanager-production
TARGETS += nvidia-open-gpu-kernel-modules-lts
TARGETS += nvidia-open-gpu-kernel-modules-production
TARGETS += nvme-cli
TARGETS += qemu-guest-agent
TARGETS += qlogic-firmware
TARGETS += realtek-firmware
Expand Down
38 changes: 38 additions & 0 deletions tools/nvme-cli/libnvme/pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: libnvme
variant: scratch
shell: /toolchain/bin/bash
dependencies:
- stage: base
- image: "{{ .BUILD_ARG_PKGS_PREFIX }}/openssl:{{ .BUILD_ARG_PKGS }}"
- image: "{{ .BUILD_ARG_PKGS_PREFIX }}/libjson-c:{{ .BUILD_ARG_PKGS }}"
steps:
- sources:
- url: https://github.com/linux-nvme/libnvme/archive/refs/tags/{{ .LIBNVME_VERSION }}.tar.gz
destination: libnvme.tar.gz
sha256: 6d5d8ba2cc4c94a61a994c9f7f25b3b26ef973fb5c0daa37729890903f37a1f1
sha512: 8720f2907a3d13af44fb3deec883cd6eb247d5861c4459b5fe0e67ff9ecfb565462a5faf39d43e08b5284f3e8ca8e72d41b333984beaa45d3287b1a258f3e59d
prepare:
- |
tar xf libnvme.tar.gz --strip-components=1
mkdir -p /usr/bin
ln -s /toolchain/bin/env /usr/bin/env
ln -s /toolchain/bin/python3 /toolchain/bin/python
pip3 install ninja
export PKG_CONFIG_PATH=/usr/lib/pkgconfig
meson setup \
-Db_lto=true \
-Djson-c=enabled \
-Dpython=disabled \
.build
build:
- |
meson compile -C .build
install:
- |
DESTDIR=/rootfs meson install -C .build
finalize:
- from: /rootfs
to: /rootfs
10 changes: 10 additions & 0 deletions tools/nvme-cli/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: v1alpha1
metadata:
name: nvme-cli
version: "$VERSION"
author: Sidero Labs
description: |
This system extension provides the NVMe command line interface.
compatibility:
talos:
version: ">= v1.0.0"
11 changes: 11 additions & 0 deletions tools/nvme-cli/patches/basename.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/main/nvme-cli/basename.patch
--- a/plugins/netapp/netapp-nvme.c 2024-10-31 10:39:11
+++ b/plugins/netapp/netapp-nvme.c 2024-11-11 21:02:24
@@ -22,6 +22,7 @@
#include <unistd.h>
#include <errno.h>
#include <string.h>
+#include <libgen.h>

#include "common.h"
#include "nvme.h"
16 changes: 16 additions & 0 deletions tools/nvme-cli/patches/locale.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
https://gitlab.alpinelinux.org/alpine/aports/-/blob/master/main/nvme-cli/locale.patch
diff --git a/nvme-print.c b/nvme-print.c
index 170e5c12..5b1f2e82 100644
--- a/nvme-print.c
+++ b/nvme-print.c
@@ -797,6 +797,10 @@ static bool is_fahrenheit_country(const char *country)
return false;
}

+#ifndef LC_MEASUREMENT
+#define LC_MEASUREMENT LC_ALL
+#endif
+
static bool is_temperature_fahrenheit(void)
{
const char *locale, *underscore;
59 changes: 59 additions & 0 deletions tools/nvme-cli/pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: nvme-cli
variant: scratch
shell: /toolchain/bin/bash
dependencies:
- stage: base
- image: "{{ .BUILD_ARG_PKGS_PREFIX }}/openssl:{{ .BUILD_ARG_PKGS }}"
- image: "{{ .BUILD_ARG_PKGS_PREFIX }}/libjson-c:{{ .BUILD_ARG_PKGS }}"
- stage: libnvme
from: /rootfs # build dependency
- stage: libnvme
from: /rootfs
to: /rootfs
steps:
- sources:
- url: https://github.com/linux-nvme/nvme-cli/archive/refs/tags/{{ .NVME_CLI_VERSION }}.tar.gz
destination: nvme-cli.tar.gz
sha256: 5e4dc73dbb488c6b1e6ad1c78d0c62b624076fcb0c052bd9039674a1dbd6517b
sha512: 33de20ad990a3b87fef46fa486832edde41907223aa6b8a47606e605b360745fd7e2054226bf93a59b2a09c6bc04d0b684e4b3bb27c3fc0e6110c64a558cadc0
prepare:
- |
tar xf nvme-cli.tar.gz --strip-components=1
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig
mkdir -p /usr/bin
ln -s /toolchain/bin/env /usr/bin/env
ln -s /toolchain/bin/python3 /toolchain/bin/python
pip3 install ninja
export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig
patch -p1 < /pkg/patches/locale.patch
patch -p1 < /pkg/patches/basename.patch
meson setup \
-Db_lto=true \
-Dudevrulesdir=/usr/lib/udev/rules.d \
-Djson-c=enabled \
.build
- |
sed -i 's#$VERSION#{{ .NVME_CLI_VERSION }}#' /pkg/manifest.yaml
build:
- |
meson compile -C .build
install:
- |
DESTDIR=/rootfs meson install -C .build
rm -rf /rootfs/usr/local/{include,lib/{dracut,systemd},share}
test:
- |
mkdir -p /extensions-validator-rootfs
cp -r /rootfs/ /extensions-validator-rootfs/rootfs
cp /pkg/manifest.yaml /extensions-validator-rootfs/manifest.yaml
/extensions-validator validate --rootfs=/extensions-validator-rootfs --pkg-name="${PKG_NAME}"
finalize:
- from: /rootfs
to: /rootfs
- from: /pkg/manifest.yaml
to: /
1 change: 1 addition & 0 deletions tools/nvme-cli/vars.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION: "{{ .NVME_CLI_VERSION }}"
4 changes: 4 additions & 0 deletions tools/vars.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# renovate: datasource=github-releases depName=linux-nvme/libnvme
LIBNVME_VERSION: v1.11.1
# renovate: datasource=github-releases depName=linux-nvme/nvme-cli
NVME_CLI_VERSION: v2.11

0 comments on commit 08b7478

Please sign in to comment.