Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ant -diagnostics instead of realpath to get ANT_HOME #28

Open
terryzuoty opened this issue Feb 1, 2018 · 5 comments
Open

Use ant -diagnostics instead of realpath to get ANT_HOME #28

terryzuoty opened this issue Feb 1, 2018 · 5 comments

Comments

@terryzuoty
Copy link

terryzuoty commented Feb 1, 2018

In the makefile of stf, this parts of code is trying to define the ANT_HOME

      ANT_BINDIR:=$(dir $(firstword $(shell $(WHICH) ant$(BAT) 2>$(NULL))))
      $(warning $(WHICH) ant$(BAT) 2>$(NULL) returned)
      $(warning $(ANT_BINDIR))
      ifneq (,$(ANT_BINDIR))
        ANT_BINDIR:=$(realpath $(ANT_BINDIR)$(D)ant$(BAT))
        ANT_HOME:=$(abspath $(ANT_BINDIR)$(D)..$(D)..)
        $(warning ANT_BINDIR set to $(ANT_BINDIR))
        $(warning ANT_HOME set to $(ANT_HOME))
        $(warning Found $(ANT_BINDIR), will start build with $(ANT_LAUNCHER).  Run make configure to install the required ant version 1.10.1 or follow the prereq install instructions in build$(D)build.md)

However, this part of code doesn't work as expected on RHEL7

RHEL7:

> makefile:174: ANT_HOME not set, looking in /tmp/svttemp/git/stf/../../systemtest_prereqs/apache-ant-1.10.1
> makefile:178: Cannot find /tmp/svttemp/git/stf/../../systemtest_prereqs/apache-ant-1.10.1/lib/ant-launcher.jar, looking for ant on the PATH
> makefile:194: which ant 2>/dev/null returned
> makefile:195: /usr/bin/
> makefile:199: ANT_BINDIR set to /usr/bin/ant
> makefile:200: ANT_HOME set to /usr
> makefile:201: Found /usr/bin/ant, will start build with /usr/lib/ant-launcher.jar.  Run make configure to install the required ant version 1.10.1 or follow the prereq install instructions in build/build.md


$ make -version
GNU Make 3.82
Built for x86_64-redhat-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Ubuntu16:

> makefile:174: ANT_HOME not set, looking in /tmp/svttemp/git/stf/../../systemtest_prereqs/apache-ant-1.10.1
> makefile:178: Cannot find /tmp/svttemp/git/stf/../../systemtest_prereqs/apache-ant-1.10.1/lib/ant-launcher.jar, looking for ant on the PATH
> makefile:194: which ant 2>/dev/null returned
> makefile:195: /usr/bin/
> makefile:199: ANT_BINDIR set to /usr/share/ant/bin/ant
> makefile:200: ANT_HOME set to /usr/share/ant
> makefile:201: Found /usr/share/ant/bin/ant, will start build with /usr/share/ant/lib/ant-launcher.jar.  Run make configure to install the required ant version 1.10.1 or follow the prereq install instructions in build/build.md

GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Instead of using realpath in the makefile, is using ant -diagnostics a proper approach to get the correct ant.home? For example

root@113fe7939c9b:~/systemtest_prereqs# ant -diagnostics | grep "ant.home" -m 1 --max-count=1 | cut -d ':' -f 2 
 /usr/share/ant
root@113fe7939c9b:~/systemtest_prereqs# 

There should be a same way on Windows to parse the ant -diagnostics result to get the real ant.home

@terryzuoty terryzuoty changed the title Use ant -diagnostics instead of realpath to get AN_HOME Use ant -diagnostics instead of realpath to get ANT_HOME Feb 2, 2018
@terryzuoty
Copy link
Author

terryzuoty commented Feb 5, 2018

HI @sxa555 , do you have any insight about this?

@sxa
Copy link
Member

sxa commented Feb 13, 2018

A fair comment and that sounds like a reasonable approach - that code predates me being involved with the project so I'll tag in @lumpfish :-)

@lumpfish
Copy link
Contributor

@TianyuZuo - what is it you are saying is not working? Are you saying that on RHEL /tmp/svttemp/git/stf/../../systemtest_prereqs/apache-ant-1.10.1/lib/ant-launcher.jar does actually exist? Since the code is trying to find ant I can't see how running ant is going to help. What if ant is not on the path?

@terryzuoty
Copy link
Author

Not exactly.
What I was trying to talk about is the Ant in the system which was initially used to run the top level build.xml, not the stf-downloaded Ant.

If the Ant in the system was not successfully setup, the code snippet in the makefile may fail to find the realpath of system installed Ant. Taking that RHEL machine as an example, the Ant was installed in /usr/share/ant/bin/ant but the makefile can only find its symlink /usr/bin/ant. If the ant -diagnostics was used, the ant.home would be printed out and that was correctly pointing to /usr/share/ant.

If Ant was not on the path, I don't think which ant would give back a correct path either. So this suggestion is assuming that system can find a usable Ant on Path at least, the same as the previous makefile.

@lumpfish
Copy link
Contributor

Looking at the gmake doc: https://www.gnu.org/software/make/manual/html_node/File-Name-Functions.html realpath is supported to follow symlinks. Do you still have access to the machine where this is not working? I see you have included make -version output - are you saying there is an issue with realpath in make 3.82?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants