guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

14/16: build-derivations: scan for hashes, not full paths.


From: guix-commits
Subject: 14/16: build-derivations: scan for hashes, not full paths.
Date: Sat, 20 Apr 2019 17:25:29 -0400 (EDT)

reepca pushed a commit to branch guile-daemon
in repository guix.

commit 55c3dbdda656846ee9b2c2f94bbd371964f2d4ed
Author: Caleb Ristvedt <address@hidden>
Date:   Fri Apr 19 23:14:58 2019 -0500

    build-derivations: scan for hashes, not full paths.
    
    * guix/store/build-derivations.scm (scanning-wrapper-port): Now assumes the
      strings being searched for are store paths and searches for the
      corresponding hash parts.
---
 guix/store/build-derivations.scm | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/guix/store/build-derivations.scm b/guix/store/build-derivations.scm
index beade05..9b3dca5 100644
--- a/guix/store/build-derivations.scm
+++ b/guix/store/build-derivations.scm
@@ -587,13 +587,20 @@ already in TRIE."
       ((current)
        #f))))
 
-(define (scanning-wrapper-port output-port strings)
+(define (scanning-wrapper-port output-port paths)
   "Creates a wrapper port which passes through bytes to OUTPUT-PORT and
 returns it as well as a procedure which, when called, returns a list of all
-references out of the possibilities enumerated in STRINGS that were
-detected. STRINGS must not be empty."
+references out of the possibilities enumerated in PATHS that were
+detected. PATHS must not be empty."
   ;; Not sure if I should be using custom ports or soft ports...
-  (let* ((lookback-size (apply max (map (compose bytevector-length 
string->utf8)
+  (let* ((strings (map store-path-hash-part paths))
+         (string->path (fold (lambda (current prev)
+                               (vhash-cons (store-path-hash-part current)
+                                           current
+                                           prev))
+                             vlist-null
+                             paths))
+         (lookback-size (apply max (map (compose bytevector-length 
string->utf8)
                                         strings)))
          (smallest-length (apply min (map (compose bytevector-length
                                                    string->utf8)
@@ -664,7 +671,9 @@ detected. STRINGS must not be empty."
                   (if match-result
                       (begin
                         (set! references
-                          (let ((str-result (utf8->string match-result)))
+                          (let ((str-result
+                                 (cdr (vhash-assoc (utf8->string match-result)
+                                                   string->path))))
                             (format #t "Found reference to: ~a~%" str-result)
                             (cons str-result
                                   references)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]