From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?G=C3=A1bor_Boskovits?= Subject: Re: java: How to patch a jar-sources Date: Tue, 16 Apr 2019 11:50:45 +0200 Message-ID: References: <20190415080248.679c6749@alma-ubu> <20190415171953.655dd24d@scratchpost.org> <20190416014932.5d101b6d@alma-ubu> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([209.51.188.92]:52517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hGKk0-00020L-Bv for guix-devel@gnu.org; Tue, 16 Apr 2019 05:51:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hGKjz-0001di-8i for guix-devel@gnu.org; Tue, 16 Apr 2019 05:51:00 -0400 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]:42708) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hGKjy-0001dF-Vh for guix-devel@gnu.org; Tue, 16 Apr 2019 05:50:59 -0400 Received: by mail-ed1-x543.google.com with SMTP id x61so17305529edc.9 for ; Tue, 16 Apr 2019 02:50:58 -0700 (PDT) In-Reply-To: <20190416014932.5d101b6d@alma-ubu> 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: =?UTF-8?B?QmrDtnJuIEjDtmZsaW5n?= Cc: guix-devel Hello Bj=C3=B6rn, Bj=C3=B6rn H=C3=B6fling ezt =C3=ADrta (= id=C5=91pont: 2019. =C3=A1pr. 16., K, 1:49): > > 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. > > > 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"))) > > (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))) > > - (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-guil= e-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? > I don't see the whole code here, but I guess that the last time use decompression-type in a section under different quoting rules. Is that possible? Also, you might have a look at url-fetch/tarbomb, as something similar must be done there. > Bj=C3=B6rn Best regards, g_bor