vmware/photon

openjdk17-17.0.8 does not compile when building package with Photon OS 5.0 on WSL2

dcasota opened this issue · 3 comments

Describe the bug

no priority, just fyi

Make build of a new iso fails when building package openjdk17. As the summary suggests, when building in WSL2, the package
make build fails. This doesn't happen e.g. on VMware Workstation.

The configuration script ./stage/photonroot/openjdk17-17.0.8/usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/build/.configure-support/generated-configure.sh tries to analyze the environment. x86_64-pc-wsl as build system type is detected correctly, however openjdk-build os-cpu = windows-x86_64, windows environment type = wsl1 and wslpath not found are wrong. The expected detection should include linux-x86_64 with wsl2 and /bin/wslpath or /usr/bin/wslpath (both are symbolic links of /init.

Reproduction steps

  1. @lamw-style of an unsupported but documented setup of Photon OS 5.0 on WSL2, documented here.
    Photon OS on WSL2 is installed as user distribution and not as replacement of the system distribution cbl-mariner.
  2. build iso from source

Expected behavior

successful make build on Photon OS on WSL2

Additional context

Similar to https://bugs.busybox.net/show_bug.cgi?id=14561.
I will update this issue in case of problem solving news.

building Photon OS on WSL is not in our scope. Please don't create issues on something which are not in our scope.

strange, starting ./stage/photonroot/openjdk17-17.0.8/usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/configure manually, shows that wslpath is found in the 2nd turn, also, wsl2 is detected.

[...]
configure: WARNING: Ignoring value of PATHTOOL from the environment. Use command line variables instead.
checking for cygpath... [not found]
checking for wslpath... /usr/bin/wslpath
checking for cmd.exe... /mnt/c/Windows/system32/cmd.exe
checking build system type... x86_64-pc-wsl
checking host system type... x86_64-pc-wsl
checking target system type... x86_64-pc-wsl
checking openjdk-build os-cpu... windows-x86_64
checking openjdk-target os-cpu... windows-x86_64
checking compilation type... native
checking Windows environment type... wsl2
checking wsl2 drive prefix... '/mnt'
checking wsl2 root directory as Windows path... '\\wsl.localhost\Ph5'
checking wsl2 temp directory... /usr/bin/wslpath: Invalid argument
Usage:    -a    force result to absolute path format    -u    translate from a Windows path to a WSL path (default)    -w    translate from a WSL path to a Windows path    -m    translate from a WSL path to a Windows path, with '/' instead of '\'EX: wslpath 'c:\users'
/root/photon/stage/photonroot/openjdk17-17.0.8/usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/build/.configure-support/generated-configure.sh: line 12873: cd: Usage:    -a    force result to absolute path format    -u    translate from a Windows path to a WSL path (default)    -w    translate from a WSL path to a Windows path    -m    translate from a WSL path to a Windows path, with '/' instead of '\'EX: wslpath 'c:\users': No such file or directory
cp: cannot create regular file 'Usage:    -a    force result to absolute path format    -u    translate from a Windows path to a WSL path (default)    -w    translate from a WSL path to a Windows path    -m    translate from a WSL path to a Windows path, with '\''/'\'' instead of '\''\'\''EX: wslpath '\''c:\users'\''': No such file or directory
checking wsl2 release... 5.15.146.1-microsoft-standard-WSL2+
checking wsl2 version... #1 SMP Sat Mar 2 11:58:41 CET 2024
checking Windows version... /root/photon/stage/photonroot/openjdk17-17.0.8/usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/build/.configure-support/generated-configure.sh: line 12899: cd: too many arguments

checking wsl distribution... /root/photon/stage/photonroot/openjdk17-17.0.8/usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/build/.configure-support/generated-configure.sh: line 12924: -d: command not found

checking what kind of 'find' is first on the PATH... unix style
/root/photon/stage/photonroot/openjdk17-17.0.8/usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/make/scripts/fixpath.sh: illegal option -- a
/root/photon/stage/photonroot/openjdk17-17.0.8/usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/make/scripts/fixpath.sh: illegal option -- a
configure: error: The path of TOPDIR, which resolves as "/root/photon/stage/photonroot/openjdk17-17.0.8/usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5", could not be imported.

Copying the source to /usr/src/photon/SOURCES helps, but rpmbuild still fails.

Here the findings so far.

topdir issue

The topdir issue has been mentioned in #1412 (comment). Sort of same issue as the progress outcome seems similar.

root [ ~/photon/stage/photonroot/openjdk17-17.0.8 ]# ls
bin  boot  dev  etc  home  inputrpms  lib  lib64  media  mnt  proc  publishrpms  publishxrpms  root  run  sbin  srv  sys  tmp  usr  var
root [ ~/photon/stage/photonroot/openjdk17-17.0.8 ]# mkdir ./rpmbuild
root [ ~/photon/stage/photonroot/openjdk17-17.0.8 ]# cd rpmbuild/
root [ ~/photon/stage/photonroot/openjdk17-17.0.8/rpmbuild ]# mkdir -p $PWD/{RPMS,SRPMS,SOURCES,SPECS,LOGS,BUILD,BUILDROOT}
root [ ~/photon/stage/photonroot/openjdk17-17.0.8/rpmbuild ]# ls
BUILD  BUILDROOT  LOGS  RPMS  SOURCES  SPECS  SRPMS
root [ ~/photon/stage/photonroot/openjdk17-17.0.8/rpmbuild ]# cd SOURCES
root [ ~/photon/stage/photonroot/openjdk17-17.0.8/rpmbuild/SOURCES ]# rpm2cpio https://packages.vmware.com/photon/5.0/photon_srpms_5.0_x86_64/openjdk17-17.0.8-6.ph5.src.rpm | cpio -idm
206780 blocks
root [ ~/photon/stage/photonroot/openjdk17-17.0.8/rpmbuild/SOURCES ]# cd ..
root [ ~/photon/stage/photonroot/openjdk17-17.0.8/rpmbuild ]# cp SOURCES/openjdk17.spec SPECS/openjdk17.spec
root [ ~/photon/stage/photonroot/openjdk17-17.0.8/rpmbuild ]# rpmbuild -bb SPECS/openjdk17.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.0Yrhu2
+ umask 022
+ cd /usr/src/photon/BUILD
+ cd /usr/src/photon/BUILD
+ rm -rf jdk17u-jdk-17.0.8-5
+ /usr/lib/rpm/rpmuncompress -x /usr/src/photon/SOURCES/jdk-17.0.8-5.tar.gz
error: File /usr/src/photon/SOURCES/jdk-17.0.8-5.tar.gz: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.0Yrhu2 (%prep)

RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.0Yrhu2 (%prep)

After rpmbuild, there are two directories build and BUILD in /usr/src/photon/ as consequence of the topdir issue.

build  BUILD  BUILDROOT  RPMS  SOURCES  SPECS  SRPMS

No solution found yet. On the rpmbuild output, the first indicator of an uppercase/lowercase issue is the build directory in checking for top-level directory... /usr/src/photon/build/jdk17u-jdk-17.0.8-5.

lsb_release

lsb_release isn't installed on Photon OS. Therefore /usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/build/.configure-support/generated-configure.sh fails on line 12924 with -d: command not found.
There is a workaround: Shutdown the user distribution of Photon OS. Login on the system distribution. Run tdnf install lsb-release. Logout. Start Photon OS and login. Set variable export LSB_RELEASE="/usr/bin/lsb_release".

gnu make

gnu make seems to be necessary.
I installed gnu make 3.82 manually and started ./configure MAKE=/usr/bin/gmake, but rpmbuild still fails. gmake 3.82 was been installed using info-5.1-5.el7.x86_64.rpm and make-3.82-24.el7.x86_64.rpm. Configured ln -s /usr/bin/gmake /opt/gmake3.81/gmake.

fixpath

The rpmbuild output issue fixpath is strange. The file simply contains the export PATH and runs wslpath.

#!/bin/bash
export PATH="$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files (x86)/VMware/VMware Workstation/bin/:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/bin:/mnt/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/libnvvp:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Program Files/usbipd-win/"
. /usr/src/photon/build/jdk17u-jdk-17.0.8-5/make/scripts/fixpath.sh -e /usr/bin/wslpath -p /mnt -r \\\\wsl.localhost\\Ph5 -t /mnt/c/Users/dcaso/AppData/Local/Temp -c /mnt/c/Windows/system32/cmd.exe -q "$@"

Because of the uppercase/lowercase issue, the following workaround helped:

ln -s /usr/src/photon/BUILD/jdk17u-jdk-17.0.8-5/make /usr/src/photon/build/jdk17u-jdk-17.0.8-5

Before rerunning rpmbuild with buildroot, I also did a few reinstalls: tdnf reinstall tdnf, tdnf install openjdk17.
rpmbuild now works so far, but fails at the end because of a Boot JDK issue.
After having added export PATH="/usr/lib/jvm/OpenJDK-17/bin/:$PATH", BOOT JDK is solved. rpmbuild proceeded until toolchain microsoft.

ms build tools for visual studio

Depending on the Visual Studio edition, the build tools for Visual Studio must be explicitly downloaded from https://visualstudio.microsoft.com/de/downloads/ and installed. vcvars.bat is installed by default in C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\vsdevcmd\ext. I tried the following on windows:

mkdir mkdir "C:\Program Files\Microsoft Visual Studio\2022\Community\vc\bin\amd64"
copy "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\vsdevcmd\ext\vcvars.bat" "C:\Program Files\Microsoft Visual Studio\2022\Community\vc\bin\amd64\vcvars64.bat"
mkdir "C:\Program Files\Microsoft Visual Studio\2022\Community\vc\bin\amd64\vcvars"
copy "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\vsdevcmd\ext\vcvars\*" "C:\Program Files\Microsoft Visual Studio\2022\Community\vc\bin\amd64\vcvars\"

The recognition seems to work, but rpmbuild didn't extract the environment variables needed for the VS setup.

A successful make build of an iso on Photon OS on WSL2 could include microsoft certs as custom certs for secure boot.

March 7th 2024: I haven't found out how to make build successfully openjdk17.0.8 on wsl2. Accordingly to https://mail.openjdk.org/pipermail/jdk-updates-dev/2024-January/029089.html, the issue of os detection might be a known bug JDK-8312620: WSL Linux build crashes after JDK-8310233, which should have been fixed with openjdk17.0.10. However, accordingly to https://wiki.openjdk.org/display/Build/Supported+Build+Platforms, WSL2 is not officially supported.