From patchwork Tue Nov 5 23:15:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 69901 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 7200A27BBEA; Tue, 5 Nov 2024 23:17:21 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id CBF5527BBE2 for ; Tue, 5 Nov 2024 23:17:20 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t8SnN-0003jR-BO; Tue, 05 Nov 2024 18:17:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t8SnL-0003eE-9I for guix-patches@gnu.org; Tue, 05 Nov 2024 18:17:07 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t8SnL-0002aT-02 for guix-patches@gnu.org; Tue, 05 Nov 2024 18:17:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=KDhBy+0LEZ240Nj2YFMpRPvbrlr0VVjvxLF4Q9WgEK8=; b=sDCYaRs8AtpGjnQGyjT7bS1CAKik1vN5p1bNBnz36jSCv0Zr4uP5OQiux5aV+WXQJf2MoNkwfN4oSDfgEnRucd/pv4rldfQr2ovd+au5vjKlUiIqX21YT13eV5A39InZRnDJXiZvPr0vlfSZm72KySrJVcv8MBpeJqcyBNqtZ613gqp20P5NFFAKpQaM1l/g5LRnYmiitX2PRZ1B2vFgnSXNZHuHuK2J5wuH5kfXug51qEG2qR24AtprY7Z8HrMwQcMcm05J/fvXzveXzFJBaMD6jAPTD2M6ENxVShKcC3P+7Ld8Q3iWJObT8aiPxlHjU2qG0qKllHLun4+WJUwIZA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t8SnK-0004RK-R1 for guix-patches@gnu.org; Tue, 05 Nov 2024 18:17:06 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#73896] [PATCH v4 20/20] gnu: clamav: Unbundle rust dependencies. Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 05 Nov 2024 23:17:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73896 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 73896@debbugs.gnu.org Cc: Nicolas Graves Received: via spool by 73896-submit@debbugs.gnu.org id=B73896.173084860816952 (code B ref 73896); Tue, 05 Nov 2024 23:17:06 +0000 Received: (at 73896) by debbugs.gnu.org; 5 Nov 2024 23:16:48 +0000 Received: from localhost ([127.0.0.1]:38484 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t8Sn2-0004PH-0s for submit@debbugs.gnu.org; Tue, 05 Nov 2024 18:16:48 -0500 Received: from 4.mo576.mail-out.ovh.net ([46.105.42.102]:58447) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t8Smz-0004Ot-Ou for 73896@debbugs.gnu.org; Tue, 05 Nov 2024 18:16:46 -0500 Received: from director2.ghost.mail-out.ovh.net (unknown [10.108.2.235]) by mo576.mail-out.ovh.net (Postfix) with ESMTP id 4Xjkk50lfHz1vdq for <73896@debbugs.gnu.org>; Tue, 5 Nov 2024 23:16:45 +0000 (UTC) Received: from ghost-submission-5b5ff79f4f-76zrf (unknown [10.110.96.185]) by director2.ghost.mail-out.ovh.net (Postfix) with ESMTPS id D7DA81FD3C; Tue, 5 Nov 2024 23:16:44 +0000 (UTC) Received: from ngraves.fr ([37.59.142.104]) by ghost-submission-5b5ff79f4f-76zrf with ESMTPSA id 8F4WLlynKmcNpT4Ayyemgg (envelope-from ); Tue, 05 Nov 2024 23:16:44 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-104R0055301d63e-41a5-4e8b-9d1a-b5121a49aec0, 7DA11F85E05AC71F4B07BAB71687C1137F5318AF) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 86.246.19.221 Date: Wed, 6 Nov 2024 00:15:08 +0100 Message-ID: <20241105231519.22378-20-ngraves@ngraves.fr> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241105231519.22378-1-ngraves@ngraves.fr> References: <20241105231519.22378-1-ngraves@ngraves.fr> MIME-Version: 1.0 X-Ovh-Tracer-Id: 12059795380540465890 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeefuddrtddugddtlecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheppfhitgholhgrshcuifhrrghvvghsuceonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqeenucggtffrrghtthgvrhhnpeelffejteeutefhfeekfffffedvudekjeekgfeludeitdfhkeevhfeivdfhffeggeenucfkphepuddvjedrtddrtddruddpkeeirddvgeeirdduledrvddvuddpfeejrdehledrudegvddruddtgeenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepnhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrpdhnsggprhgtphhtthhopedupdhrtghpthhtohepjeefkeelieesuggvsggsuhhgshdrghhnuhdrohhrghdpoffvtefjohhsthepmhhoheejiegmpdhmohguvgepshhmthhpohhuth DKIM-Signature: a=rsa-sha256; bh=KDhBy+0LEZ240Nj2YFMpRPvbrlr0VVjvxLF4Q9WgEK8=; c=relaxed/relaxed; d=ngraves.fr; h=From; s=ovhmo4487190-selector1; t=1730848605; v=1; b=jDZLifXAUeRxNibSjK8cf5BUCp2dPD3dBF/kcbKZb7vzUVVPdPmGlyyB+nuCLLOnkLLG00TT Wg7Nlf4rerbtGIlqMT4XHIXbMCl1sypP1rK6EhO6bGS+Rcp3e4pmmlevqqWB5ocCIFkuwawhxgd MekW1Bap6KsOqVHa+5P/R8TS20jNmzdsjcktQTxRctad6GZZ0Jo5gYeRhPY/fcKw6k3NYJA7DvI Nppy3O95XErxCGCNH0tJX9L8u3Blf+QlxbS2YgsAGVaI+DdgnK8mBxC/zl4zA2PA0sa8WUHPFci 0uceGNRQwpKBZcXILGZekRUZ0Ic33OIEVzbVW1N6vzk7w== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches X-Patchwork-Original-From: Nicolas Graves via Guix-patches via From: Nicolas Graves Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/packages/antivirus.scm (clamav) [origin]: Unbundle rust dependencies. [build-system]: Switch to cargo-build-system. [arguments]: Adapt to the change of base build-system. [native-inputs]: Add cmake-minimal. Remove rust and rust:cargo. --- gnu/packages/antivirus.scm | 135 +++++++++++++++++++++++++++---------- 1 file changed, 99 insertions(+), 36 deletions(-) diff --git a/gnu/packages/antivirus.scm b/gnu/packages/antivirus.scm index 1a23657a61..b561ff060a 100644 --- a/gnu/packages/antivirus.scm +++ b/gnu/packages/antivirus.scm @@ -31,12 +31,17 @@ (define-module (gnu packages antivirus) #:use-module (gnu packages) #:use-module (gnu packages check) #:use-module (gnu packages compression) + #:use-module (gnu packages cmake) + #:use-module (gnu packages crates-crypto) + #:use-module (gnu packages crates-graphics) + #:use-module (gnu packages crates-io) #:use-module (gnu packages curl) #:use-module (gnu packages ncurses) #:use-module (gnu packages pcre) #:use-module (gnu packages pkg-config) #:use-module (gnu packages python) #:use-module (gnu packages python-check) + #:use-module (gnu packages rust-apps) #:use-module (gnu packages rust) #:use-module (gnu packages tls) #:use-module (gnu packages web) @@ -62,49 +67,107 @@ (define-public clamav (snippet '(begin (delete-file "Cargo.lock") - (for-each - delete-file - (find-files ".cargo/vendor" ".cargo-checksum\\.json")) (for-each delete-file-recursively - '("win32" ; unnecessary + '(".cargo" ; vendored rust inputs + "win32" ; unnecessary "libclamunrar")))))) ; non-free license - (build-system cmake-build-system) + (build-system cargo-build-system) (arguments - (list - #:configure-flags - #~(list "-DENABLE_MILTER=OFF" "-DENABLE_UNRAR=OFF") - #:imported-modules `((guix build cargo-utils) - ,@%cmake-build-system-modules) - #:phases - #~(modify-phases %standard-phases - (add-after 'unpack 'inject-rust-onenote - (lambda _ - (substitute* "libclamav_rust/Cargo.toml" - (("onenote_parser = .*") - "onenote_parser = \"0.3.1\"\n")))) - (add-after 'patch-source-shebangs 'patch-cargo-checksums - (lambda _ - (use-modules - (srfi srfi-1) (ice-9 ftw) (guix build cargo-utils)) - (with-directory-excursion ".cargo/vendor" - (for-each generate-all-checksums - (delete "." (delete ".." (scandir "."))))))) - (add-after 'unpack 'skip-clamd-tests - ;; XXX: The check?_clamd tests fail inside the build - ;; chroot, but pass outside. - (lambda* (#:key tests? #:allow-other-keys) - (when tests? - (substitute* "unit_tests/CMakeLists.txt" - (("clamd_test\\.py" test) - (string-append - test " -k \"not test_clamd_08_VirusEvent\""))))))))) + (let ((cargo-inputs + `(("rust-flate2" ,rust-flate2-1) + ("rust-hex" ,rust-hex-0.4) + ("rust-libc" ,rust-libc-0.2) + ("rust-log" ,rust-log-0.4) + ("rust-sha2" ,rust-sha2-0.10) + ("rust-tempfile" ,rust-tempfile-3) + ("rust-thiserror" ,rust-thiserror-1) + ("rust-image" ,rust-image-0.24) + ("rust-rustdct" ,rust-rustdct-0.7) + ("rust-transpose" ,rust-transpose-0.2) + ("rust-num-traits" ,rust-num-traits-0.2) + ("rust-base64" ,rust-base64-0.21) + ("rust-sha1" ,rust-sha1-0.10) + ("rust-unicode-segmentation" ,rust-unicode-segmentation-1) + ("rust-bindgen" ,rust-bindgen-0.66) + ("rust-onenote-parser" ,rust-onenote-parser-for-clamav) + ("rust-hex-literal" ,rust-hex-literal-0.4) + ("rust-inflate" ,rust-inflate-0.4) + ("rust-bzip2-rs" ,rust-bzip2-rs-0.1) + ("rust-byteorder" ,rust-byteorder-1) + ("rust-delharc" ,rust-delharc-0.6))) + (cargo-development-inputs + `(("rust-cbindgen" ,rust-cbindgen-0.26) + ("rust-bindgen" ,rust-bindgen-0.66)))) + (list + #:cargo-inputs cargo-inputs + #:cargo-development-inputs cargo-development-inputs + #:vendor-dir ".cargo/vendor" + #:imported-modules `(,@%cmake-build-system-modules + ,@%cargo-build-system-modules) + #:modules '((guix build cargo-build-system) + ((guix build cmake-build-system) #:prefix cmake:) + (guix build utils)) + #:phases + #~(modify-phases %standard-phases + ;; There is a .exe file used in unit tests. + (delete 'check-for-pregenerated-files) + (add-after 'configure 'fix-cargo-inputs-vendoring + (lambda _ + ;; Reproduce the original layout, fails with config. + (rename-file ".cargo/config" ".cargo/config.toml") + ;; Wrongly placed by configure + (delete-file-recursively + (string-append ".cargo/vendor/clamav-" #$version ".tar.zst")))) + (add-after 'patch-cargo-checksums 'cmake-configure + (lambda* (#:key outputs #:allow-other-keys) + ((assoc-ref cmake:%standard-phases 'configure) + #:configure-flags + (list "-DENABLE_MILTER=OFF" "-DENABLE_UNRAR=OFF") + #:outputs outputs))) + (replace 'build + (assoc-ref cmake:%standard-phases 'build)) + (add-after 'patch-cargo-checksums 'patch-rust-requirements + (lambda _ + (substitute* "libclamav_rust/Cargo.toml" + (("onenote_parser = .*") + (format #f "onenote_parser = ~s~%" + #$(package-version + (car (assoc-ref cargo-inputs + "rust-onenote-parser"))))) + (("^bindgen = .*") + (format #f "bindgen = ~s~%" + #$(package-version + (car (assoc-ref cargo-inputs + "rust-bindgen"))))) + (("cbindgen = \\{ version =\".*\",") + (format #f "cbindgen = { version =~s," + #$(package-version + (car (assoc-ref cargo-development-inputs + "rust-cbindgen")))))))) + (delete 'package) + (replace 'install + (assoc-ref cmake:%standard-phases 'install)) + (replace 'check + (lambda* (#:key tests? #:allow-other-keys) + ((assoc-ref cmake:%standard-phases 'check) + #:tests? tests? + #:parallel-tests? #t + #:test-target "test"))) + (add-after 'unpack 'skip-clamd-tests + ;; XXX: The check?_clamd tests fail inside the build + ;; chroot, but pass outside. + (lambda* (#:key tests? #:allow-other-keys) + (when tests? + (substitute* "unit_tests/CMakeLists.txt" + (("clamd_test\\.py" test) + (string-append + test " -k \"not test_clamd_08_VirusEvent\"")))))))))) (native-inputs (list check ; for tests + cmake-minimal pkg-config python-minimal - python-pytest - rust - (list rust "cargo"))) + python-pytest)) (inputs (list bzip2 curl