I'm trying to build an Emacs package of my local git checkout:

--8<---------------cut here---------------start------------->8---
(define-public emacs-dev
  (package
    (inherit emacs)
    (name "emacs-dev")
    (version "27.0.0")
    (source (local-file "/home/ambrevar/projects/emacs" #:recursive? #t))
    (arguments
     `(#:tests? #f               ; TODO: Enable tests?  Need to fix tramp first.
                #:phases
                (modify-phases %standard-phases
                  (delete 'reset-gzip-timestamps) ; TODO: Why does this fail?
                  (delete 'build))))
    (synopsis "Emacs (development version)")
    (license license:lgpl3+)))
--8<---------------cut here---------------end--------------->8---

The above declaration works on a clean checkout (e.g. after a `make
clean`).

When developing and building locally multiple times, it is more
efficient to only run the install phase during Guix packaging.

Emacs is based on the GNU build system which on Guix uses a separate
"source" and "build" folder.  Unfortunately, some Emacs files are
generated during the build phase inside the "source" folder no matter
what.  (Am I wrong about that?)

Since all file timestamps are set to Epoch by 'unpack', the build phase
tries to rebuild everything.
And since the files unpacked to "source" are read-only, `make` fails to
regenerate the files that go in "source".

Excerpt from the build log:

--8<---------------cut here---------------start------------->8---
make -C ../admin/charsets all
make[2]: Entering directory 
'/tmp/guix-build-emacs-dev-27.0.0.drv-0/build/admin/charsets'
  GEN      ../../../source/etc/charsets/JISX2131.map
/gnu/store/icz3hd36aqpjz5slyp4hhr8wsfbgiml1-bash-minimal-4.4.12/bin/bash: line 
2: ../../../source/etc/charsets/JISX2131.map: Permission denied
--8<---------------cut here---------------end--------------->8---

And the offending files details (notice the permissions and the mtime):

- Source /home/ambrevar/projects/emacs/etc/charsets/JISX2131.map:
-rw-r--r--   1 ambrevar       users    120k 2018-05-17 15:08 JISX2131.map

- Destination 
/tmp/guix-build-emacs-dev-27.0.0.drv-0/source/etc/charsets/JISX2131.map:
-r--r--r--   1 ambrevar       users    120k 1970-01-01  1970 JISX2131.map

The same error occurs for all the generated files (mostly .map files and
stamp files).

From the source, 'unpack' is supposed to preserve the timestamp:

--8<---------------cut here---------------start------------->8---
(define* (unpack #:key source #:allow-other-keys)
  "Unpack SOURCE in the working directory, and change directory within the
source.  When SOURCE is a directory, copy it in a sub-directory of the current
working directory."
  (if (file-is-directory? source)
      (begin
        (mkdir "source")
        (chdir "source")

        ;; Preserve timestamps (set to the Epoch) on the copied tree so that
        ;; things work deterministically.
        (copy-recursively source "."
                          #:keep-mtime? #t)
        #t)
      (and (if (string-suffix? ".zip" source)
               (zero? (system* "unzip" source))
               (zero? (system* "tar" "xvf" source)))
           (chdir (first-subdirectory ".")))))
--8<---------------cut here---------------end--------------->8---

Bug?

--
Pierre Neidhardt

Attachment: signature.asc
Description: PGP signature

Reply via email to