gnu: Search for patches under $GUIX_PACKAGE_PATH.

Fixes <http://bugs.gnu.org/19364>.
Reported by Tomáš Čech <sleep_walker@suse.cz>
and Mark H Weaver <mhw@netris.org>.

* gnu/packages.scm (%patch-path): Move after definition of
  %package-module-path'.  Append "/gnu/packages/patches" only to
  %DISTRO-ROOT-DIRECTORY.
* tests/guix-package.sh: Add 'emacs-foo-bar-patched' test.
This commit is contained in:
Ludovic Courtès 2015-01-03 23:49:42 +01:00
parent e13f715be0
commit ee06af5b4b
2 changed files with 32 additions and 8 deletions

View file

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
;;; ;;;
@ -64,11 +64,6 @@ (define-module (gnu packages)
;; and an extra environment variable. One advantage of this setup is ;; and an extra environment variable. One advantage of this setup is
;; that everything just works in an auto-compilation setting. ;; that everything just works in an auto-compilation setting.
(define %patch-path
(make-parameter
(map (cut string-append <> "/gnu/packages/patches")
%load-path)))
(define %bootstrap-binaries-path (define %bootstrap-binaries-path
(make-parameter (make-parameter
(map (cut string-append <> "/gnu/packages/bootstrap") (map (cut string-append <> "/gnu/packages/bootstrap")
@ -104,6 +99,16 @@ (define %package-module-path
(make-parameter (make-parameter
(append environment `((,%distro-root-directory . "gnu/packages")))))) (append environment `((,%distro-root-directory . "gnu/packages"))))))
(define %patch-path
;; Define it after '%package-module-path' so that '%load-path' contains user
;; directories, allowing patches in $GUIX_PACKAGE_PATH to be found.
(make-parameter
(map (lambda (directory)
(if (string=? directory %distro-root-directory)
(string-append directory "/gnu/packages/patches")
directory))
%load-path)))
(define* (scheme-files directory) (define* (scheme-files directory)
"Return the list of Scheme files found under DIRECTORY, recursively. The "Return the list of Scheme files found under DIRECTORY, recursively. The
returned list is sorted in alphabetical order." returned list is sorted in alphabetical order."

View file

@ -1,5 +1,5 @@
# GNU Guix --- Functional package management for GNU # GNU Guix --- Functional package management for GNU
# Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org> # Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org> # Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
# #
# This file is part of GNU Guix. # This file is part of GNU Guix.
@ -289,10 +289,29 @@ GUIX_PACKAGE_PATH="$module_dir"
export GUIX_PACKAGE_PATH export GUIX_PACKAGE_PATH
guix package -A emacs-foo-bar | grep 42 guix package -A emacs-foo-bar | grep 42
guix package -i emacs-foo-bar-42 -n guix package -i emacs-foo-bar-42 -n
# Make sure patches that live under $GUIX_PACKAGE_PATH are found.
cat > "$module_dir/emacs.patch"<<EOF
This is a fake patch.
EOF
cat > "$module_dir/foo.scm"<<EOF
(define-module (foo)
#:use-module (guix packages)
#:use-module (gnu packages)
#:use-module (gnu packages emacs))
(define-public x
(package (inherit emacs)
(source (origin (inherit (package-source emacs))
(patches (list (search-patch "emacs.patch")))))
(name "emacs-foo-bar-patched")
(version "42")))
EOF
guix package -i emacs-foo-bar-patched -n
unset GUIX_PACKAGE_PATH unset GUIX_PACKAGE_PATH
# Using 'GUIX_BUILD_OPTIONS'. # Using 'GUIX_BUILD_OPTIONS'.
available="`guix package -A | sort`" available="`guix package -A | sort`"
GUIX_BUILD_OPTIONS="--dry-run" GUIX_BUILD_OPTIONS="--dry-run"
export GUIX_BUILD_OPTIONS export GUIX_BUILD_OPTIONS