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 cFX/NSzHqV+6SAAA0tVLHw (envelope-from ) for ; Mon, 09 Nov 2020 22:48:12 +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 aO7bMSzHqV9rZQAA1q6Kng (envelope-from ) for ; Mon, 09 Nov 2020 22:48:12 +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 346BB940546 for ; Mon, 9 Nov 2020 22:48:12 +0000 (UTC) Received: from localhost ([::1]:56540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcFxL-0001x8-2I for larch@yhetil.org; Mon, 09 Nov 2020 17:48:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcFxC-0001v2-6r for bug-guix@gnu.org; Mon, 09 Nov 2020 17:48:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:52507) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kcFxB-0007Iq-UO for bug-guix@gnu.org; Mon, 09 Nov 2020 17:48:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kcFxB-0003vm-TW for bug-guix@gnu.org; Mon, 09 Nov 2020 17:48:01 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#43893: [PATCH v5] 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 22:48:01 +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.160496203615040 (code B ref 43893); Mon, 09 Nov 2020 22:48:01 +0000 Received: (at 43893) by debbugs.gnu.org; 9 Nov 2020 22:47:16 +0000 Received: from localhost ([127.0.0.1]:35818 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kcFwS-0003uV-8q for submit@debbugs.gnu.org; Mon, 09 Nov 2020 17:47:16 -0500 Received: from mail-qk1-f173.google.com ([209.85.222.173]:46657) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kcFwQ-0003uB-5S for 43893@debbugs.gnu.org; Mon, 09 Nov 2020 17:47:14 -0500 Received: by mail-qk1-f173.google.com with SMTP id h15so9644090qkl.13 for <43893@debbugs.gnu.org>; Mon, 09 Nov 2020 14:47:14 -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=B/eh71dzYvSv7GtXIFYGqFxujZ08N/F9Cuh8CiqQOxM=; b=gqrCF40zDGAAatSr0oj77IidLVIXV3/k7c73qtkbY9VJBRrTgArUZTDtQPox189LbD Bns/Osq0fWbO97jVUJGaq3twGnCkJqu3kvjdtuGja6XK6Q5tVgJ12eWWweQ1fWY7PJqU 7698n3mI8IV1dx7MgqJjBsvYaGt6trgHU8ZqfStRHFws7RAP7n+BtWqWv3rm+UVNs3hl HlYR7vX8da8VTSjQ+pSzBJYCjIpO48p/t8mBR35hHlmQM4KtPTVOrXMnfg3nwMFy0KoT ApJZ7YDh316Os0voeJjB/mtZRSGJXB6t+u/6c4IQ/RVNAHgZbdiinkfNfWKzPCeS5SNV zmVg== 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=B/eh71dzYvSv7GtXIFYGqFxujZ08N/F9Cuh8CiqQOxM=; b=Z7IvPIjc3BVCWaoaglBEeCgd6hT8LBWiSP+ADpWBbB4pGsL1sVDhu1kbR4umsCIRiM H7h7MCHBqOWniGUrTkMpLba14hM9X2Rlfm5yYkbgShi+FUB0EFZklGrFA1huywMkh8sR 2E0p5/iudWjRGo6ZWWnrSOIFoRdjx+6hx+qeL75NFaUdWyvqfqFMgYRgJKPRikDE0Zzc xIARDFhdZ5b0FIZ2mY5puC3mhxwT9yNZzRmB79faDQmUiN3DIKKasUJDyw3K3VVMgSwL Z6A8ny8zOduc9rJRpfLbjTLjiAC+EdHmcqo5r070ok8+3g2nsEgnxdFOgjsb8UzkVwVL bYew== X-Gm-Message-State: AOAM532gOK58WYuXwp6IQmU22diz+hO1VkNXBl6nwWWytlenVv3p3T5U 4KF8XEXQahckwSp0zpsx9Y1uuCladK4= X-Google-Smtp-Source: ABdhPJwsqhPb/c6HfxkvSLKmlLvc00mtAHAp8646tnuDlKF3P5YKOXzShes/FDtusfoa1E3TqIPSgA== X-Received: by 2002:a37:b0c:: with SMTP id 12mr3701710qkl.247.1604962028272; Mon, 09 Nov 2020 14:47:08 -0800 (PST) Received: from localhost.localdomain (dsl-153-45.b2b2c.ca. [66.158.153.45]) by smtp.gmail.com with ESMTPSA id q20sm7177384qke.0.2020.11.09.14.47.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 14:47:07 -0800 (PST) From: Maxim Cournoyer Date: Mon, 9 Nov 2020 17:44:43 -0500 Message-Id: <20201109224443.27495-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=gqrCF40z; 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: EAM+j5s63nH3 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. Exit gracefully when FIND-ORIGIN-REMOTE returns #f. (%savannah-guix-git-repo-push-url-regexp): Adjust match for a potential colon separator. * Makefile.am (GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT): Adjust. * .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 +- Makefile.am | 14 +++--- build-aux/update-guix-package.scm | 73 ++++++++++++++++++++++--------- doc/contributing.texi | 11 ++--- 4 files changed, 64 insertions(+), 36 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/Makefile.am b/Makefile.am index e7053ee4f4..6faf8c9349 100644 --- a/Makefile.am +++ b/Makefile.am @@ -826,9 +826,10 @@ release: dist-with-updated-version $(MKDIR_P) "$(releasedir)" rm -f "$(releasedir)"/* mv $(SOURCE_TARBALLS) "$(releasedir)" - $(top_builddir)/pre-inst-env "$(GUILE)" \ - $(top_srcdir)/build-aux/update-guix-package.scm \ - "`git rev-parse HEAD`" "$(PACKAGE_VERSION)" + GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT=yes \ + $(top_builddir)/pre-inst-env "$(GUILE)" \ + $(top_srcdir)/build-aux/update-guix-package.scm \ + "`git rev-parse HEAD`" "$(PACKAGE_VERSION)" git add $(top_srcdir)/gnu/packages/package-management.scm git commit -m "gnu: guix: Update to $(PACKAGE_VERSION)." $(top_builddir)/pre-inst-env guix build $(GUIX_FOR_BINARY_TARBALL) \ @@ -840,9 +841,10 @@ release: dist-with-updated-version mv "guix-binary.$$system.tar.xz" \ "$(releasedir)/guix-binary-$(PACKAGE_VERSION).$$system.tar.xz" ; \ done - $(top_builddir)/pre-inst-env "$(GUILE)" \ - $(top_srcdir)/build-aux/update-guix-package.scm \ - "`git rev-parse HEAD`" + GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT=yes \ + $(top_builddir)/pre-inst-env "$(GUILE)" \ + $(top_srcdir)/build-aux/update-guix-package.scm \ + "`git rev-parse HEAD`" git add $(top_srcdir)/gnu/packages/package-management.scm git commit -m "gnu: guix: Update to `git rev-parse HEAD | cut -c1-7`." $(top_builddir)/pre-inst-env guix build guix \ diff --git a/build-aux/update-guix-package.scm b/build-aux/update-guix-package.scm index ff6b105468..b79e96eb96 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,12 +121,12 @@ 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)))))) (define %savannah-guix-git-repo-push-url-regexp - "git.(savannah|sv).gnu.org/srv/git/guix.git \\(push\\)") + "git.(savannah|sv).gnu.org:?/srv/git/guix.git \\(push\\)") (define-syntax-rule (with-input-pipe-to-string prog arg ...) (let* ((input-pipe (open-pipe* OPEN_READ prog arg ...)) @@ -156,27 +154,60 @@ 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 ((commit version) (with-directory-excursion %top-srcdir (or (getenv "GUIX_ALLOW_ME_TO_USE_PRIVATE_COMMIT") - (commit-already-pushed? (find-origin-remote) commit) + (let ((remote (find-origin-remote))) + (unless remote + (leave (G_ "Failed to find the origin git remote.~%"))) + (commit-already-pushed? 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