Subject: Re: bug#36685: ant-bootstrap fails on core-updates (409 dependents)

From: Ricardo Wurmus <[email-masked]>
Date: Tue, 16 Jul 2019 18:13:38 +0200

Chris Marusich <[email-masked]> writes:

> Hi,
>
> At commit 464a29d3d74e7d2f27042db6ab166bfdbe1f992e ('git branch --all
> --contains 464a29d3d74e7d2f27042db6ab166bfdbe1f992e' tells me that only
> core-updates has this commit at this time), the following error occurs
> when trying to build ant-bootstrap, which causes the 409 dependent
> packages to fail, also:
>
> --8<---------------cut here---------------start------------->8---
> $ guix build -e '(@@ (gnu packages java) ant-bootstrap)'
[…]
> BUILD FAILED
> Could not load the version information.

This error means that it couldn’t find the version.txt file.  This is
strange because it’s right there in src/main, but not in build/classes.
So I thought I could just fix this by copying files from src/main to
build/classes and the bootstrap build does in fact begin:

--8<---------------cut here---------------start------------->8---
diff --git a/gnu/packages/java.scm b/gnu/packages/java.scm
index 403c446a82..0ec582d10a 100644
--- a/gnu/packages/java.scm
+++ b/gnu/packages/java.scm
@@ -244,6 +244,8 @@ JNI.")
              (setenv "HOME" "/tmp")
              (with-output-to-file "/tmp/.ant.properties"
                (lambda _ (display "")))
+             (with-output-to-file ".ant.properties"
+               (lambda _ (display "")))

              ;; Use jikes instead of javac for <javac ...> tags in build.xml
              (setenv "ANT_OPTS" "-Dbuild.compiler=jikes")
@@ -260,6 +262,17 @@ JNI.")
                       `((string-append m "-Xnocompact "))
                       `((string-append m "-Xnocompact -Xnoinlining ")))))

+             (substitute* "src/main/org/apache/tools/ant/version.txt"
+               (("VERSION=.*") (string-append "VERSION=" ,version "\n"))
+               (("DATE=.*") "DATE=reproducible"))
+
+             ;; XXX: Copying the source files appears to be necessary because
+             ;; ant won't find the XML and txt resources in src/main for some
+             ;; reason.  It really shouldn't be needed, so maybe this can be
+             ;; avoided by setting some environment variable.
+             (substitute* "bootstrap.sh"
+               (("cp src/script/antRun bin" m)
+                (string-append m "\ncp -ar src/main/* build/classes/")))
              ;; Disable tests because we are bootstrapping and thus don't have
              ;; any of the dependencies required to build and run the tests.
              (substitute* "build.xml"
--8<---------------cut here---------------end--------------->8---

It’s possible we could get away with just adding these lines:

  cp {src/main,build/classes}/org/apache/tools/ant/antlib.xml
  cp {src/main,build/classes}/org/apache/tools/ant/version.txt

However, this doesn’t seem to help.  Yes, the bootstrap script no longer
aborts but it gets stuck compiling things.  I can’t get it to tell me
anything about the compilation progress, but strace shows me that it
keeps stat’ing for non-existent files like "/tmp/files16bfb86414e_b"
until the end of the day.

Judging by the name of the file I think this is ant’s
src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
that creates them, which is used by Jikes.java.  We should see if
there’s a race somewhere or if perhaps “jikes” crashes and thus gets
executed over and over again.

--
Ricardo