chromium-extension: Build .crx files in a deterministic fashion.

* gnu/build/chromium-extension.scm (make-crx): Pass #:keep-mtime? #t to
COPY-RECURSIVELY.  Remove defunct FAKETIME workaround.  While at it, pack the
extension in the scratch working directory instead of the transient
store-mapped /tmp.
This commit is contained in:
Marius Bakke 2021-12-16 19:06:35 +01:00
parent 40ebf85b86
commit aec6bd0169
No known key found for this signature in database
GPG key ID: A2A06DF2A33A54FA

View file

@ -19,8 +19,6 @@
(define-module (gnu build chromium-extension) (define-module (gnu build chromium-extension)
#:use-module (guix gexp) #:use-module (guix gexp)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (gnu packages base)
#:use-module (gnu packages check)
#:use-module (gnu packages chromium) #:use-module (gnu packages chromium)
#:use-module (gnu packages gnupg) #:use-module (gnu packages gnupg)
#:use-module (gnu packages tls) #:use-module (gnu packages tls)
@ -77,20 +75,17 @@ (define version (package-version package))
(use-modules (guix build utils)) (use-modules (guix build utils))
(let ((chromium #$(file-append ungoogled-chromium "/bin/chromium")) (let ((chromium #$(file-append ungoogled-chromium "/bin/chromium"))
(xvfb #$(file-append xorg-server "/bin/Xvfb")) (xvfb #$(file-append xorg-server "/bin/Xvfb"))
(packdir "/tmp/extension")) (packdir (string-append (getcwd) "/extension")))
(mkdir-p (dirname packdir)) (mkdir packdir)
(copy-recursively (ungexp package package-output) packdir) (copy-recursively (ungexp package package-output) packdir
;; Ensure consistent file modification times.
#:keep-mtime? #t)
(system (string-append xvfb " :1 &")) (system (string-append xvfb " :1 &"))
(setenv "DISPLAY" ":1") (setenv "DISPLAY" ":1")
(sleep 2) ;give Xorg some time to initialize... (sleep 2) ;give Xorg some time to initialize...
;; Chromium stores the current time in the .crx Zip archive. ;; Chromium stores the current time in the .crx Zip archive.
;; Use a fixed timestamp for deterministic behavior. ;; Use a fixed timestamp for deterministic behavior.
;; FIXME (core-updates): faketime is missing an absolute reference (invoke chromium
;; to 'date', hence the need to set PATH.
(setenv "PATH" #$(file-append coreutils "/bin"))
(invoke #$(file-append libfaketime "/bin/faketime")
"2000-01-01 00:00:00"
chromium
"--user-data-dir=/tmp/signing-profile" "--user-data-dir=/tmp/signing-profile"
(string-append "--pack-extension=" packdir) (string-append "--pack-extension=" packdir)
(string-append "--pack-extension-key=" #$signing-key)) (string-append "--pack-extension-key=" #$signing-key))