unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Björn Höfling" <bjoern.hoefling@bjoernhoefling.de>
To: Danny Milosavljevic <dannym@scratchpost.org>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Re: java: How to patch a jar-sources
Date: Tue, 16 Apr 2019 01:49:32 +0200	[thread overview]
Message-ID: <20190416014932.5d101b6d@alma-ubu> (raw)
In-Reply-To: <20190415171953.655dd24d@scratchpost.org>

[-- Attachment #1: Type: text/plain, Size: 4774 bytes --]

On Mon, 15 Apr 2019 17:19:53 +0200
Danny Milosavljevic <dannym@scratchpost.org> 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 (_ #(#<directory (guile-user) 5ce140> "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=? 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 ".")))
+            (let ((directory (if (string=? 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 #<memoized decompression-type> ()]
In unknown file:
   ?: 0 [memoize-variable-access! # #]

ERROR: In procedure memoize-variable-access!:
ERROR: Unbound variable: decompression-type

What's wrong here?

Björn

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  reply	other threads:[~2019-04-15 23:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-15  6:02 java: How to patch a jar-sources Björn Höfling
2019-04-15 12:26 ` Gábor Boskovits
2019-04-15 15:11   ` Björn Höfling
2019-04-15 15:18 ` Danny Milosavljevic
2019-04-15 15:19 ` Danny Milosavljevic
2019-04-15 23:49   ` Björn Höfling [this message]
2019-04-16  9:50     ` Gábor Boskovits
2019-04-16 18:00       ` Björn Höfling
2019-04-18  5:09         ` Björn Höfling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190416014932.5d101b6d@alma-ubu \
    --to=bjoern.hoefling@bjoernhoefling.de \
    --cc=dannym@scratchpost.org \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).