<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>8672</bug_id>
          
          <creation_ts>2015-11-10 12:02:22 +0000</creation_ts>
          <short_desc>gpgconf has incorrect paths when installing in host toolchain</short_desc>
          <delta_ts>2015-11-19 12:05:21 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>core</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>VERIFIED</bug_status>
          <resolution>NOTABUG</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.1</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Gatis Paeglis">gatis.paeglis</reporter>
          <assigned_to name="Jussi Kukkonen">jku</assigned_to>
          <cc>bogdanx.a.voiculescu</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
          
          <qa_contact name="Bogdan Alexandru Voiculescu">bogdanx.a.voiculescu</qa_contact>
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>56351</commentid>
    <comment_count>0</comment_count>
    <who name="Gatis Paeglis">gatis.paeglis</who>
    <bug_when>2015-11-10 12:02:22 +0000</bug_when>
    <thetext>Steps to reproduce:

1) Add BBCLASSEXTEND = &quot;native nativesdk&quot; to the gnupg recipe.
2) Build toolchain for host.
3) Install the toolchain in custom prefix (MY_PREFIX).
4) Run ${MY_PREFIX}/sysroots/x86_64-pokysdk-linux/usr/bin/gpgconf

Where on my setup it prints:

gpg:GPG for OpenPGP:/opt/b2qt/1.7/sysroots/x86_64-pokysdk-linux/usr/bin/gpg2
gpg-agent:GPG Agent:/opt/b2qt/1.7/sysroots/x86_64-pokysdk-linux/usr/bin/gpg-agent
scdaemon:Smartcard Daemon:/opt/b2qt/1.7/sysroots/x86_64-pokysdk-linux/usr/lib/gnupg/scdaemon
gpgsm:GPG for S/MIME:/opt/b2qt/1.7/sysroots/x86_64-pokysdk-linux/usr/bin/gpgsm
dirmngr:Directory Manager:/opt/b2qt/1.7/sysroots/x86_64-pokysdk-linux/usr/bin/dirmngr

But the expected output would be:

gpg:GPG for OpenPGP:${MY_PREFIX}/sysroots/x86_64-pokysdk-linux/usr/bin/gpg2
gpg-agent:GPG Agent:${MY_PREFIX}/sysroots/x86_64-pokysdk-linux/usr/bin/gpg-agent
scdaemon:Smartcard Daemon:${MY_PREFIX}/sysroots/x86_64-pokysdk-linux/usr/lib/gnupg/scdaemon
gpgsm:GPG for S/MIME:${MY_PREFIX}sysroots/x86_64-pokysdk-linux/usr/bin/gpgsm
dirmngr:Directory Manager:${MY_PREFIX}/sysroots/x86_64-pokysdk-linux/usr/bin/dirmngr

Looking at the source code in gpgme library (gpgme/src/dirinfo.c::get_gpgconf_item) I see that it uses the gpgconf to find the gpg binary, but failing to find gpg in that path results in:
error: Unable to lookup key ID MY_KEY_ID: GPGME: Invalid crypto engine

Possibly recipe should add

/etc/gnupg/gpgconf.conf

as described in http://manpages.ubuntu.com/manpages/hardy/man1/gpgconf.1.html

Or run:

gpgconf --change-options when installing the toolchain.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56360</commentid>
    <comment_count>1</comment_count>
    <who name="Gatis Paeglis">gatis.paeglis</who>
    <bug_when>2015-11-10 15:50:07 +0000</bug_when>
    <thetext>After looking some more at this I see that there is no way to change the prefix at runtime, it is defined at build time.

As I was told, other recipes have solved similar issues with patching the original library to add envvars and then use &quot;create_wrapper pattern&quot; from recipes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56424</commentid>
    <comment_count>2</comment_count>
      <attachid>2849</attachid>
    <who name="Gatis Paeglis">gatis.paeglis</who>
    <bug_when>2015-11-12 13:55:02 +0000</bug_when>
    <thetext>Created attachment 2849
gnupg recipe bbappend</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56425</commentid>
    <comment_count>3</comment_count>
      <attachid>2850</attachid>
    <who name="Gatis Paeglis">gatis.paeglis</who>
    <bug_when>2015-11-12 13:57:26 +0000</bug_when>
    <thetext>Created attachment 2850
gnupg library patch

This is not complete. There are few other places in gnupg src that uses GNUPG_ defines, but this patch covers my use cases.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56427</commentid>
    <comment_count>4</comment_count>
    <who name="Gatis Paeglis">gatis.paeglis</who>
    <bug_when>2015-11-12 14:07:15 +0000</bug_when>
    <thetext>And here is the relevant discussion from gnupg-devel mailing list:
http://lists.gnupg.org/pipermail/gnupg-devel/2015-November/030547.html

It is not very useful, since I did not manage to convince them that there is an issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56428</commentid>
    <comment_count>5</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2015-11-12 14:12:10 +0000</bug_when>
    <thetext>Can you submit the patches to the mailing list (openembedded-core@) for review?  We don&apos;t do patch review in bugzilla. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56429</commentid>
    <comment_count>6</comment_count>
    <who name="Gatis Paeglis">gatis.paeglis</who>
    <bug_when>2015-11-12 14:19:08 +0000</bug_when>
    <thetext>I don&apos;t do patches on mailing lists :) But if seriously, then the patch for gnupg library is not complete and probably should be handled in cleaner way and ideally would be done by upstream project (gnupg).

It works for me, so I attached it here for convenience if others experience the same issue or somebody wants to fix this properly. I do not have time for that unfortunately. Also I would like to see yocto project switching from ML to something more modern, like https://en.wikipedia.org/wiki/Gerrit_%28software%29</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56463</commentid>
    <comment_count>7</comment_count>
    <who name="Gatis Paeglis">gatis.paeglis</who>
    <bug_when>2015-11-13 12:26:55 +0000</bug_when>
    <thetext>Just a note: this patch was tested with gnupg_2.0.26 and wont work with gnupg_2.1.1 for example. Also in my patch I export this adjusted env only before calling gpgconf, but the same env is probably needed also for other gpg binaries.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56466</commentid>
    <comment_count>8</comment_count>
    <who name="Jussi Kukkonen">jku</who>
    <bug_when>2015-11-13 14:26:04 +0000</bug_when>
    <thetext>I might be missing something... can you explain why gpgconf needs to be able to run in sysroot? gpgconf as I&apos;ve understood it is a tool for modifying user configuration in place in ~/.gnupg: this doesn&apos;t sound like a toolchain tool to me.

Can you generate the configuration once and install that in a recipe (possibly with some sed-replacements in the recipe if needed)?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56467</commentid>
    <comment_count>9</comment_count>
    <who name="Gatis Paeglis">gatis.paeglis</who>
    <bug_when>2015-11-13 14:41:39 +0000</bug_when>
    <thetext>&gt; I might be missing something... can you explain why gpgconf needs to be able &gt; to run in sysroot? gpgconf as I&apos;ve understood it is a tool for modifying user &gt; configuration in place in ~/.gnupg: this doesn&apos;t sound like a toolchain tool &gt; to me.

My current situation is that I want to provide customers a binary executable of &quot;something&quot; that does not come as installable *.deb package on Ubuntu. It could be challenging for some to build this &quot;something&quot; natively on Ubuntu, so I want to provide it in my toolchain for convenience. This &quot;something&quot; depends on GNUPG (and gpgme) and that is the reason why I have been trying to make it work from a toolchain.

Looking at the source code in gpgme library (gpgme/src/dirinfo.c::get_gpgconf_item) I see that it uses the gpgconf to find the gpg binary, but failing to find gpg in that path results in:
error: Unable to lookup key ID MY_KEY_ID: GPGME: Invalid crypto engine

So this is what gpgconf seems to be used for in addition to other things.

I was thinking since GNUPG is a runtime dependency, maybe there is a way to force &quot;something&quot; from toolchain to uses the GNUGP from the system instead?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56510</commentid>
    <comment_count>10</comment_count>
    <who name="Gatis Paeglis">gatis.paeglis</who>
    <bug_when>2015-11-17 10:27:17 +0000</bug_when>
    <thetext>Seems like nobody has ever tried this setup and also I droped GNUPG from my toolchain. This task can be closed as out-of-scope.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56519</commentid>
    <comment_count>11</comment_count>
    <who name="Jussi Kukkonen">jku</who>
    <bug_when>2015-11-17 11:51:10 +0000</bug_when>
    <thetext>I agree that it&apos;s kind of out-of-scope, marking NOTABUG.

If you need advice on how to get a tool in sysroot to use host gnupg, you could try the mailing list: I&apos;m guessing it&apos;s possible but can&apos;t think of suggestions right now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>56621</commentid>
    <comment_count>12</comment_count>
    <who name="Bogdan Alexandru Voiculescu">bogdanx.a.voiculescu</who>
    <bug_when>2015-11-19 12:05:21 +0000</bug_when>
    <thetext>out of scope.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>2849</attachid>
            <date>2015-11-12 13:55:02 +0000</date>
            <delta_ts>2015-11-13 08:18:55 +0000</delta_ts>
            <desc>gnupg recipe bbappend</desc>
            <filename>gnupg_%.bbappend</filename>
            <type>text/plain</type>
            <size>654</size>
            <attacher name="Gatis Paeglis">gatis.paeglis</attacher>
            
              <data encoding="base64">IyBodHRwczovL2J1Z3ppbGxhLnlvY3RvcHJvamVjdC5vcmcvc2hvd19idWcuY2dpP2lkPTg2NzIK
IyBUaGUgcGF0Y2ggdGhhdCB3ZSBhZGQgdG8gZ251cGcgaXMgbm90IGNvbXBsZXRlLCBidXQgaXQK
IyBjb3ZlcnMgb3VyIHVzZSBjYXNlcy4KClNSQ19VUklfYXBwZW5kX2NsYXNzLW5hdGl2ZXNkayA9
ICIgXAogICAgZmlsZTovLzAwMDEtVXNlLWVudmFycy1mb3ItaGFyZGNvZGVkLXBhdGhzLnBhdGNo
IFwKICAgICIKRklMRVNFWFRSQVBBVEhTX2FwcGVuZCA6PSAiJHtUSElTRElSfS8ke1BOfToiCgpk
b19pbnN0YWxsX2FwcGVuZF9jbGFzcy1uYXRpdmVzZGsoKSB7CiAgICAjIEVudnZhciBwYXRocyBh
cmUgdGFrZW4gZnJvbSB0aGUgZ2VuZXJhdGVkIE1ha2VmaWxlCgljcmVhdGVfd3JhcHBlciAke0R9
LyR7YmluZGlyfS9ncGdjb25mIFwKCSAgICBHTlVQR19CSU5ESVI9JHtiaW5kaXJ9IFwKICAgICAg
ICBHTlVQR19MSUJFWEVDRElSPSR7bGliZXhlY2Rpcn0gXAogICAgICAgIEdOVVBHX0xJQkRJUj0k
e2xpYmRpcn0vZ251cGcgXAogICAgICAgIEdOVVBHX0RBVEFESVI9JHtkYXRhZGlyfS9nbnVwZyBc
CiAgICAgICAgR05VUEdfU1lTQ09ORkRJUj0ke3N5c2NvbmZkaXJ9L2dudXBnCn0KCkJCQ0xBU1NF
WFRFTkQgPSAibmF0aXZlIG5hdGl2ZXNkayIK
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>2850</attachid>
            <date>2015-11-12 13:57:26 +0000</date>
            <delta_ts>2015-11-12 13:57:26 +0000</delta_ts>
            <desc>gnupg library patch</desc>
            <filename>0001-Use-envars-for-hardcoded-paths.patch</filename>
            <type>text/plain</type>
            <size>1400</size>
            <attacher name="Gatis Paeglis">gatis.paeglis</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL2NvbW1vbi9ob21lZGlyLmMgYi9jb21tb24vaG9tZWRpci5jCmluZGV4IDRi
MDNjZmUuLmVlYzBlNGUgMTAwNjQ0Ci0tLSBhL2NvbW1vbi9ob21lZGlyLmMKKysrIGIvY29tbW9u
L2hvbWVkaXIuYwpAQCAtMzQ4LDYgKzM0OCw5IEBAIG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gKHZvaWQpCiAgICAgfQogICBy
ZXR1cm4gbmFtZTsKICNlbHNlIC8qIUhBVkVfVzMyX1NZU1RFTSovCisgIGNvbnN0IGNoYXIgKmxp
YmRpciA9IGdldGVudigiR05VUEdfTElCRElSIik7CisgIGlmIChsaWJkaXIgIT0gTlVMTCkKKyAg
ICByZXR1cm4gbGliZGlyOwogICByZXR1cm4gR05VUEdfTElCRElSOwogI2VuZGlmIC8qIUhBVkVf
VzMyX1NZU1RFTSovCiB9CkBAIC00MjQsNiArNDM2LDkgQEAgZ251cGdfZGF0YWRpciAodm9pZCkK
ICAgICB9CiAgIHJldHVybiBuYW1lOwogI2Vsc2UgLyohSEFWRV9XMzJfU1lTVEVNKi8KKyAgY29u
c3QgY2hhciAqZGF0YWRpciA9IGdldGVudigiR05VUEdfREFUQURJUiIpOworICBpZiAoZGF0YWRp
ciAhPSBOVUxMKQorICAgIHJldHVybiBkYXRhZGlyOwogICByZXR1cm4gR05VUEdfREFUQURJUjsK
ICNlbmRpZiAvKiFIQVZFX1czMl9TWVNURU0qLwogfQo=
</data>

          </attachment>
      

    </bug>

</bugzilla>