From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:50936) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsNLt-0007xD-BS for guix-patches@gnu.org; Tue, 30 Jul 2019 04:19:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsNLb-0007h8-OE for guix-patches@gnu.org; Tue, 30 Jul 2019 04:19:21 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:40684) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsNLb-0007h0-Ic for guix-patches@gnu.org; Tue, 30 Jul 2019 04:19:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hsNLa-0004Z4-3J for guix-patches@gnu.org; Tue, 30 Jul 2019 04:19:03 -0400 Subject: [bug#36841] [PATCH] build/cargo-build-system: Patch cargo checksums. Resent-Message-ID: Date: Tue, 30 Jul 2019 11:17:57 +0300 From: Efraim Flashner Message-ID: <20190730081757.GB21431@E2140> References: <20190729190422.6834-1-efraim@flashner.co.il> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="bKyqfOwhbdpXa4YI" Content-Disposition: inline In-Reply-To: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ivan Petkov Cc: 36841@debbugs.gnu.org --bKyqfOwhbdpXa4YI Content-Type: multipart/mixed; boundary="DKU6Jbt7q3WqK7+M" Content-Disposition: inline --DKU6Jbt7q3WqK7+M Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 29, 2019 at 06:44:31PM -0700, Ivan Petkov wrote: > Hi Efraim, >=20 > > On Jul 29, 2019, at 12:04 PM, Efraim Flashner w= rote: > >=20 > > +;; After patching the 'patch-generated-file-shebangs phase any vendore= d crates > > +;; will have a mismatch on their checksum. > > +(define* (patch-cargo-checksums #:key > > + (vendor-dir "guix-vendor") > > + #:allow-other-keys) >=20 > [snip] >=20 > > + (replace 'install install) > > + (add-after 'patch-generated-file-shebangs 'patch-cargo-checksums p= atch-cargo-checksums))) >=20 > I can=E2=80=99t quite remember the order the phases run in off the top of= my head. Would it be possible to > make the configure/checksum generation phase run after shebang-patching (= or ensure the patching > happens first)? It would avoid having to checksum all the files twice tha= t way=E2=80=A6 The 'configure phase could be renamed the plop-vendored-crates-into-place phase. It actually can't come after the 'patch-generated-file-shebangs phase since then there won't be any vendored crates to patch. If we remove the generate-checksums call from 'configure then there won't be a .cargo-checksum.json to remove and regenerate during the 'patch-cargo-checksums phase, so I've changed that to search for "Cargo.toml$" and not delete it. Not as robust as "for each top-level directory in the 'vendor-dir'", but should be good enough. --=20 Efraim Flashner =D7=90=D7=A4=D7=A8=D7=99=D7=9D = =D7=A4=D7=9C=D7=A9=D7=A0=D7=A8 GPG key =3D A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted --DKU6Jbt7q3WqK7+M Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="0001-build-cargo-build-system-Patch-cargo-checksums.patch" Content-Transfer-Encoding: quoted-printable =46rom abf262fbe7ed8d9a532a3ce63cb7453c1666d914 Mon Sep 17 00:00:00 2001 =46rom: Efraim Flashner Date: Mon, 29 Jul 2019 22:01:05 +0300 Subject: [PATCH] build/cargo-build-system: Patch cargo checksums. * guix/build/cargo-build-system.scm (update-cargo-lock, patch-cargo-checksums): New phases. (%standard-phases): Add 'update=3Dcargo-lock after 'configure and 'patch-cargo-checksums after 'patch-generated-file-shebangs. --- guix/build/cargo-build-system.scm | 37 ++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-sys= tem.scm index f38de16cf7..dfc7923c8d 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -2,6 +2,7 @@ ;;; Copyright =C2=A9 2016 David Craven ;;; Copyright =C2=A9 2017 Mathieu Othacehe ;;; Copyright =C2=A9 2019 Ivan Petkov +;;; Copyright =C2=A9 2019 Efraim Flashner ;;; ;;; This file is part of GNU Guix. ;;; @@ -94,8 +95,7 @@ Cargo.toml file present at its root." ;; so that we can generate any cargo checksums. ;; The --strip-components argument is needed to prevent crea= ting ;; an extra directory within `crate-dir`. - (invoke "tar" "xvf" path "-C" crate-dir "--strip-components"= "1") - (generate-checksums crate-dir))))) + (invoke "tar" "xvf" path "-C" crate-dir "--strip-components"= "1"))))) inputs) =20 ;; Configure cargo to actually use this new directory. @@ -121,6 +121,35 @@ directory =3D '" port) (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc")) #t) =20 +;; The Cargo.lock file tells the build system which crates are required for +;; building and hardcodes their version and checksum. In order to build w= ith +;; the inputs we provide, we need to recreate the file with our inputs. +(define* (update-cargo-lock #:key + (vendor-dir "guix-vendor") + #:allow-other-keys) + "Regenerate the Cargo.lock file with the current build inputs." + (when (file-exists? "Cargo.lock") + (begin + (delete-file "Cargo.lock") + (invoke "cargo" "generate-lockfile"))) + #t) + +;; After the 'patch-generated-file-shebangs phase any vendored crates who = have +;; their shebangs patched will have a mismatch on their checksum. +(define* (patch-cargo-checksums #:key + (vendor-dir "guix-vendor") + #:allow-other-keys) + "Patch the checksums of the vendored crates after patching their shebang= s." + (for-each + (lambda (filename) + (let* ((dir (dirname filename))) + (display (string-append + "patch-cargo-checksums: generate-checksums for " + dir "\n")) + (generate-checksums dir))) + (find-files "guix-vendor" "Cargo.toml$")) + #t) + (define* (build #:key skip-build? (cargo-build-flags '("--release")) @@ -162,7 +191,9 @@ directory =3D '" port) (replace 'configure configure) (replace 'build build) (replace 'check check) - (replace 'install install))) + (replace 'install install) + (add-after 'configure 'update-cargo-lock update-cargo-lock) + (add-after 'patch-generated-file-shebangs 'patch-cargo-checksums patch= -cargo-checksums))) =20 (define* (cargo-build #:key inputs (phases %standard-phases) #:allow-other-keys #:rest args) --=20 2.22.0 --DKU6Jbt7q3WqK7+M-- --bKyqfOwhbdpXa4YI Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAl0//SwACgkQQarn3Mo9 g1Fiag/+KYGYP2xW/0v6xusUK2Yv47LhcSEz2fJ9vg5orrAX3+jzZ+kkuzeNlkSL ubVpL9dHZsuJ94UIiJ+yvQdqcJKBdZ6fM4cp5KMLf+CPfoapdavngOd0eITbXp8R fwn5hjYvPCzisHewMcHRB2mPHNvFaWzyrC0rU/lKvfO7FdNUnz2BtiSTLy9GXx8F ro0TJEbK48nat3NAcOHD0D7SVIdzJYxk7YREOIFmzs4O0/VuWD/SJOGB3M/d6+lT QzLBh0QDtE5PovyFo7iwYrj5rx5BYZJ3Wfl6sS8Je4wT1tvX3yTeAF6SPH7Z5+H7 owYghTtsEYx6tHnUun+st4INxup5TI5xFV+O43K4DsWpJb3YaeTyaqebQV7HWkmi P8jdVe1Gsrx3FC54ArrVPO+VdMc0NS7wCmHZgIjVxFreEkYHXlD5ty1ZepG610yV gIoym7aj/aIDAkkinWrbmIfy7iKk0qatAkrWUg3NSfD1WgnBiECEZCUg81YHQUbK oV2Xv/XQoQ72i6di8BzY1UP3cl5dFEcodC64vzTLA97tsSOB9DE+IFfx83as2sIS afVA6rMaT/uFabVyCmiIOkStOEaNnd9S3snHgn7ULUk9zuqozbsW0OhGL8ElvPUP 9Xfl2xXxlNQnGIGDjgmbL79fA0w46op3Uc4ZSzGK99aM2OFNzYo= =CBt1 -----END PGP SIGNATURE----- --bKyqfOwhbdpXa4YI--