From 713f7467298d7e00f5a02a764ff9613985e2304c Mon Sep 17 00:00:00 2001
From: Ivan Petkov <ivanppetkov@gmail.com>
Date: Sat, 27 Apr 2019 21:39:48 -0700
Subject: [PATCH 1/4] build/cargo-utils: remove src-name parameter

* gnu/packages/gnuzilla.scm: (icecat)['patch-cargo-checksums]: Remove
null-file variable.
* gnu/packages/rust.scm: (%cargo-reference-project-file): Remove it.
* gnu/packages/rust.scm: (rust-1.19): Remove reference to
%cargo-reference-project-file
* guix/build/cargo-utils.scm: (generate-checksums): Remove src-name
parameter.
---
 gnu/packages/gnuzilla.scm         |  5 ++---
 gnu/packages/rust.scm             |  5 ++---
 guix/build/cargo-build-system.scm |  2 +-
 guix/build/cargo-utils.scm        | 11 ++++++-----
 4 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/gnu/packages/gnuzilla.scm b/gnu/packages/gnuzilla.scm
index afebc82cf1..ae46c3c820 100644
--- a/gnu/packages/gnuzilla.scm
+++ b/gnu/packages/gnuzilla.scm
@@ -832,8 +832,7 @@ from forcing GEXP-PROMISE."
          (add-after 'patch-source-shebangs 'patch-cargo-checksums
            (lambda _
              (use-modules (guix build cargo-utils))
-             (let ((null-file "/dev/null")
-                   (null-hash "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"))
+             (let ((null-hash "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"))
                (substitute* '("Cargo.lock" "servo/Cargo.lock")
                  (("(\"checksum .* = )\".*\"" all name)
                   (string-append name "\"" null-hash "\"")))
@@ -844,7 +843,7 @@ from forcing GEXP-PROMISE."
                     (display (string-append
                               "patch-cargo-checksums: generate-checksums for "
                               dir "\n"))
-                    (generate-checksums dir null-file)))
+                    (generate-checksums dir)))
                 (find-files "third_party/rust" ".cargo-checksum.json")))
              #t))
          (add-before 'configure 'augment-CPLUS_INCLUDE_PATH
diff --git a/gnu/packages/rust.scm b/gnu/packages/rust.scm
index 61fc0d46ac..27388d307e 100644
--- a/gnu/packages/rust.scm
+++ b/gnu/packages/rust.scm
@@ -55,7 +55,6 @@
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-26))
 
-(define %cargo-reference-project-file "/dev/null")
 (define %cargo-reference-hash
   "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
 
@@ -320,7 +319,7 @@ test = { path = \"../libtest\" }
                   (display (string-append
                             "patch-cargo-checksums: generate-checksums for "
                             dir "\n"))
-                  (generate-checksums dir ,%cargo-reference-project-file)))
+                  (generate-checksums dir)))
               (find-files "src/vendor" ".cargo-checksum.json"))
              #t))
          ;; This phase is overridden by newer versions.
@@ -973,7 +972,7 @@ jemalloc = \"" jemalloc "/lib/libjemalloc_pic.a" "\"
                       (display (string-append
                                 "patch-cargo-checksums: generate-checksums for "
                                 dir "\n"))
-                      (generate-checksums dir ,%cargo-reference-project-file)))
+                      (generate-checksums dir)))
                   (find-files "vendor" ".cargo-checksum.json"))
                  #t))
              (add-after 'enable-codegen-tests 'override-jemalloc
diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index b68a1f90d2..9f44bd6ee9 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -131,7 +131,7 @@ directory = '" port)
     ;; to store paths.
     (copy-recursively "." rsrc)
     (touch (string-append rsrc "/.cargo-ok"))
-    (generate-checksums rsrc "/dev/null")
+    (generate-checksums rsrc)
     (install-file "Cargo.toml" rsrc)
     #t))
 
diff --git a/guix/build/cargo-utils.scm b/guix/build/cargo-utils.scm
index 6af572e611..79e5440378 100644
--- a/guix/build/cargo-utils.scm
+++ b/guix/build/cargo-utils.scm
@@ -41,12 +41,10 @@
       (close-pipe port)
       result)))
 
-(define (generate-checksums dir-name src-name)
+(define (generate-checksums dir-name)
   "Given DIR-NAME, a store directory, checksum all the files in it one
 by one and put the result into the file \".cargo-checksum.json\" in
-the same directory.  Also includes the checksum of an extra file
-SRC-NAME as if it was part of the directory DIR-NAME with name
-\"package\"."
+the same directory."
   (let* ((file-names (find-files dir-name "."))
          (dir-prefix-name (string-append dir-name "/"))
          (dir-prefix-name-len (string-length dir-prefix-name))
@@ -62,6 +60,9 @@ SRC-NAME as if it was part of the directory DIR-NAME with name
                   (write file-relative-name port)
                   (display ":" port)
                   (write (file-sha256 file-name) port))) file-names))
+        ;; NB: cargo requires the "package" field in order to check if the Cargo.lock
+        ;; file needs to be regenerated when the value changes. However, it doesn't
+        ;; appear to care what the value is to begin with...
         (display "},\"package\":" port)
-        (write (file-sha256 src-name) port)
+        (write (file-sha256 "/dev/null") port)
         (display "}" port)))))
-- 
2.21.0

