guix: texlive-build-system: Add #:link-scripts argument.
* doc/guix.texi (Build Systems): Document argument. * guix/build-system/texlive.scm (texlive-build): Add #:LINK-SCRIPTS argument. * guix/build/texlive-build-system.scm (link-scripts): (patch-shell-scripts): New function. (%standard-phases): Add new functions as phases.
This commit is contained in:
		
							parent
							
								
									24e6732b15
								
							
						
					
					
						commit
						c8e75dfa24
					
				
					 3 changed files with 48 additions and 2 deletions
				
			
		| 
						 | 
					@ -10011,7 +10011,9 @@ of file names.
 | 
				
			||||||
It also generates font metrics (i.e., @file{.tfm} files) out of Metafont
 | 
					It also generates font metrics (i.e., @file{.tfm} files) out of Metafont
 | 
				
			||||||
files whenever possible.  Likewise, it can also create TeX formats
 | 
					files whenever possible.  Likewise, it can also create TeX formats
 | 
				
			||||||
(i.e., @file{.fmt} files) listed in the @code{#:create-formats}
 | 
					(i.e., @file{.fmt} files) listed in the @code{#:create-formats}
 | 
				
			||||||
argument.
 | 
					argument, and generate a symbolic link from @file{bin/} directory to any
 | 
				
			||||||
 | 
					script located in located in @file{texmf-dist/scripts/}, provided its
 | 
				
			||||||
 | 
					file name is listed in @code{#:link-scripts} argument.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
The build system adds @code{texlive-bin} from @code{(gnu packages tex)}
 | 
					The build system adds @code{texlive-bin} from @code{(gnu packages tex)}
 | 
				
			||||||
to the native inputs.  It can be overridden with the
 | 
					to the native inputs.  It can be overridden with the
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -132,6 +132,7 @@ level package ID."
 | 
				
			||||||
                        (tests? #f)
 | 
					                        (tests? #f)
 | 
				
			||||||
                        (build-targets #f)
 | 
					                        (build-targets #f)
 | 
				
			||||||
                        (create-formats #f)
 | 
					                        (create-formats #f)
 | 
				
			||||||
 | 
					                        (link-scripts #f)
 | 
				
			||||||
                        (tex-engine #f)
 | 
					                        (tex-engine #f)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        ;; FIXME: This would normally default to "luatex" but
 | 
					                        ;; FIXME: This would normally default to "luatex" but
 | 
				
			||||||
| 
						 | 
					@ -163,6 +164,7 @@ level package ID."
 | 
				
			||||||
                               #:source #+source
 | 
					                               #:source #+source
 | 
				
			||||||
                               #:build-targets #$build-targets
 | 
					                               #:build-targets #$build-targets
 | 
				
			||||||
                               #:create-formats #$create-formats
 | 
					                               #:create-formats #$create-formats
 | 
				
			||||||
 | 
					                               #:link-scripts #$link-scripts
 | 
				
			||||||
                               #:tex-engine #$(if tex-engine
 | 
					                               #:tex-engine #$(if tex-engine
 | 
				
			||||||
                                                  tex-engine
 | 
					                                                  tex-engine
 | 
				
			||||||
                                                  tex-format)
 | 
					                                                  tex-format)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -79,6 +79,18 @@ runfile to replace.  If a file has no matching runfile, it is ignored."
 | 
				
			||||||
                           (basename file)))))
 | 
					                           (basename file)))))
 | 
				
			||||||
              (find-files dir regexp))))
 | 
					              (find-files dir regexp))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(define* (patch-shell-scripts #:rest _)
 | 
				
			||||||
 | 
					  "Expand filenames for usual tools in shell scripts."
 | 
				
			||||||
 | 
					  (when (file-exists? "scripts")
 | 
				
			||||||
 | 
					    (let* ((commands '("awk" "basename" "cat" "grep" "mkdir" "rm" "sed" "sort"
 | 
				
			||||||
 | 
					                       "uname"))
 | 
				
			||||||
 | 
					           (command-regexp (format #f
 | 
				
			||||||
 | 
					                                   "\\b(~a)\\b"
 | 
				
			||||||
 | 
					                                   (string-join commands "|"))))
 | 
				
			||||||
 | 
					      (substitute* (find-files "scripts" "\\.sh$")
 | 
				
			||||||
 | 
					        ((command-regexp _ command)
 | 
				
			||||||
 | 
					         (which command))))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(define* (delete-drv-files #:rest _)
 | 
					(define* (delete-drv-files #:rest _)
 | 
				
			||||||
  "Delete pre-generated \".drv\" files in order to prevent build failures."
 | 
					  "Delete pre-generated \".drv\" files in order to prevent build failures."
 | 
				
			||||||
  (when (file-exists? "source")
 | 
					  (when (file-exists? "source")
 | 
				
			||||||
| 
						 | 
					@ -244,16 +256,46 @@ runfile to replace.  If a file has no matching runfile, it is ignored."
 | 
				
			||||||
                    (copy-recursively root destination)))
 | 
					                    (copy-recursively root destination)))
 | 
				
			||||||
                (runfiles-root-directories)))))
 | 
					                (runfiles-root-directories)))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					(define* (link-scripts #:key link-scripts outputs #:allow-other-keys)
 | 
				
			||||||
 | 
					  (when (pair? link-scripts)
 | 
				
			||||||
 | 
					    (unless (file-exists? "scripts")
 | 
				
			||||||
 | 
					      (error "missing \"scripts\" directory: no script to link"))
 | 
				
			||||||
 | 
					    (let ((bin (string-append (assoc-ref outputs "out") "/bin"))
 | 
				
			||||||
 | 
					          (filenames
 | 
				
			||||||
 | 
					           (filter (lambda (f) (any (cut string-suffix? <> f) link-scripts))
 | 
				
			||||||
 | 
					                   (find-files "scripts"))))
 | 
				
			||||||
 | 
					      ;; Sanity check: make sure no provided script is ignored.
 | 
				
			||||||
 | 
					      (let ((unknown (lset-difference string=?
 | 
				
			||||||
 | 
					                                      (map basename link-scripts)
 | 
				
			||||||
 | 
					                                      (map basename filenames))))
 | 
				
			||||||
 | 
					        (when (pair? unknown)
 | 
				
			||||||
 | 
					          (error (format #f "cannot find script(s): ~a~%"
 | 
				
			||||||
 | 
					                         (string-join unknown)))))
 | 
				
			||||||
 | 
					      ;; All lights are green.  Create "bin/" and the symlinks.
 | 
				
			||||||
 | 
					      (mkdir-p bin)
 | 
				
			||||||
 | 
					      (for-each
 | 
				
			||||||
 | 
					       (lambda (script)
 | 
				
			||||||
 | 
					         ;; Remove extension, if any.
 | 
				
			||||||
 | 
					         (let ((name (match (string-split (basename script) #\.)
 | 
				
			||||||
 | 
					                       ((name) name)
 | 
				
			||||||
 | 
					                       (tokens (string-join (drop-right tokens 1)))))
 | 
				
			||||||
 | 
					               (origin (string-append "../share/texmf-dist/" script)))
 | 
				
			||||||
 | 
					           (format #t "linking bin/~s to ~s~%" name origin)
 | 
				
			||||||
 | 
					           (symlink origin (string-append bin "/" name))))
 | 
				
			||||||
 | 
					       filenames))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(define %standard-phases
 | 
					(define %standard-phases
 | 
				
			||||||
  (modify-phases gnu:%standard-phases
 | 
					  (modify-phases gnu:%standard-phases
 | 
				
			||||||
    (delete 'bootstrap)
 | 
					    (delete 'bootstrap)
 | 
				
			||||||
    (delete 'configure)
 | 
					    (delete 'configure)
 | 
				
			||||||
 | 
					    (add-after 'unpack 'patch-shell-scripts patch-shell-scripts)
 | 
				
			||||||
    (add-before 'build 'delete-drv-files delete-drv-files)
 | 
					    (add-before 'build 'delete-drv-files delete-drv-files)
 | 
				
			||||||
    (add-after 'delete-drv-files 'generate-font-metrics generate-font-metrics)
 | 
					    (add-after 'delete-drv-files 'generate-font-metrics generate-font-metrics)
 | 
				
			||||||
    (replace 'build build)
 | 
					    (replace 'build build)
 | 
				
			||||||
    (add-after 'build 'create-formats create-formats)
 | 
					    (add-after 'build 'create-formats create-formats)
 | 
				
			||||||
    (delete 'check)
 | 
					    (delete 'check)
 | 
				
			||||||
    (replace 'install install)))
 | 
					    (replace 'install install)
 | 
				
			||||||
 | 
					    (add-after 'install 'link-scripts link-scripts)))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(define* (texlive-build #:key inputs (phases %standard-phases)
 | 
					(define* (texlive-build #:key inputs (phases %standard-phases)
 | 
				
			||||||
                        #:allow-other-keys #:rest args)
 | 
					                        #:allow-other-keys #:rest args)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in a new issue