Subject: [PATCH] gnu: criu: Update to 3.19.

From: Sergio Pastor Pérez <[email-masked]>
Date: Tue, 23 Jul 2024 20:09:39 +0200

* gnu/packages/virtualization.scm (criu): Update to 3.19.

Change-Id: I701f925a47597eea559b6448a08c117ed65b453d
---
Hello, I'm updating CRIU to version 3.19.

As you can see I've changed the input style and phases so they use
G-Expressions.

I had to add a new phase before `install` to avoid pip from fetching
dependencies over the network. I'm not sure that this is the best way to do it
but I could not find an equivalent flag to `--single-version-externally-managed`
for pip.

Hope this helps.
Regards,
Sergio.

 gnu/packages/virtualization.scm | 213 +++++++++++++++++---------------
 1 file changed, 116 insertions(+), 97 deletions(-)

diff --git a/gnu/packages/virtualization.scm b/gnu/packages/virtualization.scm
index 061748bb4a..3860eabe7e 100644
--- a/gnu/packages/virtualization.scm
+++ b/gnu/packages/virtualization.scm
@@ -1948,7 +1948,7 @@ (define-public vmware-open-vm-tools-gtk
 (define-public criu
   (package
     (name "criu")
-    (version "3.17.1")
+    (version "3.19")
     (source
      (origin
        (method git-fetch)
@@ -1957,110 +1957,129 @@ (define-public criu
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "0ff3xfcf0wfz02fc0qbj56mci1a0xdl8jzaihaw6qyjvgrsiq7fh"))))
+        (base32 "01mbr90hsk6s9i33wi5l6swba302a8w4iqckbfkdbvp6fw2g2jab"))))
     (build-system gnu-build-system)
     (arguments
-     `(#:test-target "test"
-       #:tests? #f ; tests require mounting as root
-       #:make-flags
-       (list (string-append "PREFIX=" (assoc-ref %outputs "out"))
-             (string-append "LIBDIR=$(PREFIX)/lib")
-             ;; Upstream mistakenly puts binaries in /var.  Now, in practice no
-             ;; plugins are built, but the build system still fails otherwise.
-             (string-append "PLUGINDIR=$(LIBDIR)/criu")
-             (string-append "ASCIIDOC="
-                            (search-input-file %build-inputs
-                                               "/bin/asciidoc"))
-             (string-append "PYTHON=python3")
-             (string-append "XMLTO="
-                            (search-input-file %build-inputs
-                                               "/bin/xmlto")))
-       #:modules ((ice-9 ftw)
+     (list
+      #:test-target "test"
+      #:tests? #f ;tests require mounting as root
+      #:make-flags #~(list (string-append "PREFIX="
+                                          #$output)
+                           (string-append "LIBDIR=$(PREFIX)/lib")
+                           ;; Upstream mistakenly puts binaries in /var.  Now,
+                           ;; in practice no plugins are built, but the build
+                           ;; system still fails otherwise.
+                           (string-append "PLUGINDIR=$(LIBDIR)/criu")
+                           (string-append "ASCIIDOC="
+                                          (string-append #$asciidoc
+                                                         "/bin/asciidoc"))
+                           (string-append "PYTHON=python3")
+                           (string-append "XMLTO="
+                                          (string-append #$xmlto "/bin/xmlto")))
+      #:modules `((ice-9 ftw)
                   ,@%gnu-build-system-modules)
-       #: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"))))
-             ))
-         ;; TODO: use
-         ;; (@@ (guix build python-build-system) ensure-no-mtimes-pre-1980)
-         ;; when it no longer throws due to trying to call UTIME on symlinks.
-         (add-after 'unpack 'ensure-no-mtimes-pre-1980
-           (lambda _
-             (let ((early-1980 315619200))  ; 1980-01-02 UTC
-               (ftw "." (lambda (file stat flag)
-                          (unless (or (<= early-1980 (stat:mtime stat))
-                                      (eq? (stat:type stat) 'symlink))
-                            (utime file early-1980 early-1980))
-                          #t)))))
-         (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* ((out  (assoc-ref outputs "out"))
-                    (site (string-append out "/lib/python"
-                                         ,(version-major+minor
-                                           (package-version python))
-                                         "/site-packages"))
-                    (path (getenv "GUIX_PYTHONPATH")))
-               (wrap-program (string-append out "/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* (#:key outputs #:allow-other-keys)
-             (let ((out (assoc-ref outputs "out")))
-               (for-each delete-file (find-files out "\\.a$"))))))))
-    (inputs
-     `(("protobuf" ,protobuf)
-       ("python-protobuf" ,python-protobuf)
-       ("iproute" ,iproute)
-       ("libaio" ,libaio)
-       ("libcap" ,libcap)
-       ("libnet" ,libnet)
-       ("libnl" ,libnl)
-       ("libbsd" ,libbsd)
-       ("nftables" ,nftables)))
-    (native-inputs
-     (list pkg-config
-           perl
-           asciidoc
-           xmlto
-           docbook-xml
-           docbook-xsl
-           python-toolchain))
+      #:phases #~(modify-phases %standard-phases
+                   (delete 'configure) ;no configure script
+                   (add-after 'unpack 'fix-documentation
+                     (lambda _
+                       (substitute* "Documentation/Makefile"
+                         (("-m custom.xsl")
+                          (string-append "-m custom.xsl --skip-validation -x "
+                           #$docbook-xsl
+                           "/xml/xsl/"
+                           #$(package-name docbook-xsl)
+                           "-"
+                           #$(package-version docbook-xsl)
+                           "/manpages/docbook.xsl")))))
+                   (add-after 'unpack 'hardcode-variables
+                     (lambda _
+                       ;; Hardcode arm version detection
+                       (substitute* "Makefile"
+                         (("ARMV.*:=.*")
+                          "ARMV := 7\n"))
+                       ;; Hard-code the correct PLUGINDIR above.
+                       (substitute* "criu/include/plugin.h"
+                         (("/var")
+                          #$output))))
+                   ;; TODO: use (@@ (guix build python-build-system)
+                   ;; ensure-no-mtimes-pre-1980) when it no longer throws due to
+                   ;; trying to call UTIME on symlinks.
+                   (add-after 'unpack 'ensure-no-mtimes-pre-1980
+                     (lambda _
+                       (let ((early-1980 315619200))
+                         ;; 1980-01-02 UTC
+                         (ftw "."
+                              (lambda (file stat flag)
+                                (unless (or (<= early-1980
+                                                (stat:mtime stat))
+                                            (eq? (stat:type stat)
+                                                 'symlink))
+                                  (utime file early-1980 early-1980)) #t)))))
+                   (add-before 'build 'fix-symlink
+                     (lambda _
+                       ;; The file 'images/google/protobuf/descriptor.proto'
+                       ;; points to /usr/include/..., which does not exist.
+                       (let* ((file "google/protobuf/descriptor.proto")
+                              (target (string-append "images/" file))
+                              (source (string-append #$protobuf "/include/"
+                                                     file)))
+                         (delete-file target)
+                         (symlink source target))))
+                   (add-before 'install 'fix-python-install
+                     (lambda _
+                       (let ((install-cmd (string-append "$(PYTHON)"
+                                           " setup.py install"
+                                           " --no-compile"
+                                           " --single-version-externally-managed"
+                                           " --root=/"
+                                           " --prefix=$(DESTDIR)$(PREFIX)\n")))
+                         (substitute* "lib/Makefile"
+                           (("\\$\\(PYTHON\\) -m pip install.*")
+                            (string-append "cd lib; " install-cmd)))
+                         (substitute* "crit/Makefile"
+                           (("\\$\\(PYTHON\\) -m pip install.*")
+                            (string-append "cd crit; " install-cmd))))))
+                   (add-after 'install 'wrap
+                     (lambda _
+                       ;; 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 bash-minimal
+                  protobuf
+                  python-protobuf
+                  iproute
+                  libaio
+                  libcap
+                  libnet
+                  libnl
+                  libbsd
+                  nftables))
+    (native-inputs (list pkg-config
+                         perl
+                         asciidoc
+                         xmlto
+                         docbook-xml
+                         docbook-xsl
+                         python-toolchain))
     (propagated-inputs
      ;; included by 'rpc.pb-c.h'
      (list protobuf-c))
     (home-page "https://criu.org")
     (synopsis "Checkpoint and restore in user space")
-    (description "Using this tool, you can freeze a running application (or
+    (description
+     "Using this tool, you can freeze a running application (or
 part of it) and checkpoint it to a hard drive as a collection of files.  You
 can then use the files to restore and run the application from the point it
 was frozen at.  The distinctive feature of the CRIU project is that it is

base-commit: d007b64356764f49677c78d82643f1125b5353b7
-- 
2.45.2