From 1aa767cd3571891bb951c5688a484b18d213b178 Mon Sep 17 00:00:00 2001 From: Petr Hodina Date: Sat, 26 Apr 2025 10:58:34 +0200 Subject: [PATCH] psb_status: init at 0-unstable-2024-10-10 --- .../iotools/001-fix-werror-in-sprintf.patch | 26 ++++++++--- pkgs/by-name/ps/psb_status/package.nix | 44 +++++++++++++++++++ 2 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 pkgs/by-name/ps/psb_status/package.nix diff --git a/pkgs/by-name/io/iotools/001-fix-werror-in-sprintf.patch b/pkgs/by-name/io/iotools/001-fix-werror-in-sprintf.patch index 58d6e01de398..22a0b87b8f36 100644 --- a/pkgs/by-name/io/iotools/001-fix-werror-in-sprintf.patch +++ b/pkgs/by-name/io/iotools/001-fix-werror-in-sprintf.patch @@ -1,13 +1,27 @@ diff --git a/commands.c b/commands.c -index a83f1d5..b3f217a 100644 +index a28e6da..0f76ac7 100644 --- a/commands.c +++ b/commands.c -@@ -152,1 +152,7 @@ build_symlink_name(const char *path_to_bin, const struct cmd_info *cmd) +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + #include + #include "commands.h" + #include "platform.h" +@@ -150,7 +151,13 @@ build_symlink_name(const char *path_to_bin, const struct cmd_info *cmd) + { + static char link_name[FILENAME_MAX]; + - snprintf(link_name, FILENAME_MAX, "%s/%s", path_to_bin, cmd->name); -+ int result = snprintf(link_name, FILENAME_MAX, "%s/%s", path_to_bin, cmd->name); ++ int result = snprintf(link_name, PATH_MAX, "%s/%s", path_to_bin, cmd->name); + -+ if (result >= FILENAME_MAX) { -+ link_name[FILENAME_MAX - 1] = '\0'; -+ } else if (result < 0) { ++ if (result >= PATH_MAX) { ++ link_name[PATH_MAX - 1] = '\0'; ++ } else if (result < 0) { + link_name[0] = '\0'; + } + + return link_name; + } diff --git a/pkgs/by-name/ps/psb_status/package.nix b/pkgs/by-name/ps/psb_status/package.nix new file mode 100644 index 000000000000..86098227854e --- /dev/null +++ b/pkgs/by-name/ps/psb_status/package.nix @@ -0,0 +1,44 @@ +{ + lib, + stdenvNoCC, + fetchFromGitHub, + bash, + iotools, + makeWrapper, +}: + +stdenvNoCC.mkDerivation (finalAttrs: { + pname = "psb_status"; + version = "0-unstable-2024-10-10"; + + src = fetchFromGitHub { + owner = "mkopec"; + repo = "psb_status"; + rev = "be896832c53d6b0b70cf8a87f7ee46ad33deefc2"; + hash = "sha256-4anPyjO8y3FgnYWa4bGFxI8Glk9srw/XF552tnixc8I="; + }; + + dontBuild = true; + + nativeBuildInputs = [ makeWrapper ]; + + installPhase = '' + runHook preInstall + + mkdir -p $out/bin + install -m755 psb_status.sh $out/bin/psb_status + wrapProgram $out/bin/psb_status \ + --prefix PATH : ${lib.makeBinPath [ iotools ]} + + runHook postInstall + ''; + + meta = { + description = "Script to check Platform Secure Boot enablement on Zen based AMD CPUs"; + homepage = "https://github.com/mkopec/psb_status"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ phodina ]; + platforms = [ "x86_64-linux" ]; + mainProgram = "psb_status"; + }; +})