Created attachment 206349 [details] [patch] fix javavmwrapper/files/pkg-install.in for globbing problem & insufficient bootstrap-openjdk exclusion pattern I believe that the following commit broke java/javavmwrapper's pkg-install 7-ish years ago: r306536 | jkim | 2012-10-27 20:11:29 -0600 The problem is that the wildcards used for the find(1) regex expression get evaluated by the shell before they are passed to find(1). In particular, 'find *jdk* *jre* -depth 2 -regex .*/bin/java' when run from /usr/local expands to 'find openjdk8 openjdk11 -depth 2 -regex ./bin/java' which returns no hits. Thus nothing is passed to a 'registervm' invocation. And, if a user does not have /usr/ports tree installed, then the javavmwrapper does not find any java (or for testing, if JAVAVM_FALLBACK_ONLY is set): % java -version java: error: no suitable JavaVMs found An old installation that might already have java VMs registered (in /usr/local/etc/javavms) could still work, but new installations would fail as above (again, that's if the /usr/ports tree is not installed - since javavmwrapper looks there first for the default location). It's a little surprising this has not been noticed in 7 years, so maybe I missed something in my analysis. To try to reproduce the failure, I think you could do the following (assumes some java/openjdk* is installed): % sudo pkg delete -f javavmwrapper % sudo rm /usr/local/etc/javavms % sudo make -C /usr/ports/java/javavmwrapper install clean Then either: % env JAVAVM_FALLBACK_ONLY=1 java -version or % mv /usr/ports /usr/ports.tmp-mv-away % java -version The attached path resolves this by modifying pkg-install to use noglob when the wildcard characters should not be evaluated by the shell. While here, fix the bootstrap exclusion now that /usr/local/bootstrap-openjdk* dirs are named bootstrap-openjdk8, ...jdk11, etc. (rather than the old bootstrap-openjdk removed in 2017-12). The patch excludes bootstrap-openjdk.* (regex) instead. I believe this was changed when java/bootstrap-openjdk was replaced with java/bootstrap-openjdkXX, and pkg-install was not updated to accommodate the change.
I think your analysis is correct and this hasn't shown up because this script rarely has any impact. All of the Java versions available have javavmwrapper as a dependency, so it is installed before them, and, as you may have noticed, /usr/local/etc/javavms is not removed when the package is removed. So it is only significant during a forced deinstall/reinstall, which I imagine very few users do.
A commit references this bug: Author: glewis Date: Sat Aug 10 19:28:19 UTC 2019 New revision: 508503 URL: https://svnweb.freebsd.org/changeset/ports/508503 Log: Fixes to pkg-install and version handling * In pkg-install, fix the exclusion of the bootstrap directories. [1] * In pkg-install, fix the find expression so it actually finds jdks if there are multiple present. [1] * When determining the VM version, be better about ensuring we end up with only a number. PR: 239705 [1] Submitted by: John Hein <jcfyecrayz@liamekaens.com> [1] Changes: head/java/javavmwrapper/Makefile head/java/javavmwrapper/files/pkg-install.in head/java/javavmwrapper/src/javavmwrapper.sh
Thanks!