gnu: linux-libre: Update deblobbing scripts.
[jackhill/guix/guix.git] / gnu / packages / linux.scm
index 83c23dc..3f9103a 100644 (file)
@@ -34,6 +34,8 @@
 ;;; Copyright © 2018 Vasile Dumitrascu <va511e@yahoo.com>
 ;;; Copyright © 2019 Tim Gesthuizen <tim.gesthuizen@yahoo.de>
 ;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2019 Stefan Stefanović <stefanx2ovic@gmail.com>
+;;; Copyright © 2019 Pierre Langlois <pierre.langlois@gmx.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
   #:use-module (gnu packages samba)
   #:use-module (gnu packages serialization)
   #:use-module (gnu packages slang)
-  #:use-module (gnu packages storage)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages valgrind)
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
+  #:use-module (guix gexp)
+  #:use-module (guix store)
+  #:use-module (guix monads)
   #:use-module (guix utils)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-2)
           ((string-prefix? "alpha" arch) "alpha")
           ((string-prefix? "powerpc" arch) "powerpc") ;including "powerpc64le"
           ((string-prefix? "s390" arch) "s390")
+          ((string-prefix? "riscv" arch) "riscv")
           (else arch))))
 
 (define-public (system->defconfig system)
@@ -153,6 +158,174 @@ defconfig.  Return the appropriate make target if applicable, otherwise return
         ((string-prefix? "powerpc64le-" system) "ppc64_defconfig")
         (else "defconfig")))
 
+\f
+;;;
+;;; Kernel source code deblobbing.
+;;;
+
+(define (linux-libre-deblob-scripts version
+                                    deblob-hash
+                                    deblob-check-hash)
+  (list (version-major+minor version)
+        (origin
+          (method url-fetch)
+          (uri (string-append "https://linux-libre.fsfla.org"
+                              "/pub/linux-libre/releases/" version "-gnu/"
+                              "deblob-" (version-major+minor version)))
+          (sha256 deblob-hash))
+        (origin
+          (method url-fetch)
+          (uri (string-append "https://linux-libre.fsfla.org"
+                              "/pub/linux-libre/releases/" version "-gnu/"
+                              "deblob-check"))
+          (sha256 deblob-check-hash))))
+
+(define deblob-scripts-5.2
+  (linux-libre-deblob-scripts
+   "5.2.3"
+   (base32 "076fwxlm6jq6z4vg1xq3kr474zz7qk71r90sf9dnfia3rw2pb4fa")
+   (base32 "0d3pp1bqchqc7vnxr1a56km5r0hzjiiipzz2xc3wgjwfi51k9kxc")))
+
+(define deblob-scripts-4.19
+  (linux-libre-deblob-scripts
+   "4.19.61"
+   (base32 "02zs405awaxydbapka4nz8h6lmnc0dahgczqsrs5s2bmzjyyqkcy")
+   (base32 "1fyacg28aym6virxyn7wk99qil2fjbks3iwm7p3hxy51pccn34za")))
+
+(define deblob-scripts-4.14
+  (linux-libre-deblob-scripts
+   "4.14.134"
+   (base32 "091jk9jkn9jf39bxpc7395bhcb7p96nkg3a8047380ki06lnfxh6")
+   (base32 "0x9nd3hnyrm753cbgdqmy92mbnyw86w64g4hvyibnkpq5n7s3z9n")))
+
+(define deblob-scripts-4.9
+  (linux-libre-deblob-scripts
+   "4.9.186"
+   (base32 "1wvldzlv7q2xdbadas87dh593nxr4a8p5n0f8zpm72lja6w18hmg")
+   (base32 "1gmjn5cwxydg6qb47wcmahwkv37npsjx4papynzkkdxyidmrccya")))
+
+(define deblob-scripts-4.4
+  (linux-libre-deblob-scripts
+   "4.4.186"
+   (base32 "0x2j1i88am54ih2mk7gyl79g25l9zz4r08xhl482l3fvjj2irwbw")
+   (base32 "1x40lbiaizksy8z38ax7wpqr9ldgq7qvkxbb0ca98vd1axpklb10")))
+
+(define* (computed-origin-method gexp-promise hash-algo hash
+                                 #:optional (name "source")
+                                 #:key (system (%current-system))
+                                 (guile (default-guile)))
+  "Return a derivation that executes the G-expression that results
+from forcing GEXP-PROMISE."
+  (mlet %store-monad ((guile (package->derivation guile system)))
+    (gexp->derivation (or name "computed-origin")
+                      (force gexp-promise)
+                      #:graft? #f       ;nothing to graft
+                      #:system system
+                      #:guile-for-build guile)))
+
+(define (make-linux-libre-source version
+                                 upstream-source
+                                 deblob-scripts)
+  "Return a 'computed' origin that generates a Linux-libre tarball from the
+corresponding UPSTREAM-SOURCE (an origin), using the given DEBLOB-SCRIPTS."
+  (match deblob-scripts
+    ((deblob-version (? origin? deblob) (? origin? deblob-check))
+     (unless (string=? deblob-version (version-major+minor version))
+       ;; The deblob script cannot be expected to work properly on a
+       ;; different version (major+minor) of Linux, even if no errors
+       ;; are signaled during execution.
+       (error "deblob major+minor version mismatch"))
+     (origin
+       (method computed-origin-method)
+       (file-name (string-append "linux-libre-" version "-guix.tar.xz"))
+       (sha256 #f)
+       (uri
+        (delay
+          (with-imported-modules '((guix build utils))
+            #~(begin
+                (use-modules (guix build utils)
+                             (srfi srfi-1)
+                             (ice-9 match)
+                             (ice-9 ftw))
+                (let ((dir (string-append "linux-" #$version)))
+
+                  (mkdir "/tmp/bin")
+                  (set-path-environment-variable
+                   "PATH" '("bin")
+                   (list "/tmp"
+                         #+(canonical-package bash)
+                         #+(canonical-package coreutils)
+                         #+(canonical-package diffutils)
+                         #+(canonical-package findutils)
+                         #+(canonical-package patch)
+                         #+(canonical-package xz)
+                         #+(canonical-package sed)
+                         #+(canonical-package grep)
+                         #+(canonical-package bzip2)
+                         #+(canonical-package gzip)
+                         #+(canonical-package tar)
+                         ;; The comments in the 'deblob-check' script
+                         ;; claim that it supports Python 2 and 3, but
+                         ;; in fact it fails when run in Python 3 as
+                         ;; of version 5.1.3.
+                         #+python-2))
+
+                  (with-directory-excursion "/tmp/bin"
+
+                    (copy-file #+deblob "deblob")
+                    (chmod "deblob" #o755)
+                    (substitute* "deblob"
+                      (("/bin/sh") (which "sh")))
+
+                    (copy-file #+deblob-check "deblob-check")
+                    (chmod "deblob-check" #o755)
+                    (substitute* "deblob-check"
+                      (("/bin/sh") (which "sh"))
+                      (("/bin/sed") (which "sed"))
+                      (("/usr/bin/python") (which "python"))))
+
+                  (if (file-is-directory? #+upstream-source)
+                      (begin
+                        (format #t "Copying upstream linux source...~%")
+                        (force-output)
+                        (invoke "cp" "--archive" #+upstream-source dir)
+                        (invoke "chmod" "--recursive" "u+w" dir))
+                      (begin
+                        (format #t "Unpacking upstream linux tarball...~%")
+                        (force-output)
+                        (invoke "tar" "xf" #$upstream-source)
+                        (match (scandir "."
+                                        (lambda (name)
+                                          (and (not (member name '("." "..")))
+                                               (file-is-directory? name))))
+                          ((unpacked-dir)
+                           (unless (string=? dir unpacked-dir)
+                             (rename-file unpacked-dir dir)))
+                          (dirs
+                           (error "multiple directories found" dirs)))))
+
+                  (with-directory-excursion dir
+                    (setenv "PYTHON" (which "python"))
+                    (format #t "Running deblob script...~%")
+                    (force-output)
+                    (invoke "/tmp/bin/deblob"))
+
+                  (format #t "~%Packing new Linux-libre tarball...~%")
+                  (force-output)
+                  (invoke "tar" "cvfa" #$output
+                          ;; Avoid non-determinism in the archive.
+                          "--mtime=@0"
+                          "--owner=root:0"
+                          "--group=root:0"
+                          "--sort=name"
+                          "--hard-dereference"
+                          dir))))))))))
+
+\f
+;;;
+;;; Kernel sources.
+;;;
+
 (define (linux-libre-urls version)
   "Return a list of URLs for Linux-Libre VERSION."
   (list (string-append
@@ -169,18 +342,127 @@ defconfig.  Return the appropriate make target if applicable, otherwise return
          "mirror://gnu/linux-libre/" version "-gnu/linux-libre-"
          version "-gnu.tar.xz")))
 
-(define-public linux-libre-headers
+(define (%upstream-linux-source version hash)
+  (origin
+    (method url-fetch)
+    (uri (string-append "mirror://kernel.org"
+                        "/linux/kernel/v" (version-major version) ".x/"
+                        "linux-" version ".tar.xz"))
+    (sha256 hash)))
+
+(define-public linux-libre-5.2-version "5.2.2")
+(define-public linux-libre-5.2-pristine-source
+  (let ((version linux-libre-5.2-version)
+        (hash (base32 "173da67d51qcjwrczqsfd6g9phzazqzr11xfxwlf54ckd6117ng5")))
+   (make-linux-libre-source version
+                            (%upstream-linux-source version hash)
+                            deblob-scripts-5.2)))
+
+(define-public linux-libre-4.19-version "4.19.60")
+(define-public linux-libre-4.19-pristine-source
+  (let ((version linux-libre-4.19-version)
+        (hash (base32 "0ibayrvrnw2lw7si78vdqnr20mm1d3z0g6a0ykndvgn5vdax5x9a")))
+    (make-linux-libre-source version
+                             (%upstream-linux-source version hash)
+                             deblob-scripts-4.19)))
+
+(define-public linux-libre-4.14-version "4.14.134")
+(define-public linux-libre-4.14-pristine-source
+  (let ((version linux-libre-4.14-version)
+        (hash (base32 "0b9xj1rwr5fpw2giirfghzxxc0wp1hwf4nqvalx314pxxysyf88b")))
+    (make-linux-libre-source version
+                             (%upstream-linux-source version hash)
+                             deblob-scripts-4.14)))
+
+(define-public linux-libre-4.9-version "4.9.186")
+(define-public linux-libre-4.9-pristine-source
+  (let ((version linux-libre-4.9-version)
+        (hash (base32 "0sjbp7m6d625rw06wv34a0805d1lgldii4pxiqfpja871m1q8914")))
+    (make-linux-libre-source version
+                             (%upstream-linux-source version hash)
+                             deblob-scripts-4.9)))
+
+(define-public linux-libre-4.4-version "4.4.186")
+(define-public linux-libre-4.4-pristine-source
+  (let ((version linux-libre-4.4-version)
+        (hash (base32 "113rjf8842glzi23y1g1yrwncihv2saah6wz0r726r06bk9p64hb")))
+    (make-linux-libre-source version
+                             (%upstream-linux-source version hash)
+                             deblob-scripts-4.4)))
+
+(define %boot-logo-patch
+  ;; Linux-Libre boot logo featuring Freedo and a gnu.
+  (origin
+    (method url-fetch)
+    (uri (string-append "http://www.fsfla.org/svn/fsfla/software/linux-libre/"
+                        "lemote/gnewsense/branches/3.16/100gnu+freedo.patch"))
+    (sha256
+     (base32
+      "1hk9swxxc80bmn2zd2qr5ccrjrk28xkypwhl4z0qx4hbivj7qm06"))))
+
+(define %linux-libre-arm-export-__sync_icache_dcache-patch
+  (origin
+    (method url-fetch)
+    (uri (string-append
+          "https://salsa.debian.org/kernel-team/linux"
+          "/raw/34a7d9011fcfcfa38b68282fd2b1a8797e6834f0"
+          "/debian/patches/bugfix/arm/"
+          "arm-mm-export-__sync_icache_dcache-for-xen-privcmd.patch"))
+    (file-name "linux-libre-arm-export-__sync_icache_dcache.patch")
+    (sha256
+     (base32 "1ifnfhpakzffn4b8n7x7w5cps9mzjxlkcfz9zqak2vaw8nzvl39f"))))
+
+(define (source-with-patches source patches)
+  (origin
+    (inherit source)
+    (patches (append (origin-patches source)
+                     patches))))
+
+(define-public linux-libre-5.2-source
+  (source-with-patches linux-libre-5.2-pristine-source
+                       (list %boot-logo-patch
+                             %linux-libre-arm-export-__sync_icache_dcache-patch)))
+
+(define-public linux-libre-4.19-source
+  (source-with-patches linux-libre-4.19-pristine-source
+                       (list %boot-logo-patch
+                             %linux-libre-arm-export-__sync_icache_dcache-patch)))
+
+(define-public linux-libre-4.14-source
+  (source-with-patches linux-libre-4.14-pristine-source
+                       (list %boot-logo-patch)))
+
+(define-public linux-libre-4.9-source
+  (source-with-patches linux-libre-4.9-pristine-source
+                       (list %boot-logo-patch)))
+
+(define-public linux-libre-4.4-source
+  (source-with-patches linux-libre-4.4-pristine-source
+                       (list %boot-logo-patch)))
+
+\f
+;;;
+;;; Kernel headers.
+;;;
+
+(define (make-linux-libre-headers version hash-string)
+  (make-linux-libre-headers* version
+                             (origin
+                               (method url-fetch)
+                               (uri (linux-libre-urls version))
+                               (sha256 (base32 hash-string)))))
+
+(define (make-linux-libre-headers* version source)
   (package
     (name "linux-libre-headers")
-    (version "4.14.67")
-    (source (origin
-             (method url-fetch)
-             (uri (linux-libre-urls version))
-             (sha256
-              (base32
-               "050zvdxjy6sc64q75pr1gxsmh49chwav2pwxz8xlif39bvahnrpg"))))
+    (version version)
+    (source source)
     (build-system gnu-build-system)
-    (native-inputs `(("perl" ,perl)))
+    (native-inputs `(("perl" ,perl)
+                     ,@(if (version>=? version "4.16")
+                           `(("flex" ,flex)
+                             ("bison" ,bison))
+                           '())))
     (arguments
      `(#:modules ((guix build gnu-build-system)
                   (guix build utils)
@@ -228,27 +510,38 @@ defconfig.  Return the appropriate make target if applicable, otherwise return
     (description "Headers of the Linux-Libre kernel.")
     (license license:gpl2)))
 
-(define %boot-logo-patch
-  ;; Linux-Libre boot logo featuring Freedo and a gnu.
-  (origin
-    (method url-fetch)
-    (uri (string-append "http://www.fsfla.org/svn/fsfla/software/linux-libre/"
-                        "lemote/gnewsense/branches/3.16/100gnu+freedo.patch"))
-    (sha256
-     (base32
-      "1hk9swxxc80bmn2zd2qr5ccrjrk28xkypwhl4z0qx4hbivj7qm06"))))
+(define-public linux-libre-headers-5.2
+  (make-linux-libre-headers* linux-libre-5.2-version
+                             linux-libre-5.2-source))
 
-(define %linux-libre-arm-export-__sync_icache_dcache-patch
-  (origin
-    (method url-fetch)
-    (uri (string-append
-          "https://salsa.debian.org/kernel-team/linux"
-          "/raw/34a7d9011fcfcfa38b68282fd2b1a8797e6834f0"
-          "/debian/patches/bugfix/arm/"
-          "arm-mm-export-__sync_icache_dcache-for-xen-privcmd.patch"))
-    (file-name "linux-libre-arm-export-__sync_icache_dcache.patch")
-    (sha256
-     (base32 "1ifnfhpakzffn4b8n7x7w5cps9mzjxlkcfz9zqak2vaw8nzvl39f"))))
+(define-public linux-libre-headers-4.19
+  (make-linux-libre-headers* linux-libre-4.19-version
+                             linux-libre-4.19-source))
+
+(define-public linux-libre-headers-4.14
+  (make-linux-libre-headers* linux-libre-4.14-version
+                             linux-libre-4.14-source))
+
+(define-public linux-libre-headers-4.9
+  (make-linux-libre-headers* linux-libre-4.9-version
+                             linux-libre-4.9-source))
+
+(define-public linux-libre-headers-4.4
+  (make-linux-libre-headers* linux-libre-4.4-version
+                             linux-libre-4.4-source))
+
+;; The following package is used in the early bootstrap, and thus must be kept
+;; stable and with minimal build requirements.
+(define-public linux-libre-headers-4.14.67
+  (make-linux-libre-headers "4.14.67"
+                            "050zvdxjy6sc64q75pr1gxsmh49chwav2pwxz8xlif39bvahnrpg"))
+
+(define-public linux-libre-headers linux-libre-headers-4.14.67)
+
+\f
+;;;
+;;; Kernel configurations.
+;;;
 
 (define* (kernel-config arch #:key variant)
   "Return the absolute file name of the Linux-Libre build configuration file
@@ -268,7 +561,9 @@ for ARCH and optionally VARIANT, or #f if there is no such configuration."
     (search-auxiliary-file file)))
 
 (define %default-extra-linux-options
-  `(;; Modules required for initrd:
+  `(;; Some very mild hardening.
+    ("CONFIG_SECURITY_DMESG_RESTRICT" . #t)
+    ;; Modules required for initrd:
     ("CONFIG_NET_9P" . m)
     ("CONFIG_NET_9P_VIRTIO" . m)
     ("CONFIG_VIRTIO_BLK" . m)
@@ -291,7 +586,12 @@ for ARCH and optionally VARIANT, or #f if there is no such configuration."
                     options)
                "\n"))
 
-(define* (make-linux-libre version hash supported-systems
+\f
+;;;
+;;; Kernel package utilities.
+;;;
+
+(define* (make-linux-libre version hash-string supported-systems
                            #:key
                            ;; A function that takes an arch and a variant.
                            ;; See kernel-config for an example.
@@ -300,16 +600,32 @@ for ARCH and optionally VARIANT, or #f if there is no such configuration."
                            (defconfig "defconfig")
                            (extra-options %default-extra-linux-options)
                            (patches (list %boot-logo-patch)))
+  (make-linux-libre* version
+                     (origin
+                       (method url-fetch)
+                       (uri (linux-libre-urls version))
+                       (sha256 (base32 hash-string))
+                       (patches patches))
+                     supported-systems
+                     #:extra-version extra-version
+                     #:configuration-file configuration-file
+                     #:defconfig defconfig
+                     #:extra-options extra-options))
+
+(define* (make-linux-libre* version source supported-systems
+                            #:key
+                            ;; A function that takes an arch and a variant.
+                            ;; See kernel-config for an example.
+                            (extra-version #f)
+                            (configuration-file #f)
+                            (defconfig "defconfig")
+                            (extra-options %default-extra-linux-options))
   (package
     (name (if extra-version
               (string-append "linux-libre-" extra-version)
               "linux-libre"))
     (version version)
-    (source (origin
-              (method url-fetch)
-              (uri (linux-libre-urls version))
-              (sha256 (base32 hash))
-              (patches patches)))
+    (source source)
     (supported-systems supported-systems)
     (build-system gnu-build-system)
     (native-inputs
@@ -351,11 +667,6 @@ for ARCH and optionally VARIANT, or #f if there is no such configuration."
              (substitute* (find-files "." "^Makefile(\\.include)?$")
                (("/bin/pwd") "pwd"))
              #t))
-         (add-before 'configure 'work-around-gcc-7-include-path-issue
-           (lambda _
-             (unsetenv "C_INCLUDE_PATH")
-             (unsetenv "CPLUS_INCLUDE_PATH")
-             #t))
          (replace 'configure
            (lambda* (#:key inputs native-inputs target #:allow-other-keys)
              ;; Avoid introducing timestamps
@@ -426,114 +737,105 @@ for ARCH and optionally VARIANT, or #f if there is no such configuration."
 It has been modified to remove all non-free binary blobs.")
     (license license:gpl2)))
 
-(define %linux-libre-version "5.1.4")
-(define %linux-libre-hash "02pzad29w2apcqsk4r4fq93539z3by8kvk1f59lb8xnl0gvhdi5v")
-
-(define %linux-libre-5.1-patches
-  (list %boot-logo-patch
-        %linux-libre-arm-export-__sync_icache_dcache-patch))
-
-(define-public linux-libre
-  (make-linux-libre %linux-libre-version
-                    %linux-libre-hash
-                    '("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux")
-                    #:patches %linux-libre-5.1-patches
-                    #:configuration-file kernel-config))
+\f
+;;;
+;;; Generic kernel packages.
+;;;
 
-(define %linux-libre-4.19-version "4.19.45")
-(define %linux-libre-4.19-hash "1wiy8vzpzzml4k76nv3ycjx7ky55x7dqx3mgpjqbh73mj2gcr5bx")
+(define-public linux-libre-5.2
+  (make-linux-libre* linux-libre-5.2-version
+                     linux-libre-5.2-source
+                     '("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux")
+                     #:configuration-file kernel-config))
 
-(define %linux-libre-4.19-patches
-  (list %boot-logo-patch
-        %linux-libre-arm-export-__sync_icache_dcache-patch))
+(define-public linux-libre-version         linux-libre-5.2-version)
+(define-public linux-libre-pristine-source linux-libre-5.2-pristine-source)
+(define-public linux-libre-source          linux-libre-5.2-source)
+(define-public linux-libre                 linux-libre-5.2)
 
 (define-public linux-libre-4.19
-  (make-linux-libre %linux-libre-4.19-version
-                    %linux-libre-4.19-hash
-                    '("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux")
-                    #:patches %linux-libre-4.19-patches
-                    #:configuration-file kernel-config))
-
-(define %linux-libre-4.14-version "4.14.121")
-(define %linux-libre-4.14-hash "1g7gyjmp056pasf9m34dqs8pa15my6hqasdd551jw8mgkbhsfnxg")
+  (make-linux-libre* linux-libre-4.19-version
+                     linux-libre-4.19-source
+                     '("x86_64-linux" "i686-linux" "armhf-linux" "aarch64-linux")
+                     #:configuration-file kernel-config))
 
 (define-public linux-libre-4.14
-  (make-linux-libre %linux-libre-4.14-version
-                    %linux-libre-4.14-hash
-                    '("x86_64-linux" "i686-linux" "armhf-linux")
-                    #:configuration-file kernel-config))
+  (make-linux-librelinux-libre-4.14-version
+                     linux-libre-4.14-source
+                     '("x86_64-linux" "i686-linux" "armhf-linux")
+                     #:configuration-file kernel-config))
 
 (define-public linux-libre-4.9
-  (make-linux-libre "4.9.178"
-                    "1ridlkymf382qnkc6hi07pkghrrxfv2avx55snjnkfcpdccvsmrb"
-                    '("x86_64-linux" "i686-linux")
-                    #:configuration-file kernel-config))
+  (make-linux-libre* linux-libre-4.9-version
+                     linux-libre-4.9-source
+                     '("x86_64-linux" "i686-linux")
+                     #:configuration-file kernel-config))
 
 (define-public linux-libre-4.4
-  (make-linux-libre "4.4.180"
-                    "157kfs4slii86q9yrspvqdynpiv6rff80hrrn569v6h4nkc4b7ag"
-                    '("x86_64-linux" "i686-linux")
-                    #:configuration-file kernel-config
-                    #:extra-options
-                    (append
-                     `(;; https://lists.gnu.org/archive/html/guix-devel/2014-04/msg00039.html
-                       ;; This option was removed upstream in version 4.7.
-                       ("CONFIG_DEVPTS_MULTIPLE_INSTANCES" . #t))
-                     %default-extra-linux-options)))
+  (make-linux-libre* linux-libre-4.4-version
+                     linux-libre-4.4-source
+                     '("x86_64-linux" "i686-linux")
+                     #:configuration-file kernel-config
+                     #:extra-options
+                     (append
+                      `(;; https://lists.gnu.org/archive/html/guix-devel/2014-04/msg00039.html
+                        ;; This option was removed upstream in version 4.7.
+                        ("CONFIG_DEVPTS_MULTIPLE_INSTANCES" . #t))
+                      %default-extra-linux-options)))
+
+\f
+;;;
+;;; Specialized kernel variants.
+;;;
 
 (define-public linux-libre-arm-veyron
-  (make-linux-libre %linux-libre-version
-                    %linux-libre-hash
-                    '("armhf-linux")
-                    #:patches %linux-libre-5.1-patches
-                    #:configuration-file kernel-config-veyron
-                    #:extra-version "arm-veyron"))
+  (make-linux-libre* linux-libre-version
+                     linux-libre-source
+                     '("armhf-linux")
+                     #:configuration-file kernel-config-veyron
+                     #:extra-version "arm-veyron"))
 
 (define-public linux-libre-arm-generic
-  (make-linux-libre %linux-libre-version
-                    %linux-libre-hash
-                    '("armhf-linux")
-                    #:patches %linux-libre-5.1-patches
-                    #:defconfig "multi_v7_defconfig"
-                    #:extra-version "arm-generic"))
+  (make-linux-libre* linux-libre-version
+                     linux-libre-source
+                     '("armhf-linux")
+                     #:defconfig "multi_v7_defconfig"
+                     #:extra-version "arm-generic"))
 
 (define-public linux-libre-arm-generic-4.19
-  (make-linux-libre %linux-libre-4.19-version
-                    %linux-libre-4.19-hash
-                    '("armhf-linux")
-                    #:patches %linux-libre-4.19-patches
-                    #:defconfig "multi_v7_defconfig"
-                    #:extra-version "arm-generic"))
+  (make-linux-libre* linux-libre-4.19-version
+                     linux-libre-4.19-source
+                     '("armhf-linux")
+                     #:defconfig "multi_v7_defconfig"
+                     #:extra-version "arm-generic"))
 
 (define-public linux-libre-arm-generic-4.14
-  (make-linux-libre %linux-libre-4.14-version
-                    %linux-libre-4.14-hash
-                    '("armhf-linux")
-                    #:defconfig "multi_v7_defconfig"
-                    #:extra-version "arm-generic"))
+  (make-linux-librelinux-libre-4.14-version
+                     linux-libre-4.14-source
+                     '("armhf-linux")
+                     #:defconfig "multi_v7_defconfig"
+                     #:extra-version "arm-generic"))
 
 (define-public linux-libre-arm-omap2plus
-  (make-linux-libre %linux-libre-version
-                    %linux-libre-hash
-                    '("armhf-linux")
-                    #:patches %linux-libre-5.1-patches
-                    #:defconfig "omap2plus_defconfig"
-                    #:extra-version "arm-omap2plus"))
+  (make-linux-libre* linux-libre-version
+                     linux-libre-source
+                     '("armhf-linux")
+                     #:defconfig "omap2plus_defconfig"
+                     #:extra-version "arm-omap2plus"))
 
 (define-public linux-libre-arm-omap2plus-4.19
-  (make-linux-libre %linux-libre-4.19-version
-                    %linux-libre-4.19-hash
-                    '("armhf-linux")
-                    #:patches %linux-libre-4.19-patches
-                    #:defconfig "omap2plus_defconfig"
-                    #:extra-version "arm-omap2plus"))
+  (make-linux-libre* linux-libre-4.19-version
+                     linux-libre-4.19-source
+                     '("armhf-linux")
+                     #:defconfig "omap2plus_defconfig"
+                     #:extra-version "arm-omap2plus"))
 
 (define-public linux-libre-arm-omap2plus-4.14
-  (make-linux-libre %linux-libre-4.14-version
-                    %linux-libre-4.14-hash
-                    '("armhf-linux")
-                    #:defconfig "omap2plus_defconfig"
-                    #:extra-version "arm-omap2plus"))
+  (make-linux-librelinux-libre-4.14-version
+                     linux-libre-4.14-source
+                     '("armhf-linux")
+                     #:defconfig "omap2plus_defconfig"
+                     #:extra-version "arm-omap2plus"))
 
 \f
 ;;;
@@ -920,7 +1222,7 @@ slabtop, and skill.")
 (define-public e2fsprogs
   (package
     (name "e2fsprogs")
-    (version "1.44.5")
+    (version "1.45.2")
     (source (origin
              (method url-fetch)
              (uri (string-append
@@ -929,7 +1231,7 @@ slabtop, and skill.")
                    name "-" version ".tar.xz"))
              (sha256
               (base32
-               "1ff56h6h1h17sj2zvlddv5c88nmbx46p1fcbh6b0s5k9kl3b6pms"))))
+               "02g0cm72sgz709s9pkg4mvj56m7bgs7rwnyc2cp7cvg3j6pcjlj9"))))
     (build-system gnu-build-system)
     (inputs `(("util-linux" ,util-linux)))
     (native-inputs `(("pkg-config" ,pkg-config)
@@ -1156,7 +1458,7 @@ intercept and print the system calls executed by the program.")
 (define-public alsa-lib
   (package
     (name "alsa-lib")
-    (version "1.1.8")
+    (version "1.1.9")
     (source (origin
              (method url-fetch)
              (uri (string-append
@@ -1164,7 +1466,7 @@ intercept and print the system calls executed by the program.")
                    version ".tar.bz2"))
              (sha256
               (base32
-               "1pxf0zkmps03l3zzd0fr828xhkg6a8hxljmbxzc2cyj2ls9kmp1w"))))
+               "0jwr9g4yxg9gj6xx0sb2r6wrdl8amrjd19hilkrq4rirynp770s8"))))
     (build-system gnu-build-system)
     (home-page "https://www.alsa-project.org/")
     (synopsis "The Advanced Linux Sound Architecture libraries")
@@ -1176,14 +1478,14 @@ MIDI functionality to the Linux-based operating system.")
 (define-public alsa-utils
   (package
     (name "alsa-utils")
-    (version "1.1.8")
+    (version "1.1.9")
     (source (origin
              (method url-fetch)
              (uri (string-append "ftp://ftp.alsa-project.org/pub/utils/"
                                  name "-" version ".tar.bz2"))
              (sha256
               (base32
-               "1kx45yhrxai3k595yyqs4wj0p2n5b0c9mf0k36ljjf1bj8lgb6zx"))))
+               "0fi11b7r8hg1bdjw74s8sqx8rc4qb310jaj9lsia9labvfyjrpsx"))))
     (build-system gnu-build-system)
     (arguments
      ;; XXX: Disable man page creation until we have DocBook.
@@ -1230,14 +1532,14 @@ MIDI functionality to the Linux-based operating system.")
 (define-public alsa-plugins
   (package
     (name "alsa-plugins")
-    (version "1.1.8")
+    (version "1.1.9")
     (source (origin
              (method url-fetch)
              (uri (string-append "ftp://ftp.alsa-project.org/pub/plugins/"
                                  name "-" version ".tar.bz2"))
              (sha256
               (base32
-               "152r82i6f97gfilfgiax5prxkd4xlcipciv8ha8yrk452qbxyxvz"))))
+               "01zrg0h2jw9dlj9233vjsn916yf4f2s667yry6xsn8d57lq745qn"))))
     (build-system gnu-build-system)
     ;; TODO: Split libavcodec and speex if possible. It looks like they can not
     ;; be split, there are references to both in files.
@@ -1388,7 +1690,7 @@ that the Ethernet protocol is much simpler than the IP protocol.")
 (define-public iproute
   (package
     (name "iproute2")
-    (version "5.1.0")
+    (version "5.2.0")
     (source (origin
               (method url-fetch)
               (uri (string-append
@@ -1396,7 +1698,7 @@ that the Ethernet protocol is much simpler than the IP protocol.")
                     version ".tar.xz"))
               (sha256
                (base32
-                "1kvvrz5mlpjxqcm7vl6i8w6l1cb2amp6p5xyq006pgzafc49hnnw"))))
+                "1a2dywa2kam24951byv9pl32mb9z6klh7d4vp8fwfgrm4vn5vfd5"))))
     (build-system gnu-build-system)
     (arguments
      `( ;; There is a test suite, but it wants network namespaces and sudo.
@@ -2244,7 +2546,7 @@ from the module-init-tools project.")
   ;; The post-systemd fork, maintained by Gentoo.
   (package
     (name "eudev")
-    (version "3.2.7")
+    (version "3.2.8")
     (source (origin
               (method git-fetch)
               (uri (git-reference (url "https://github.com/gentoo/eudev")
@@ -2252,7 +2554,7 @@ from the module-init-tools project.")
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "1la7x7v7yqb84wnc7w0kj53sa0an0m9xp6wn01ypi8drh02wjjy2"))
+                "1g95yzzx4qxm5qhhylbi930lrq4gsbz207n72018nkvswj6gmpjw"))
               (patches (search-patches "eudev-rules-directory.patch"))))
     (build-system gnu-build-system)
     (arguments
@@ -2522,7 +2824,7 @@ compliance.")
 (define-public wireless-regdb
   (package
     (name "wireless-regdb")
-    (version "2017.03.07")
+    (version "2019.06.03")
     (source (origin
               (method url-fetch)
               (uri (string-append
@@ -2530,7 +2832,7 @@ compliance.")
                     "wireless-regdb-" version ".tar.xz"))
               (sha256
                (base32
-                "1f9mcp78sdd4sci6v32vxfcl1rfjpv205jisz1p93kkfnaisy7ip"))
+                "1gslvh0aqdkv48jyr2ddq153mw28i7qz2ybrjj9qvkk3dgc7x4fd"))
 
               ;; We're building 'regulatory.bin' by ourselves.
               (snippet '(begin
@@ -2538,13 +2840,25 @@ compliance.")
                           #t))))
     (build-system gnu-build-system)
     (arguments
-     '(#:phases (modify-phases %standard-phases
-                  (add-after 'unpack 'gzip-determinism
-                    (lambda _
-                      (substitute* "Makefile"
-                        (("gzip") "gzip --no-name"))
-                      #t))
-                  (delete 'configure))
+     '(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'gzip-determinism
+           (lambda _
+             (substitute* "Makefile"
+               (("gzip") "gzip --no-name"))
+             #t))
+         (add-after 'unpack 'omit-signature
+           (lambda _
+             (substitute* "Makefile"
+               ;; Signing requires a REGDB_PUBCERT and REGDB_PRIVKEY which we
+               ;; don't provide (see below).  Disable it.
+               ((" regulatory\\.db\\.p7s") "")
+               ;; regulatory.db is built as a dependency of regulatory.db.p7s,
+               ;; but ‘make install’ depends only on the latter while installing
+               ;; both (and failing).  Depend on it explicitly.
+               (("^install: " all) (string-append all "regulatory.db ")))
+             #t))
+         (delete 'configure))  ; no configure script
 
        ;; The 'all' target of the makefile depends on $(REGDB_CHANGED), which
        ;; is computed and can be equal to 'maintainer-clean'; when that
@@ -2552,19 +2866,22 @@ compliance.")
        ;; just built.  Thus, build things sequentially.
        #:parallel-build? #f
 
-       #:tests? #f                                ;no tests
-       #:make-flags (let ((out (assoc-ref %outputs "out")))
-                      (list (string-append "PREFIX=" out)
-                            (string-append "LSB_ID=Guix")
-                            (string-append "DISTRO_PUBKEY=/dev/null")
-                            (string-append "DISTRO_PRIVKEY=/dev/null")
-                            (string-append "REGDB_PUBKEY=/dev/null")
-
-                            ;; Leave that empty so that db2bin.py doesn't try
-                            ;; to sign 'regulatory.bin'.  This allows us to
-                            ;; avoid managing a key pair for the whole distro.
-                            (string-append "REGDB_PRIVKEY=")))))
-    (native-inputs `(("python" ,python-2)))
+       #:tests? #f                      ; no tests
+       #:make-flags
+       (let ((out (assoc-ref %outputs "out")))
+         (list (string-append "PREFIX=" out)
+               (string-append "FIRMWARE_PATH=$(PREFIX)/lib/firmware")
+
+               ;; Leave this empty so that db2bin.py doesn't try to sign
+               ;; ‘regulatory.bin’.  This allows us to avoid managing a key
+               ;; pair for the whole distribution.
+               (string-append "REGDB_PRIVKEY=")
+               ;; Don't generate a public key for the same reason.  These are
+               ;; used as Makefile targets and can't be the empty string.
+               (string-append "REGDB_PUBCERT=/dev/null")
+               (string-append "REGDB_PUBKEY=/dev/null")))))
+    (native-inputs
+     `(("python" ,python-wrapper)))
     (home-page
      "https://wireless.wiki.kernel.org/en/developers/regulatory/wireless-regdb")
     (synopsis "Wireless regulatory database")
@@ -2847,12 +3164,16 @@ thanks to the use of namespaces.")
                   (substitute* "bin/singularity.in"
                     (("^PATH=.*" all)
                      (string-append "#" all "\n")))
+
+                  (substitute* (find-files "libexec/cli" "\\.exec$")
+                    (("\\$SINGULARITY_libexecdir/singularity/bin/([a-z]+)-suid"
+                      _ program)
+                     (string-append "/run/setuid-programs/singularity-"
+                                    program "-helper")))
                   #t))))
     (build-system gnu-build-system)
     (arguments
-     `(#:configure-flags
-       (list "--disable-suid"
-             "--localstatedir=/var")
+     `(#:configure-flags '("--localstatedir=/var")
        #:phases
        (modify-phases %standard-phases
          (add-after 'unpack 'patch-reference-to-squashfs-tools
@@ -3212,7 +3533,7 @@ arrays when needed.")
 (define-public multipath-tools
   (package
     (name "multipath-tools")
-    (version "0.7.9")
+    (version "0.8.2")
     (source (origin
               (method url-fetch)
               (uri (string-append "https://git.opensvc.com/?p=multipath-tools/"
@@ -3220,7 +3541,7 @@ arrays when needed.")
               (file-name (string-append name "-" version ".tar.gz"))
               (sha256
                (base32
-                "1jhi6bhl4ih75rfmyyjxd35ghgch5ls1gw40cjxwy9d6bd41z6q1"))
+                "0kb4mhzwyygdbikikmby6hj39pb3nrzv05v526c75wnycwnpxg31"))
               (modules '((guix build utils)))
               (snippet
                '(begin
@@ -3264,8 +3585,7 @@ arrays when needed.")
        ("pkg-config" ,pkg-config)
        ("valgrind" ,valgrind)))
     (inputs
-     `(("ceph:lib" ,ceph "lib")
-       ("json-c" ,json-c)
+     `(("json-c" ,json-c)
        ("libaio" ,libaio)
        ("liburcu" ,liburcu)
        ("lvm2" ,lvm2)
@@ -3316,14 +3636,14 @@ applications.")
 (define-public sbc
   (package
     (name "sbc")
-    (version "1.3")
+    (version "1.4")
     (source (origin
               (method url-fetch)
               (uri (string-append "mirror://kernel.org/linux/bluetooth/sbc-"
                                   version ".tar.xz"))
               (sha256
                (base32
-                "02ckd2z51z0h85qgv7x8vv8ybp5czm9if1z78411j53gaz7j4476"))))
+                "1jal98pnrjkzxlkiqy0ykh4qmgnydz9bmsp1jn581p5kddpg92si"))))
     (build-system gnu-build-system)
     (inputs
      `(("libsndfile" ,libsndfile)))
@@ -3502,7 +3822,7 @@ and copy/paste text in the console and in xterm.")
 (define-public btrfs-progs
   (package
     (name "btrfs-progs")
-    (version "5.1")
+    (version "5.1.1")
     (source (origin
               (method url-fetch)
               (uri (string-append "mirror://kernel.org/linux/kernel/"
@@ -3510,7 +3830,7 @@ and copy/paste text in the console and in xterm.")
                                   "btrfs-progs-v" version ".tar.xz"))
               (sha256
                (base32
-                "0dgh56pamav8wb9nmabjwdlpcazvqc9pgzwablxn77mqh0qrhkaq"))))
+                "06xybs7rglxjqkbzl2409acb3rgmnc5zc0xhyaxsc2p1x5yipfcw"))))
     (build-system gnu-build-system)
     (outputs '("out"
                "static"))      ; static versions of the binaries in "out"
@@ -3544,7 +3864,8 @@ and copy/paste text in the console and in xterm.")
               ("lzo" ,lzo)
               ("zlib" ,zlib)
               ("zlib:static" ,zlib "static")
-              ("zstd" ,zstd)))
+              ("zstd" ,zstd "lib")
+              ("zstd:static" ,zstd "static")))
     (native-inputs `(("pkg-config" ,pkg-config)
                      ("asciidoc" ,asciidoc)
                      ("python" ,python)
@@ -4039,6 +4360,39 @@ Linux kernel to retrieve and control processor features related to power saving,
 such as frequency and voltage scaling.")
     (license license:gpl2)))
 
+(define-public x86-energy-perf-policy
+  (package
+    (name "x86-energy-perf-policy")
+    (version (package-version linux-libre))
+    (source (package-source linux-libre))
+    (build-system gnu-build-system)
+    (arguments
+     '(#:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'enter-subdirectory
+           (lambda _
+             (chdir "tools/power/x86/x86_energy_perf_policy")
+             #t))
+         (delete 'configure)
+         (add-before 'build 'fix-makefile
+           (lambda _
+             (substitute* "Makefile" (("/usr") ""))
+             #t)))
+       #:make-flags
+       (let ((out (assoc-ref %outputs "out")))
+         (list (string-append "DESTDIR=" out)
+               (string-append "LDFLAGS=-Wl,-rpath=" out "/lib")))))
+    (supported-systems '("i686-linux" "x86_64-linux"))
+    (home-page (package-home-page linux-libre))
+    (synopsis "Display and update Intel-CPU energy-performance policy")
+    (description
+     "@command{x86_energy_perf_policy} displays and updates energy-performance
+policy settings specific to Intel Architecture Processors.  Settings are
+accessed via Model Specific Register (MSR) updates, no matter if the Linux
+cpufreq sub-system is enabled or not.")
+    (license license:gpl2)))
+
 (define-public haveged
   (package
     (name "haveged")
@@ -4316,15 +4670,16 @@ developers.")
 (define-public radeontop
   (package
     (name "radeontop")
-    (version "1.1")
-    (home-page "https://github.com/clbr/radeontop/")
-    (source (origin
-              (method url-fetch)
-              (uri (string-append home-page "archive/v" version ".tar.gz"))
-              (file-name (string-append name "-" version ".tar.gz"))
-              (sha256
-               (base32
-                "1fv06j5c99imvzkac3j40lgjhr5b2i77fnyffhlvj92bli1fm1c6"))))
+    (version "1.2")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/clbr/radeontop.git")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1b1m30r2nfwqkajqw6m01xmfhlq83z1qylyijxg7962mp9x2k0gw"))))
     (build-system gnu-build-system)
     (arguments
      `(#:phases (modify-phases %standard-phases
@@ -4348,6 +4703,7 @@ developers.")
        ("libpciaccess" ,libpciaccess)
        ("libxcb" ,libxcb)
        ("ncurses" ,ncurses)))
+    (home-page "https://github.com/clbr/radeontop/")
     (synopsis "Usage monitor for AMD Radeon graphics")
     (description "RadeonTop monitors resource consumption on supported AMD
 Radeon Graphics Processing Units (GPUs), either in real time as bar graphs on
@@ -4567,10 +4923,19 @@ interface in sysfs, which can be accomplished with the included udev rules.")
               ("sed" ,sed)
               ("usbutils" ,usbutils)
               ("util-linux" ,util-linux)
-              ("wireless-tools" ,wireless-tools)))
+              ("wireless-tools" ,wireless-tools)
+              ,@(if (let ((system (or (%current-target-system)
+                                      (%current-system))))
+                      (or (string-prefix? "i686-" system)
+                          (string-prefix? "x86_64-" system)))
+                    `(("x86-energy-perf-policy" ,x86-energy-perf-policy))
+                    '())))
     (build-system gnu-build-system)
     (arguments
-     `(#:phases
+     `(#:modules ((guix build gnu-build-system)
+                  (guix build utils)
+                  (srfi srfi-1))
+       #:phases
        (modify-phases %standard-phases
          (delete 'configure)            ; no configure script
          (add-before 'build 'setenv
@@ -4608,30 +4973,34 @@ interface in sysfs, which can be accomplished with the included udev rules.")
              (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))
                     (bin-files (find-files bin ".*")))
                (define (bin-directory input-name)
-                 (string-append (assoc-ref inputs input-name) "/bin"))
+                 (let ((p (assoc-ref inputs input-name)))
+                   (and p (string-append p "/bin"))))
                (define (sbin-directory input-name)
                  (string-append (assoc-ref inputs input-name) "/sbin"))
                (for-each (lambda (program)
                            (wrap-program program
                              `("PATH" ":" prefix
                                ,(append
-                                 (map bin-directory '("bash"
-                                                      "coreutils"
-                                                      "dbus"
-                                                      "eudev"
-                                                      "grep"
-                                                      "inetutils"
-                                                      "kmod"
-                                                      "perl"
-                                                      "sed"
-                                                      "usbutils"
-                                                      "util-linux"))
-                                 (map sbin-directory '("ethtool"
-                                                       "hdparm"
-                                                       "iw"
-                                                       "pciutils"
-                                                       "rfkill"
-                                                       "wireless-tools"))))))
+                                 (filter-map bin-directory
+                                             '("bash"
+                                               "coreutils"
+                                               "dbus"
+                                               "eudev"
+                                               "grep"
+                                               "inetutils"
+                                               "kmod"
+                                               "perl"
+                                               "sed"
+                                               "usbutils"
+                                               "util-linux"
+                                               "x86-energy-perf-policy"))
+                                 (filter-map sbin-directory
+                                             '("ethtool"
+                                               "hdparm"
+                                               "iw"
+                                               "pciutils"
+                                               "rfkill"
+                                               "wireless-tools"))))))
                          bin-files)
                #t))))))
     (home-page "http://linrunner.de/en/tlp/tlp.html")
@@ -4698,14 +5067,14 @@ re-use code and to avoid re-inventing the wheel.")
 (define-public libnftnl
   (package
     (name "libnftnl")
-    (version "1.1.2")
+    (version "1.1.3")
     (source
      (origin
        (method url-fetch)
        (uri (string-append "mirror://netfilter.org/libnftnl/"
                            "libnftnl-" version ".tar.bz2"))
        (sha256
-        (base32 "0pffmsv41alsn5ac7mwnb9fh3qpwzqk13jrzn6c5i71wq6kbgix5"))))
+        (base32 "03xszkcpqk3s1rqc6vh7g5j13kh3d3yjnvjhk5scds3an39rgp92"))))
     (build-system gnu-build-system)
     (native-inputs
      `(("pkg-config" ,pkg-config)))