summaryrefslogtreecommitdiff
path: root/guix/transformations.scm
diff options
context:
space:
mode:
authorMarius Bakke <marius@gnu.org>2021-08-12 00:30:27 +0200
committerMarius Bakke <marius@gnu.org>2021-08-12 00:30:27 +0200
commitc4133c43c7cfe2476ebfae87f9e4d10d96de9bc7 (patch)
tree47bd773d2f434384b54e56916c1a287dd8e51511 /guix/transformations.scm
parentffa01e68859bb7a6daa9fcffdc8d77ca35db4bc0 (diff)
parent4eb0a5146ae5a195a29c79f586fcc1e58f7fa69b (diff)
downloadguix-patches-c4133c43c7cfe2476ebfae87f9e4d10d96de9bc7.tar
guix-patches-c4133c43c7cfe2476ebfae87f9e4d10d96de9bc7.tar.gz
Merge branch 'master' into core-updates-frozen
Conflicts: gnu/packages/algebra.scm gnu/packages/games.scm gnu/packages/golang.scm gnu/packages/kerberos.scm gnu/packages/mail.scm gnu/packages/python.scm gnu/packages/ruby.scm gnu/packages/scheme.scm gnu/packages/tex.scm gnu/packages/tls.scm gnu/packages/version-control.scm
Diffstat (limited to 'guix/transformations.scm')
-rw-r--r--guix/transformations.scm45
1 files changed, 36 insertions, 9 deletions
diff --git a/guix/transformations.scm b/guix/transformations.scm
index b0c09a0c92..5122baa403 100644
--- a/guix/transformations.scm
+++ b/guix/transformations.scm
@@ -460,19 +460,46 @@ to the same package but with #:strip-binaries? #f in its 'arguments' field."
(rewrite obj)
obj)))
+(define (patched-source name source patches)
+ "Return a file-like object with the given NAME that applies PATCHES to
+SOURCE. SOURCE must itself be a file-like object of any type, including
+<git-checkout>, <local-file>, etc."
+ (define patch
+ (module-ref (resolve-interface '(gnu packages base)) 'patch))
+
+ (computed-file name
+ (with-imported-modules '((guix build utils))
+ #~(begin
+ (use-modules (guix build utils))
+
+ (setenv "PATH" #+(file-append patch "/bin"))
+
+ ;; XXX: Assume SOURCE is a directory. This is true in
+ ;; most practical cases, where it's a <git-checkout>.
+ (copy-recursively #+source #$output)
+ (chdir #$output)
+ (for-each (lambda (patch)
+ (invoke "patch" "-p1" "--batch"
+ "-i" patch))
+ '(#+@patches))))))
+
(define (transform-package-patches specs)
"Return a procedure that, when passed a package, returns a package with
additional patches."
(define (package-with-extra-patches p patches)
- (if (origin? (package-source p))
- (package/inherit p
- (source (origin
- (inherit (package-source p))
- (patches (append (map (lambda (file)
- (local-file file))
- patches)
- (origin-patches (package-source p)))))))
- p))
+ (let ((patches (map (lambda (file)
+ (local-file file))
+ patches)))
+ (if (origin? (package-source p))
+ (package/inherit p
+ (source (origin
+ (inherit (package-source p))
+ (patches (append patches
+ (origin-patches (package-source p)))))))
+ (package/inherit p
+ (source (patched-source (string-append (package-full-name p "-")
+ "-source")
+ (package-source p) patches))))))
(define (coalesce-alist alist)
;; Coalesce multiple occurrences of the same key in ALIST.