gnu: hplip: Actually wrap binaries.
* gnu/packages/cups.scm (hplip)[arguments]: Reduce indentation. Replace ‘wrap-binaries’ phase with a custom implementation.
This commit is contained in:
		
							parent
							
								
									119d6ff6a9
								
							
						
					
					
						commit
						fbaa66ac2d
					
				
					 1 changed files with 76 additions and 47 deletions
				
			
		| 
						 | 
				
			
			@ -491,7 +491,8 @@ should only be used as part of the Guix cups-pk-helper service.")
 | 
			
		|||
                  (guix build utils)
 | 
			
		||||
                  ((guix build python-build-system) #:prefix python:))
 | 
			
		||||
 | 
			
		||||
       #:phases (modify-phases %standard-phases
 | 
			
		||||
       #:phases
 | 
			
		||||
       (modify-phases %standard-phases
 | 
			
		||||
         (add-after 'unpack 'fix-hard-coded-file-names
 | 
			
		||||
           (lambda* (#:key inputs outputs #:allow-other-keys)
 | 
			
		||||
             (let ((out (assoc-ref outputs "out"))
 | 
			
		||||
| 
						 | 
				
			
			@ -535,10 +536,38 @@ should only be used as part of the Guix cups-pk-helper service.")
 | 
			
		|||
                                 "/lib/systemd/system"))
 | 
			
		||||
                 (("/etc/sane.d")
 | 
			
		||||
                  (string-append out "/etc/sane.d"))))))
 | 
			
		||||
 | 
			
		||||
                  ;; Wrap bin/* so that the Python libraries are found.
 | 
			
		||||
         (add-after 'install 'wrap-binaries
 | 
			
		||||
                    (assoc-ref python:%standard-phases 'wrap)))))
 | 
			
		||||
           ;; Scripts in /bin are all symlinks to .py files in /share/hplip.
 | 
			
		||||
           ;; Symlinks are immune to the Python build system's 'WRAP phase,
 | 
			
		||||
           ;; and the .py files can't be wrapped because they are reused as
 | 
			
		||||
           ;; modules.  Replacing the symlinks in /bin with copies and
 | 
			
		||||
           ;; wrapping them also doesn't work (“ModuleNotFoundError:
 | 
			
		||||
           ;; No module named 'base'”).  Behold: a custom WRAP-PROGRAM.
 | 
			
		||||
           (lambda* (#:key inputs outputs #:allow-other-keys)
 | 
			
		||||
             (let* ((out (assoc-ref outputs "out"))
 | 
			
		||||
                    (bin (string-append out "/bin"))
 | 
			
		||||
                    (python (assoc-ref inputs "python")))
 | 
			
		||||
               (with-directory-excursion bin
 | 
			
		||||
                 (for-each (lambda (file)
 | 
			
		||||
                             (let ((target (readlink file)))
 | 
			
		||||
                               (delete-file file)
 | 
			
		||||
                               (with-output-to-file file
 | 
			
		||||
                                 (lambda _
 | 
			
		||||
                                   (format #t
 | 
			
		||||
                                           "#!~a~@
 | 
			
		||||
                                           export PYTHONPATH=\"~a:~a\"~@
 | 
			
		||||
                                           exec -a \"$0\" \"~a/~a\" \"$@\"~%"
 | 
			
		||||
                                           (which "bash")
 | 
			
		||||
                                           (string-append
 | 
			
		||||
                                            out "/lib/python"
 | 
			
		||||
                                            (python:python-version python)
 | 
			
		||||
                                            "/site-packages")
 | 
			
		||||
                                           (getenv "PYTHONPATH")
 | 
			
		||||
                                           bin target)))
 | 
			
		||||
                               (chmod file #o755)))
 | 
			
		||||
                  (find-files "." (lambda (file stat)
 | 
			
		||||
                                    (eq? 'symlink (stat:type stat)))))
 | 
			
		||||
                 #t)))))))
 | 
			
		||||
 | 
			
		||||
    ;; Note that the error messages printed by the tools in the case of
 | 
			
		||||
    ;; missing dependencies are often downright misleading.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue