GNU bug report logs - #45774
[PATCH core-updates 1/1] guix: packages: Allow patch-and-repack to work with plain files.

Previous Next

Package: guix-patches;

Reported by: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Date: Sun, 10 Jan 2021 20:06:01 UTC

Severity: normal

Tags: patch

Merged with 45773, 45959

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 45774 in the body.
You can then email your comments to 45774 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#45774; Package guix-patches. (Sun, 10 Jan 2021 20:06:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sun, 10 Jan 2021 20:06:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: 45773 <at> gnu.org,
	guix-patches <at> gnu.org
Cc: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Subject: [PATCH core-updates 1/1] guix: packages: Allow patch-and-repack to
 work with plain files.
Date: Sun, 10 Jan 2021 15:05:35 -0500
This change allows the use of the snippet field on a single file origin.
Previously, the patch-and-repack procedure would fail on plain files, as it
would end up invoking tar when attempting to extract non-tarballs.

* guix/packages.scm (patch-and-repack): Only add the compressor utility to the
PATH when the file is compressed.  Bind more inputs in the mlet, and use them
for decompressing single files.  Adjust decompression and compression routines.
[decompression-type]: Return #f when no known compression extension is used.
[tarball?]: New nested procedure.
* tests/packages.scm: Add tests.  Add missing copyright year for Jan.
---
 guix/packages.scm  | 96 +++++++++++++++++++++++++++++++---------------
 tests/packages.scm | 87 +++++++++++++++++++++++++++++++++++++++--
 2 files changed, 149 insertions(+), 34 deletions(-)

diff --git a/guix/packages.scm b/guix/packages.scm
index 93407c143c..f6336e7345 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -5,7 +5,7 @@
 ;;; Copyright © 2016 Alex Kost <alezost <at> gmail.com>
 ;;; Copyright © 2017, 2019, 2020 Efraim Flashner <efraim <at> flashner.co.il>
 ;;; Copyright © 2019 Marius Bakke <mbakke <at> fastmail.com>
-;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
+;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -615,7 +615,8 @@ specifies modules in scope when evaluating SNIPPET."
           ((string-suffix? "bz2" source-file-name) "bzip2")
           ((string-suffix? "lz" source-file-name)  "lzip")
           ((string-suffix? "zip" source-file-name) "unzip")
-          (else "xz")))
+          ((string-suffix? "xz" source-file-name) "xz")
+          (else #f)))                   ;no compression used
 
   (define original-file-name
     ;; Remove the store prefix plus the slash, hash, and hyphen.
@@ -653,19 +654,29 @@ specifies modules in scope when evaluating SNIPPET."
        (lower-object patch system))))
 
   (mlet %store-monad ((tar ->     (lookup-input "tar"))
+                      (gzip ->    (lookup-input "gzip"))
+                      (bzip2 ->   (lookup-input "bzip2"))
+                      (lzip ->    (lookup-input "lzip"))
                       (xz ->      (lookup-input "xz"))
                       (patch ->   (lookup-input "patch"))
                       (locales -> (lookup-input "locales"))
-                      (decomp ->  (lookup-input decompression-type))
+                      (decomp ->  (and=> decompression-type lookup-input))
                       (patches    (sequence %store-monad
                                             (map instantiate-patch patches))))
     (define build
       (with-imported-modules '((guix build utils))
         #~(begin
             (use-modules (ice-9 ftw)
+                         (ice-9 match)
+                         (ice-9 regex)
                          (srfi srfi-1)
+                         (srfi srfi-26)
                          (guix build utils))
 
+            (define (tarball? file-name)
+              ;; Return true if FILE-NAME has a tar extension.
+              (string-match "\\.tar(\\..*)?$" file-name))
+
             ;; The --sort option was added to GNU tar in version 1.28, released
             ;; 2014-07-28.  During bootstrap we must cope with older versions.
             (define tar-supports-sort?
@@ -702,12 +713,15 @@ specifies modules in scope when evaluating SNIPPET."
                                              (package-version locales)))))
               (setlocale LC_ALL "en_US.utf8"))
 
-            (setenv "PATH" (string-append #+xz "/bin" ":"
-                                          #+decomp "/bin"))
+            (setenv "PATH"
+                    (string-append #+xz "/bin"
+                                   (if #+decomp
+                                       (string-append ":" #+decomp "/bin")
+                                       "")))
 
             (setenv "XZ_DEFAULTS" (string-join (%xz-parallel-args)))
 
-            ;; SOURCE may be either a directory or a tarball.
+            ;; SOURCE may be either a directory, a tarball or a simple file.
             (if (file-is-directory? #+source)
                 (let* ((store     (%store-directory))
                        (len       (+ 1 (string-length store)))
@@ -716,31 +730,51 @@ specifies modules in scope when evaluating SNIPPET."
                        (directory (string-drop base (+ 1 dash))))
                   (mkdir directory)
                   (copy-recursively #+source directory))
-                #+(if (string=? decompression-type "unzip")
-                      #~(invoke "unzip" #+source)
-                      #~(invoke (string-append #+tar "/bin/tar")
-                                "xvf" #+source)))
-
-            (let ((directory (first-file ".")))
-              (format (current-error-port)
-                      "source is under '~a'~%" directory)
-              (chdir directory)
-
-              (for-each apply-patch '#+patches)
-
-              #+(if snippet
-                    #~(let ((module (make-fresh-user-module)))
-                        (module-use-interfaces!
-                         module
-                         (map resolve-interface '#+modules))
-                        ((@ (system base compile) compile)
-                         '#+snippet
-                         #:to 'value
-                         #:opts %auto-compilation-options
-                         #:env module))
-                    #~#t)
-
-              (chdir "..")
+                ;; File is *not* a directory.
+                (cond
+                 ((tarball? #+source)
+                  (invoke (string-append #+tar "/bin/tar")
+                          "xvf" #+source))
+                 ((and=> #+decompression-type (cut string= "unzip" <>))
+                  ("unzip" (invoke "unzip" #+source)))
+                 (else
+                  ;; A simple file, either compressed or not.
+                  (match #+decompression-type
+                    ;; Note: Referring to the store unzip here (#+unzip)
+                    ;; introduces a cycle.
+                    ("unzip" (invoke "unzip" #+source))
+                    (else
+                     ;; bzip2, gzip, lzip and xz share a common CLI.
+                     (let ((name (strip-store-file-name #+source))
+                           (command (and=> #+decomp
+                                           (cut string-append <> "/bin/"
+                                                #+decompression-type))))
+                       (copy-file #+source name)
+                       (when command
+                         (invoke command "--decompress" name))))))))
+
+
+            (let* ((file (first-file "."))
+                   (directory (if (file-is-directory? file)
+                                  file
+                                  ".")))
+              (format (current-error-port) "source is at '~a'~%" file)
+
+              (with-directory-excursion directory
+
+                (for-each apply-patch '#+patches)
+
+                #+(if snippet
+                      #~(let ((module (make-fresh-user-module)))
+                          (module-use-interfaces!
+                           module
+                           (map resolve-interface '#+modules))
+                          ((@ (system base compile) compile)
+                           '#+snippet
+                           #:to 'value
+                           #:opts %auto-compilation-options
+                           #:env module))
+                      #~#t))
 
               (unless tar-supports-sort?
                 (call-with-output-file ".file_list"
diff --git a/tests/packages.scm b/tests/packages.scm
index a867f2fd6d..5c84dbf4b8 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo <at> gnu.org>
-;;; Copyright © Jan (janneke) Nieuwenhuizen <janneke <at> gnu.org>
+;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke <at> gnu.org>
+;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -17,12 +18,12 @@
 ;;; You should have received a copy of the GNU General Public License
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
-(define-module (test-packages)
+(define-module (tests packages)
   #:use-module (guix tests)
   #:use-module (guix store)
   #:use-module (guix monads)
   #:use-module (guix grafts)
-  #:use-module ((guix gexp) #:select (local-file local-file-file))
+  #:use-module (guix gexp)
   #:use-module (guix utils)
   #:use-module ((guix diagnostics)
                 ;; Rename the 'location' binding to allow proper syntax
@@ -32,6 +33,7 @@
                                   (else name))))
   #:use-module ((gcrypt hash) #:prefix gcrypt:)
   #:use-module (guix derivations)
+  #:use-module (guix download)
   #:use-module (guix packages)
   #:use-module (guix grafts)
   #:use-module (guix search-paths)
@@ -576,6 +578,11 @@
     (build-derivations %store (list drv))
     (call-with-input-file output get-string-all)))
 
+
+;;;
+;;; Source derivation with snippets.
+;;;
+
 (unless (network-reachable?) (test-skip 1))
 (test-equal "package-source-derivation, snippet"
   "OK"
@@ -631,6 +638,80 @@
     (and (build-derivations %store (list (pk 'snippet-drv drv)))
          (call-with-input-file out get-string-all))))
 
+;; Note: lzip is not part of bootstrap-coreutils&co, so is not included to
+;; avoid having to rebuild the world.
+(define compressors '(("gzip"  . "gz")
+                      ("xz"    . "xz")
+                      ("bzip2" . "bz2")
+                      (#f      . #f)))
+
+(for-each
+ (match-lambda
+   ((comp . ext)
+    (unless (network-reachable?) (test-skip 1))
+    (test-equal (string-append "origin->derivation, single file with snippet "
+                               "(compression: " (if comp comp "None") ")")
+      "2 + 2 = 4"
+      (let* ((name "maths")
+             (compressed-name (if comp
+                                  (string-append name "." ext)
+                                  name))
+             (command #~(if #+comp
+                            (string-append #+%bootstrap-coreutils&co
+                                           "/bin/" #+comp)
+                            #f))
+             (f (with-imported-modules '((guix build utils))
+                  (computed-file compressed-name
+                                 #~(begin
+                                     (use-modules (guix build utils)
+                                                  (rnrs io simple))
+                                     (with-output-to-file #+name
+                                       (lambda _
+                                         (format #t "2 + 2 = 5")))
+                                     (when #+command
+                                       (invoke #+command #+name))
+                                     (copy-file #+compressed-name #$output)))))
+             (file-drv (run-with-store %store (lower-object f)))
+             (file (derivation->output-path file-drv))
+             (file-drv-outputs (derivation-outputs file-drv))
+             (_ (build-derivations %store (list file-drv)))
+             (file-hash (derivation-output-hash
+                         (assoc-ref file-drv-outputs "out")))
+             ;; Create an origin using the above computed file and its hash.
+             (source (origin
+                       (method url-fetch)
+                       (uri (string-append "file://" file))
+                       (file-name compressed-name)
+                       (patch-inputs `(("tar"   ,%bootstrap-coreutils&co)
+                                       ("xz"    ,%bootstrap-coreutils&co)
+                                       ("bzip2" ,%bootstrap-coreutils&co)
+                                       ("gzip"  ,%bootstrap-coreutils&co)))
+                       (patch-guile %bootstrap-guile)
+                       (modules '((guix build utils)))
+                       (snippet `(substitute* ,name
+                                   (("5") "4")))
+                       (hash (content-hash file-hash))))
+             ;; Build origin.
+             (drv (run-with-store %store (origin->derivation source)))
+             (out (derivation->output-path drv)))
+        ;; Decompress the resulting tar.xz and return its content.
+        (and (build-derivations %store (list drv))
+             (let* ((bin #~(string-append #+%bootstrap-coreutils&co
+                                          "/bin"))
+                    (f (computed-file
+                        name
+                        (with-imported-modules '((guix build utils))
+                          #~(begin
+                              (use-modules (guix build utils))
+                              (setenv "PATH" #+bin)
+                              (invoke "tar" "xvf" #+out)
+                              (copy-file #+name #$output)))))
+                    (drv (run-with-store %store (lower-object f)))
+                    (_ (build-derivations %store (list drv))))
+               (call-with-input-file (derivation->output-path drv)
+                 get-string-all)))))))
+ compressors)
+
 (test-assert "return value"
   (let ((drv (package-derivation %store (dummy-package "p"))))
     (and (derivation? drv)
-- 
2.29.2





Forcibly Merged 45773 45774. Request was from Maxim Cournoyer <maxim.cournoyer <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 10 Jan 2021 22:01:02 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#45774; Package guix-patches. (Wed, 13 Jan 2021 17:41:02 GMT) Full text and rfc822 format available.

Message #10 received at 45774 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: 45774 <at> debbugs.gnu.org
Cc: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Subject: [PATCH core-updates v2] build-systems/gnu: Allow unpacking/repacking
 more kind of files.
Date: Wed, 13 Jan 2021 12:40:21 -0500
Before this change, only plain directories, tar or zip archives were supported
as the source of a package for the GNU build system; anything else would cause
the unpack phase to fail.  Origins relying on snippets would suffer from the
same problem.

This change adds the support to use files of the following extensions: .gz,
.Z, .bz2, .lz, and .xz, even when they are not tarballs.  Files of unknown
extensions are treated as uncompressed files and supported as well.

* guix/packages.scm (patch-and-repack): Only add the compressor utility to the
PATH when the file is compressed.  Bind more inputs in the mlet, and use them
for decompressing single files.  Adjust decompression and compression routines.
[decompression-type]: Return #f when no known compression extension is used.
[tarball?]: New nested procedure.
* guix/build/utils.scm (compressor, tarball?): New procedures.  Move
%xz-parallel-args to the new 'compression helpers' section.
* tests/packages.scm: Add tests.  Add missing copyright year for Jan.
* guix/build/gnu-build-system.scm (first-subdirectory): Return #f when no
sub-directory was found.
(unpack): Support more file types, including uncompressed plain files.
---
 guix/build/gnu-build-system.scm |  24 ++++++--
 guix/build/utils.scm            |  47 ++++++++++-----
 guix/packages.scm               | 100 +++++++++++++++++---------------
 guix/tests.scm                  |  40 ++++++++++++-
 tests/builders.scm              |  40 ++++++++++++-
 tests/packages.scm              |  69 +++++++++++++++++++++-
 6 files changed, 247 insertions(+), 73 deletions(-)

diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index e556457db9..d36aecb75e 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2018 Mark H Weaver <mhw <at> netris.org>
 ;;; Copyright © 2020 Brendan Tildesley <mail <at> brendan.scot>
+;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -60,13 +61,15 @@ See https://reproducible-builds.org/specs/source-date-epoch/."
   (setenv "SOURCE_DATE_EPOCH" "1"))
 
 (define (first-subdirectory directory)
-  "Return the file name of the first sub-directory of DIRECTORY."
+  "Return the file name of the first sub-directory of DIRECTORY or false, when
+there are none."
   (match (scandir directory
                   (lambda (file)
                     (and (not (member file '("." "..")))
                          (file-is-directory? (string-append directory "/"
                                                             file)))))
-    ((first . _) first)))
+    ((first . _) first)
+    (_ #f)))
 
 (define* (set-paths #:key target inputs native-inputs
                     (search-paths '()) (native-search-paths '())
@@ -155,10 +158,19 @@ working directory."
         (copy-recursively source "."
                           #:keep-mtime? #t))
       (begin
-        (if (string-suffix? ".zip" source)
-            (invoke "unzip" source)
-            (invoke "tar" "xvf" source))
-        (chdir (first-subdirectory ".")))))
+        (cond
+         ((string-suffix? ".zip" source)
+          (invoke "unzip" source))
+         ((tarball? source)
+          (invoke "tar" "xvf" source))
+         (else
+          (let ((name (strip-store-file-name source))
+                (command (compressor source)))
+            (copy-file source name)
+            (when command
+              (invoke command "--decompress" name)))))
+        ;; Attempt to change into child directory.
+        (and=> (first-subdirectory ".") chdir))))
 
 (define* (bootstrap #:key bootstrap-scripts
                     #:allow-other-keys)
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 76180e67e0..5e7ac74033 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -6,7 +6,7 @@
 ;;; Copyright © 2018 Arun Isaac <arunisaac <at> systemreboot.net>
 ;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado <at> elephly.net>
 ;;; Copyright © 2020 Efraim Flashner <efraim <at> flashner.co.il>
-;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
+;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -51,6 +51,10 @@
             package-name->name+version
             parallel-job-count
 
+            compressor
+            tarball?
+            %xz-parallel-args
+
             directory-exists?
             executable-file?
             symbolic-link?
@@ -113,9 +117,7 @@
 
             make-desktop-entry-file
 
-            locale-category->string
-
-            %xz-parallel-args))
+            locale-category->string))
 
 
 ;;;
@@ -137,6 +139,32 @@
    (module-replace! (current-module) '(setvbuf)))
   (else #f))
 
+
+;;;
+;;; Compression helpers.
+;;;
+
+(define (compressor file-name)
+  "Return the name of the compressor package/binary used to compress or
+decompress FILE-NAME, based on its file extension, else false."
+  (cond ((string-suffix? "gz"  file-name)  "gzip")
+        ((string-suffix? "Z"   file-name)  "gzip")
+        ((string-suffix? "bz2" file-name)  "bzip2")
+        ((string-suffix? "lz"  file-name)  "lzip")
+        ((string-suffix? "zip" file-name)  "unzip")
+        ((string-suffix? "xz"  file-name)  "xz")
+        (else #f)))                ;no compression used/unknown file extension
+
+(define (tarball? file-name)
+  "True when FILE-NAME has a tar file extension."
+  (string-match "\\.(tar(\\..*)?|tgz|tbz)$" file-name))
+
+(define (%xz-parallel-args)
+  "The xz arguments required to enable bit-reproducible, multi-threaded
+compression."
+  (list "--memlimit=50%"
+        (format #f "--threads=~a" (max 2 (parallel-job-count)))))
+
 
 ;;;
 ;;; Directories.
@@ -1536,17 +1564,6 @@ returned."
              LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE
              LC_TIME)))
 
-
-;;;
-;;; Others.
-;;;
-
-(define (%xz-parallel-args)
-  "The xz arguments required to enable bit-reproducible, multi-threaded
-compression."
-  (list "--memlimit=50%"
-        (format #f "--threads=~a" (max 2 (parallel-job-count)))))
-
 ;;; Local Variables:
 ;;; eval: (put 'call-with-output-file/atomic 'scheme-indent-function 1)
 ;;; eval: (put 'call-with-ascii-input-file 'scheme-indent-function 1)
diff --git a/guix/packages.scm b/guix/packages.scm
index 4caaa9cb79..8f4dc7ec36 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -5,7 +5,7 @@
 ;;; Copyright © 2016 Alex Kost <alezost <at> gmail.com>
 ;;; Copyright © 2017, 2019, 2020 Efraim Flashner <efraim <at> flashner.co.il>
 ;;; Copyright © 2019 Marius Bakke <mbakke <at> fastmail.com>
-;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
+;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -23,6 +23,7 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (guix packages)
+  #:use-module ((guix build utils) #:select (compressor tarball?))
   #:use-module (guix utils)
   #:use-module (guix records)
   #:use-module (guix store)
@@ -609,14 +610,6 @@ specifies modules in scope when evaluating SNIPPET."
           ((package) package)
           (#f        #f)))))
 
-  (define decompression-type
-    (cond ((string-suffix? "gz" source-file-name)  "gzip")
-          ((string-suffix? "Z" source-file-name)  "gzip")
-          ((string-suffix? "bz2" source-file-name) "bzip2")
-          ((string-suffix? "lz" source-file-name)  "lzip")
-          ((string-suffix? "zip" source-file-name) "unzip")
-          (else "xz")))
-
   (define original-file-name
     ;; Remove the store prefix plus the slash, hash, and hyphen.
     (let* ((sans (string-drop source-file-name
@@ -653,17 +646,24 @@ specifies modules in scope when evaluating SNIPPET."
        (lower-object patch system))))
 
   (mlet %store-monad ((tar ->     (lookup-input "tar"))
+                      (gzip ->    (lookup-input "gzip"))
+                      (bzip2 ->   (lookup-input "bzip2"))
+                      (lzip ->    (lookup-input "lzip"))
                       (xz ->      (lookup-input "xz"))
                       (patch ->   (lookup-input "patch"))
                       (locales -> (lookup-input "locales"))
-                      (decomp ->  (lookup-input decompression-type))
+                      (comp ->    (and=> (compressor source-file-name)
+                                         lookup-input))
                       (patches    (sequence %store-monad
                                             (map instantiate-patch patches))))
     (define build
       (with-imported-modules '((guix build utils))
         #~(begin
             (use-modules (ice-9 ftw)
+                         (ice-9 match)
+                         (ice-9 regex)
                          (srfi srfi-1)
+                         (srfi srfi-26)
                          (guix build utils))
 
             ;; The --sort option was added to GNU tar in version 1.28, released
@@ -702,45 +702,53 @@ specifies modules in scope when evaluating SNIPPET."
                                              (package-version locales)))))
               (setlocale LC_ALL "en_US.utf8"))
 
-            (setenv "PATH" (string-append #+xz "/bin" ":"
-                                          #+decomp "/bin"))
+            (setenv "PATH"
+                    (string-append #+xz "/bin"
+                                   (if #+comp
+                                       (string-append ":" #+comp "/bin")
+                                       "")))
 
             (setenv "XZ_DEFAULTS" (string-join (%xz-parallel-args)))
 
-            ;; SOURCE may be either a directory or a tarball.
-            (if (file-is-directory? #+source)
-                (let* ((store     (%store-directory))
-                       (len       (+ 1 (string-length store)))
-                       (base      (string-drop #+source len))
-                       (dash      (string-index base #\-))
-                       (directory (string-drop base (+ 1 dash))))
-                  (mkdir directory)
-                  (copy-recursively #+source directory))
-                #+(if (string=? decompression-type "unzip")
-                      #~(invoke "unzip" #+source)
-                      #~(invoke (string-append #+tar "/bin/tar")
-                                "xvf" #+source)))
-
-            (let ((directory (first-file ".")))
-              (format (current-error-port)
-                      "source is under '~a'~%" directory)
-              (chdir directory)
-
-              (for-each apply-patch '#+patches)
-
-              #+(if snippet
-                    #~(let ((module (make-fresh-user-module)))
-                        (module-use-interfaces!
-                         module
-                         (map resolve-interface '#+modules))
-                        ((@ (system base compile) compile)
-                         '#+snippet
-                         #:to 'value
-                         #:opts %auto-compilation-options
-                         #:env module))
-                    #~#t)
-
-              (chdir "..")
+            ;; SOURCE may be either a directory, a tarball or a simple file.
+            (let ((name (strip-store-file-name #+source))
+                  (command (and=> #+comp (cut string-append <> "/bin/"
+                                              (compressor #+source)))))
+              (if (file-is-directory? #+source)
+                  (copy-recursively #+source name)
+                  (cond
+                   ((tarball? #+source)
+                    (invoke (string-append #+tar "/bin/tar") "xvf" #+source))
+                   ((and=> (compressor #+source) (cut string= "unzip" <>))
+                    ;; Note: Referring to the store unzip here (#+unzip)
+                    ;; would introduce a cycle.
+                    ("unzip" (invoke "unzip" #+source)))
+                   (else
+                    (copy-file #+source name)
+                    (when command
+                      (invoke command "--decompress" name))))))
+
+            (let* ((file (first-file "."))
+                   (directory (if (file-is-directory? file)
+                                  file
+                                  ".")))
+              (format (current-error-port) "source is at '~a'~%" file)
+
+              (with-directory-excursion directory
+
+                (for-each apply-patch '#+patches)
+
+                #+(if snippet
+                      #~(let ((module (make-fresh-user-module)))
+                          (module-use-interfaces!
+                           module
+                           (map resolve-interface '#+modules))
+                          ((@ (system base compile) compile)
+                           '#+snippet
+                           #:to 'value
+                           #:opts %auto-compilation-options
+                           #:env module))
+                      #~#t))
 
               (unless tar-supports-sort?
                 (call-with-output-file ".file_list"
diff --git a/guix/tests.scm b/guix/tests.scm
index fc3d521163..daf4a4d15f 100644
--- a/guix/tests.scm
+++ b/guix/tests.scm
@@ -20,12 +20,13 @@
   #:use-module ((guix config) #:select (%storedir %localstatedir))
   #:use-module (guix store)
   #:use-module (guix derivations)
+  #:use-module (guix gexp)
   #:use-module (guix packages)
   #:use-module (guix base32)
   #:use-module (guix serialization)
   #:use-module (guix monads)
   #:use-module ((guix utils) #:select (substitute-keyword-arguments))
-  #:use-module ((guix build utils) #:select (mkdir-p))
+  #:use-module ((guix build utils) #:select (mkdir-p compressor))
   #:use-module ((gcrypt hash) #:hide (sha256))
   #:use-module (guix build-system gnu)
   #:use-module (gnu packages base)
@@ -60,7 +61,9 @@
             dummy-package
             dummy-origin
 
-            gnu-make-for-tests))
+            gnu-make-for-tests
+
+            test-file))
 
 ;;; Commentary:
 ;;;
@@ -435,6 +438,39 @@ default values, and with EXTRA-FIELDS set as specified."
      (native-inputs '())                          ;no need for 'pkg-config'
      (inputs %bootstrap-inputs-for-tests))))
 
+
+;;;
+;;; Test utility procedures.
+
+(define (test-file store name content)
+  "Create a simple file in STORE with CONTENT (a string), compressed according
+to its file name extension.  Return both its file name and its hash."
+  (let* ((name-sans-ext (string-take name (string-index-right name #\.)))
+         (comp (compressor name))
+         (command #~(if #+comp
+                        (string-append #+%bootstrap-coreutils&co
+                                       "/bin/" #+comp)
+                        #f))
+         (f (with-imported-modules '((guix build utils))
+              (computed-file name
+                             #~(begin
+                                 (use-modules (guix build utils)
+                                              (rnrs io simple))
+                                 (with-output-to-file #+name-sans-ext
+                                   (lambda _
+                                     (format #t #+content)))
+                                 (when #+command
+                                   (invoke #+command #+name-sans-ext))
+                                 (copy-file #+name #$output)))))
+         (file-drv (run-with-store store (lower-object f)))
+         (file (derivation->output-path file-drv))
+         (file-drv-outputs (derivation-outputs file-drv))
+         (_ (build-derivations store (list file-drv)))
+         (file-hash (derivation-output-hash
+                     (assoc-ref file-drv-outputs "out"))))
+    (values file file-hash)))
+
+;;;
 ;; Local Variables:
 ;; eval: (put 'call-with-derivation-narinfo 'scheme-indent-function 1)
 ;; eval: (put 'call-with-derivation-substitute 'scheme-indent-function 2)
diff --git a/tests/builders.scm b/tests/builders.scm
index fdcf38ded3..7b9cfca362 100644
--- a/tests/builders.scm
+++ b/tests/builders.scm
@@ -17,7 +17,7 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 
-(define-module (test-builders)
+(define-module (tests builders)
   #:use-module (guix download)
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
@@ -78,4 +78,42 @@
 (test-assert "gnu-build-system"
   (build-system? gnu-build-system))
 
+;;; FIXME: The following fails because the store file names of the test-env
+;;; environment are longer than the real ones, so strip-store-file-name
+;;; doesn't work as intended.
+
+;; (use-modules (guix build gnu-build-system)
+;;              (guix build utils)
+;;              (ice-9 textual-ports)
+;;              (srfi srfi-11))
+
+;; (define unpack (assoc-ref %standard-phases 'unpack))
+;
+;; (define compressors '(("gzip"  . "gz")
+;;                       ("xz"    . "xz")
+;;                       ("bzip2" . "bz2")
+;;                       (#f      . #f)))
+
+;; (for-each
+;;  (match-lambda
+;;    ((comp . ext)
+
+;;     (unless (network-reachable?) (test-skip 1)) ;for bootstrap binaries
+;;     (test-equal (string-append "gnu-build-system unpack phase, "
+;;                                 "single file (compression: "
+;;                                 (if comp comp "None") ")")
+;;       "expected text"
+;;       (let*-values
+;;           (((name) "test")
+;;            ((compressed-name) (if ext
+;;                                   (string-append name "." ext)
+;;                                   name))
+;;            ((file hash) (test-file %store compressed-name "expected text")))
+;;         (call-with-temporary-directory
+;;          (lambda (dir)
+;;            (with-directory-excursion dir
+;;              (unpack #:source file)
+;;              (call-with-input-file name get-string-all))))))))
+;;  compressors)
+
 (test-end "builders")
diff --git a/tests/packages.scm b/tests/packages.scm
index a867f2fd6d..423485b68e 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo <at> gnu.org>
-;;; Copyright © Jan (janneke) Nieuwenhuizen <janneke <at> gnu.org>
+;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke <at> gnu.org>
+;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -17,12 +18,12 @@
 ;;; You should have received a copy of the GNU General Public License
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
-(define-module (test-packages)
+(define-module (tests packages)
   #:use-module (guix tests)
   #:use-module (guix store)
   #:use-module (guix monads)
   #:use-module (guix grafts)
-  #:use-module ((guix gexp) #:select (local-file local-file-file))
+  #:use-module (guix gexp)
   #:use-module (guix utils)
   #:use-module ((guix diagnostics)
                 ;; Rename the 'location' binding to allow proper syntax
@@ -32,6 +33,7 @@
                                   (else name))))
   #:use-module ((gcrypt hash) #:prefix gcrypt:)
   #:use-module (guix derivations)
+  #:use-module (guix download)
   #:use-module (guix packages)
   #:use-module (guix grafts)
   #:use-module (guix search-paths)
@@ -50,6 +52,7 @@
   #:use-module (gnu packages version-control)
   #:use-module (gnu packages xml)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
@@ -576,6 +579,11 @@
     (build-derivations %store (list drv))
     (call-with-input-file output get-string-all)))
 
+
+;;;
+;;; Source derivation with snippets.
+;;;
+
 (unless (network-reachable?) (test-skip 1))
 (test-equal "package-source-derivation, snippet"
   "OK"
@@ -631,6 +639,61 @@
     (and (build-derivations %store (list (pk 'snippet-drv drv)))
          (call-with-input-file out get-string-all))))
 
+;; Note: lzip is not part of bootstrap-coreutils&co, so is not included to
+;; avoid having to rebuild the world.
+(define compressors '(("gzip"  . "gz")
+                      ("xz"    . "xz")
+                      ("bzip2" . "bz2")
+                      (#f      . #f)))
+
+(for-each
+ (match-lambda
+   ((comp . ext)
+    (unless (network-reachable?) (test-skip 1))
+    (test-equal (string-append "origin->derivation, single file with snippet "
+                               "(compression: " (if comp comp "None") ")")
+      "2 + 2 = 4"
+      (let*-values
+          (((name) "maths")
+           ((compressed-name) (if comp
+                                  (string-append name "." ext)
+                                  name))
+           ((file hash) (test-file %store compressed-name "2 + 2 = 5"))
+           ;; Create an origin using the above computed file and its hash.
+           ((source) (origin
+                       (method url-fetch)
+                       (uri (string-append "file://" file))
+                       (file-name compressed-name)
+                       (patch-inputs `(("tar"   ,%bootstrap-coreutils&co)
+                                       ("xz"    ,%bootstrap-coreutils&co)
+                                       ("bzip2" ,%bootstrap-coreutils&co)
+                                       ("gzip"  ,%bootstrap-coreutils&co)))
+                       (patch-guile %bootstrap-guile)
+                       (modules '((guix build utils)))
+                       (snippet `(substitute* ,name
+                                   (("5") "4")))
+                       (hash (content-hash hash))))
+           ;; Build origin.
+           ((drv) (run-with-store %store (origin->derivation source)))
+           ((out) (derivation->output-path drv)))
+        ;; Decompress the resulting tar.xz and return its content.
+        (and (build-derivations %store (list drv))
+             (let* ((bin #~(string-append #+%bootstrap-coreutils&co
+                                          "/bin"))
+                    (f (computed-file
+                        name
+                        (with-imported-modules '((guix build utils))
+                          #~(begin
+                              (use-modules (guix build utils))
+                              (setenv "PATH" #+bin)
+                              (invoke "tar" "xvf" #+out)
+                              (copy-file #+name #$output)))))
+                    (drv (run-with-store %store (lower-object f)))
+                    (_ (build-derivations %store (list drv))))
+               (call-with-input-file (derivation->output-path drv)
+                 get-string-all)))))))
+ compressors)
+
 (test-assert "return value"
   (let ((drv (package-derivation %store (dummy-package "p"))))
     (and (derivation? drv)
-- 
2.29.2





Information forwarded to guix-patches <at> gnu.org:
bug#45774; Package guix-patches. (Thu, 14 Jan 2021 17:49:02 GMT) Full text and rfc822 format available.

Message #13 received at 45774 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: 45774 <at> debbugs.gnu.org, 45773 <at> debbugs.gnu.org
Subject: Re: bug#45773: [PATCH core-updates 0/1] Allow patch-and-repack to
 work with plain files.
Date: Thu, 14 Jan 2021 18:48:04 +0100
Hi!

Maxim Cournoyer <maxim.cournoyer <at> gmail.com> skribis:

> Before this change, only plain directories, tar or zip archives were supported
> as the source of a package for the GNU build system; anything else would cause
> the unpack phase to fail.  Origins relying on snippets would suffer from the
> same problem.
>
> This change adds the support to use files of the following extensions: .gz,
> .Z, .bz2, .lz, and .xz, even when they are not tarballs.  Files of unknown
> extensions are treated as uncompressed files and supported as well.
>
> * guix/packages.scm (patch-and-repack): Only add the compressor utility to the
> PATH when the file is compressed.  Bind more inputs in the mlet, and use them
> for decompressing single files.  Adjust decompression and compression routines.
> [decompression-type]: Return #f when no known compression extension is used.
> [tarball?]: New nested procedure.
> * guix/build/utils.scm (compressor, tarball?): New procedures.  Move
> %xz-parallel-args to the new 'compression helpers' section.
> * tests/packages.scm: Add tests.  Add missing copyright year for Jan.
> * guix/build/gnu-build-system.scm (first-subdirectory): Return #f when no
> sub-directory was found.
> (unpack): Support more file types, including uncompressed plain files.
> ---
>  guix/build/gnu-build-system.scm |  24 ++++++--
>  guix/build/utils.scm            |  47 ++++++++++-----
>  guix/packages.scm               | 100 +++++++++++++++++---------------
>  guix/tests.scm                  |  40 ++++++++++++-
>  tests/builders.scm              |  40 ++++++++++++-
>  tests/packages.scm              |  69 +++++++++++++++++++++-
>  6 files changed, 247 insertions(+), 73 deletions(-)

How frequent is it for an origin to be a regular file other than an
archive?  The underlying question for me is: will this generalization
and increased complexity pay off?  WDYT?

There are aspects of the patch that I find welcome regardless, such as
the improved handling of compression helpers.

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#45774; Package guix-patches. (Thu, 14 Jan 2021 18:44:02 GMT) Full text and rfc822 format available.

Message #16 received at 45774 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 45774 <at> debbugs.gnu.org, 45773 <at> debbugs.gnu.org
Subject: Re: bug#45773: [PATCH core-updates 0/1] Allow patch-and-repack to
 work with plain files.
Date: Thu, 14 Jan 2021 13:43:43 -0500
Hi Ludovic,

Ludovic Courtès <ludo <at> gnu.org> writes:

> Hi!
>
> Maxim Cournoyer <maxim.cournoyer <at> gmail.com> skribis:
>
>> Before this change, only plain directories, tar or zip archives were supported
>> as the source of a package for the GNU build system; anything else would cause
>> the unpack phase to fail.  Origins relying on snippets would suffer from the
>> same problem.
>>
>> This change adds the support to use files of the following extensions: .gz,
>> .Z, .bz2, .lz, and .xz, even when they are not tarballs.  Files of unknown
>> extensions are treated as uncompressed files and supported as well.
>>
>> * guix/packages.scm (patch-and-repack): Only add the compressor utility to the
>> PATH when the file is compressed.  Bind more inputs in the mlet, and use them
>> for decompressing single files.  Adjust decompression and compression routines.
>> [decompression-type]: Return #f when no known compression extension is used.
>> [tarball?]: New nested procedure.
>> * guix/build/utils.scm (compressor, tarball?): New procedures.  Move
>> %xz-parallel-args to the new 'compression helpers' section.
>> * tests/packages.scm: Add tests.  Add missing copyright year for Jan.
>> * guix/build/gnu-build-system.scm (first-subdirectory): Return #f when no
>> sub-directory was found.
>> (unpack): Support more file types, including uncompressed plain files.
>> ---
>>  guix/build/gnu-build-system.scm |  24 ++++++--
>>  guix/build/utils.scm            |  47 ++++++++++-----
>>  guix/packages.scm               | 100 +++++++++++++++++---------------
>>  guix/tests.scm                  |  40 ++++++++++++-
>>  tests/builders.scm              |  40 ++++++++++++-
>>  tests/packages.scm              |  69 +++++++++++++++++++++-
>>  6 files changed, 247 insertions(+), 73 deletions(-)
>
> How frequent is it for an origin to be a regular file other than an
> archive?  The underlying question for me is: will this generalization
> and increased complexity pay off?  WDYT?

I think consistency is the main driver here.  The url-fetch method
supports single file sources; it makes sense that the other components
handling sources support it as well.  It's hard to judge of the
popularity of such a feature when it's never been available; but some
use cases come to mind such as single Emacs package file.  I've made use
of such feature for the new texlive-updmap.cfg definition in
<http://issues.guix.gnu.org/45870>.

> There are aspects of the patch that I find welcome regardless, such as
> the improved handling of compression helpers.

Great!  Thanks for looking at it.

Maxim




Information forwarded to guix-patches <at> gnu.org:
bug#45774; Package guix-patches. (Mon, 18 Jan 2021 16:52:01 GMT) Full text and rfc822 format available.

Message #19 received at 45774 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: guix-patches <at> gnu.org,
	45774 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org, Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Subject: [PATCH core-updates v3 1/2] utils: Retrieve the store prefix from
 NIX_STORE_DIR, not STORE_DIR.
Date: Mon, 18 Jan 2021 11:51:20 -0500
On the daemon side, nixStore gets set to the environment variable
NIX_STORE_DIR, else the environment variable NIX_STORE else the compile time
macro NIX_STORE_DIR (see the Settings::processEnvironment method in
nix/libstore/globals.cc).  Hence, it is more appropriate to lookup the
environment variable NIX_STORE_DIR than NIX_STORE in (guix build utils).

* guix/build/utils.scm (%store-directory): Call getenv with NIX_STORE_DIR
instead of NIX_STORE.
---
 guix/build/utils.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 76180e67e0..2cbdb31505 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -144,7 +144,7 @@
 
 (define (%store-directory)
   "Return the directory name of the store."
-  (or (getenv "NIX_STORE")
+  (or (getenv "NIX_STORE_DIR")
       "/gnu/store"))
 
 (define (store-file-name? file)
-- 
2.29.2





Information forwarded to guix-patches <at> gnu.org:
bug#45774; Package guix-patches. (Mon, 18 Jan 2021 16:53:03 GMT) Full text and rfc822 format available.

Message #22 received at 45774 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: guix-patches <at> gnu.org,
	45774 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org, Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Subject: [PATCH core-updates v3 2/2] build-systems/gnu: Allow
 unpacking/repacking more kind of files.
Date: Mon, 18 Jan 2021 11:51:21 -0500
Before this change, only plain directories, tar or zip archives were supported
as the source of a package for the GNU build system; anything else would cause
the unpack phase to fail.  Origins relying on snippets would suffer from the
same problem.

This change adds the support to use files of the following extensions: .gz,
.Z, .bz2, .lz, and .xz, even when they are not tarballs.  Files of unknown
extensions are treated as uncompressed files and supported as well.

* guix/packages.scm (patch-and-repack): Only add the compressor utility to the
PATH when the file is compressed.  Bind more inputs in the mlet, and use them
for decompressing single files.  Adjust the decompression and compression
routines.
[decompression-type]: Remove nested variable.
* guix/build/utils.scm (compressor, tarball?): New procedures.  Move
%xz-parallel-args to the new 'compression helpers' section.
* tests/packages.scm: Add tests.  Add missing copyright year for Jan.
* guix/build/gnu-build-system.scm (first-subdirectory): Return #f when no
sub-directory was found.
(unpack): Support more file types, including uncompressed plain files.
---
 guix/build/gnu-build-system.scm |  24 +++++--
 guix/build/utils.scm            |  47 +++++++++----
 guix/packages.scm               | 117 ++++++++++++++++++--------------
 guix/tests.scm                  |  43 +++++++++++-
 tests/builders.scm              |  35 +++++++++-
 tests/packages.scm              |  72 +++++++++++++++++++-
 6 files changed, 259 insertions(+), 79 deletions(-)

diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index f8e8a46854..66edd2de2d 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2018 Mark H Weaver <mhw <at> netris.org>
 ;;; Copyright © 2020 Brendan Tildesley <mail <at> brendan.scot>
+;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -60,13 +61,15 @@ See https://reproducible-builds.org/specs/source-date-epoch/."
   (setenv "SOURCE_DATE_EPOCH" "1"))
 
 (define (first-subdirectory directory)
-  "Return the file name of the first sub-directory of DIRECTORY."
+  "Return the file name of the first sub-directory of DIRECTORY or false, when
+there are none."
   (match (scandir directory
                   (lambda (file)
                     (and (not (member file '("." "..")))
                          (file-is-directory? (string-append directory "/"
                                                             file)))))
-    ((first . _) first)))
+    ((first . _) first)
+    (_ #f)))
 
 (define* (set-paths #:key target inputs native-inputs
                     (search-paths '()) (native-search-paths '())
@@ -155,10 +158,19 @@ working directory."
         (copy-recursively source "."
                           #:keep-mtime? #t))
       (begin
-        (if (string-suffix? ".zip" source)
-            (invoke "unzip" source)
-            (invoke "tar" "xvf" source))
-        (chdir (first-subdirectory ".")))))
+        (cond
+         ((string-suffix? ".zip" source)
+          (invoke "unzip" source))
+         ((tarball? source)
+          (invoke "tar" "xvf" source))
+         (else
+          (let ((name (strip-store-file-name source))
+                (command (compressor source)))
+            (copy-file source name)
+            (when command
+              (invoke command "--decompress" name)))))
+        ;; Attempt to change into child directory.
+        (and=> (first-subdirectory ".") chdir))))
 
 (define* (bootstrap #:key bootstrap-scripts
                     #:allow-other-keys)
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 2cbdb31505..01904785bd 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -6,7 +6,7 @@
 ;;; Copyright © 2018 Arun Isaac <arunisaac <at> systemreboot.net>
 ;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado <at> elephly.net>
 ;;; Copyright © 2020 Efraim Flashner <efraim <at> flashner.co.il>
-;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
+;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -51,6 +51,10 @@
             package-name->name+version
             parallel-job-count
 
+            compressor
+            tarball?
+            %xz-parallel-args
+
             directory-exists?
             executable-file?
             symbolic-link?
@@ -113,9 +117,7 @@
 
             make-desktop-entry-file
 
-            locale-category->string
-
-            %xz-parallel-args))
+            locale-category->string))
 
 
 ;;;
@@ -137,6 +139,32 @@
    (module-replace! (current-module) '(setvbuf)))
   (else #f))
 
+
+;;;
+;;; Compression helpers.
+;;;
+
+(define (compressor file-name)
+  "Return the name of the compressor package/binary used to compress or
+decompress FILE-NAME, based on its file extension, else false."
+  (cond ((string-suffix? "gz"  file-name)  "gzip")
+        ((string-suffix? "Z"   file-name)  "gzip")
+        ((string-suffix? "bz2" file-name)  "bzip2")
+        ((string-suffix? "lz"  file-name)  "lzip")
+        ((string-suffix? "zip" file-name)  "unzip")
+        ((string-suffix? "xz"  file-name)  "xz")
+        (else #f)))                ;no compression used/unknown file extension
+
+(define (tarball? file-name)
+  "True when FILE-NAME has a tar file extension."
+  (string-match "\\.(tar(\\..*)?|tgz|tbz)$" file-name))
+
+(define (%xz-parallel-args)
+  "The xz arguments required to enable bit-reproducible, multi-threaded
+compression."
+  (list "--memlimit=50%"
+        (format #f "--threads=~a" (max 2 (parallel-job-count)))))
+
 
 ;;;
 ;;; Directories.
@@ -1536,17 +1564,6 @@ returned."
              LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE
              LC_TIME)))
 
-
-;;;
-;;; Others.
-;;;
-
-(define (%xz-parallel-args)
-  "The xz arguments required to enable bit-reproducible, multi-threaded
-compression."
-  (list "--memlimit=50%"
-        (format #f "--threads=~a" (max 2 (parallel-job-count)))))
-
 ;;; Local Variables:
 ;;; eval: (put 'call-with-output-file/atomic 'scheme-indent-function 1)
 ;;; eval: (put 'call-with-ascii-input-file 'scheme-indent-function 1)
diff --git a/guix/packages.scm b/guix/packages.scm
index cd2cded9ee..73f605f3a9 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -5,7 +5,7 @@
 ;;; Copyright © 2016 Alex Kost <alezost <at> gmail.com>
 ;;; Copyright © 2017, 2019, 2020 Efraim Flashner <efraim <at> flashner.co.il>
 ;;; Copyright © 2019 Marius Bakke <mbakke <at> fastmail.com>
-;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
+;;; Copyright © 2020, 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -23,6 +23,7 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (guix packages)
+  #:use-module ((guix build utils) #:select (compressor tarball?))
   #:use-module (guix utils)
   #:use-module (guix records)
   #:use-module (guix store)
@@ -609,14 +610,6 @@ specifies modules in scope when evaluating SNIPPET."
           ((package) package)
           (#f        #f)))))
 
-  (define decompression-type
-    (cond ((string-suffix? "gz" source-file-name)  "gzip")
-          ((string-suffix? "Z" source-file-name)  "gzip")
-          ((string-suffix? "bz2" source-file-name) "bzip2")
-          ((string-suffix? "lz" source-file-name)  "lzip")
-          ((string-suffix? "zip" source-file-name) "unzip")
-          (else "xz")))
-
   (define original-file-name
     ;; Remove the store prefix plus the slash, hash, and hyphen.
     (let* ((sans (string-drop source-file-name
@@ -651,17 +644,24 @@ specifies modules in scope when evaluating SNIPPET."
        (lower-object patch system))))
 
   (mlet %store-monad ((tar ->     (lookup-input "tar"))
+                      (gzip ->    (lookup-input "gzip"))
+                      (bzip2 ->   (lookup-input "bzip2"))
+                      (lzip ->    (lookup-input "lzip"))
                       (xz ->      (lookup-input "xz"))
                       (patch ->   (lookup-input "patch"))
                       (locales -> (lookup-input "locales"))
-                      (decomp ->  (lookup-input decompression-type))
+                      (comp ->    (and=> (compressor source-file-name)
+                                         lookup-input))
                       (patches    (sequence %store-monad
                                             (map instantiate-patch patches))))
     (define build
       (with-imported-modules '((guix build utils))
         #~(begin
             (use-modules (ice-9 ftw)
+                         (ice-9 match)
+                         (ice-9 regex)
                          (srfi srfi-1)
+                         (srfi srfi-26)
                          (guix build utils))
 
             ;; The --sort option was added to GNU tar in version 1.28, released
@@ -723,54 +723,67 @@ specifies modules in scope when evaluating SNIPPET."
                                              (package-version locales)))))
               (setlocale LC_ALL "en_US.utf8"))
 
-            (setenv "PATH" (string-append #+xz "/bin" ":"
-                                          #+decomp "/bin"))
+            (setenv "PATH"
+                    (string-append #+xz "/bin"
+                                   (if #+comp
+                                       (string-append ":" #+comp "/bin")
+                                       "")))
 
             (setenv "XZ_DEFAULTS" (string-join (%xz-parallel-args)))
 
-            ;; SOURCE may be either a directory or a tarball.
-            (if (file-is-directory? #+source)
-                (let* ((store     (%store-directory))
-                       (len       (+ 1 (string-length store)))
-                       (base      (string-drop #+source len))
-                       (dash      (string-index base #\-))
-                       (directory (string-drop base (+ 1 dash))))
-                  (mkdir directory)
-                  (copy-recursively #+source directory))
-                #+(if (string=? decompression-type "unzip")
-                      #~(invoke "unzip" #+source)
-                      #~(invoke (string-append #+tar "/bin/tar")
-                                "xvf" #+source)))
-
-            (let ((directory (first-file ".")))
-              (format (current-error-port)
-                      "source is under '~a'~%" directory)
-              (chdir directory)
-
-              (for-each apply-patch '#+patches)
-
-              #+(if snippet
-                    #~(let ((module (make-fresh-user-module)))
-                        (module-use-interfaces!
-                         module
-                         (map resolve-interface '#+modules))
-                        ((@ (system base compile) compile)
-                         '#+snippet
-                         #:to 'value
-                         #:opts %auto-compilation-options
-                         #:env module))
-                    #~#t)
-
-              (chdir "..")
+            ;; SOURCE may be either a directory, a tarball or a simple file.
+            (let ((name (strip-store-file-name #+source))
+                  (command (and=> #+comp (cut string-append <> "/bin/"
+                                              (compressor #+source)))))
+              (if (file-is-directory? #+source)
+                  (copy-recursively #+source name)
+                  (cond
+                   ((tarball? #+source)
+                    (invoke (string-append #+tar "/bin/tar") "xvf" #+source))
+                   ((and=> (compressor #+source) (cut string= "unzip" <>))
+                    ;; Note: Referring to the store unzip here (#+unzip)
+                    ;; would introduce a cycle.
+                    ("unzip" (invoke "unzip" #+source)))
+                   (else
+                    (copy-file #+source name)
+                    (when command
+                      (invoke command "--decompress" name))))))
+
+            (let* ((file (first-file "."))
+                   (directory (if (file-is-directory? file)
+                                  file
+                                  ".")))
+              (format (current-error-port) "source is at '~a'~%" file)
+
+              (with-directory-excursion directory
+
+                (for-each apply-patch '#+patches)
+
+                #+(if snippet
+                      #~(let ((module (make-fresh-user-module)))
+                          (module-use-interfaces!
+                           module
+                           (map resolve-interface '#+modules))
+                          ((@ (system base compile) compile)
+                           '#+snippet
+                           #:to 'value
+                           #:opts %auto-compilation-options
+                           #:env module))
+                      #~#t))
 
               ;; If SOURCE is a directory (such as a checkout), return a
               ;; directory.  Otherwise create a tarball.
-              (if (file-is-directory? #+source)
-                  (copy-recursively directory #$output
-                                    #:log (%make-void-port "w"))
-                  (repack directory #$output))))))
-
-    (let ((name (if (checkout? original-file-name)
+              (cond
+               ((file-is-directory? #+source)
+                (copy-recursively directory #$output
+                                  #:log (%make-void-port "w")))
+               ((not #+comp)
+                (copy-file file #$output))
+               (else
+                (repack directory #$output)))))))
+
+    (let ((name (if (or (checkout? original-file-name)
+                        (not (compressor original-file-name)))
                     original-file-name
                     (tarxz-name original-file-name))))
       (gexp->derivation name build
diff --git a/guix/tests.scm b/guix/tests.scm
index fc3d521163..da75835099 100644
--- a/guix/tests.scm
+++ b/guix/tests.scm
@@ -20,12 +20,13 @@
   #:use-module ((guix config) #:select (%storedir %localstatedir))
   #:use-module (guix store)
   #:use-module (guix derivations)
+  #:use-module (guix gexp)
   #:use-module (guix packages)
   #:use-module (guix base32)
   #:use-module (guix serialization)
   #:use-module (guix monads)
   #:use-module ((guix utils) #:select (substitute-keyword-arguments))
-  #:use-module ((guix build utils) #:select (mkdir-p))
+  #:use-module ((guix build utils) #:select (mkdir-p compressor))
   #:use-module ((gcrypt hash) #:hide (sha256))
   #:use-module (guix build-system gnu)
   #:use-module (gnu packages base)
@@ -60,7 +61,9 @@
             dummy-package
             dummy-origin
 
-            gnu-make-for-tests))
+            gnu-make-for-tests
+
+            test-file))
 
 ;;; Commentary:
 ;;;
@@ -435,6 +438,42 @@ default values, and with EXTRA-FIELDS set as specified."
      (native-inputs '())                          ;no need for 'pkg-config'
      (inputs %bootstrap-inputs-for-tests))))
 
+
+;;;
+;;; Test utility procedures.
+
+(define (test-file store name content)
+  "Create a simple file in STORE with CONTENT (a string), compressed according
+to its file name extension.  Return both its file name and its hash."
+  (let* ((ext (string-index-right name #\.))
+         (name-sans-ext (if ext
+                            (string-take name (string-index-right name #\.))
+                            name))
+         (comp (compressor name))
+         (command #~(if #+comp
+                        (string-append #+%bootstrap-coreutils&co
+                                       "/bin/" #+comp)
+                        #f))
+         (f (with-imported-modules '((guix build utils))
+              (computed-file name
+                             #~(begin
+                                 (use-modules (guix build utils)
+                                              (rnrs io simple))
+                                 (with-output-to-file #+name-sans-ext
+                                   (lambda _
+                                     (format #t #+content)))
+                                 (when #+command
+                                   (invoke #+command #+name-sans-ext))
+                                 (copy-file #+name #$output)))))
+         (file-drv (run-with-store store (lower-object f)))
+         (file (derivation->output-path file-drv))
+         (file-drv-outputs (derivation-outputs file-drv))
+         (_ (build-derivations store (list file-drv)))
+         (file-hash (derivation-output-hash
+                     (assoc-ref file-drv-outputs "out"))))
+    (values file file-hash)))
+
+;;;
 ;; Local Variables:
 ;; eval: (put 'call-with-derivation-narinfo 'scheme-indent-function 1)
 ;; eval: (put 'call-with-derivation-substitute 'scheme-indent-function 2)
diff --git a/tests/builders.scm b/tests/builders.scm
index fdcf38ded3..624547500a 100644
--- a/tests/builders.scm
+++ b/tests/builders.scm
@@ -17,10 +17,12 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 
-(define-module (test-builders)
+(define-module (tests builders)
   #:use-module (guix download)
   #:use-module (guix build-system)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build gnu-build-system)
+  #:use-module (guix build utils)
   #:use-module (guix store)
   #:use-module (guix utils)
   #:use-module (guix base32)
@@ -32,7 +34,9 @@
                           package-derivation package-native-search-paths))
   #:use-module (gnu packages bootstrap)
   #:use-module (ice-9 match)
+  #:use-module (ice-9 textual-ports)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-64))
 
 ;; Test the higher-level builders.
@@ -78,4 +82,33 @@
 (test-assert "gnu-build-system"
   (build-system? gnu-build-system))
 
+(define unpack (assoc-ref %standard-phases 'unpack))
+
+(define compressors '(("gzip"  . "gz")
+                      ("xz"    . "xz")
+                      ("bzip2" . "bz2")
+                      (#f      . #f)))
+
+(for-each
+ (match-lambda
+   ((comp . ext)
+
+    (unless (network-reachable?) (test-skip 1)) ;for bootstrap binaries
+    (test-equal (string-append "gnu-build-system unpack phase, "
+                               "single file (compression: "
+                               (if comp comp "None") ")")
+      "expected text"
+      (let*-values
+          (((name) "test")
+           ((compressed-name) (if ext
+                                  (string-append name "." ext)
+                                  name))
+           ((file hash) (test-file %store compressed-name "expected text")))
+        (call-with-temporary-directory
+         (lambda (dir)
+           (with-directory-excursion dir
+             (unpack #:source file)
+             (call-with-input-file name get-string-all))))))))
+ compressors)
+
 (test-end "builders")
diff --git a/tests/packages.scm b/tests/packages.scm
index a867f2fd6d..b3ccd98e48 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo <at> gnu.org>
-;;; Copyright © Jan (janneke) Nieuwenhuizen <janneke <at> gnu.org>
+;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke <at> gnu.org>
+;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -17,13 +18,14 @@
 ;;; You should have received a copy of the GNU General Public License
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
-(define-module (test-packages)
+(define-module (tests packages)
   #:use-module (guix tests)
   #:use-module (guix store)
   #:use-module (guix monads)
   #:use-module (guix grafts)
-  #:use-module ((guix gexp) #:select (local-file local-file-file))
+  #:use-module (guix gexp)
   #:use-module (guix utils)
+  #:use-module ((guix build utils) #:select (tarball?))
   #:use-module ((guix diagnostics)
                 ;; Rename the 'location' binding to allow proper syntax
                 ;; matching when setting the 'location' field of a package.
@@ -32,6 +34,7 @@
                                   (else name))))
   #:use-module ((gcrypt hash) #:prefix gcrypt:)
   #:use-module (guix derivations)
+  #:use-module (guix download)
   #:use-module (guix packages)
   #:use-module (guix grafts)
   #:use-module (guix search-paths)
@@ -50,6 +53,7 @@
   #:use-module (gnu packages version-control)
   #:use-module (gnu packages xml)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
@@ -576,6 +580,11 @@
     (build-derivations %store (list drv))
     (call-with-input-file output get-string-all)))
 
+
+;;;
+;;; Source derivation with snippets.
+;;;
+
 (unless (network-reachable?) (test-skip 1))
 (test-equal "package-source-derivation, snippet"
   "OK"
@@ -631,6 +640,63 @@
     (and (build-derivations %store (list (pk 'snippet-drv drv)))
          (call-with-input-file out get-string-all))))
 
+;; Note: lzip is not part of bootstrap-coreutils&co, so is not included to
+;; avoid having to rebuild the world.
+(define compressors '(("gzip"  . "gz")
+                      ("xz"    . "xz")
+                      ("bzip2" . "bz2")
+                      (#f      . #f)))
+
+(for-each
+ (match-lambda
+   ((comp . ext)
+    (unless (network-reachable?) (test-skip 1))
+    (test-equal (string-append "origin->derivation, single file with snippet "
+                               "(compression: " (if comp comp "None") ")")
+      "2 + 2 = 4"
+      (let*-values
+          (((name) "maths")
+           ((compressed-name) (if comp
+                                  (string-append name "." ext)
+                                  name))
+           ((file hash) (test-file %store compressed-name "2 + 2 = 5"))
+           ;; Create an origin using the above computed file and its hash.
+           ((source) (origin
+                       (method url-fetch)
+                       (uri (string-append "file://" file))
+                       (file-name compressed-name)
+                       (patch-inputs `(("tar"   ,%bootstrap-coreutils&co)
+                                       ("xz"    ,%bootstrap-coreutils&co)
+                                       ("bzip2" ,%bootstrap-coreutils&co)
+                                       ("gzip"  ,%bootstrap-coreutils&co)))
+                       (patch-guile %bootstrap-guile)
+                       (modules '((guix build utils)))
+                       (snippet `(substitute* ,name
+                                   (("5") "4")))
+                       (hash (content-hash hash))))
+           ;; Build origin.
+           ((drv) (run-with-store %store (origin->derivation source)))
+           ((out) (derivation->output-path drv)))
+        ;; Decompress the resulting tar.xz and return its content.
+        (and (build-derivations %store (list drv))
+             (if (tarball? out)
+                 (let* ((bin #~(string-append #+%bootstrap-coreutils&co
+                                              "/bin"))
+                        (f (computed-file
+                            name
+                            (with-imported-modules '((guix build utils))
+                              #~(begin
+                                  (use-modules (guix build utils))
+                                  (setenv "PATH" #+bin)
+                                  (invoke "tar" "xvf" #+out)
+                                  (copy-file #+name #$output)))))
+                        (drv (run-with-store %store (lower-object f)))
+                        (_ (build-derivations %store (list drv))))
+                   (call-with-input-file (derivation->output-path drv)
+                     get-string-all))
+                 (call-with-input-file out get-string-all)))))))
+ compressors)
+
 (test-assert "return value"
   (let ((drv (package-derivation %store (dummy-package "p"))))
     (and (derivation? drv)
-- 
2.29.2





Forcibly Merged 45773 45774 45959. Request was from Maxim Cournoyer <maxim.cournoyer <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 25 Jan 2021 14:21:02 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#45774; Package guix-patches. (Wed, 27 Jan 2021 03:58:04 GMT) Full text and rfc822 format available.

Message #27 received at 45774-done <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 45774-done <at> debbugs.gnu.org, 45773-done <at> debbugs.gnu.org
Subject: Re: bug#45773: [PATCH core-updates 0/1] Allow patch-and-repack to
 work with plain files.
Date: Tue, 26 Jan 2021 22:57:22 -0500
Hi Ludo,

Maxim Cournoyer <maxim.cournoyer <at> gmail.com> writes:

> Hi Ludovic,
>
> Ludovic Courtès <ludo <at> gnu.org> writes:
>
>> Hi!
>>
>> Maxim Cournoyer <maxim.cournoyer <at> gmail.com> skribis:
>>
>>> Before this change, only plain directories, tar or zip archives were supported
>>> as the source of a package for the GNU build system; anything else would cause
>>> the unpack phase to fail.  Origins relying on snippets would suffer from the
>>> same problem.
>>>
>>> This change adds the support to use files of the following extensions: .gz,
>>> .Z, .bz2, .lz, and .xz, even when they are not tarballs.  Files of unknown
>>> extensions are treated as uncompressed files and supported as well.
>>>
>>> * guix/packages.scm (patch-and-repack): Only add the compressor utility to the
>>> PATH when the file is compressed.  Bind more inputs in the mlet, and use them
>>> for decompressing single files.  Adjust decompression and compression routines.
>>> [decompression-type]: Return #f when no known compression extension is used.
>>> [tarball?]: New nested procedure.
>>> * guix/build/utils.scm (compressor, tarball?): New procedures.  Move
>>> %xz-parallel-args to the new 'compression helpers' section.
>>> * tests/packages.scm: Add tests.  Add missing copyright year for Jan.
>>> * guix/build/gnu-build-system.scm (first-subdirectory): Return #f when no
>>> sub-directory was found.
>>> (unpack): Support more file types, including uncompressed plain files.
>>> ---
>>>  guix/build/gnu-build-system.scm |  24 ++++++--
>>>  guix/build/utils.scm            |  47 ++++++++++-----
>>>  guix/packages.scm               | 100 +++++++++++++++++---------------
>>>  guix/tests.scm                  |  40 ++++++++++++-
>>>  tests/builders.scm              |  40 ++++++++++++-
>>>  tests/packages.scm              |  69 +++++++++++++++++++++-
>>>  6 files changed, 247 insertions(+), 73 deletions(-)
>>
>> How frequent is it for an origin to be a regular file other than an
>> archive?  The underlying question for me is: will this generalization
>> and increased complexity pay off?  WDYT?
>
> I think consistency is the main driver here.  The url-fetch method
> supports single file sources; it makes sense that the other components
> handling sources support it as well.  It's hard to judge of the
> popularity of such a feature when it's never been available; but some
> use cases come to mind such as single Emacs package file.  I've made use
> of such feature for the new texlive-updmap.cfg definition in
> <http://issues.guix.gnu.org/45870>.

I've been building a sizable part of core-updates on top of this change
now for nearly two weeks, and in this time it's already come handy
twice.

I've made sure the tests ran fine and pushed to core-updates as commit
cfcead2e515c0dae02127e5a76496463898be6b6.

Let me know if anything breaks :-).

Maxim




Information forwarded to guix-patches <at> gnu.org:
bug#45774; Package guix-patches. (Wed, 27 Jan 2021 03:59:01 GMT) Full text and rfc822 format available.

Message #30 received at 45774-done <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: 45958-done <at> debbugs.gnu.org
Cc: 45774-done <at> debbugs.gnu.org, ludo <at> gnu.org
Subject: Re: bug#45958: [PATCH core-updates v3 1/2] utils: Retrieve the
 store prefix from NIX_STORE_DIR, not STORE_DIR.
Date: Tue, 26 Jan 2021 22:58:53 -0500
Hello,

Maxim Cournoyer <maxim.cournoyer <at> gmail.com> writes:

> On the daemon side, nixStore gets set to the environment variable
> NIX_STORE_DIR, else the environment variable NIX_STORE else the compile time
> macro NIX_STORE_DIR (see the Settings::processEnvironment method in
> nix/libstore/globals.cc).  Hence, it is more appropriate to lookup the
> environment variable NIX_STORE_DIR than NIX_STORE in (guix build utils).
>
> * guix/build/utils.scm (%store-directory): Call getenv with NIX_STORE_DIR
> instead of NIX_STORE.
> ---
>  guix/build/utils.scm | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/guix/build/utils.scm b/guix/build/utils.scm
> index 76180e67e0..2cbdb31505 100644
> --- a/guix/build/utils.scm
> +++ b/guix/build/utils.scm
> @@ -144,7 +144,7 @@
>  
>  (define (%store-directory)
>    "Return the directory name of the store."
> -  (or (getenv "NIX_STORE")
> +  (or (getenv "NIX_STORE_DIR")
>        "/gnu/store"))
>  
>  (define (store-file-name? file)

I found that both environment variables should be honored and pushed
with a revised explanation in 47a6a938c3c4d0bbe7b6a3c64ff75d7bfb2f24fb.

Closing,

Maxim




Information forwarded to guix-patches <at> gnu.org:
bug#45774; Package guix-patches. (Wed, 27 Jan 2021 23:12:01 GMT) Full text and rfc822 format available.

Message #33 received at 45774-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Cc: 45774-done <at> debbugs.gnu.org, 45958-done <at> debbugs.gnu.org
Subject: Re: bug#45958: [PATCH core-updates v3 1/2] utils: Retrieve the
 store prefix from NIX_STORE_DIR, not STORE_DIR.
Date: Thu, 28 Jan 2021 00:10:53 +0100
Maxim Cournoyer <maxim.cournoyer <at> gmail.com> skribis:

>>  (define (%store-directory)
>>    "Return the directory name of the store."
>> -  (or (getenv "NIX_STORE")
>> +  (or (getenv "NIX_STORE_DIR")
>>        "/gnu/store"))
>>  
>>  (define (store-file-name? file)
>
> I found that both environment variables should be honored and pushed
> with a revised explanation in 47a6a938c3c4d0bbe7b6a3c64ff75d7bfb2f24fb.

Sounds good to me, thanks!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 25 Feb 2021 12:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 32 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.