From e771153f957e1bd41dbef32bf6f7e997f9a732f5 Mon Sep 17 00:00:00 2001 From: Tim Gesthuizen Date: Fri, 4 Jan 2019 12:22:34 +0100 Subject: [PATCH 3/7] gnu: linux-libre: Copy source to the store The source code is needed by some kernel modules to compile. The item in the store only symlinks the build directory in /tmp which is not reachable later on and is a source of non determinism for the store item. This patch deletes the symlinks and copies the source to a separate output. * gnu/packages/linux.scm (linux-libre): [outputs]: Add output source [arguments]: Add phase to copy source to the store item. --- gnu/packages/linux.scm | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index ccad6eba0..50c348b15 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -343,10 +343,12 @@ VERSION." '()) ((? string? config) `(("kconfig" ,config)))))) + (outputs '("out" "source")) (arguments `(#:modules ((guix build gnu-build-system) (guix build utils) (srfi srfi-1) + (ice-9 format) (ice-9 match)) #:phases (modify-phases %standard-phases @@ -421,7 +423,40 @@ VERSION." (string-append "INSTALL_PATH=" out) (string-append "INSTALL_MOD_PATH=" out) "INSTALL_MOD_STRIP=1" - "modules_install"))))) + "modules_install")))) + ;; After installing the source and build directories are symlinked to + ;; the build location in /tmp and are not reachable later on. Copying + ;; the files to a separate output keeps them available. + (add-after 'install 'copy-source + (lambda* (#:key outputs #:allow-other-keys) + ;; The patch is left out in the official kernel version numbering + ;; if it is 0. The module path is however always constructed with + ;; major.minor.patch. + (let* ((out (assoc-ref outputs "out")) + (source (assoc-ref outputs "source")) + (basesubdir ,(linux-libre-module-path version)) + (source-dir (string-append out basesubdir "/source")) + (build-dir (string-append out basesubdir "/build"))) + (for-each (lambda (file) + (when (symbolic-link? file) + (delete-file file))) + (list source-dir build-dir)) + (let ((source-dest (string-append source + basesubdir + "/source")) + (build-dest (string-append source + basesubdir + "/build"))) + (mkdir-p (string-append source basesubdir)) + (format #t "Copying source to ~a\n" + source-dest) + (with-output-to-port (%make-void-port "w") + (lambda _ (copy-recursively (getcwd) source-dest + #:follow-symlinks? #t + #:keep-mtime? #t))) + ;; source-dir content = build-dir content + (symlink source-dest build-dest)) + #t)))) #:tests? #f)) (home-page "https://www.gnu.org/software/linux-libre/") (synopsis "100% free redistribution of a cleaned Linux kernel") -- 2.20.1