[meta-java,3/3] ca-certificates-java: Distinguish between SYSROOT and D

Submitted by Yevgeny Popovych on Sept. 7, 2018, 6:10 p.m. | Patch ID: 154722

Details

Message ID 1536343810-87649-4-git-send-email-yevgenyp@pointgrab.com
State Changes Requested
Delegated to: Richard Leitner
Headers show

Commit Message

Yevgeny Popovych Sept. 7, 2018, 6:10 p.m.
This fixes ca-certificates-java-hook invocation via
update-ca-certificates on build host and as a native tool.
Provide SYSROOT variable in the postinst and consume it in the script,
like ca-certificates recipe does.

SYSROOT is set whenever the script is executed on the build host
(do_rootfs, or as native dependency).
D is only set during do_rootfs.

Change-Id: Ifbf50ca705a98012e1357ebf5afa33c07ea6cd87
Signed-off-by: Yevgeny Popovych <yevgenyp@pointgrab.com>
---
 .../ca-certificates-java/ca-certificates-java.hook.in   | 17 ++++++++---------
 .../ca-certificates-java_20180516.bb                    |  2 +-
 2 files changed, 9 insertions(+), 10 deletions(-)

Patch hide | download patch | download mbox

diff --git a/recipes-core/ca-certificates-java/ca-certificates-java/ca-certificates-java.hook.in b/recipes-core/ca-certificates-java/ca-certificates-java/ca-certificates-java.hook.in
index 611a4ef..5e89dd9 100755
--- a/recipes-core/ca-certificates-java/ca-certificates-java/ca-certificates-java.hook.in
+++ b/recipes-core/ca-certificates-java/ca-certificates-java/ca-certificates-java.hook.in
@@ -8,20 +8,21 @@ 
 # and package update in OE, so the distinction between cases 2)
 # and 3) isn't perfect.
 
+# SYSROOT is set whenever the script is executed on the build host
+# (do_rootfs, or as native dependency).
+# D is only set during do_rootfs.
+
 self=$(basename $0)
-jvm_libdir="@@libdir_jvm@@"
+jvm_libdir="${JVM_LIBDIR:-@@libdir_jvm@@}"
 
-if [ -n "${D:-}" ] ; then
-    # called from postinst as part of image build on host
+if [ -n "${SYSROOT:-}" ] ; then
+    # called on build host - from postinst (directly or as a hook) or as a native tool
     if [ -z "${JVM_LIBDIR:-}" ] ; then
         # if JVM_LIBDIR is not present - we were called as a hook
         echo "called as a hook of ca-certificates on do_rootfs, exiting"
         exit 0
     fi
 fi
-if [ -n "${JVM_LIBDIR:-}" ] ; then
-    jvm_libdir="${JVM_LIBDIR}"
-fi
 
 for JAVA in icedtea7-native/bin/java \
             openjdk-8-native/bin/java openjdk-8/bin/java openjre-8/bin/java \
@@ -58,6 +59,4 @@  else
     while read filename ; do
         echo "+${filename}"
     done
-fi | SYSROOT="${D:-}" ${JAVA} -Xmx64m \
-                              -jar ${D:-}@@datadir_java@@/@@JARFILENAME@@ \
-                              -storepass changeit
+fi | ${JAVA} -Xmx64m -jar ${D:-}@@datadir_java@@/@@JARFILENAME@@ -storepass changeit
diff --git a/recipes-core/ca-certificates-java/ca-certificates-java_20180516.bb b/recipes-core/ca-certificates-java/ca-certificates-java_20180516.bb
index 7db5110..2f2536d 100644
--- a/recipes-core/ca-certificates-java/ca-certificates-java_20180516.bb
+++ b/recipes-core/ca-certificates-java/ca-certificates-java_20180516.bb
@@ -100,7 +100,7 @@  pkg_postinst_${PN} () {
 	    fi
 	    JVM_LIBDIR=$NATIVE_ROOT${libdir_jvm}
 	fi
-	JVM_LIBDIR=$JVM_LIBDIR $D${sbindir}/create-ca-certificates-java
+	SYSROOT=$D JVM_LIBDIR=$JVM_LIBDIR $D${sbindir}/create-ca-certificates-java
 }
 
 RDEPENDS_${PN} = "ca-certificates"

Comments

André Draszik Sept. 17, 2018, 3 p.m.
On Fri, 2018-09-07 at 21:10 +0300, Yevgeny Popovych wrote:
> This fixes ca-certificates-java-hook invocation via
> update-ca-certificates on build host and as a native tool.
> Provide SYSROOT variable in the postinst and consume it in the script,
> like ca-certificates recipe does.
> 
> SYSROOT is set whenever the script is executed on the build host
> (do_rootfs, or as native dependency).
> D is only set during do_rootfs.
> 

I think I'm missing something...
It looks like this patch switches the hook script to use $SYSROOT instead of
$D, and SYSROOT is set to $D in the postinst explicitly.

In both cases, the expansion of $SYSROOT or $D will yield the same. How is
that fixing anything? What am I missing?


Cheers,
Andre'


> Change-Id: Ifbf50ca705a98012e1357ebf5afa33c07ea6cd87
> Signed-off-by: Yevgeny Popovych <yevgenyp@pointgrab.com>
> ---
>  .../ca-certificates-java/ca-certificates-java.hook.in   | 17 ++++++++--
> -------
>  .../ca-certificates-java_20180516.bb                    |  2 +-
>  2 files changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/recipes-core/ca-certificates-java/ca-certificates-java/ca-
> certificates-java.hook.in b/recipes-core/ca-certificates-java/ca-
> certificates-java/ca-certificates-java.hook.in
> index 611a4ef..5e89dd9 100755
> --- a/recipes-core/ca-certificates-java/ca-certificates-java/ca-
> certificates-java.hook.in
> +++ b/recipes-core/ca-certificates-java/ca-certificates-java/ca-
> certificates-java.hook.in
> @@ -8,20 +8,21 @@
>  # and package update in OE, so the distinction between cases 2)
>  # and 3) isn't perfect.
>  
> +# SYSROOT is set whenever the script is executed on the build host
> +# (do_rootfs, or as native dependency).
> +# D is only set during do_rootfs.
> +
>  self=$(basename $0)
> -jvm_libdir="@@libdir_jvm@@"
> +jvm_libdir="${JVM_LIBDIR:-@@libdir_jvm@@}"
>  
> -if [ -n "${D:-}" ] ; then
> -    # called from postinst as part of image build on host
> +if [ -n "${SYSROOT:-}" ] ; then
> +    # called on build host - from postinst (directly or as a hook) or as
> a native tool
>      if [ -z "${JVM_LIBDIR:-}" ] ; then
>          # if JVM_LIBDIR is not present - we were called as a hook
>          echo "called as a hook of ca-certificates on do_rootfs, exiting"
>          exit 0
>      fi
>  fi
> -if [ -n "${JVM_LIBDIR:-}" ] ; then
> -    jvm_libdir="${JVM_LIBDIR}"
> -fi
>  
>  for JAVA in icedtea7-native/bin/java \
>              openjdk-8-native/bin/java openjdk-8/bin/java openjre-
> 8/bin/java \
> @@ -58,6 +59,4 @@ else
>      while read filename ; do
>          echo "+${filename}"
>      done
> -fi | SYSROOT="${D:-}" ${JAVA} -Xmx64m \
> -                              -jar ${D:-}@@datadir_java@@/@@JARFILENAME@@ 
> \
> -                              -storepass changeit
> +fi | ${JAVA} -Xmx64m -jar ${D:-}@@datadir_java@@/@@JARFILENAME@@
> -storepass changeit
> diff --git a/recipes-core/ca-certificates-java/ca-certificates-
> java_20180516.bb b/recipes-core/ca-certificates-java/ca-certificates-
> java_20180516.bb
> index 7db5110..2f2536d 100644
> --- a/recipes-core/ca-certificates-java/ca-certificates-java_20180516.bb
> +++ b/recipes-core/ca-certificates-java/ca-certificates-java_20180516.bb
> @@ -100,7 +100,7 @@ pkg_postinst_${PN} () {
>  	    fi
>  	    JVM_LIBDIR=$NATIVE_ROOT${libdir_jvm}
>  	fi
> -	JVM_LIBDIR=$JVM_LIBDIR $D${sbindir}/create-ca-certificates-java
> +	SYSROOT=$D JVM_LIBDIR=$JVM_LIBDIR $D${sbindir}/create-ca-
> certificates-java
>  }
>  
>  RDEPENDS_${PN} = "ca-certificates"
> -- 
> 2.7.4
>
Yevgeny Popovych Sept. 19, 2018, 10:09 a.m.
On 09/17/2018 06:00 PM, André Draszik wrote:
> On Fri, 2018-09-07 at 21:10 +0300, Yevgeny Popovych wrote:
>> This fixes ca-certificates-java-hook invocation via
>> update-ca-certificates on build host and as a native tool.
>> Provide SYSROOT variable in the postinst and consume it in the script,
>> like ca-certificates recipe does.
>>
>> SYSROOT is set whenever the script is executed on the build host
>> (do_rootfs, or as native dependency).
>> D is only set during do_rootfs.
>>
> 
> I think I'm missing something...
> It looks like this patch switches the hook script to use $SYSROOT instead of
> $D, and SYSROOT is set to $D in the postinst explicitly.
> 
> In both cases, the expansion of $SYSROOT or $D will yield the same. How is
> that fixing anything? What am I missing?

The only difference would be between usage as a native tool and on do_rootfs.
SYSROOT is always set when run on build host and it points to the files we want to modify.
D is used only on do_rootfs and is used to find the hook (jar). On do_roofs these are equal.

> 
> 
> Cheers,
> Andre'
> 
> 
>> Change-Id: Ifbf50ca705a98012e1357ebf5afa33c07ea6cd87
>> Signed-off-by: Yevgeny Popovych <yevgenyp@pointgrab.com>
>> ---
>>  .../ca-certificates-java/ca-certificates-java.hook.in   | 17 ++++++++--
>> -------
>>  .../ca-certificates-java_20180516.bb                    |  2 +-
>>  2 files changed, 9 insertions(+), 10 deletions(-)
>>
>> diff --git a/recipes-core/ca-certificates-java/ca-certificates-java/ca-
>> certificates-java.hook.in b/recipes-core/ca-certificates-java/ca-
>> certificates-java/ca-certificates-java.hook.in
>> index 611a4ef..5e89dd9 100755
>> --- a/recipes-core/ca-certificates-java/ca-certificates-java/ca-
>> certificates-java.hook.in
>> +++ b/recipes-core/ca-certificates-java/ca-certificates-java/ca-
>> certificates-java.hook.in
>> @@ -8,20 +8,21 @@
>>  # and package update in OE, so the distinction between cases 2)
>>  # and 3) isn't perfect.
>>  
>> +# SYSROOT is set whenever the script is executed on the build host
>> +# (do_rootfs, or as native dependency).
>> +# D is only set during do_rootfs.
>> +
>>  self=$(basename $0)
>> -jvm_libdir="@@libdir_jvm@@"
>> +jvm_libdir="${JVM_LIBDIR:-@@libdir_jvm@@}"
>>  
>> -if [ -n "${D:-}" ] ; then
>> -    # called from postinst as part of image build on host
>> +if [ -n "${SYSROOT:-}" ] ; then
>> +    # called on build host - from postinst (directly or as a hook) or as
>> a native tool
>>      if [ -z "${JVM_LIBDIR:-}" ] ; then
>>          # if JVM_LIBDIR is not present - we were called as a hook
>>          echo "called as a hook of ca-certificates on do_rootfs, exiting"
>>          exit 0
>>      fi
>>  fi
>> -if [ -n "${JVM_LIBDIR:-}" ] ; then
>> -    jvm_libdir="${JVM_LIBDIR}"
>> -fi
>>  
>>  for JAVA in icedtea7-native/bin/java \
>>              openjdk-8-native/bin/java openjdk-8/bin/java openjre-
>> 8/bin/java \
>> @@ -58,6 +59,4 @@ else
>>      while read filename ; do
>>          echo "+${filename}"
>>      done
>> -fi | SYSROOT="${D:-}" ${JAVA} -Xmx64m \
>> -                              -jar ${D:-}@@datadir_java@@/@@JARFILENAME@@ 
>> \
>> -                              -storepass changeit
>> +fi | ${JAVA} -Xmx64m -jar ${D:-}@@datadir_java@@/@@JARFILENAME@@
>> -storepass changeit
>> diff --git a/recipes-core/ca-certificates-java/ca-certificates-
>> java_20180516.bb b/recipes-core/ca-certificates-java/ca-certificates-
>> java_20180516.bb
>> index 7db5110..2f2536d 100644
>> --- a/recipes-core/ca-certificates-java/ca-certificates-java_20180516.bb
>> +++ b/recipes-core/ca-certificates-java/ca-certificates-java_20180516.bb
>> @@ -100,7 +100,7 @@ pkg_postinst_${PN} () {
>>  	    fi
>>  	    JVM_LIBDIR=$NATIVE_ROOT${libdir_jvm}
>>  	fi
>> -	JVM_LIBDIR=$JVM_LIBDIR $D${sbindir}/create-ca-certificates-java
>> +	SYSROOT=$D JVM_LIBDIR=$JVM_LIBDIR $D${sbindir}/create-ca-
>> certificates-java
>>  }
>>  
>>  RDEPENDS_${PN} = "ca-certificates"
>> -- 
>> 2.7.4
>>
>