Skip to contentSkip to conversation

package/openjdk: fix hash

PATCH New aduskett at gmail.com 3 participants 11 messages Apr 17, 2020 – Apr 18, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 package/openjdk: fix hash

From: Adam Duskett <[email protected]>

The hash should be 6815dbac7dd0f86291254e84ed17565c89477eeb6b0847a9648b00ecb4f07634

---
 package/openjdk/openjdk.hash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/openjdk/openjdk.hash +1 -1
index d5be642052..07bf4d5479 100644
@@ -1,3 +1,3 @@
 # Locally computed
-sha256 6815dbac7dd0f86291254e84ed17565c89477eeb6b0847a9648b00ecb4f07634  jdk-14+36.tar.gz
+sha256 fcd13ebd63d40c1c2f3cabfb7bc368962ff7b5935523be2a0e769352987145ae  jdk-14+36.tar.gz
 sha256 4b9abebc4338048a7c2dc184e9f800deb349366bdf28eb23c2677a77b4c87726  LICENSE
Signature · 1 line
2.25.2
#1 lore raw

PATCH 2/4 package/openjdk: fix installation with merged usr directories

From: Adam Duskett <[email protected]>

Currently, Buildroot installs the jre libraries using
cp -dprf /build/linux-*-release/images/jre/lib/* $(TARGET_DIR)/usr/lib/

However, if a system has a merged /usr directory, and there is a built kernel before installing OpenJDK, the installation fails because jre/lib has binary modules file, which causes the following error:
cp: cannot overwrite directory '/usr/lib/modules with non-directory

The obvious fix is to install the modules to /usr/lib/jvm/ and set the appropriate rpaths via the --with-extra-ldflags conf option. However, this fix does not work because the binaries themselves do not link against libjava.so and instead search for libjava.so with hardcoded paths in the following directories:
- /usr/lib
- /usr/jre/lib
- $(dirname $0)/../lib

As such, most distributions such as Redhat create the directory /usr/lib/jvm/java-$(JAVA_VERSION)/ and install all directories and files found in images/jre to that directory, and then symlink the binaries to /usr/bin.

However, because Buildroot does not need to support multiple versions of java concurrently, there is no need for the java-$(JAVA_VERSION) directory.

To fix the above error, perform the following changes:
- Introduce the variable "OPENJDK_INSTALL_BASE" which points to usr/lib/jvm
- Set the --with-extra-ldflags conf_opt to

      "-Wl,-rpath,/$(OPENJDK_INSTALL_BASE)/lib,-rpath,
      /$(OPENJDK_INSTALL_BASE)/lib/$(OPENJDK_JVM_VARIANT)"

- Run "mkdir -p $(TARGET_DIR)/usr/lib/jvm" in the INSTALL_TARGET_CMDS step.
- Copy both the lib and bin directories to /usr/lib/jvm/
- Symlink the binaries in /usr/lib/jvm/bin/ to /usr/bin.

---
 package/openjdk/openjdk.mk | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
package/openjdk/openjdk.mk +15 -2
index edc86c6fbe..d540b65edc 100644
@@ -46,6 +46,14 @@ OPENJDK_JVM_VARIANT = zero
 OPENJDK_DEPENDENCIES += libffi
 endif
 
+# Because jre/lib has a modules file, installation on a system with a merged
+# /usr directory, and a built Kernel before OpenJDK, the following error
+# occurs: "cp: cannot overwrite directory '/usr/lib/modules with non-directory"
+# To prevent this error, we follow what other distributions traditionally do:
+# Install the OpenJDK files in /usr/lib/jvm/ and symlink the binaries to
+# /usr/bin.
+OPENJDK_INSTALL_BASE=usr/lib/jvm
+
 # OpenJDK ignores some variables unless passed via the environment.
 # These variables are PATH, LD, CC, CXX, and CPP.
 # OpenJDK defaults ld to the ld binary but passes -Xlinker and -z as
@@ -75,6 +83,7 @@ OPENJDK_CONF_OPTS = \
 	--with-devkit=$(HOST_DIR) \
 	--with-extra-cflags="$(TARGET_CFLAGS)" \
 	--with-extra-cxxflags="$(TARGET_CXXFLAGS)" \
+	--with-extra-ldflags="-Wl,-rpath,/$(OPENJDK_INSTALL_BASE)/lib,-rpath,/$(OPENJDK_INSTALL_BASE)/lib/$(OPENJDK_JVM_VARIANT)" \
 	--with-giflib=system \
 	--with-jobs=$(PARALLEL_JOBS) \
 	--with-jvm-variants=$(OPENJDK_JVM_VARIANT) \
@@ -114,8 +123,12 @@ endef
 # Calling make install always builds and installs the JDK instead of the JRE,
 # which makes manual installation necessary.
 define OPENJDK_INSTALL_TARGET_CMDS
-	cp -dpfr $(@D)/build/linux-*-release/images/jre/bin/* $(TARGET_DIR)/usr/bin/
-	cp -dpfr $(@D)/build/linux-*-release/images/jre/lib/* $(TARGET_DIR)/usr/lib/
+	mkdir -p $(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
+	cp -dpfr $(@D)/build/linux-*-release/images/jre/bin/ \
+		$(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
+	cp -dpfr $(@D)/build/linux-*-release/images/jre/lib/ \
+		$(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
+	cd $(TARGET_DIR)/usr/bin && ln -snf ../../$(OPENJDK_INSTALL_BASE)/bin/* .
 endef
 
 $(eval $(generic-package))
Signature · 1 line
2.25.2
#2 lore raw

PATCH 2/4 package/openjdk: fix installation with merged usr directories

Adam, All,

On 2020-04-17 16:29 -0700, aduskett at gmail.com spake thusly:

Quoted 27 lines

From: Adam Duskett <[email protected]>

Currently, Buildroot installs the jre libraries using
cp -dprf /build/linux-*-release/images/jre/lib/* $(TARGET_DIR)/usr/lib/

However, if a system has a merged /usr directory, and there is a built kernel before installing OpenJDK, the installation fails because jre/lib has binary modules file, which causes the following error:
cp: cannot overwrite directory '/usr/lib/modules with non-directory

The obvious fix is to install the modules to /usr/lib/jvm/ and set the appropriate rpaths via the --with-extra-ldflags conf option. However, this fix does not work because the binaries themselves do not link against libjava.so and instead search for libjava.so with hardcoded paths in the following directories:
- /usr/lib
- /usr/jre/lib
- $(dirname $0)/../lib

As such, most distributions such as Redhat create the directory /usr/lib/jvm/java-$(JAVA_VERSION)/ and install all directories and files found in images/jre to that directory, and then symlink the binaries to /usr/bin.

However, because Buildroot does not need to support multiple versions of java concurrently, there is no need for the java-$(JAVA_VERSION) directory.

Quoted 8 lines

To fix the above error, perform the following changes:
- Introduce the variable "OPENJDK_INSTALL_BASE" which points to usr/lib/jvm
- Set the --with-extra-ldflags conf_opt to

      "-Wl,-rpath,/$(OPENJDK_INSTALL_BASE)/lib,-rpath,
      /$(OPENJDK_INSTALL_BASE)/lib/$(OPENJDK_JVM_VARIANT)"

- Run "mkdir -p $(TARGET_DIR)/usr/lib/jvm" in the INSTALL_TARGET_CMDS step.
- Copy both the lib and bin directories to /usr/lib/jvm/
- Symlink the binaries in /usr/lib/jvm/bin/ to /usr/bin.

There: this is a good commit log: it explains the problem, and the reason for it, lists the various solutions that have been attempted, and provides explanations for the final solutio that was implemented (partly again rephrasing the code, but that's OK given the rest is good). :-)

See a little nit below...

Quoted 12 lines
---
 package/openjdk/openjdk.mk | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
package/openjdk/openjdk.mk +0 -0
index edc86c6fbe..d540b65edc 100644

package/openjdk/openjdk.mk OPENJDK_JVM_VARIANT = zero · line 51

Quoted 6 lines
package/openjdk/openjdk.mk +3 -0
@@ -46,6 +46,14 @@ OPENJDK_JVM_VARIANT = zero
 OPENJDK_DEPENDENCIES += libffi
 endif
 
+# Because jre/lib has a modules file, installation on a system with a merged
+# /usr directory, and a built Kernel before OpenJDK, the following error
+# occurs: "cp: cannot overwrite directory '/usr/lib/modules with non-directory"

This is a bit confusing, and I'm afraid will be hard to parse in the future. What about:

# openJDK installs a file named 'modules' in jre/lib, which gets # installed as /usr/lib/modules. However, with a merged /usr, this # will conflict with the directory named 'modules' installed by the # kernel. If openJDK gets built after the kernel, this manifests # itself with: "cp: cannot overwrite directory '/usr/lib/modules # with non-directory"

package/openjdk/openjdk.mk OPENJDK_JVM_VARIANT = zero · line 55

Quoted 4 lines
package/openjdk/openjdk.mk +4 -0
+# To prevent this error, we follow what other distributions traditionally do:
+# Install the OpenJDK files in /usr/lib/jvm/ and symlink the binaries to
+# /usr/bin.
+OPENJDK_INSTALL_BASE=usr/lib/jvm

This is supposed to be an absolute path on the target, so really make that an absolute path (also, spaces around '='):

OPENJDK_INSTALL_BASE = /usr/lib/jvm

package/openjdk/openjdk.mk OPENJDK_CONF_OPTS = \ · line 86

Quoted 8 lines
package/openjdk/openjdk.mk +1 -0
 # OpenJDK ignores some variables unless passed via the environment.
 # These variables are PATH, LD, CC, CXX, and CPP.
 # OpenJDK defaults ld to the ld binary but passes -Xlinker and -z as
@@ -75,6 +83,7 @@ OPENJDK_CONF_OPTS = \
 	--with-devkit=$(HOST_DIR) \
 	--with-extra-cflags="$(TARGET_CFLAGS)" \
 	--with-extra-cxxflags="$(TARGET_CXXFLAGS)" \
+	--with-extra-ldflags="-Wl,-rpath,/$(OPENJDK_INSTALL_BASE)/lib,-rpath,/$(OPENJDK_INSTALL_BASE)/lib/$(OPENJDK_JVM_VARIANT)" \

And here, you don't need to prepend the leading '/' (twice)

Quoted 4 lines
package/openjdk/openjdk.mk +0 -0
 	--with-giflib=system \
 	--with-jobs=$(PARALLEL_JOBS) \
 	--with-jvm-variants=$(OPENJDK_JVM_VARIANT) \

package/openjdk/openjdk.mk endef · line 130

Quoted 10 lines
package/openjdk/openjdk.mk +5 -2
@@ -114,8 +123,12 @@ endef
 # Calling make install always builds and installs the JDK instead of the JRE,
 # which makes manual installation necessary.
 define OPENJDK_INSTALL_TARGET_CMDS
-	cp -dpfr $(@D)/build/linux-*-release/images/jre/bin/* $(TARGET_DIR)/usr/bin/
-	cp -dpfr $(@D)/build/linux-*-release/images/jre/lib/* $(TARGET_DIR)/usr/lib/
+	mkdir -p $(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
+	cp -dpfr $(@D)/build/linux-*-release/images/jre/bin/ \
+		$(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
+	cp -dpfr $(@D)/build/linux-*-release/images/jre/lib/ \
+		$(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)

In all thos e 'cp'. repeatign the '/' can be avoided too. But that is not a real problem either...

Regards,
Yann E. MORIN.

Quoted 11 lines
package/openjdk/openjdk.mk +1 -0
+	cd $(TARGET_DIR)/usr/bin && ln -snf ../../$(OPENJDK_INSTALL_BASE)/bin/* .
 endef
 
 $(eval $(generic-package))
Signature · 6 lines
2.25.2

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH 2/4 package/openjdk: fix installation with merged usr directories

In reply to aduskett at gmail.com

Adam, All,

On 2020-04-17 16:29 -0700, aduskett at gmail.com spake thusly:

Quoted 8 lines

From: Adam Duskett <[email protected]>
Currently, Buildroot installs the jre libraries using
cp -dprf /build/linux-*-release/images/jre/lib/* $(TARGET_DIR)/usr/lib/

However, if a system has a merged /usr directory, and there is a built kernel before installing OpenJDK, the installation fails because jre/lib has binary modules file, which causes the following error:
cp: cannot overwrite directory '/usr/lib/modules with non-directory

[--SNIP--]

package/openjdk/openjdk.mk

Quoted 4 lines
package/openjdk/openjdk.mk +0 -0
index edc86c6fbe..d540b65edc 100644

[--SNIP--]

package/openjdk/openjdk.mk endef · line 130

Quoted 11 lines
package/openjdk/openjdk.mk +5 -2
@@ -114,8 +123,12 @@ endef
 # Calling make install always builds and installs the JDK instead of the JRE,
 # which makes manual installation necessary.
 define OPENJDK_INSTALL_TARGET_CMDS
-	cp -dpfr $(@D)/build/linux-*-release/images/jre/bin/* $(TARGET_DIR)/usr/bin/
-	cp -dpfr $(@D)/build/linux-*-release/images/jre/lib/* $(TARGET_DIR)/usr/lib/
+	mkdir -p $(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
+	cp -dpfr $(@D)/build/linux-*-release/images/jre/bin/ \
+		$(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
+	cp -dpfr $(@D)/build/linux-*-release/images/jre/lib/ \
+		$(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)

Additional nit in addition to the previous review...

When the target is a directory, make it sure to copy to a directory by appending a trailing '/' :

    cp -dpfr $(@D)/build/linux-*-release/images/jre/lib/ \
        (TARGET_DIR)/$(OPENJDK_INSTALL_BASE)/

Regards,
Yann E. MORIN.

Quoted 11 lines
package/openjdk/openjdk.mk +1 -0
+	cd $(TARGET_DIR)/usr/bin && ln -snf ../../$(OPENJDK_INSTALL_BASE)/bin/* .
 endef
 
 $(eval $(generic-package))
Signature · 6 lines
2.25.2

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#4 lore raw

PATCH 3/4 package/openjdk: copy all directories and files when installing

In reply to aduskett at gmail.com

From: Adam Duskett <[email protected]>

Several directories and files are currently not installed during the target installation, these include:
- conf
Several configuration files, including security configuration files which may be necessary for running various java applications.

- legal
This directory contains legal notices that some java applications may require.

- release
This directory contains a list of modules included in the image.

Because these directories take up less than of megabyte extra, it is not an issue to install all of them.

---
 package/openjdk/openjdk.mk | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
package/openjdk/openjdk.mk +1 -3
index d540b65edc..19e71e98b2 100644
@@ -124,9 +124,7 @@ endef
 # which makes manual installation necessary.
 define OPENJDK_INSTALL_TARGET_CMDS
 	mkdir -p $(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
-	cp -dpfr $(@D)/build/linux-*-release/images/jre/bin/ \
-		$(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
-	cp -dpfr $(@D)/build/linux-*-release/images/jre/lib/ \
+	cp -dpfr $(@D)/build/linux-*-release/images/jre/* \
 		$(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
 	cd $(TARGET_DIR)/usr/bin && ln -snf ../../$(OPENJDK_INSTALL_BASE)/bin/* .
 endef
Signature · 1 line
2.25.2
#5 lore raw

PATCH 3/4 package/openjdk: copy all directories and files when installing

Adam, All,

On 2020-04-17 16:29 -0700, aduskett at gmail.com spake thusly:

Quoted 11 lines

From: Adam Duskett <[email protected]>

Several directories and files are currently not installed during the target installation, these include:
- conf
Several configuration files, including security configuration files which may be necessary for running various java applications.

- legal
This directory contains legal notices that some java applications may require.

At runtime, really?

Quoted 7 lines

- release
This directory contains a list of modules included in the image.

Because these directories take up less than of megabyte extra, it is not an issue to install all of them.

Regards,
Yann E. MORIN.

Quoted 26 lines
---
 package/openjdk/openjdk.mk | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
package/openjdk/openjdk.mk +1 -3
index d540b65edc..19e71e98b2 100644
@@ -124,9 +124,7 @@ endef
 # which makes manual installation necessary.
 define OPENJDK_INSTALL_TARGET_CMDS
 	mkdir -p $(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
-	cp -dpfr $(@D)/build/linux-*-release/images/jre/bin/ \
-		$(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
-	cp -dpfr $(@D)/build/linux-*-release/images/jre/lib/ \
+	cp -dpfr $(@D)/build/linux-*-release/images/jre/* \
 		$(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
 	cd $(TARGET_DIR)/usr/bin && ln -snf ../../$(OPENJDK_INSTALL_BASE)/bin/* .
 endef
Signature · 6 lines
2.25.2

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#6 lore raw

PATCH 3/4 package/openjdk: copy all directories and files when installing

Quoted 12 lines · Yann E. MORIN

Adam, All,

On 2020-04-17 16:29 -0700, aduskett at gmail.com spake thusly:

Quoted 8 lines

From: Adam Duskett <[email protected]>

Several directories and files are currently not installed during the target installation, these include:
- conf
Several configuration files, including security configuration files which may be necessary for running various java applications.

Quoted 6 lines
Quoted 3 lines

- legal
This directory contains legal notices that some java applications may require.

At runtime, really?

Unfortunately yes, as they can be used by some applications to print legal information,
which means if these files exist an exception is thrown.

Quoted 47 lines
Quoted 7 lines

- release
This directory contains a list of modules included in the image.

Because these directories take up less than of megabyte extra, it is not an issue to install all of them.

Regards,
Yann E. MORIN.

Quoted 22 lines
---
 package/openjdk/openjdk.mk | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
package/openjdk/openjdk.mk +1 -4
index d540b65edc..19e71e98b2 100644
@@ -124,9 +124,7 @@ endef
 # which makes manual installation necessary.
 define OPENJDK_INSTALL_TARGET_CMDS
      mkdir -p $(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
-     cp -dpfr $(@D)/build/linux-*-release/images/jre/bin/ \
-             $(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
-     cp -dpfr $(@D)/build/linux-*-release/images/jre/lib/ \
+     cp -dpfr $(@D)/build/linux-*-release/images/jre/* \
              $(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
      cd $(TARGET_DIR)/usr/bin && ln -snf ../../$(OPENJDK_INSTALL_BASE)/bin/* .
 endef
--

2.25.2

Quoted 4 lines

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

--
.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |

'------------------------------^-------^------------------^--------------------'

#7 lore raw

PATCH 4/4 package/openjdk: add support for building the full jdk

In reply to aduskett at gmail.com

From: Adam Duskett <[email protected]>

Some users may require the full JDK on the target to debug or compile programs. This change is relatively trivial to add.

To install the full JDK, do the following:
- Add a new entry in package/openjdk/Config.in with the variable BR2_PACKAGE_OPENJDK_FULL_JDK

- Check for this variable in openjdk.mk, if it is selected set the following variables:
OPENJDK_INSTALL_DIR = jdk
OPENJDK_MAKE_TARGET=jdk-image
Otherwise, set the variables to jre and legacy-jre-image respectively.

- change legacy-jre-image to $(OPENJDK_MAKE_TARGET) in the OPENJD_BUILD_CMDS define.

- Change jre/* to $(OPENJDK_INSTALL_DIR)/* in the OPENJDK_INSTALL_TARGET_CMDS define

---
 package/openjdk/Config.in  |  7 +++++++
 package/openjdk/openjdk.mk | 12 ++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)
package/openjdk/Config.in +7 -0
index 61294ec49f..158f3031c3 100644
@@ -49,6 +49,13 @@ config BR2_PACKAGE_OPENJDK
 
 if BR2_PACKAGE_OPENJDK
 
+config BR2_PACKAGE_OPENJDK_FULL_JDK
+	bool "Build the full JDK"
+	help
+	  Install the full JDK instead of just the run time.
+	  Selecting this option will increase the file system by
+	  approximately 110M.
+
 choice
 	prompt "openjdk variant"
 	default BR2_PACKAGE_OPENJDK_JVM_VARIANT_SERVER if !BR2_powerpc
package/openjdk/openjdk.mk +10 -2
index 19e71e98b2..e8803f3cb5 100644
@@ -46,6 +46,14 @@ OPENJDK_JVM_VARIANT = zero
 OPENJDK_DEPENDENCIES += libffi
 endif
 
+ifeq ($(BR2_PACKAGE_OPENJDK_FULL_JDK),y)
+OPENJDK_INSTALL_DIR = jdk
+OPENJDK_MAKE_TARGET=jdk-image
+else
+OPENJDK_INSTALL_DIR = jre
+OPENJDK_MAKE_TARGET=legacy-jre-image
+endif
+
 # Because jre/lib has a modules file, installation on a system with a merged
 # /usr directory, and a built Kernel before OpenJDK, the following error
 # occurs: "cp: cannot overwrite directory '/usr/lib/modules with non-directory"
@@ -117,14 +125,14 @@ endef
 # Make -jn is unsupported. Instead, set the "--with-jobs=" configure option,
 # and use $(MAKE1).
 define OPENJDK_BUILD_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE1) -C $(@D) legacy-jre-image
+	$(TARGET_MAKE_ENV) $(OPENJDK_CONF_ENV) $(MAKE1) -C $(@D) $(OPENJDK_MAKE_TARGET)
 endef
 
 # Calling make install always builds and installs the JDK instead of the JRE,
 # which makes manual installation necessary.
 define OPENJDK_INSTALL_TARGET_CMDS
 	mkdir -p $(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
-	cp -dpfr $(@D)/build/linux-*-release/images/jre/* \
+	cp -dpfr $(@D)/build/linux-*-release/images/$(OPENJDK_INSTALL_DIR)/* \
 		$(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
 	cd $(TARGET_DIR)/usr/bin && ln -snf ../../$(OPENJDK_INSTALL_BASE)/bin/* .
 endef
Signature · 1 line
2.25.2
#8 lore raw

PATCH 4/4 package/openjdk: add support for building the full jdk

Quoted 1 line · On Fri, 17 Apr 2020 16:29:22 -0700 aduskett at gmail.com wrote:

Some users may require the full JDK on the target to debug or compile programs.

I don't think we should do that. Buildroot has always had a policy that we don't support doing development on the target. That's why we don't support installing gcc or g++ on the target.

So I think this policy should also apply to the JDK: we should support *running* Java programs on the target, but not *building* Java programs on the target.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#9 lore raw

PATCH 4/4 package/openjdk: add support for building the full jdk

In reply to aduskett at gmail.com

Adam, All,

On 2020-04-17 16:29 -0700, aduskett at gmail.com spake thusly:

Quoted 4 lines

From: Adam Duskett <[email protected]>

Some users may require the full JDK on the target to debug or compile programs. This change is relatively trivial to add.

I concur with Thomas on that one: we do not want to support doing development on the target.

I've marked the patch as rejected in patchwork, now.

Still, please read on for further review of this comit log...

Quoted 10 lines

To install the full JDK, do the following:
- Add a new entry in package/openjdk/Config.in with the variable BR2_PACKAGE_OPENJDK_FULL_JDK

- Check for this variable in openjdk.mk, if it is selected set the following variables:
OPENJDK_INSTALL_DIR = jdk
OPENJDK_MAKE_TARGET=jdk-image
Otherwise, set the variables to jre and legacy-jre-image respectively.

Quoted 5 lines

- change legacy-jre-image to $(OPENJDK_MAKE_TARGET) in the OPENJD_BUILD_CMDS define.

- Change jre/* to $(OPENJDK_INSTALL_DIR)/* in the OPENJDK_INSTALL_TARGET_CMDS define

Again, this commit log is not very helpful: it explains what is done, which is not so much interesting in itself: it is just restating what the code does, so it is bnetter to look at the code. What a commit log should do, is explain *why* a change needs to be done.

Basically, a commit log should be a three-stage story:

1. description of the problem
2. explanations of why the problem occurs
3. explanations on how we solve the problem

Regards,
Yann E. MORIN.

Quoted 67 lines
---
 package/openjdk/Config.in  |  7 +++++++
 package/openjdk/openjdk.mk | 12 ++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)
package/openjdk/Config.in +7 -0
index 61294ec49f..158f3031c3 100644
@@ -49,6 +49,13 @@ config BR2_PACKAGE_OPENJDK
 
 if BR2_PACKAGE_OPENJDK
 
+config BR2_PACKAGE_OPENJDK_FULL_JDK
+	bool "Build the full JDK"
+	help
+	  Install the full JDK instead of just the run time.
+	  Selecting this option will increase the file system by
+	  approximately 110M.
+
 choice
 	prompt "openjdk variant"
 	default BR2_PACKAGE_OPENJDK_JVM_VARIANT_SERVER if !BR2_powerpc
package/openjdk/openjdk.mk +10 -2
index 19e71e98b2..e8803f3cb5 100644
@@ -46,6 +46,14 @@ OPENJDK_JVM_VARIANT = zero
 OPENJDK_DEPENDENCIES += libffi
 endif
 
+ifeq ($(BR2_PACKAGE_OPENJDK_FULL_JDK),y)
+OPENJDK_INSTALL_DIR = jdk
+OPENJDK_MAKE_TARGET=jdk-image
+else
+OPENJDK_INSTALL_DIR = jre
+OPENJDK_MAKE_TARGET=legacy-jre-image
+endif
+
 # Because jre/lib has a modules file, installation on a system with a merged
 # /usr directory, and a built Kernel before OpenJDK, the following error
 # occurs: "cp: cannot overwrite directory '/usr/lib/modules with non-directory"
@@ -117,14 +125,14 @@ endef
 # Make -jn is unsupported. Instead, set the "--with-jobs=" configure option,
 # and use $(MAKE1).
 define OPENJDK_BUILD_CMDS
-	$(TARGET_MAKE_ENV) $(MAKE1) -C $(@D) legacy-jre-image
+	$(TARGET_MAKE_ENV) $(OPENJDK_CONF_ENV) $(MAKE1) -C $(@D) $(OPENJDK_MAKE_TARGET)
 endef
 
 # Calling make install always builds and installs the JDK instead of the JRE,
 # which makes manual installation necessary.
 define OPENJDK_INSTALL_TARGET_CMDS
 	mkdir -p $(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
-	cp -dpfr $(@D)/build/linux-*-release/images/jre/* \
+	cp -dpfr $(@D)/build/linux-*-release/images/$(OPENJDK_INSTALL_DIR)/* \
 		$(TARGET_DIR)/$(OPENJDK_INSTALL_BASE)
 	cd $(TARGET_DIR)/usr/bin && ln -snf ../../$(OPENJDK_INSTALL_BASE)/bin/* .
 endef
Signature · 6 lines
2.25.2

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#10 lore raw

PATCH 1/4 package/openjdk: fix hash

In reply to aduskett at gmail.com
Quoted 4 lines · On Fri, 17 Apr 2020 16:29:19 -0700 aduskett at gmail.com wrote:

From: Adam Duskett <[email protected]>

The hash should be 6815dbac7dd0f86291254e84ed17565c89477eeb6b0847a9648b00ecb4f07634

No, the hash was 6815dbac7dd0f86291254e84ed17565c89477eeb6b0847a9648b00ecb4f07634, and it is now fcd13ebd63d40c1c2f3cabfb7bc368962ff7b5935523be2a0e769352987145ae.

But still, why do you fix hashes like that, without investigating at least a little bit what's going on? How come we committed a wrong hash? How come there are no build failures related to this incorrect hash?

If you look at
http://autobuild.buildroot.net/results/0a4/0a4608828365df301114b533d6b59a4733599d94/build-end.log,
you will see why:

- We download from the original upstream location, and indeed the hash of the upstream tarball is fcd13ebd63d40c1c2f3cabfb7bc368962ff7b5935523be2a0e769352987145ae, but we expect 6815dbac7dd0f86291254e84ed17565c89477eeb6b0847a9648b00ecb4f07634

- So we fallback to sources.buildroot.net, and here the tarball has the expected hash, i.e 6815dbac7dd0f86291254e84ed17565c89477eeb6b0847a9648b00ecb4f07634

So this means that:

(1) Upstream changed the contents of their tarball, which is really BAD and we want to understand what are the changes. So you should diff the new upstream tarball, and the tarball that we have in sources.buildroot.net and investigate the differences.

(2) We need to notify upstream that this is really bad.

(3) You can't change the hash just like this, because it would mean that the hash would no longer match with the tarball we have backed up on sources.buildroot.net.

If we have hashes, it's not to blindly update them. We have hashes precisely to detect that kind of situation, so if you blindly update the hashes without doing any investigation, it makes it completely useless to have hashes.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com