Subject: [bug#63044] [PATCH 4/4] gnu: criu: Change timestamps to 1-Jan-1980 before compressing

From: Brian Cully <[email-masked]>
Date: Sun, 23 Apr 2023 21:18:59 -0400

The zip library used by bdist in python-setuptools throws an error unless
files are from at least 1980.

 * gnu/packages/virtualization.scm (sssd) [change-file-datetimes]: new phase
---
 gnu/packages/virtualization.scm | 99 ++++++++++++++++++---------------
 1 file changed, 53 insertions(+), 46 deletions(-)

diff --git a/gnu/packages/virtualization.scm b/gnu/packages/virtualization.scm
index 20cbfcfcfe..910f8b321d 100644
--- a/gnu/packages/virtualization.scm
+++ b/gnu/packages/virtualization.scm
@@ -141,6 +141,7 @@ (define-module (gnu packages virtualization)
   #:use-module (guix git-download)
   #:use-module (guix gexp)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix modules)
   #:use-module (guix packages)
   #:use-module (guix utils)
   #:use-module (srfi srfi-1)
@@ -1699,52 +1700,58 @@ (define-public criu
                              (search-input-file %build-inputs
                                                 "/bin/xmlto")))
       #:phases
-      #~(modify-phases %standard-phases
-          (delete 'configure)            ; no configure script
-          (add-after 'unpack 'fix-documentation
-            (lambda* (#:key inputs outputs #:allow-other-keys)
-              (substitute* "Documentation/Makefile"
-                (("-m custom.xsl")
-                 (string-append
-                  "-m custom.xsl --skip-validation -x "
-                  (assoc-ref inputs "docbook-xsl") "/xml/xsl/"
-                  #$(package-name docbook-xsl) "-"
-                  #$(package-version docbook-xsl)
-                  "/manpages/docbook.xsl")))))
-          (add-after 'unpack 'hardcode-variables
-            (lambda* (#:key inputs outputs #:allow-other-keys)
-              ;; Hardcode arm version detection
-              (substitute* "Makefile"
-                (("ARMV.*:=.*") "ARMV := 7\n"))
-              ;; Hard-code the correct PLUGINDIR above.
-              (substitute* "criu/include/plugin.h"
-                (("/var") (string-append (assoc-ref outputs "out"))))
-              ))
-          (add-before 'build 'fix-symlink
-            (lambda* (#:key inputs #:allow-other-keys)
-              ;; The file 'images/google/protobuf/descriptor.proto' points to
-              ;; /usr/include/..., which obviously does not exist.
-              (let* ((file "google/protobuf/descriptor.proto")
-                     (target (string-append "images/" file))
-                     (source (search-input-file
-                              inputs
-                              (string-append "include/" file))))
-                (delete-file target)
-                (symlink source target))))
-          (add-after 'install 'wrap
-            (lambda* (#:key inputs outputs #:allow-other-keys)
-              ;; Make sure 'crit' runs with the correct PYTHONPATH.
-              (let* ((site (string-append #$output "/lib/python"
-                                          #$(version-major+minor
-                                             (package-version python))
-                                          "/site-packages"))
-                     (path (getenv "GUIX_PYTHONPATH")))
-                (wrap-program (string-append #$output "/bin/crit")
-                  `("GUIX_PYTHONPATH" ":" prefix (,site ,path))))))
-          (add-after 'install 'delete-static-libraries
-            ;; Not building/installing these at all doesn't seem to be supported.
-            (lambda _
-              (for-each delete-file (find-files #$output "\\.a$")))))))
+      (with-imported-modules (source-module-closure '((guix utils)))
+        #~(modify-phases %standard-phases
+            (delete 'configure)            ; no configure script
+            (add-after 'unpack 'fix-documentation
+              (lambda* (#:key inputs outputs #:allow-other-keys)
+                (substitute* "Documentation/Makefile"
+                  (("-m custom.xsl")
+                   (string-append
+                    "-m custom.xsl --skip-validation -x "
+                    (assoc-ref inputs "docbook-xsl") "/xml/xsl/"
+                    #$(package-name docbook-xsl) "-"
+                    #$(package-version docbook-xsl)
+                    "/manpages/docbook.xsl")))))
+            (add-after 'unpack 'hardcode-variables
+              (lambda* (#:key inputs outputs #:allow-other-keys)
+                ;; Hardcode arm version detection
+                (substitute* "Makefile"
+                  (("ARMV.*:=.*") "ARMV := 7\n"))
+                ;; Hard-code the correct PLUGINDIR above.
+                (substitute* "criu/include/plugin.h"
+                  (("/var") (string-append (assoc-ref outputs "out"))))
+                ))
+            (add-before 'build 'fix-symlink
+              (lambda* (#:key inputs #:allow-other-keys)
+                ;; The file 'images/google/protobuf/descriptor.proto' points to
+                ;; /usr/include/..., which obviously does not exist.
+                (let* ((file "google/protobuf/descriptor.proto")
+                       (target (string-append "images/" file))
+                       (source (search-input-file
+                                inputs
+                                (string-append "include/" file))))
+                  (delete-file target)
+                  (symlink source target))))
+            (add-before 'install 'change-file-datetimes
+              (lambda _
+                (use-modules (guix utils))
+                (change-file-timestamps-recursively "./"
+                                                    "1980-01-01 00:00:00")))
+            (add-after 'install 'wrap
+              (lambda* (#:key inputs outputs #:allow-other-keys)
+                ;; Make sure 'crit' runs with the correct PYTHONPATH.
+                (let* ((site (string-append #$output "/lib/python"
+                                            #$(version-major+minor
+                                               (package-version python))
+                                            "/site-packages"))
+                       (path (getenv "GUIX_PYTHONPATH")))
+                  (wrap-program (string-append #$output "/bin/crit")
+                    `("GUIX_PYTHONPATH" ":" prefix (,site ,path))))))
+            (add-after 'install 'delete-static-libraries
+              ;; Not building/installing these at all doesn't seem to be supported.
+              (lambda _
+                (for-each delete-file (find-files #$output "\\.a$"))))))))
     (inputs
      (list protobuf
            python
-- 
2.39.2