[bug#35312] core-update: Handle jar-files with patches

Message ID 20190418070621.09cd7307@alma-ubu
State Accepted
Headers show
Series [bug#35312] core-update: Handle jar-files with patches | expand

Checks

Context Check Description
cbaines/applying patch fail Apply failed

Commit Message

Björn Höfling April 18, 2019, 5:06 a.m. UTC
Please review carefully, this is my first work below the gexp-border.

This patch is the outcome of my question at:

https://lists.gnu.org/archive/html/guix-devel/2019-04/msg00226.html

When a jar-file had patches, it was not recognized and wrongly handled
with "tar xz".

There is one open question: For patch-and-repack, the flags defaults
to '("p1"), but for jar-files we would usually need a "p0". That would
mean for jar-sources with patches, one would need to manually add the
patch-flags with "p0" to the origin. This is not nice. On the other
hand, I would not like to override the patch-flags for jar-files to
always "p0".

WDYT?

Björn

Comments

swedebugia June 27, 2019, 2:15 p.m. UTC | #1
On 2019-04-18 07:06, Björn Höfling wrote:
> Please review carefully, this is my first work below the gexp-border.
> 
> This patch is the outcome of my question at:
> 
> https://lists.gnu.org/archive/html/guix-devel/2019-04/msg00226.html
> 
> When a jar-file had patches, it was not recognized and wrongly handled
> with "tar xz".
> 
> There is one open question: For patch-and-repack, the flags defaults
> to '("p1"), but for jar-files we would usually need a "p0". That would
> mean for jar-sources with patches, one would need to manually add the
> patch-flags with "p0" to the origin. This is not nice. On the other
> hand, I would not like to override the patch-flags for jar-files to
> always "p0".
> 
> WDYT?
> 
> Björn
> 
This seem to have fallen through the cracks. Can someone with gexp 
knowledge review this?

Patch

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(-)

diff --git a/guix/packages.scm b/guix/packages.scm
index a961dc3973..5af2c25cd9 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -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