From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id CBuyEdmYqV/0NgAA0tVLHw (envelope-from ) for ; Mon, 09 Nov 2020 19:30:33 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id GKi5DdmYqV8DWwAA1q6Kng (envelope-from ) for ; Mon, 09 Nov 2020 19:30:33 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D0B57940105 for ; Mon, 9 Nov 2020 19:30:32 +0000 (UTC) Received: from localhost ([::1]:34706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcCs3-0007oX-QP for larch@yhetil.org; Mon, 09 Nov 2020 14:30:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcCra-0007nI-K4 for bug-guix@gnu.org; Mon, 09 Nov 2020 14:30:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:52292) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kcCra-00083x-9O for bug-guix@gnu.org; Mon, 09 Nov 2020 14:30:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kcCra-0002rS-5U for bug-guix@gnu.org; Mon, 09 Nov 2020 14:30:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#43893: [PATCH] maint: update-guix-package: Optionally add sources to store. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Mon, 09 Nov 2020 19:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43893 X-GNU-PR-Package: guix X-GNU-PR-Keywords: patch To: 43893@debbugs.gnu.org Received: via spool by 43893-submit@debbugs.gnu.org id=B43893.160495019610967 (code B ref 43893); Mon, 09 Nov 2020 19:30:02 +0000 Received: (at 43893) by debbugs.gnu.org; 9 Nov 2020 19:29:56 +0000 Received: from localhost ([127.0.0.1]:35605 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kcCrT-0002qo-Tq for submit@debbugs.gnu.org; Mon, 09 Nov 2020 14:29:56 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:41754) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kcCrS-0002qb-An for 43893@debbugs.gnu.org; Mon, 09 Nov 2020 14:29:54 -0500 Received: by mail-qt1-f194.google.com with SMTP id j31so6831838qtb.8 for <43893@debbugs.gnu.org>; Mon, 09 Nov 2020 11:29:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=80EzxwR+9bLQITRHRol3Mszdo6uVjNFg92rOPwGd+Es=; b=Jhbmh8pfb6/H+tqvjQROTfQb62CJj5pQkeOTluxHbTScb7dTUYRATZlfHPrUyLBx8A ACxcd4dpOz+oou7gRnkYL2Vms8g73nGTL4btn13RJOEHMuFicUZw64Wt8jDzp6REaAHj 9yJn6jV1MXhsZQyH3n/C9XA4OW8W5ex3IOp2oxussgKuz92AGHYlXgpXgMIF3/LikzgW x7wZDweTJu3ftqexba9WrmdFDRQvI8l148of9YuaTBGDxbEdhjip9eJF2QiEkVzROrtp uz0FBoH5Fb/yMMh0/8DAUFcfuht/qJ+/Lktc2wG8d/hK61F8GKUeA19oP4nVri6MFG2J TCbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=80EzxwR+9bLQITRHRol3Mszdo6uVjNFg92rOPwGd+Es=; b=TmWqfs5m5Z1lLH0OElG2Zf79SXaLntyNVHdQCgnGWI/XOts/kqjcjHE248SWi7mocb i1gJffkZLlyVD9PBDrpjpCAY29q3InqUGweXKaQTF7CWwEzuPMHv8lTuFjX42wmyKCSc r45neXuxy57VXx+iMRBtxNKK8btZkgTH8mZXViirV3gxKfsnCE5X1KJ039I9CsYZmPI2 9GbGIgkJoAuAkybX1LCsac9C7FVFmp+mdHdtAEyAAdbaoCzhX4TQwgmIEhTKvNTfQciz wvZ1Rj48dbXFHHUI/lr94PWyYZqxgauOHBdHMuYf5mkqFME3RPH6jbNjTYz4ZI6mNdti YhOA== X-Gm-Message-State: AOAM530AEPhuHANs9MeVE12zsj5Hu+b+svzrZalCoEkGa/0kaOlhQ+ZR iTETmOxATFccyQenDgVq4RRgij9qbAk= X-Google-Smtp-Source: ABdhPJwQpRQhgQdRnGiwLye3alKkuMb3fOym6zcimrxq02xfVezWw/FkJlWTNVbTcUDt4KYgW3GRRg== X-Received: by 2002:ac8:679a:: with SMTP id b26mr7513654qtp.79.1604950188423; Mon, 09 Nov 2020 11:29:48 -0800 (PST) Received: from localhost.localdomain (dsl-153-45.b2b2c.ca. [66.158.153.45]) by smtp.gmail.com with ESMTPSA id e22sm6270280qtq.38.2020.11.09.11.29.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 11:29:47 -0800 (PST) From: Maxim Cournoyer Date: Mon, 9 Nov 2020 14:29:23 -0500 Message-Id: <20201109192923.29580-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <871rhevfpp.fsf@gnu.org> References: <871rhevfpp.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxim Cournoyer Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Scanner: ns3122888.ip-94-23-21.eu Authentication-Results: aspmx1.migadu.com; dkim=fail (body hash did not verify) header.d=gmail.com header.s=20161025 header.b=Jhbmh8pf; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Spam-Score: 0.09 X-TUID: Sy/XqAGyTDBy Following discussions in , keeping a copy of the updated package source is desirable when generating a release. * build-aux/update-guix-package.scm (version-controlled?): Remove variable. (call-with-temporary-git-worktree): Renamed from 'with-temporary-git-worktree'. Update doc. Do not change directory implicitly. (keep-source-in-store): New procedure. (main): Adjust to use with call-with-temporary-git-worktree. Add the sources to the store when GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT is set. * .dir-locals.el (scheme-mode): Update. * doc/contributing.texi (Updating the Guix Package): Update doc. Co-authored-by: Ludovic Courtès --- .dir-locals.el | 2 +- build-aux/update-guix-package.scm | 66 ++++++++++++++++++++++--------- doc/contributing.texi | 11 ++---- 3 files changed, 51 insertions(+), 28 deletions(-) diff --git a/.dir-locals.el b/.dir-locals.el index 8e5d3902e3..38bb3af344 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -123,7 +123,7 @@ (eval . (put 'call-with-progress-reporter 'scheme-indent-function 1)) (eval . (put 'with-repository 'scheme-indent-function 2)) (eval . (put 'with-temporary-git-repository 'scheme-indent-function 2)) - (eval . (put 'with-temporary-git-worktree 'scheme-indent-function 2)) + (eval . (put 'call-with-temporary-git-worktree 'scheme-indent-function 2)) (eval . (put 'with-environment-variables 'scheme-indent-function 1)) (eval . (put 'with-fresh-gnupg-setup 'scheme-indent-function 1)) diff --git a/build-aux/update-guix-package.scm b/build-aux/update-guix-package.scm index ff6b105468..f197bc7e2a 100644 --- a/build-aux/update-guix-package.scm +++ b/build-aux/update-guix-package.scm @@ -44,9 +44,6 @@ (define %top-srcdir (string-append (current-source-directory) "/..")) -(define version-controlled? - (git-predicate %top-srcdir)) - (define (package-definition-location) "Return the source properties of the definition of the 'guix' package." (call-with-input-file (location-file (package-location guix)) @@ -114,8 +111,9 @@ COMMIT." "Create a new git worktree at DIRECTORY, detached on commit COMMIT." (invoke "git" "worktree" "add" "--detach" directory commit)) -(define-syntax-rule (with-temporary-git-worktree commit body ...) - "Execute BODY in the context of a temporary git worktree created from COMMIT." +(define-syntax-rule (call-with-temporary-git-worktree commit proc) + "Execute PROC in the context of a temporary git worktree created from +COMMIT. PROC receives the temporary directory file name as an argument." (call-with-temporary-directory (lambda (tmp-directory) (dynamic-wind @@ -123,7 +121,7 @@ COMMIT." #t) (lambda () (git-add-worktree tmp-directory commit) - (with-directory-excursion tmp-directory body ...)) + (proc tmp-directory)) (lambda () (invoke "git" "worktree" "remove" "--force" tmp-directory)))))) @@ -156,6 +154,30 @@ COMMIT." "git" "branch" "-r" "--contains" commit (string-append remote "/master"))))) +(define (keep-source-in-store store source) + "Add SOURCE to the store under the name that the 'guix' package expects." + + ;; Add SOURCE to the store, but this time under the real name used in the + ;; 'origin'. This allows us to build the package without having to make a + ;; real checkout; thus, it also works when working on a private branch. + (reload-module + (resolve-module '(gnu packages package-management))) + + (let* ((source (add-to-store store + (origin-file-name (package-source guix)) + #t "sha256" source + #:select? (git-predicate source))) + (root (store-path-package-name source))) + + ;; Add an indirect GC root for SOURCE in the current directory. + (false-if-exception (delete-file root)) + (symlink source root) + (add-indirect-root store + (string-append (getcwd) "/" root)) + + (info (G_ "source code kept in ~a (GC root: ~a)~%") + source root))) + (define (main . args) (match args @@ -164,19 +186,25 @@ COMMIT." (or (getenv "GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT") (commit-already-pushed? (find-origin-remote) commit) (leave (G_ "Commit ~a is not pushed upstream. Aborting.~%") commit)) - (let* ((hash (with-temporary-git-worktree commit - (nix-base32-string->bytevector - (string-trim-both - (with-output-to-string - (lambda () - (guix-hash "-rx" "."))))))) - (location (package-definition-location)) - (old-hash (content-hash-value - (origin-hash (package-source guix))))) - (edit-expression location - (update-definition commit hash - #:old-hash old-hash - #:version version))))) + (call-with-temporary-git-worktree commit + (lambda (tmp-directory) + (let* ((hash (nix-base32-string->bytevector + (string-trim-both + (with-output-to-string + (lambda () + (guix-hash "-rx" tmp-directory)))))) + (location (package-definition-location)) + (old-hash (content-hash-value + (origin-hash (package-source guix))))) + (edit-expression location + (update-definition commit hash + #:old-hash old-hash + #:version version)) + ;; When GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT is set, the sources are + ;; added to the store. This is used as part of 'make release'. + (when (getenv "GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT") + (with-store store + (keep-source-in-store store tmp-directory)))))))) ((commit) ;; Automatically deduce the version and revision numbers. (main commit #f)))) diff --git a/doc/contributing.texi b/doc/contributing.texi index d3f6325c3f..d8de71055a 100644 --- a/doc/contributing.texi +++ b/doc/contributing.texi @@ -1368,11 +1368,6 @@ commit that others can't refer to, a check is made that the commit used has already been pushed to the Savannah-hosted Guix git repository. This check can be disabled, @emph{at your own peril}, by setting the -@code{GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT} environment variable. - -To build the resulting 'guix' package when using a private commit, the -following command can be used: - -@example -./pre-inst-env guix build guix --with-git-url=guix=$PWD -@end example +@code{GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT} environment variable. When +this variable is set, the updated package source is also added to the +store. This is used as part of the release process of Guix. -- 2.28.0