-
Notifications
You must be signed in to change notification settings - Fork 270
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
add two facts: libjvm and java executable paths #117
Conversation
|
👍 for the |
| java_path = Facter.value(:java_path) | ||
| java_package = Facter::Util::Resolution.exec('dpkg -S '+java_path).split(':').first | ||
| #Facter::Util::Resolution.exec('dpkg -L '+java_package+' | grep libjvm.so\$').lines.first.strip | ||
| Facter::Util::Resolution.exec('dpkg -L '+java_package).lines.find_all { |l| l =~ /libjvm.so$/}.first.strip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of doing find_all.first, why not just do find?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignorance!
|
Thanks for these constructive comments. I'll integrate them ASAP but currently I'm fighting with rspec: I just realized I was only testing the debian part in the test for libjvm fact, and now I'm trying to find a way to test both osfamilies. If you have any idea on how to test that without the Edit: I just found this which should help |
|
It would maybe be more useful to have the |
|
I agree that the |
|
I decided to go with the |
|
Hi is there anything else I can do to have this merged? |
|
Hi! Could you explain why the path to libjvm.so is useful? Is this something that is generally needed, or is there some special case that this is for? Also is it possible to use some generic method like |
|
Sure thing! So why do we need to do this?
Unfortunately, I have no better way to find its location apart from using the local packager or |
| Facter.add(:java_path) do | ||
| setcode do | ||
| if Facter::Util::Resolution.which('readlink') | ||
| Facter::Util::Resolution.exec('readlink -e /usr/bin/java').strip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Patches welcome!
But you're right the code should probably be confined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... or Windows. Please just add the confine to :kernel => "Linux" if you do not want to support other platforms (which is totally fine with me!)
8562fd9
to
7510f4c
Compare
|
I confined the Cheers |
| if java_path.empty? | ||
| nil | ||
| elsif Facter::Util::Resolution.which('dpkg') | ||
| java_package = Facter::Util::Resolution.exec('dpkg -S '+java_path).split(':').first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You missed one string concatenation here.
|
thanks! |
|
The tests look OK to me. There is still a minor comment outstanding on the coding style. On a higher level, I'm wondering whether there is a reason not to use |
|
On a more organizational note, pleas add a short description of the facts to the README (there's already some described there) and squash everything into a single commit, to keep the history clean! |
|
I was unaware of the existence of |
|
I added the implementation proposed by @DavidS as default resolution, so I can keep the rpm/deb based implementation in case the former is failing. |
|
In what case would you expect the rpm/dpkg based variant to succeed when the globbing one doesn't? I've also read a bit through the java docs, and it seems that moving the
Thank you for your patience and support in getting the best possible solution here! |
|
here's what I found googling:
The Problem is, I'm no java expert, so maybe we should ask one :) |
|
So I talked to two of our java devs and the base directory we're talking about is the java "home". Given that we're talking about the system default and to avoid any misunderstandings I'd recommend calling the fact "java_default_home" or "java_system_home" and return the dirname(dirname(readlink(usr/bin/java))). That way it is useful on its own. |
|
is this what you'd like? Example |
All the other directories below it (/lib, /bin, /jre/lib and /jre/bin) are the same across java versions. |
|
I wouldn't use |
|
the |
|
I'll go for this as for the multiple resolutions, I think it's always a good thing to have a fallback method, especially now that it's already there and tested. If you prefer to keep things simple though, I'll remove the deb/rpm based ones. |
|
@DavidS please advise on the last open quesion: do you want to keep the alternate package resolutions of libjvm.so or do you prefer to drop them? |
|
@faxm0dem Personally I'd prefer to leave the code out as long as there is not a immediate use-case for it. |
* dirname containing base directory of java
* e.g. java binary is `${::java_default_home}/jre/bin/java`
* dirname containing `libjvm.so`
* Most people will use this for LD_LIBRARY_PATH
dd97178
to
9c15489
Compare
|
@DavidS all right, please review |
add two facts: libjvm and java executable paths
|
Thank you for your work! |
It's complicated to automatically determine the location of
libjvm.so. Neither openjdk nor oracle packages provide hints forld.so.conf.d. The path to the java executable is just a byproduct than I thought could be useful.