Subject: [bug#69620] [PATCH rust-team 2/2] gnu: rust-rocket: Upgraded and enabled full build

From: Aaron Covrig <[email-masked]>
Date: Thu, 7 Mar 2024 21:14:22 -0500

From: Aaron Covrig <[email-masked]>

    * gnu/packages/crates-web.scm (rust-hyper-sync-rustls-0.3) : Upgraded to version 0.3.0-rc17 (and maintained v0.3.0-rc4 as latest has breaking changes)
    * gnu/packages/crates-web.scm (rust-rocket) : Upgraded to v0.4.11 and changed to full build
    * gnu/packages/crates-web.scm (rust-rocket-codegen) : Upgraded to v0.4.11 and changed to build
    * gnu/packages/crates-web.scm (rust-rocket-http) : Upgraded to v0.4.11 and changed to build with tests
---
 gnu/packages/crates-web.scm | 171 ++++++++++++++++++++++++------------
 1 file changed, 114 insertions(+), 57 deletions(-)

diff --git a/gnu/packages/crates-web.scm b/gnu/packages/crates-web.scm
index 60c735efa7..58436084ed 100644
--- a/gnu/packages/crates-web.scm
+++ b/gnu/packages/crates-web.scm
@@ -42,6 +42,7 @@ (define-module (gnu packages crates-web)
   #:use-module (gnu packages crates-windows)
   #:use-module (gnu packages curl)
   #:use-module (gnu packages gtk)
+  #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages webkit))
@@ -3178,33 +3179,53 @@ (define-public rust-hyper-rustls-0.21
 (define-public rust-hyper-sync-rustls-0.3
   (package
     (name "rust-hyper-sync-rustls")
-    (version "0.3.0-rc.4")
+    (version "0.3.0-rc.17")
     (source
      (origin
        (method url-fetch)
        (uri (crate-uri "hyper-sync-rustls" version))
        (file-name (string-append name "-" version ".tar.gz"))
        (sha256
-        (base32 "16zirxhsk26kz5jxxxs37wxsm02id97h57kkqs512fj1j0x486kd"))))
+        (base32 "1az37mc4dgxgpqc745r495nm2dwx48amw2w6c8mnwj00xb219c2c"))))
     (build-system cargo-build-system)
     (arguments
-     `(#:cargo-test-flags
-       '("--release" "--"
-         ;; not all files included
-         "--skip=client"
-         "--skip=server")
-       #:cargo-inputs
-       (("rust-hyper" ,rust-hyper-0.10)
-        ("rust-rustls" ,rust-rustls-0.14)
-        ("rust-webpki" ,rust-webpki-0.18)
-        ("rust-webpki-roots" ,rust-webpki-roots-0.15))
-       #:cargo-development-inputs (("rust-env-logger" ,rust-env-logger-0.5))))
+     `(#:cargo-test-flags '("--release" "--"
+                            ;; skip tests client/server tests
+                            "--skip=client" "--skip=server")
+       #:cargo-inputs (("rust-hyper" ,rust-hyper-0.10)
+                       ("rust-rustls" ,rust-rustls-0.17)
+                       ("rust-webpki" ,rust-webpki-0.21)
+                       ("rust-webpki-roots" ,rust-webpki-roots-0.19))
+       #:cargo-development-inputs (("rust-env-logger" ,rust-env-logger-0.7))))
+    (native-inputs (list perl))
     (home-page "https://github.com/SergioBenitez/hyper-sync-rustls")
     (synopsis "Glue code for Rustls and synchronous Hyper")
     (description
      "This package provides glue code for Rustls and synchronous Hyper.")
     (license (list license:expat license:asl2.0))))
 
+(define-public rust-hyper-sync-rustls-0.3-rc4
+  (package
+    (inherit rust-hyper-sync-rustls-0.3)
+    (name "rust-hyper-sync-rustls")
+    (version "0.3.0-rc.4")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (crate-uri "hyper-sync-rustls" version))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32 "16zirxhsk26kz5jxxxs37wxsm02id97h57kkqs512fj1j0x486kd"))))
+    (arguments
+     `(#:cargo-test-flags '("--release" "--"
+                            ;; not all files included
+                            "--skip=client" "--skip=server")
+       #:cargo-inputs (("rust-hyper" ,rust-hyper-0.10)
+                       ("rust-rustls" ,rust-rustls-0.14)
+                       ("rust-webpki" ,rust-webpki-0.18)
+                       ("rust-webpki-roots" ,rust-webpki-roots-0.15))
+       #:cargo-development-inputs (("rust-env-logger" ,rust-env-logger-0.5))))))
+
 (define-public rust-hyper-timeout-0.4
   (package
     (name "rust-hyper-timeout")
@@ -3659,32 +3680,50 @@ (define-public rust-reqwest-0.10
 (define-public rust-rocket-0.4
   (package
     (name "rust-rocket")
-    (version "0.4.7")
+    (version "0.4.11")
     (source
      (origin
        (method url-fetch)
        (uri (crate-uri "rocket" version))
        (file-name (string-append name "-" version ".tar.gz"))
        (sha256
-        (base32 "04ybnhjw92zaan92lsmx6mkhqc9cpsg3885svb3wzyj39pyzvsvz"))))
+        (base32 "0pimz9v0737dvz487j0kij7kasjyahaxd7ba2bcc3p6513fdkfc3"))
+       (modules '((guix build utils)))
+       (snippet '(begin
+                   ;; enable nightly/dev in build.rs for RUSTC_BOOTSTRAP build
+                   (substitute* "build.rs"
+                     (("if !channel.supports_features")
+                      "/* if !channel.supports_features")
+                     (("if !version.at_least")
+                      "*/ \nif !version.at_least"))
+                   ;; Add missing development dependency (for tests)
+                   (substitute* "Cargo.toml"
+                     (("\\[features\\]" all)
+                      (string-append "[dev-dependencies.lazy_static]" "\n"
+                                     "version = \"1\"" "\n" all))) #t))))
     (build-system cargo-build-system)
     (arguments
-     `(#:skip-build? #t
-       #:cargo-inputs
-       (("rust-atty" ,rust-atty-0.2)
-        ("rust-base64" ,rust-base64-0.12)
-        ("rust-log" ,rust-log-0.4)
-        ("rust-memchr" ,rust-memchr-2)
-        ("rust-num-cpus" ,rust-num-cpus-1)
-        ("rust-pear" ,rust-pear-0.1)
-        ("rust-rocket-codegen" ,rust-rocket-codegen-0.4)
-        ("rust-rocket-http" ,rust-rocket-http-0.4)
-        ("rust-state" ,rust-state-0.4)
-        ("rust-time" ,rust-time-0.1)
-        ("rust-toml" ,rust-toml-0.4)
-        ("rust-version-check" ,rust-version-check-0.9)
-        ("rust-yansi" ,rust-yansi-0.5)
-        ("rust-yansi" ,rust-yansi-0.5))))
+     `(#:cargo-inputs (("rust-atty" ,rust-atty-0.2)
+                       ("rust-base64" ,rust-base64-0.12)
+                       ("rust-log" ,rust-log-0.4)
+                       ("rust-memchr" ,rust-memchr-2)
+                       ("rust-num-cpus" ,rust-num-cpus-1)
+                       ("rust-pear" ,rust-pear-0.1)
+                       ("rust-rocket-codegen" ,rust-rocket-codegen-0.4)
+                       ("rust-rocket-http" ,rust-rocket-http-0.4)
+                       ("rust-state" ,rust-state-0.4)
+                       ("rust-time" ,rust-time-0.1)
+                       ("rust-toml" ,rust-toml-0.4)
+                       ("rust-version-check" ,rust-version-check-0.9)
+                       ("rust-yansi" ,rust-yansi-0.5)
+                       ("rust-yansi" ,rust-yansi-0.5))
+       ;; Adding in missing dev dependency
+       #:cargo-development-inputs (("rust-lazy-static" ,rust-lazy-static-1))
+       #:phases (modify-phases %standard-phases
+                  ;; Enable using nightly/dev features
+                  (add-after 'unpack 'enable-unstable-features
+                    (lambda _
+                      (setenv "RUSTC_BOOTSTRAP" "1"))))))
     (home-page "https://rocket.rs")
     (synopsis
      "Web framework with focus on ease-of-use, expressibility, and speed")
@@ -3696,25 +3735,38 @@ (define-public rust-rocket-0.4
 (define-public rust-rocket-codegen-0.4
   (package
     (name "rust-rocket-codegen")
-    (version "0.4.7")
+    (version "0.4.11")
     (source
      (origin
        (method url-fetch)
        (uri (crate-uri "rocket_codegen" version))
        (file-name (string-append name "-" version ".tar.gz"))
        (sha256
-        (base32 "18s2dll8c4sd26s8cfr6cizj5z55xwnk6r6x7b2wvcf8n9ajrb6f"))))
+        (base32 "1zl4f99s4df8fpkps53qn77030baww4x7zflggwql290b1xh6418"))
+       (modules '((guix build utils)))
+       (snippet '(begin
+                   (substitute* "build.rs"
+                     ;; enable nightly/dev in build.rs for RUSTC_BOOTSTRAP build
+                     (("if !channel.supports_features")
+                      "/* if !channel.supports_features")
+                     (("if !version.at_least")
+                      "*/ \nif !version.at_least"))))))
     (build-system cargo-build-system)
     (arguments
-     `(#:skip-build? #t
-       #:cargo-inputs
-       (("rust-devise" ,rust-devise-0.2)
-        ("rust-glob" ,rust-glob-0.3)
-        ("rust-indexmap" ,rust-indexmap-1)
-        ("rust-quote" ,rust-quote-0.6)
-        ("rust-rocket-http" ,rust-rocket-http-0.4)
-        ("rust-version-check" ,rust-version-check-0.9)
-        ("rust-yansi" ,rust-yansi-0.5))))
+     `(#:tests? #f ;Tests depend on multiple undeclared crates
+       #:cargo-inputs (("rust-devise" ,rust-devise-0.2)
+                       ("rust-glob" ,rust-glob-0.3)
+                       ("rust-indexmap" ,rust-indexmap-1)
+                       ("rust-quote" ,rust-quote-0.6)
+                       ("rust-rocket-http" ,rust-rocket-http-0.4))
+       #:cargo-development-inputs (("rust-version-check" ,rust-version-check-0.9)
+                                   ("rust-yansi" ,rust-yansi-0.5)
+                                   ("rust-rocket" ,rust-rocket-0.4)) ;For tests
+       #:phases (modify-phases %standard-phases
+                  ;; Enable using nightly/dev features
+                  (add-after 'unpack 'enable-unstable-features
+                    (lambda _
+                      (setenv "RUSTC_BOOTSTRAP" "1"))))))
     (home-page "https://rocket.rs")
     (synopsis "Procedural macros for the Rocket web framework")
     (description
@@ -3724,29 +3776,34 @@ (define-public rust-rocket-codegen-0.4
 (define-public rust-rocket-http-0.4
   (package
     (name "rust-rocket-http")
-    (version "0.4.7")
+    (version "0.4.11")
     (source
      (origin
        (method url-fetch)
        (uri (crate-uri "rocket_http" version))
        (file-name (string-append name "-" version ".tar.gz"))
        (sha256
-        (base32 "0ga98nbcga8amg4xhrfkn1wljnqx9h0vv7mnay9g66vsxl042dnf"))))
+        (base32 "17xiivj4cp3anm4rxxpd8g58kzday1y2pgdys2i23wz1538wpy9b"))))
     (build-system cargo-build-system)
     (arguments
-     `(#:skip-build? #t
-       #:cargo-inputs
-       (("rust-cookie" ,rust-cookie-0.11)
-        ("rust-hyper" ,rust-hyper-0.10)
-        ("rust-hyper-sync-rustls" ,rust-hyper-sync-rustls-0.3)
-        ("rust-indexmap" ,rust-indexmap-1)
-        ("rust-pear" ,rust-pear-0.1)
-        ("rust-percent-encoding" ,rust-percent-encoding-1)
-        ("rust-rustls" ,rust-rustls-0.14)
-        ("rust-smallvec" ,rust-smallvec-1)
-        ("rust-state" ,rust-state-0.4)
-        ("rust-time" ,rust-time-0.1)
-        ("rust-unicode-xid" ,rust-unicode-xid-0.1))))
+     `(#:cargo-test-flags ;doctests depend on undeclared crates
+       '("--lib" "--bins" "--tests" "--release")
+       #:cargo-inputs (("rust-cookie" ,rust-cookie-0.11)
+                       ("rust-hyper" ,rust-hyper-0.10)
+                       ("rust-hyper-sync-rustls" ,rust-hyper-sync-rustls-0.3-rc4)
+                       ("rust-indexmap" ,rust-indexmap-1)
+                       ("rust-pear" ,rust-pear-0.1)
+                       ("rust-percent-encoding" ,rust-percent-encoding-1)
+                       ("rust-rustls" ,rust-rustls-0.14)
+                       ("rust-smallvec" ,rust-smallvec-1)
+                       ("rust-state" ,rust-state-0.4)
+                       ("rust-time" ,rust-time-0.1)
+                       ("rust-unicode-xid" ,rust-unicode-xid-0.1))
+       #:phases (modify-phases %standard-phases
+                  ;; Enable using nightly/dev features
+                  (add-after 'unpack 'enable-unstable-features
+                    (lambda _
+                      (setenv "RUSTC_BOOTSTRAP" "1"))))))
     (home-page "https://rocket.rs")
     (synopsis "HTTP requests, responses and headers tooling for Rocket")
     (description
-- 
2.41.0