From 5800d2aae2490f4192823323b72d17f2645aeb9e Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Sat, 10 Oct 2020 00:33:32 -0400 Subject: maint: update-guix-package: Prevent accidentally breaking guix pull. Fixes . This changes the 'update-guix-package' tool so that it: 1. Always uses a clean checkout to compute the hash of the updated 'guix' package. 2. Ensures the commit used in the updated 'guix' package definition has already been pushed upstream. * build-aux/update-guix-package.scm (%savannah-guix-git-repo-push-url): New variable. (with-input-pipe-to-string, with-temporary-git-worktree): New syntaxes. (find-origin-remote, git-add-worktree): New procedures. (commit-already-pushed?): New predicate. (main): Check the commit used has already been pushed upstream and compute the hash from a clean checkout. * doc/contributing.texi (Updating the Guix Package): Document it. * .dir-locals.el (scheme-mode): Fix indentation of with-temporary-git-worktree. --- .dir-locals.el | 1 + 1 file changed, 1 insertion(+) (limited to '.dir-locals.el') diff --git a/.dir-locals.el b/.dir-locals.el index 7f310d2612..19f15b3e1a 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -103,6 +103,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 'with-environment-variables 'scheme-indent-function 1)) (eval . (put 'with-fresh-gnupg-setup 'scheme-indent-function 1)) -- cgit v1.2.3 From 0e1b0958bde5ccc34a4fed9a09cf949d5f9c9519 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Sun, 25 Oct 2020 14:10:15 -0400 Subject: .dir-locals.el: Automatically set the GEISER-GUILE-LOAD-PATH variable. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thanks to Miguel Ángel Arruga Vivas and Pierre Neidhardt for their suggestions and improvements. * .dir-locals.el: Set the GUIX-DIRECTORY and GEISER-GUILE-LOAD-PATH Emacs variables based on the location of the .dir-locals file. --- .dir-locals.el | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to '.dir-locals.el') diff --git a/.dir-locals.el b/.dir-locals.el index 19f15b3e1a..0496e41ca2 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -8,7 +8,26 @@ ;; For use with 'bug-reference-prog-mode'. (bug-reference-url-format . "http://bugs.gnu.org/%s") (bug-reference-bug-regexp - . ""))) + . "") + + ;; Emacs-Guix + (eval . (setq guix-directory + (locate-dominating-file default-directory ".dir-locals.el"))) + + ;; Geiser + ;; This allows automatically setting the `geiser-guile-load-path' + ;; variable when using various Guix checkouts (e.g., via git worktrees). + (eval . (let* ((root-dir (expand-file-name + (locate-dominating-file + default-directory ".dir-locals.el"))) + ;; Workaround for bug https://issues.guix.gnu.org/43818. + (root-dir* (directory-file-name root-dir))) + (unless (boundp 'geiser-guile-load-path) + (defvar geiser-guile-load-path '())) + (make-local-variable 'geiser-guile-load-path) + (cl-pushnew root-dir* geiser-guile-load-path + :test #'string-equal))))) + (c-mode . ((c-file-style . "gnu"))) (scheme-mode . -- cgit v1.2.3 From 96d0f0b13819a68480e204716c1af6605cfdcb4c Mon Sep 17 00:00:00 2001 From: Miguel Ángel Arruga Vivas Date: Sun, 1 Nov 2020 01:57:02 +0100 Subject: .dir-locals.el: Require cl-lib at runtime. * .dir-locals.el (nil): Load cl-lib when needed. --- .dir-locals.el | 1 + 1 file changed, 1 insertion(+) (limited to '.dir-locals.el') diff --git a/.dir-locals.el b/.dir-locals.el index 0496e41ca2..8e5d3902e3 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -25,6 +25,7 @@ (unless (boundp 'geiser-guile-load-path) (defvar geiser-guile-load-path '())) (make-local-variable 'geiser-guile-load-path) + (require 'cl-lib) (cl-pushnew root-dir* geiser-guile-load-path :test #'string-equal))))) -- cgit v1.2.3 From 3de898b43c1388a9244bdedd2d9f11511c9571d2 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Mon, 9 Nov 2020 13:14:31 -0500 Subject: maint: update-guix-package: Optionally add sources to store. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Define as a procedure, not a syntax. (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): Remove entry for with-temporary-git-worktree. * doc/contributing.texi (Updating the Guix Package): Update doc. Co-authored-by: Ludovic Courtès --- .dir-locals.el | 1 - Makefile.am | 14 ++++---- build-aux/update-guix-package.scm | 73 ++++++++++++++++++++++++++++----------- doc/contributing.texi | 11 ++---- 4 files changed, 63 insertions(+), 36 deletions(-) (limited to '.dir-locals.el') diff --git a/.dir-locals.el b/.dir-locals.el index 8e5d3902e3..b1cb936a55 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -123,7 +123,6 @@ (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 '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..9fe6c201cc 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 (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. -- cgit v1.2.3 From 1d6e7732b163c9e945c9e5b32c726fe3b5f09c3a Mon Sep 17 00:00:00 2001 From: Christopher Lemmer Webber Date: Mon, 16 Nov 2020 13:04:38 -0500 Subject: .dir-locals.el: Prevent errors if .dir-locals.el isn't found. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While this repo should presumably always have a .dir-locals.el by the nature of this file itself, it seems that this behavior "leaks". See added comment for more details on the fix to this strange bug, which is likely an upstream emacs or vc-mode issue. Thanks to Miguel Ángel Arruga Vivas and Maxim Cournoyer for helping investigate this problem. * .dir-locals.el: Don't error out if .dir-locals.el isn't found. --- .dir-locals.el | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to '.dir-locals.el') diff --git a/.dir-locals.el b/.dir-locals.el index 8e5d3902e3..545c1c3e8b 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -17,17 +17,27 @@ ;; Geiser ;; This allows automatically setting the `geiser-guile-load-path' ;; variable when using various Guix checkouts (e.g., via git worktrees). - (eval . (let* ((root-dir (expand-file-name - (locate-dominating-file - default-directory ".dir-locals.el"))) - ;; Workaround for bug https://issues.guix.gnu.org/43818. - (root-dir* (directory-file-name root-dir))) - (unless (boundp 'geiser-guile-load-path) - (defvar geiser-guile-load-path '())) - (make-local-variable 'geiser-guile-load-path) - (require 'cl-lib) - (cl-pushnew root-dir* geiser-guile-load-path - :test #'string-equal))))) + (eval . (let ((root-dir-unexpanded (locate-dominating-file + default-directory ".dir-locals.el"))) + ;; While Guix should in theory always have a .dir-locals.el + ;; (we are reading this file, after all) there seems to be a + ;; strange problem where this code "escapes" to some other buffers, + ;; at least vc-mode. See: + ;; https://lists.gnu.org/archive/html/guix-devel/2020-11/msg00296.html + ;; (TODO: add/replace with upstream emacs bug link when reported) + ;; Hence the following "when", which might otherwise be unnecessary; + ;; it prevents causing an error when root-dir-unexpanded is nil. + (when root-dir-unexpanded + (let* ((root-dir (expand-file-name root-dir-unexpanded)) + ;; Workaround for bug https://issues.guix.gnu.org/43818. + (root-dir* (directory-file-name root-dir))) + + (unless (boundp 'geiser-guile-load-path) + (defvar geiser-guile-load-path '())) + (make-local-variable 'geiser-guile-load-path) + (require 'cl-lib) + (cl-pushnew root-dir* geiser-guile-load-path + :test #'string-equal))))))) (c-mode . ((c-file-style . "gnu"))) (scheme-mode -- cgit v1.2.3 From a895eace116c59aa570b54e3a165eef3fcef26c7 Mon Sep 17 00:00:00 2001 From: Christopher Lemmer Webber Date: Mon, 16 Nov 2020 13:06:27 -0500 Subject: .dir-locals.el: Use setq-local on guix-directory. * .dir-locals.el: Use setq-local on guix-directory. While a problem with using setq hasn't been identified, this seems like good hygiene. --- .dir-locals.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to '.dir-locals.el') diff --git a/.dir-locals.el b/.dir-locals.el index 545c1c3e8b..521c37950c 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -11,8 +11,9 @@ . "") ;; Emacs-Guix - (eval . (setq guix-directory - (locate-dominating-file default-directory ".dir-locals.el"))) + (eval . (setq-local guix-directory + (locate-dominating-file default-directory + ".dir-locals.el"))) ;; Geiser ;; This allows automatically setting the `geiser-guile-load-path' -- cgit v1.2.3 From 3428c66c5a4d5f1a5fd2f1ad4cd3105993ae8e6d Mon Sep 17 00:00:00 2001 From: Miguel Ángel Arruga Vivas Date: Mon, 16 Nov 2020 21:36:45 +0100 Subject: .dir-locals.el: Add upstream report link. Follow up from 1d6e7732b163c9e945c9e5b32c726fe3b5f09c3a. * .dir-locals.el: Modify comment to point at the report to bug-gnu-emacs. --- .dir-locals.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.dir-locals.el') diff --git a/.dir-locals.el b/.dir-locals.el index 521c37950c..bad3900a96 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -25,7 +25,7 @@ ;; strange problem where this code "escapes" to some other buffers, ;; at least vc-mode. See: ;; https://lists.gnu.org/archive/html/guix-devel/2020-11/msg00296.html - ;; (TODO: add/replace with upstream emacs bug link when reported) + ;; Upstream report: ;; Hence the following "when", which might otherwise be unnecessary; ;; it prevents causing an error when root-dir-unexpanded is nil. (when root-dir-unexpanded -- cgit v1.2.3