Bug 6577

Summary: buildtools-tarball (buildtools-standalone) installer produces error on install
Product: [Runtime] General Runtime Reporter: Mark Hatle <mark.hatle>
Component: General RuntimeAssignee: Chen Qi <Qi.Chen>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Undecided CC: Qi.Chen, richard.purdie
Version: 1.7   
Target Milestone: 1.7 M2   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Mark Hatle 2014-07-25 16:38:52 UTC
I built a buildtools-tarball (SDK) on my regular build machine and went to install it on a fresh CentOS 6.4 machine.  This resulted in a number of error messages about unable to grep certain components, for example:

grep: /usr/local/sdk/sysroots/x86_64-oesdk-linux/etc/ssl/certs/RSA_Security_2048_v3.pem: No such file or directory

The cause of this is the file in question is actually a symbolic link back into the main system:

etc/ssl/certs/RSA_Security_2048_v3.pem -> /usr/share/ca-certificates/mozilla/RSA_Security_2048_v3.crt


The installer should detect that this is a symbolic link and avoid evaluating or modifying components outside of the installed SDK.

The 'nativesdk' package that populates the etc/ssl/certs directory is probably doing so incorrectly and should be investigated.  The location of the ssl certs may be host-system dependent, a relative link should be used instead.
Comment 1 Richard Purdie 2014-07-28 12:40:07 UTC
+ ln -sfn /usr/share/ca-certificates/mozilla/Atos_TrustedRoot_2011.crt /home/rpurdie/test/sysroots/x86_64-pokysdk-linux/etc/ssl/certs/Atos_TrustedRoot_2011.pem
++ grep '^#!.*perl' -rl /home/rpurdie/test/sysroots/x86_64-pokysdk-linux
grep: /home/rpurdie/test/sysroots/x86_64-pokysdk-linux/etc/ssl/certs/TWCA_Root_Certification_Authority.pem: No such file or directory
grep: /home/rpurdie/test/sysroots/x86_64-pokysdk-linux/etc/ssl/certs/Starfield_Services_Root_Certificate_Authority_-_G2.pem: No such file or directory
grep: /home/rpurdie/test/sysroots/x86_64-pokysdk-linux/etc/ssl/certs/DST_ACES_CA_X6.pem: No such file or directory
grep: /home/rpurdie/test/sysroots/x86_64-pokysdk-linux/etc/ssl/certs/StartCom_Certification_Authority_2.pem: No such file or directory
grep: /home/rpurdie/test/sysroots/x86_64-pokysdk-linux/etc/ssl/certs/QuoVadis_Root_CA_2.pem: No such file or directory
grep: /home/rpurdie/test/sysroots/x86_64-pokysdk-linux/etc/ssl/certs/Go_Daddy_Root_Certificate_Authority_-_G2.pem: No such file or directory

So this is coming from the perl script handling code. It looks like it may be a change in the behaviour of grep -r.

"man grep" on centos:

       -R, -r, --recursive
              Read all files under each directory, recursively; this is equivalent to the -d recurse option.

"man grep" on a more recent ubuntu system:

       -r, --recursive
              Read all files under each directory, recursively, following symbolic links only if they are on the command line.  This
              is equivalent to the -d recurse option.

So we need to patch the script only to look at real files.
Comment 2 Richard Purdie 2014-07-28 13:12:08 UTC
diff --git a/meta/classes/populate_sdk_base.bbclass b/meta/classes/populate_sdk_base.bbclass
index 893afbb..06112dc 100644
--- a/meta/classes/populate_sdk_base.bbclass
+++ b/meta/classes/populate_sdk_base.bbclass
@@ -285,7 +285,7 @@ done
 
 # find out all perl scripts in $native_sysroot and modify them replacing the
 # host perl with SDK perl.
-for perl_script in $($SUDO_EXEC grep "^#!.*perl" -rl $native_sysroot); do
+for perl_script in $($SUDO_EXEC find $native_sysroot -type f -exec grep "^#!.*perl" -l '{}' \;); do
        $SUDO_EXEC sed -i -e "s:^#! */usr/bin/perl.*:#! /usr/bin/env perl:g" -e \
                "s: /usr/bin/perl: /usr/bin/env perl:g" $perl_script
 done