From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?B?QmrDtnJuIEjDtmZsaW5n?= Subject: Re: java: How to patch a jar-sources Date: Tue, 16 Apr 2019 01:49:32 +0200 Message-ID: <20190416014932.5d101b6d@alma-ubu> References: <20190415080248.679c6749@alma-ubu> <20190415171953.655dd24d@scratchpost.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/0LVAxCyhsql5lj.=P+vCmLG"; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:56688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGBM6-0006dE-3L for guix-devel@gnu.org; Mon, 15 Apr 2019 19:49:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGBM4-0000Ap-Ty for guix-devel@gnu.org; Mon, 15 Apr 2019 19:49:42 -0400 Received: from m4s11.vlinux.de ([83.151.27.109]:34908 helo=bjoernhoefling.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGBM4-00008z-H9 for guix-devel@gnu.org; Mon, 15 Apr 2019 19:49:40 -0400 In-Reply-To: <20190415171953.655dd24d@scratchpost.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Danny Milosavljevic Cc: guix-devel --Sig_/0LVAxCyhsql5lj.=P+vCmLG Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, 15 Apr 2019 17:19:53 +0200 Danny Milosavljevic wrote: > (define* (unpack #:key source #:allow-other-keys) > "Unpack the jar archive SOURCE. When SOURCE is not a jar archive > fall back to the default GNU unpack strategy." > (if (string-suffix? ".jar" source) > (begin > (mkdir "src") > (with-directory-excursion "src" > (invoke "jar" "-xf" source)) > #t) > ;; Use GNU unpack strategy for things that aren't jar archives. > ((assq-ref gnu:%standard-phases 'unpack) #:source source))) This is only for the case without patches. =20 > Hmm... maybe the patched source gets a random name that doesn't end > in ".jar" The problem is before: It occurs during unpacking: The .jar file is getting handled with "tar xvf". I looked into the source-derivation and found the pieces. I added this line: diff --git a/guix/packages.scm b/guix/packages.scm index c94a651f27..412dfcc04c 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -488,12 +488,13 @@ specifies modules in scope when evaluating SNIPPET." (define decompression-type (cond ((string-suffix? "gz" source-file-name) "gzip") ((string-suffix? "Z" source-file-name) "gzip") ((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) "unzip") (else "xz"))) This brings me a step further: The .jar-file will now be extracted. Unfortunately, we have this in line number 593: (let ((directory (first-file "."))) (format (current-error-port) "source is under '~a'~%" directory) (chdir directory) That means: It is expected that the tarball/zipfile/archive contains a single directory under which the sources are contained. That seams to be the case for all .tar.* and .zip archives used within Guix packages. To verify that, I (randomly) picked the fcgi package and repacked the tarball, such that sources are directly in the root folder. I then get this expected error: [..] Win32/logdump.dsp source is under 'acinclude.m4' Backtrace: 2 (primitive-load "/gnu/store/phlnb6vy2gqjn75pivpsajyf9mq?") In ice-9/eval.scm: 619:8 1 (_ #(# "acinclude.m4")) In unknown file: 0 (chdir "acinclude.m4") ERROR: In procedure chdir: In procedure chdir: Not a directory Unfortunately, .jar-source-files ARE organized in such a way that sources are organized directly in the root folder of the jar. I currently don't see a quick AND nice way to fix this. Wait, I have this idea: diff --git a/guix/packages.scm b/guix/packages.scm index c94a651f27..ffd06de358 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -491,6 +491,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"))) =20 (define original-file-name @@ -584,12 +585,16 @@ specifies modules in scope when evaluating SNIPPET." (directory (string-drop base (+ 1 dash)))) (mkdir directory) (copy-recursively #+source directory)) - #+(if (string=3D? decompression-type "unzip") + #+(if (or + (string=3D? decompression-type "unzip") + (string=3D? decompression-type "jar")) #~(invoke "unzip" #+source) #~(invoke (string-append #+tar "/bin/tar") "xvf" #+source))) =20 - (let ((directory (first-file "."))) + (let ((directory (if (string=3D? decompression-type "jar") + "." + (first-file ".")))) (format (current-error-port) "source is under '~a'~%" directory) (chdir directory) But it fails with: In unknown file: ?: 5 [primitive-load "/gnu/store/kg3pa52ydp3qjy41wgl0jcx3a98m82x9-guile-= 2.2.4.tar.xz-builder"] In ice-9/eval.scm: 411: 4 [eval # ()] 399: 3 [eval # ()] 387: 2 [eval # ()] 393: 1 [eval # ()] In unknown file: ?: 0 [memoize-variable-access! # #] ERROR: In procedure memoize-variable-access!: ERROR: Unbound variable: decompression-type What's wrong here? Bj=C3=B6rn --Sig_/0LVAxCyhsql5lj.=P+vCmLG Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQQiGUP0np8nb5SZM4K/KGy2WT5f/QUCXLUYjAAKCRC/KGy2WT5f /abhAKCbhmNHpxoSHGOgCihSa6sCDv4zXgCgsSxFM/lo9bqBz64Fdrr6nSpgjnY= =CB7J -----END PGP SIGNATURE----- --Sig_/0LVAxCyhsql5lj.=P+vCmLG--