bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#51258: [PATCH v3] gnu: emacs: Handle pdump filenames that contain a


From: Morgan . J . Smith
Subject: bug#51258: [PATCH v3] gnu: emacs: Handle pdump filenames that contain a fingerprint
Date: Sat, 23 Oct 2021 21:00:15 -0400

From: Morgan Smith <Morgan.J.Smith@outlook.com>

* gnu/packages/emacs.scm (emacs) [restore-emacs-pdmp]: Change regex to handle
filenames that have a fingerprint in them. Remove #t at the end of the
phase. Don't bother deleting the old files because rename will overwrite them
anyways.
---

find-files does sort its return so my previous 2 patches probably work great
regardless of the number of pdmps we encounter (which will only ever be 1
anyways).

Also the fingerprint is a 32 char hexidecimal number used to uniquely[1]
identify the Emacs binary (well more specifically an earlier binary generated
during the build process).  If you put the version in there it would
completely invalidate the entire purpose of this fingerprint.  Different
distros will have different fingerprints for the same version and that's the
point.

Here is another over engineered solution even though the previous 2 still work
great.  I'm not sure if I'm supposed to just throw a '(use-modules ...)' in the
phase but if we want to use the #:modules argument then it will break all of
the other Emacsen that inherit from Emacs since they use different build
systems.


1. Hash collisions are a thing so maybe not actually uniquely


 gnu/packages/emacs.scm | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 6d9950d068..e25b79b832 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -179,18 +179,18 @@ (define* (emacs-byte-compile-directory dir)
          (add-after 'glib-or-gtk-wrap 'restore-emacs-pdmp
            ;; restore the dump file that Emacs installs somewhere in
            ;; libexec/ to its original state
-           (lambda* (#:key outputs target #:allow-other-keys)
-             (let* ((libexec (string-append (assoc-ref outputs "out")
+           (lambda* (#:key outputs #:allow-other-keys)
+             (use-modules (ice-9 regex))
+             (let* ((pdmp-regex ".(emacs(-[[:xdigit:]]+)?.pdmp)-real")
+                    (libexec (string-append (assoc-ref outputs "out")
                                             "/libexec"))
-                    ;; each of these find-files should return one file
-                    (pdmp (find-files libexec "^emacs\\.pdmp$"))
-                    (pdmp-real (find-files libexec
-                                           "^\\.emacs\\.pdmp-real$")))
-               (for-each (lambda (wrapper real)
-                           (delete-file wrapper)
-                           (rename-file real wrapper))
-                         pdmp pdmp-real))
-             #t))
+                    (pdmp (find-files libexec pdmp-regex)))
+               (map
+                (lambda (pdmp)
+                  (rename-file
+                   pdmp
+                   (regexp-substitute #f (string-match pdmp-regex pdmp) 'pre 
1)))
+                pdmp))))
          (add-after 'glib-or-gtk-wrap 'strip-double-wrap
            (lambda* (#:key outputs #:allow-other-keys)
              ;; Directly copy emacs-X.Y to emacs, so that it is not wrapped
-- 
2.33.1






reply via email to

[Prev in Thread] Current Thread [Next in Thread]