gnu: Update r-mutationalpatterns to 1.4.1.
[jackhill/guix/guix.git] / gnu / packages / bootloaders.scm
index f66d0bb..20f38b2 100644 (file)
@@ -43,6 +43,7 @@
   #:use-module (gnu packages perl)
   #:use-module (gnu packages python)
   #:use-module (gnu packages texinfo)
+  #:use-module (gnu packages swig)
   #:use-module (gnu packages virtualization)
   #:use-module (guix build-system gnu)
   #:use-module (guix download)
@@ -236,7 +237,8 @@ menu to select one of the installed operating systems.")
          ("perl" ,perl)
          ("python-2" ,python-2)))
       (inputs
-       `(("libuuid" ,util-linux)))
+       `(("libuuid" ,util-linux)
+         ("mtools" ,mtools)))
       (arguments
        `(#:parallel-build? #f
          #:make-flags
@@ -251,11 +253,17 @@ menu to select one of the installed operating systems.")
          #:phases
          (modify-phases %standard-phases
            (add-after 'unpack 'patch-files
-             (lambda _
+             (lambda* (#:key inputs #:allow-other-keys)
                (substitute* (find-files "." "Makefile.*|ppmtolss16")
                  (("/bin/pwd") (which "pwd"))
                  (("/bin/echo") (which "echo"))
                  (("/usr/bin/perl") (which "perl")))
+               (let ((mtools (assoc-ref inputs "mtools")))
+                 (substitute* (find-files "." "\\.c$")
+                   (("mcopy")
+                    (string-append mtools "/bin/mcopy"))
+                   (("mattrib")
+                    (string-append mtools "/bin/mattrib"))))
                #t))
            (delete 'configure)
            (add-before 'build 'set-permissions
@@ -280,7 +288,7 @@ menu to select one of the installed operating systems.")
 (define-public dtc
   (package
     (name "dtc")
-    (version "1.4.4")
+    (version "1.4.5")
     (source (origin
               (method url-fetch)
               (uri (string-append
@@ -288,15 +296,19 @@ menu to select one of the installed operating systems.")
                     "dtc-" version ".tar.xz"))
               (sha256
                (base32
-                "1yygyvnnpdh241hl90n9p3kxcdvk3jxmsr4ndb961c8mq3ak21s7"))))
+                "08gnl39i4xy3dm8iqwlz2ygx0ml1bgc5kpiys5ll1wvah1j72b04"))))
     (build-system gnu-build-system)
     (native-inputs
      `(("bison" ,bison)
-       ("flex" ,flex)))
+       ("flex" ,flex)
+       ("swig" ,swig)))
+    (inputs
+     `(("python-2" ,python-2)))
     (arguments
      `(#:make-flags
        (list "CC=gcc"
              (string-append "PREFIX=" (assoc-ref %outputs "out"))
+             (string-append "SETUP_PREFIX=" (assoc-ref %outputs "out"))
              "INSTALL=install")
        #:phases
        (modify-phases %standard-phases
@@ -333,7 +345,8 @@ also initializes the boards (RAM etc).")
 
 (define (make-u-boot-package board triplet)
   "Returns a u-boot package for BOARD cross-compiled for TRIPLET."
-  (let ((same-arch? (if (string-prefix? (%current-system) triplet)
+  (let ((same-arch? (if (string-prefix? (%current-system)
+                                        (gnu-triplet->nix-system triplet))
                       `#t
                       `#f)))
     (package
@@ -375,7 +388,9 @@ also initializes the boards (RAM etc).")
              (lambda* (#:key outputs make-flags #:allow-other-keys)
                (let* ((out (assoc-ref outputs "out"))
                       (libexec (string-append out "/libexec"))
-                      (uboot-files (find-files "." ".*\\.(bin|efi|spl)$")))
+                      (uboot-files (append
+                                    (find-files "." ".*\\.(bin|efi|img|spl)$")
+                                    (find-files "." "^MLO$"))))
                  (mkdir-p libexec)
                  (for-each
                   (lambda (file)
@@ -395,3 +410,72 @@ also initializes the boards (RAM etc).")
 
 (define-public u-boot-odroid-c2
   (make-u-boot-package "odroid-c2" "aarch64-linux-gnu"))
+
+(define-public os-prober
+  (package
+    (name "os-prober")
+    (version "1.76")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "mirror://debian/pool/main/o/os-prober/os-prober_"
+                           version ".tar.xz"))
+       (sha256
+        (base32
+         "1vb45i76bqivlghrq7m3n07qfmmq4wxrkplqx8gywj011rhq19fk"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:modules ((guix build gnu-build-system)
+                  (guix build utils)
+                  (ice-9 regex)   ; for string-match
+                  (srfi srfi-26)) ; for cut
+       #:make-flags (list "CC=gcc")
+       #:tests? #f ; no tests
+       #:phases
+       (modify-phases %standard-phases
+         (replace 'configure
+           (lambda* (#:key outputs #:allow-other-keys)
+             (substitute* (find-files ".")
+               (("/usr") (assoc-ref outputs "out")))
+             (substitute* (find-files "." "50mounted-tests$")
+               (("mkdir") "mkdir -p"))
+             #t))
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (define (find-files-non-recursive directory)
+               (find-files directory
+                           (lambda (file stat)
+                             (string-match (string-append "^" directory "/[^/]*$")
+                                           file))
+                           #:directories? #t))
+
+             (let* ((out (assoc-ref outputs "out"))
+                    (bin (string-append out "/bin"))
+                    (lib (string-append out "/lib"))
+                    (share (string-append out "/share")))
+               (for-each (cut install-file <> bin)
+                         (list "linux-boot-prober" "os-prober"))
+               (install-file "newns" (string-append lib "/os-prober"))
+               (install-file "common.sh" (string-append share "/os-prober"))
+               (install-file "os-probes/mounted/powerpc/20macosx"
+                             (string-append lib "/os-probes/mounted"))
+               (for-each
+                (lambda (directory)
+                  (for-each
+                   (lambda (file)
+                     (let ((destination (string-append lib "/" directory
+                                                       "/" (basename file))))
+                       (mkdir-p (dirname destination))
+                       (copy-recursively file destination)))
+                   (append (find-files-non-recursive (string-append directory "/common"))
+                           (find-files-non-recursive (string-append directory "/x86")))))
+                (list "os-probes" "os-probes/mounted" "os-probes/init"
+                      "linux-boot-probes" "linux-boot-probes/mounted"))
+               #t))))))
+    (home-page "https://joeyh.name/code/os-prober")
+    (synopsis "Detect other operating systems")
+    (description "os-prober probes disks on the system for other operating
+systems so that they can be added to the bootloader.  It also works out how to
+boot existing GNU/Linux systems and detects what distribution is installed in
+order to add a suitable bootloader menu entry.")
+    (license license:gpl2+)))