From 84098800908c732facea1196cbc51b06128ff2ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20H=C3=B6fling?=
<bjoern.hoefling@bjoernhoefling.de>
Date: Thu, 18 Apr 2019 06:27:39 +0200
Subject: [PATCH] guix: Handle patching of jar-files correctly.
When jar-files are used as origins with patches, they were not
handled correctly and unpacked with the default "tar xz" command.
This fix adds a case for jar-files.
* guix/packages.scm (%standard-inputs): Add entry for jar-files.
(patch-and-repack)(decompression-type): Handle "jar" suffix.
patch-and-repack)(build): Unpack jar-files with unzip.
Don't change into first-file for jar-files.
See discussion at:
<https://lists.gnu.org/archive/html/guix-devel/2019-04/msg00226.html>.
---
guix/packages.scm | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
@@ -436,6 +436,7 @@ identifiers. The result is inferred from the file names of patches."
("gzip" ,(ref '(gnu packages compression) 'gzip))
("lzip" ,(ref '(gnu packages compression) 'lzip))
("unzip" ,(ref '(gnu packages compression) 'unzip))
+ ("jar" ,(ref '(gnu packages compression) 'unzip))
("patch" ,(ref '(gnu packages base) 'patch))
("locales" ,(ref '(gnu packages base) 'glibc-utf8-locales)))))
@@ -492,6 +493,7 @@ specifies modules in scope when evaluating SNIPPET."
((string-suffix? "bz2" source-file-name) "bzip2")
((string-suffix? "lz" source-file-name) "lzip")
((string-suffix? "zip" source-file-name) "unzip")
+ ((string-suffix? "jar" source-file-name) "jar")
(else "xz")))
(define original-file-name
@@ -585,12 +587,17 @@ specifies modules in scope when evaluating SNIPPET."
(directory (string-drop base (+ 1 dash))))
(mkdir directory)
(copy-recursively #+source directory))
- #+(if (string=? decompression-type "unzip")
+ #+(if (or
+ (string=? decompression-type "unzip")
+ (string=? decompression-type "jar"))
#~(invoke "unzip" #+source)
#~(invoke (string-append #+tar "/bin/tar")
"xvf" #+source)))
- (let ((directory (first-file ".")))
+ ;; jar-files have their contents directly in the root folder
+ (let ((directory (if (string=? #+decompression-type "jar")
+ "."
+ (first-file "."))))
(format (current-error-port)
"source is under '~a'~%" directory)
(chdir directory)
--
2.21.0