diff mbox series

[bug#49898,v4] gnu: Add spectre-meltdown-checker.

Message ID ro6LEVb1lZX66TIhJRou2oJNVqkve4lPilQvbcIvlQSie3YYQHyNr4TGnW0etRRqv53uKAwAh2IbYG0FQFiH_exvAeqFq2I3zRBTqEYthMA=@protonmail.com
State New
Headers show
Series [bug#49898,v4] gnu: Add spectre-meltdown-checker. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

phodina Sept. 18, 2021, 3:25 p.m. UTC
Hi Leo,

I've substituted most of the commands. The only commands at the moment are echo and printf. I haven't found regexp that would work as they are text is also used for variables.

Otherwise the rest of the commands should be covered.
--8<---------------cut here---------------start------------->8--
* gnu/packages/linux.scm (spectre-meltdown-checker): New variable.

--
2.32.0

Comments

Liliana Marie Prikler Sept. 18, 2021, 5:03 p.m. UTC | #1
Hi Petr,

Am Samstag, den 18.09.2021, 15:25 +0000 schrieb phodina:
> [...]
> 
> 

> +         (add-after 'unpack 'fix-relative-locations
> +           (lambda* (#:key outputs #:allow-other-keys)
> +             (let ((icoreutils (assoc-ref %build-inputs
> "coreutils"))
> +                   (igrep (assoc-ref %build-inputs "grep"))
> +                   (iutil-linux (assoc-ref %build-inputs "util-
> linux"))
> +                   (iutil-linux-with-udev
> +                     (assoc-ref %build-inputs "util-linux-with-
> udev"))
> +                   (igawk (assoc-ref %build-inputs "gawk"))
> +                   (igzip (assoc-ref %build-inputs "gzip"))
> +                   (iunzip (assoc-ref %build-inputs "unzip"))
> +                   (ilzop (assoc-ref %build-inputs "lzop"))
> +                   (iperl (assoc-ref %build-inputs "perl"))
> +                   (iprocps (assoc-ref %build-inputs "procps"))
> +                   (isqlite (assoc-ref %build-inputs "sqlite"))
> +                   (iwget (assoc-ref %build-inputs "wget"))
> +                   (iwhich (assoc-ref %build-inputs "which"))
> +                   (ixz (assoc-ref %build-inputs "xz"))
> +                   (izstd (assoc-ref %build-inputs "zstd")))
I don't think Hungarian notation is very helpful here.
> +               (substitute* "spectre-meltdown-checker.sh"
> +                ; TODO: Find regexp what will work
> +                ;(("echo") (string-append icoreutils "/bin/echo"))
> +                ;(("printf") (string-append icoreutils
> "/bin/printf"))
There are multiple ways of handling this, but I thing the best one
would be to substitute both `command -v printf' and `which echo' with
the path to false, then match the line 
  [ -z "$echo_cmd" ] && echo_cmd='echo'
and instead put there
  echo_cmd_type='printf'
  echo_cmd=(path-to "/bin/printf")

> +                 (("dirname") (string-append icoreutils
> "/bin/dirname"))
> +                 (("cat") (string-append icoreutils "/bin/cat"))
> +                 (("grep[ ]+") (string-append igrep "/bin/grep "))
> +                 (("cut") (string-append icoreutils "/bin/cut"))
> +                 (("mktemp") (string-append icoreutils
> "/bin/mktemp"))
> +                 (("stat[ ]+") (string-append icoreutils "/bin/stat
> " ))
> +                 (("tail[ ]+") (string-append icoreutils "/bin/tail
> " ))
> +                 (("head[ ]+") (string-append icoreutils "/bin/head
> " ))
> +                 (("mount[ ]+")  "/run/setuid-programs/mount ")
> +                 (("modprobe") (string-append iutil-linux
> "/bin/modprobe"))
> +                 (("dd") (string-append icoreutils "/bin/dd"))
> +                 (("dmesg[ ]+") (string-append iutil-linux-with-udev 
> "/bin/dmesg "))
> +                 (("awk") (string-append igawk "/bin/awk"))
> +                 (("gzip") (string-append igzip "/bin/gzip"))
> +                 (("unzip") (string-append iunzip "/bin/unzip"))
> +                 (("lzop") (string-append ilzop "/bin/lzop"))
> +                 (("perl") (string-append iperl "/bin/perl"))
> +                 (("ps[ ]+") (string-append iprocps "/bin/ps "))
> +                 (("sqlite3") (string-append isqlite
> "/bin/sqlite3"))
> +                 (("wget") (string-append iwget "/bin/wget"))
> +                 (("which") (string-append iwhich "/bin/which"))
> +                 (("xz") (string-append ixz "/bin/xz"))
> +                 (("zstd") (string-append izstd "/bin/zstd")))))))))
Group those that need spaces and those that don't together, with an
explanation as to why those two groups exist.
> +    (inputs `(("binutils" ,binutils)
> +              ("coreutils",coreutils)
> +              ("gawk" ,gawk)
> +              ("grep" ,grep)
> +              ("gzip" ,gzip)
> +              ("unzip" ,unzip)
> +              ("lzop" ,lzop)
> +              ("perl" ,perl)
> +              ("procps" ,procps)
> +              ("sqlite" ,sqlite)
> +              ("util-linux" ,util-linux)
> +              ("util-linux-with-udev" ,util-linux+udev)
Why both?
> +              ("wget" ,wget)
> +              ("which" ,which)
> +              ("xz" ,xz)
> +              ("zstd" ,zstd)))
> +    (synopsis "Spectre, Meltdown ... vulnerability/mitigation
> checker")
> +    (description "A shell script to assess your system's resilience
> against
> +the several transient execution CVEs that were published since early
> 2018,
> +and give you guidance as to how to mitigate them.")
> +    (home-page "https://github.com/speed47/spectre-meltdown-checker"
> )
> +    (license license:gpl3)))
> +
>  (define-public snapscreenshot
>    (package
>      (name "snapscreenshot")
> --
> 2.32.0
diff mbox series

Patch

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 46c9f817a8..905048a5be 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -53,6 +53,7 @@ 
 ;;; Copyright © 2020 pukkamustard <pukkamustard@posteo.net>
 ;;; Copyright © 2021 B. Wilson <elaexuotee@wilsonb.com>
 ;;; Copyright © 2021 Ivan Gankevich <i.gankevich@spbu.ru>
+;;; Copyright © 2021 Petr Hodina <phodina@protonmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -138,6 +139,7 @@ 
   #:use-module (gnu packages video)
   #:use-module (gnu packages vulkan)
   #:use-module (gnu packages web)
+  #:use-module (gnu packages wget)
   #:use-module (gnu packages xiph)
   #:use-module (gnu packages xml)
   #:use-module (gnu packages xdisorg)
@@ -149,6 +151,7 @@ 
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
+  #:use-module (guix build-system copy)
   #:use-module (guix build-system meson)
   #:use-module (guix build-system python)
   #:use-module (guix build-system trivial)
@@ -7372,6 +7375,93 @@  interfaces in parallel environments.")
     (supported-systems '("i686-linux" "x86_64-linux"))
     (license (list license:bsd-2 license:gpl2)))) ;dual

+(define-public spectre-meltdown-checker
+  (package
+    (name "spectre-meltdown-checker")
+    (version "0.44")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/speed47/spectre-meltdown-checker")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1b47wlc52jnp2d5c7kbqnxmlm4g3cfbv25q30llv5mlmzs6d7bam"))))
+    (build-system copy-build-system)
+    (arguments
+     `(#:install-plan '(("spectre-meltdown-checker.sh"
+                         "bin/spectre-meltdown-checker.sh"))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'fix-relative-locations
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((icoreutils (assoc-ref %build-inputs "coreutils"))
+                   (igrep (assoc-ref %build-inputs "grep"))
+                   (iutil-linux (assoc-ref %build-inputs "util-linux"))
+                   (iutil-linux-with-udev
+                     (assoc-ref %build-inputs "util-linux-with-udev"))
+                   (igawk (assoc-ref %build-inputs "gawk"))
+                   (igzip (assoc-ref %build-inputs "gzip"))
+                   (iunzip (assoc-ref %build-inputs "unzip"))
+                   (ilzop (assoc-ref %build-inputs "lzop"))
+                   (iperl (assoc-ref %build-inputs "perl"))
+                   (iprocps (assoc-ref %build-inputs "procps"))
+                   (isqlite (assoc-ref %build-inputs "sqlite"))
+                   (iwget (assoc-ref %build-inputs "wget"))
+                   (iwhich (assoc-ref %build-inputs "which"))
+                   (ixz (assoc-ref %build-inputs "xz"))
+                   (izstd (assoc-ref %build-inputs "zstd")))
+               (substitute* "spectre-meltdown-checker.sh"
+                ; TODO: Find regexp what will work
+                ;(("echo") (string-append icoreutils "/bin/echo"))
+                ;(("printf") (string-append icoreutils "/bin/printf"))
+                 (("dirname") (string-append icoreutils "/bin/dirname"))
+                 (("cat") (string-append icoreutils "/bin/cat"))
+                 (("grep[ ]+") (string-append igrep "/bin/grep "))
+                 (("cut") (string-append icoreutils "/bin/cut"))
+                 (("mktemp") (string-append icoreutils "/bin/mktemp"))
+                 (("stat[ ]+") (string-append icoreutils "/bin/stat " ))
+                 (("tail[ ]+") (string-append icoreutils "/bin/tail " ))
+                 (("head[ ]+") (string-append icoreutils "/bin/head " ))
+                 (("mount[ ]+")  "/run/setuid-programs/mount ")
+                 (("modprobe") (string-append iutil-linux "/bin/modprobe"))
+                 (("dd") (string-append icoreutils "/bin/dd"))
+                 (("dmesg[ ]+") (string-append iutil-linux-with-udev "/bin/dmesg "))
+                 (("awk") (string-append igawk "/bin/awk"))
+                 (("gzip") (string-append igzip "/bin/gzip"))
+                 (("unzip") (string-append iunzip "/bin/unzip"))
+                 (("lzop") (string-append ilzop "/bin/lzop"))
+                 (("perl") (string-append iperl "/bin/perl"))
+                 (("ps[ ]+") (string-append iprocps "/bin/ps "))
+                 (("sqlite3") (string-append isqlite "/bin/sqlite3"))
+                 (("wget") (string-append iwget "/bin/wget"))
+                 (("which") (string-append iwhich "/bin/which"))
+                 (("xz") (string-append ixz "/bin/xz"))
+                 (("zstd") (string-append izstd "/bin/zstd")))))))))
+    (inputs `(("binutils" ,binutils)
+              ("coreutils",coreutils)
+              ("gawk" ,gawk)
+              ("grep" ,grep)
+              ("gzip" ,gzip)
+              ("unzip" ,unzip)
+              ("lzop" ,lzop)
+              ("perl" ,perl)
+              ("procps" ,procps)
+              ("sqlite" ,sqlite)
+              ("util-linux" ,util-linux)
+              ("util-linux-with-udev" ,util-linux+udev)
+              ("wget" ,wget)
+              ("which" ,which)
+              ("xz" ,xz)
+              ("zstd" ,zstd)))
+    (synopsis "Spectre, Meltdown ... vulnerability/mitigation checker")
+    (description "A shell script to assess your system's resilience against
+the several transient execution CVEs that were published since early 2018,
+and give you guidance as to how to mitigate them.")
+    (home-page "https://github.com/speed47/spectre-meltdown-checker")
+    (license license:gpl3)))
+
 (define-public snapscreenshot
   (package
     (name "snapscreenshot")