All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/4] package/openjdk: fix hash
@ 2020-04-17 23:29 aduskett at gmail.com
  2020-04-17 23:29 ` [Buildroot] [PATCH 2/4] package/openjdk: fix installation with merged usr directories aduskett at gmail.com
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: aduskett at gmail.com @ 2020-04-17 23:29 UTC (permalink / raw)
  To: buildroot

From: Adam Duskett <Aduskett@gmail.com>

The hash should be
6815dbac7dd0f86291254e84ed17565c89477eeb6b0847a9648b00ecb4f07634

Signed-off-by: Adam Duskett <Aduskett@gmail.com>
---
 package/openjdk/openjdk.hash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/openjdk/openjdk.hash b/package/openjdk/openjdk.hash
index d5be642052..07bf4d5479 100644
--- a/package/openjdk/openjdk.hash
+++ b/package/openjdk/openjdk.hash
@@ -1,3 +1,3 @@
 # Locally computed
-sha256 6815dbac7dd0f86291254e84ed17565c89477eeb6b0847a9648b00ecb4f07634  jdk-14+36.tar.gz
+sha256 fcd13ebd63d40c1c2f3cabfb7bc368962ff7b5935523be2a0e769352987145ae  jdk-14+36.tar.gz
 sha256 4b9abebc4338048a7c2dc184e9f800deb349366bdf28eb23c2677a77b4c87726  LICENSE
-- 
2.25.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 2/4] package/openjdk: fix installation with merged usr directories
  2020-04-17 23:29 [Buildroot] [PATCH 1/4] package/openjdk: fix hash aduskett at gmail.com
@ 2020-04-17 23:29 ` aduskett at gmail.com
  2020-04-18 12:17   ` Yann E. MORIN
  2020-04-18 12:26   ` Yann E. MORIN
  2020-04-17 23:29 ` [Buildroot] [PATCH 3/4] package/openjdk: copy all directories and files when installing aduskett at gmail.com
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 11+ messages in thread
From: aduskett at gmail.com @ 2020-04-17 23:29 UTC (permalink / raw)
  To: buildroot

From: Adam Duskett <Aduskett@gmail.com>

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.

Fixes: https://bugs.busybox.net/show_bug.cgi?id=12751

Signed-off-by: Adam Duskett <Aduskett@gmail.com>
---
 package/openjdk/openjdk.mk | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/package/openjdk/openjdk.mk b/package/openjdk/openjdk.mk
index edc86c6fbe..d540b65edc 100644
--- a/package/openjdk/openjdk.mk
+++ b/package/openjdk/openjdk.mk
@@ -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))
-- 
2.25.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 3/4] package/openjdk: copy all directories and files when installing
  2020-04-17 23:29 [Buildroot] [PATCH 1/4] package/openjdk: fix hash aduskett at gmail.com
  2020-04-17 23:29 ` [Buildroot] [PATCH 2/4] package/openjdk: fix installation with merged usr directories aduskett at gmail.com
@ 2020-04-17 23:29 ` aduskett at gmail.com
  2020-04-18 12:21   ` Yann E. MORIN
  2020-04-17 23:29 ` [Buildroot] [PATCH 4/4] package/openjdk: add support for building the full jdk aduskett at gmail.com
  2020-04-18 10:01 ` [Buildroot] [PATCH 1/4] package/openjdk: fix hash Thomas Petazzoni
  3 siblings, 1 reply; 11+ messages in thread
From: aduskett at gmail.com @ 2020-04-17 23:29 UTC (permalink / raw)
  To: buildroot

From: Adam Duskett <Aduskett@gmail.com>

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.

Signed-off-by: Adam Duskett <Aduskett@gmail.com>
---
 package/openjdk/openjdk.mk | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/package/openjdk/openjdk.mk b/package/openjdk/openjdk.mk
index d540b65edc..19e71e98b2 100644
--- a/package/openjdk/openjdk.mk
+++ b/package/openjdk/openjdk.mk
@@ -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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 4/4] package/openjdk: add support for building the full jdk
  2020-04-17 23:29 [Buildroot] [PATCH 1/4] package/openjdk: fix hash aduskett at gmail.com
  2020-04-17 23:29 ` [Buildroot] [PATCH 2/4] package/openjdk: fix installation with merged usr directories aduskett at gmail.com
  2020-04-17 23:29 ` [Buildroot] [PATCH 3/4] package/openjdk: copy all directories and files when installing aduskett at gmail.com
@ 2020-04-17 23:29 ` aduskett at gmail.com
  2020-04-18 10:03   ` Thomas Petazzoni
  2020-04-18 12:02   ` Yann E. MORIN
  2020-04-18 10:01 ` [Buildroot] [PATCH 1/4] package/openjdk: fix hash Thomas Petazzoni
  3 siblings, 2 replies; 11+ messages in thread
From: aduskett at gmail.com @ 2020-04-17 23:29 UTC (permalink / raw)
  To: buildroot

From: Adam Duskett <Aduskett@gmail.com>

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

Signed-off-by: Adam Duskett <Aduskett@gmail.com>
---
 package/openjdk/Config.in  |  7 +++++++
 package/openjdk/openjdk.mk | 12 ++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/package/openjdk/Config.in b/package/openjdk/Config.in
index 61294ec49f..158f3031c3 100644
--- a/package/openjdk/Config.in
+++ b/package/openjdk/Config.in
@@ -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
diff --git a/package/openjdk/openjdk.mk b/package/openjdk/openjdk.mk
index 19e71e98b2..e8803f3cb5 100644
--- a/package/openjdk/openjdk.mk
+++ b/package/openjdk/openjdk.mk
@@ -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
-- 
2.25.2

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 1/4] package/openjdk: fix hash
  2020-04-17 23:29 [Buildroot] [PATCH 1/4] package/openjdk: fix hash aduskett at gmail.com
                   ` (2 preceding siblings ...)
  2020-04-17 23:29 ` [Buildroot] [PATCH 4/4] package/openjdk: add support for building the full jdk aduskett at gmail.com
@ 2020-04-18 10:01 ` Thomas Petazzoni
  3 siblings, 0 replies; 11+ messages in thread
From: Thomas Petazzoni @ 2020-04-18 10:01 UTC (permalink / raw)
  To: buildroot

On Fri, 17 Apr 2020 16:29:19 -0700
aduskett at gmail.com wrote:

> From: Adam Duskett <Aduskett@gmail.com>
> 
> 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
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 4/4] package/openjdk: add support for building the full jdk
  2020-04-17 23:29 ` [Buildroot] [PATCH 4/4] package/openjdk: add support for building the full jdk aduskett at gmail.com
@ 2020-04-18 10:03   ` Thomas Petazzoni
  2020-04-18 12:02   ` Yann E. MORIN
  1 sibling, 0 replies; 11+ messages in thread
From: Thomas Petazzoni @ 2020-04-18 10:03 UTC (permalink / raw)
  To: buildroot

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
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 4/4] package/openjdk: add support for building the full jdk
  2020-04-17 23:29 ` [Buildroot] [PATCH 4/4] package/openjdk: add support for building the full jdk aduskett at gmail.com
  2020-04-18 10:03   ` Thomas Petazzoni
@ 2020-04-18 12:02   ` Yann E. MORIN
  1 sibling, 0 replies; 11+ messages in thread
From: Yann E. MORIN @ 2020-04-18 12:02 UTC (permalink / raw)
  To: buildroot

Adam, All,

On 2020-04-17 16:29 -0700, aduskett at gmail.com spake thusly:
> From: Adam Duskett <Aduskett@gmail.com>
> 
> 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...

> 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

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.

> Signed-off-by: Adam Duskett <Aduskett@gmail.com>
> ---
>  package/openjdk/Config.in  |  7 +++++++
>  package/openjdk/openjdk.mk | 12 ++++++++++--
>  2 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/package/openjdk/Config.in b/package/openjdk/Config.in
> index 61294ec49f..158f3031c3 100644
> --- a/package/openjdk/Config.in
> +++ b/package/openjdk/Config.in
> @@ -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
> diff --git a/package/openjdk/openjdk.mk b/package/openjdk/openjdk.mk
> index 19e71e98b2..e8803f3cb5 100644
> --- a/package/openjdk/openjdk.mk
> +++ b/package/openjdk/openjdk.mk
> @@ -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
> -- 
> 2.25.2
> 
> _______________________________________________
> 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.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 2/4] package/openjdk: fix installation with merged usr directories
  2020-04-17 23:29 ` [Buildroot] [PATCH 2/4] package/openjdk: fix installation with merged usr directories aduskett at gmail.com
@ 2020-04-18 12:17   ` Yann E. MORIN
  2020-04-18 12:26   ` Yann E. MORIN
  1 sibling, 0 replies; 11+ messages in thread
From: Yann E. MORIN @ 2020-04-18 12:17 UTC (permalink / raw)
  To: buildroot

Adam, All,

On 2020-04-17 16:29 -0700, aduskett at gmail.com spake thusly:
> From: Adam Duskett <Aduskett@gmail.com>
> 
> 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.

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...

> Fixes: https://bugs.busybox.net/show_bug.cgi?id=12751
> 
> Signed-off-by: Adam Duskett <Aduskett@gmail.com>
> ---
>  package/openjdk/openjdk.mk | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/package/openjdk/openjdk.mk b/package/openjdk/openjdk.mk
> index edc86c6fbe..d540b65edc 100644
> --- a/package/openjdk/openjdk.mk
> +++ b/package/openjdk/openjdk.mk
> @@ -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"

> +# 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

>  # 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)

>  	--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)

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

Regards,
Yann E. MORIN.

> +	cd $(TARGET_DIR)/usr/bin && ln -snf ../../$(OPENJDK_INSTALL_BASE)/bin/* .
>  endef
>  
>  $(eval $(generic-package))
> -- 
> 2.25.2
> 
> _______________________________________________
> 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.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 3/4] package/openjdk: copy all directories and files when installing
  2020-04-17 23:29 ` [Buildroot] [PATCH 3/4] package/openjdk: copy all directories and files when installing aduskett at gmail.com
@ 2020-04-18 12:21   ` Yann E. MORIN
  2020-04-18 17:00     ` Adam Duskett
  0 siblings, 1 reply; 11+ messages in thread
From: Yann E. MORIN @ 2020-04-18 12:21 UTC (permalink / raw)
  To: buildroot

Adam, All,

On 2020-04-17 16:29 -0700, aduskett at gmail.com spake thusly:
> From: Adam Duskett <Aduskett@gmail.com>
> 
> 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?

>   - 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.
> 
> Signed-off-by: Adam Duskett <Aduskett@gmail.com>

Reviewed-by: Yann E. MORIN <yann.morin.1998@free.fr>

Regards,
Yann E. MORIN.

> ---
>  package/openjdk/openjdk.mk | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/package/openjdk/openjdk.mk b/package/openjdk/openjdk.mk
> index d540b65edc..19e71e98b2 100644
> --- a/package/openjdk/openjdk.mk
> +++ b/package/openjdk/openjdk.mk
> @@ -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
> 
> _______________________________________________
> 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.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 2/4] package/openjdk: fix installation with merged usr directories
  2020-04-17 23:29 ` [Buildroot] [PATCH 2/4] package/openjdk: fix installation with merged usr directories aduskett at gmail.com
  2020-04-18 12:17   ` Yann E. MORIN
@ 2020-04-18 12:26   ` Yann E. MORIN
  1 sibling, 0 replies; 11+ messages in thread
From: Yann E. MORIN @ 2020-04-18 12:26 UTC (permalink / raw)
  To: buildroot

Adam, All,

On 2020-04-17 16:29 -0700, aduskett at gmail.com spake thusly:
> From: Adam Duskett <Aduskett@gmail.com>
> 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--]
> diff --git a/package/openjdk/openjdk.mk b/package/openjdk/openjdk.mk
> index edc86c6fbe..d540b65edc 100644
> --- a/package/openjdk/openjdk.mk
> +++ b/package/openjdk/openjdk.mk
[--SNIP--]
> @@ -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.

> +	cd $(TARGET_DIR)/usr/bin && ln -snf ../../$(OPENJDK_INSTALL_BASE)/bin/* .
>  endef
>  
>  $(eval $(generic-package))
> -- 
> 2.25.2
> 
> _______________________________________________
> 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.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Buildroot] [PATCH 3/4] package/openjdk: copy all directories and files when installing
  2020-04-18 12:21   ` Yann E. MORIN
@ 2020-04-18 17:00     ` Adam Duskett
  0 siblings, 0 replies; 11+ messages in thread
From: Adam Duskett @ 2020-04-18 17:00 UTC (permalink / raw)
  To: buildroot

On Sat, Apr 18, 2020 at 5:21 AM Yann E. MORIN <yann.morin.1998@free.fr> wrote:
>
> Adam, All,
>
> On 2020-04-17 16:29 -0700, aduskett at gmail.com spake thusly:
> > From: Adam Duskett <Aduskett@gmail.com>
> >
> > 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?
>
Unfortunately yes, as they can be used by some applications to print
legal information,
which means if these files exist an exception is thrown.

> >   - 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.
> >
> > Signed-off-by: Adam Duskett <Aduskett@gmail.com>
>
> Reviewed-by: Yann E. MORIN <yann.morin.1998@free.fr>
>
> Regards,
> Yann E. MORIN.
>
> > ---
> >  package/openjdk/openjdk.mk | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/package/openjdk/openjdk.mk b/package/openjdk/openjdk.mk
> > index d540b65edc..19e71e98b2 100644
> > --- a/package/openjdk/openjdk.mk
> > +++ b/package/openjdk/openjdk.mk
> > @@ -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
> >
> > _______________________________________________
> > 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.  |
> '------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-04-18 17:00 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-17 23:29 [Buildroot] [PATCH 1/4] package/openjdk: fix hash aduskett at gmail.com
2020-04-17 23:29 ` [Buildroot] [PATCH 2/4] package/openjdk: fix installation with merged usr directories aduskett at gmail.com
2020-04-18 12:17   ` Yann E. MORIN
2020-04-18 12:26   ` Yann E. MORIN
2020-04-17 23:29 ` [Buildroot] [PATCH 3/4] package/openjdk: copy all directories and files when installing aduskett at gmail.com
2020-04-18 12:21   ` Yann E. MORIN
2020-04-18 17:00     ` Adam Duskett
2020-04-17 23:29 ` [Buildroot] [PATCH 4/4] package/openjdk: add support for building the full jdk aduskett at gmail.com
2020-04-18 10:03   ` Thomas Petazzoni
2020-04-18 12:02   ` Yann E. MORIN
2020-04-18 10:01 ` [Buildroot] [PATCH 1/4] package/openjdk: fix hash Thomas Petazzoni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.