core-update: Handle jar-files with patches

  • Open
  • quality assurance status badge
Details
2 participants
  • Björn Höfling
  • swedebugia
Owner
unassigned
Submitted by
Björn Höfling
Severity
normal
B
B
Björn Höfling wrote on 18 Apr 2019 07:06
(address . guix-patches@gnu.org)
20190418070621.09cd7307@alma-ubu
Please review carefully, this is my first work below the gexp-border.

This patch is the outcome of my question at:


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
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:
---
guix/packages.scm | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

Toggle diff (42 lines)
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
-----BEGIN PGP SIGNATURE-----

iF0EARECAB0WIQQiGUP0np8nb5SZM4K/KGy2WT5f/QUCXLgFzQAKCRC/KGy2WT5f
/TGRAJ45ly76SM+G8g+Aeh3WpBYojjRIOwCfdPG6lYuvdTiysK5fMqMWYIzsnIs=
=6EI4
-----END PGP SIGNATURE-----


S
S
swedebugia wrote on 27 Jun 2019 16:15
(address . guix-patches@gnu.org)
30fb000b-35d1-f7ab-f5f5-ceb9bc8a4ab9@riseup.net
On 2019-04-18 07:06, Björn Höfling wrote:
Toggle quote (20 lines)
> 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?

--
Cheers Swedebugia
?