<?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>14119</bug_id>
          
          <creation_ts>2020-11-07 10:38:06 +0000</creation_ts>
          <short_desc>ipk package and package feed signing</short_desc>
          <delta_ts>2026-07-14 21:58:34 +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>oe-core other</component>
          <version>3.1.4</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>5.99</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Robert Berger">pokylinux</reporter>
          <assigned_to name="Robert Berger">pokylinux</assigned_to>
          <cc>randy.macleod</cc>
    
    <cc>richard.purdie</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>88572</commentid>
    <comment_count>0</comment_count>
    <who name="Robert Berger">pokylinux</who>
    <bug_when>2020-11-07 10:38:06 +0000</bug_when>
    <thetext>I am playing around with ipk and signed package feeds and hit a well-known issue with Ubuntu 18:

Many errors like that:

ERROR: tzdata-2020a-r0 do_package_write_ipk: GPG exited with code 2: gpg: signing failed: Cannot allocate memory
gpg: signing failed: Cannot allocate memory

which seems to be related to that:

https://github.com/sbt/sbt-pgp/issues/168

I am not quite sure, but I am afraid the build system uses gpg from my Linux disto:

# gpg --version
gpg (GnuPG) 2.2.4
libgcrypt 1.8.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later &lt;https://gnu.org/licenses/gpl.html&gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /root/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

At the moment I build with BB_NUMBER_THREADS = &quot;1&quot; to avoid parallel invocations of gpg.

I hope there is a better solution to this.

-# Newer versions of gpg (at least 2.1.5 and 2.2.1) have issues when signing occurs in parallel
-# so, unfortunately, the signing must be done serially. Once the upstream problem is fixed,
-# the following line must be removed otherwise we loose all the intrinsic parallelism from
-# bitbake.  For more information, check https://bugzilla.yoctoproject.org/show_bug.cgi?id=12022.
-do_package_write_rpm[lockfiles] += &quot;${TMPDIR}/gpg.lock&quot;
+PACKAGE_WRITE_DEPS += &quot;gnupg-native&quot;

Is the upstream version (gnupg-native) fixed? 
Can I somehow enforce the usage of gnupg-native (with a newer libcrypt) instead of gpg which comes with my Linux distro to overcome the problem?

It might be that something similar was already resolved here: https://bugzilla.yoctoproject.org/show_bug.cgi?id=12022

or here:
https://patchwork.openembedded.org/patch/142916/

but all this was quite some time ago and me 3.1.2 version should work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88573</commentid>
    <comment_count>1</comment_count>
    <who name="Robert Berger">pokylinux</who>
    <bug_when>2020-11-08 03:11:04 +0000</bug_when>
    <thetext>It looks like the packages are signed, or at least each package has some .asc file now

e.g.

./all/tzdata_2020a-r0.0_all.ipk.asc
./all/tzdata_2020a-r0.0_all.ipk

Is this used?

On the target I don&apos;t see any keys:

ls /etc/opkg/
arch.conf        base-feeds.conf  opkg.conf 

-----
cat /etc/opkg/arch.conf 
arch all 1
arch any 6
arch noarch 11
arch armv5hf-vfp 16
arch armv5thf-vfp 21
arch armv5ehf-vfp 26
arch armv5tehf-vfp 31
arch armv6hf-vfp 36
arch armv6thf-vfp 41
arch armv7ahf-vfp 46
arch armv7at2hf-vfp 51
arch multi_v7_ml 56
-----
cat /etc/opkg/base-feeds.conf
src/gz uri-all-0 http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/all
src/gz uri-armv7at2hf-vfp-0 http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/armv7at2hf-vfp
src/gz uri-multi_v7_ml-0 http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/multi_v7_ml
-----
cat /etc/opkg/opkg.conf 
# Must have one or more source entries of the form:
#
#   src &lt;src-name&gt; &lt;source-url&gt;
#
# and one or more destination entries of the form:
#
#   dest &lt;dest-name&gt; &lt;target-path&gt;
#
# where &lt;src-name&gt; and &lt;dest-names&gt; are identifiers that
# should match [a-zA-Z0-9._-]+, &lt;source-url&gt; should be a
# URL that points to a directory containing a Familiar
# Packages file, and &lt;target-path&gt; should be a directory
# that exists on the target system.

# Proxy Support
#option http_proxy http://proxy.tld:3128
#option ftp_proxy http://proxy.tld:3128
#option proxy_username &lt;username&gt;
#option proxy_password &lt;password&gt;

# Enable GPGME signature
# option check_signature 1

# Offline mode (for use in constructing flash images offline)
#option offline_root target

# Default destination for installed packages
dest root /
option lists_dir /var/lib/opkg/lists
-----

It looks like, for some reason, option check_signature 1 is not enabled by default.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88574</commentid>
    <comment_count>2</comment_count>
    <who name="Robert Berger">pokylinux</who>
    <bug_when>2020-11-08 03:15:27 +0000</bug_when>
    <thetext>after updating /etc/opkg/opkg.conf:

# Enable GPGME signature
option check_signature 1

opkg update
Downloading http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/all/Packages.gz.
Downloading http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/all/Packages.sig.
wget: server returned error: HTTP/1.1 404 Not Found
Downloading http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/armv7at2hf-vfp/Packages.gz.
Downloading http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/armv7at2hf-vfp/Packages.sig.
wget: server returned error: HTTP/1.1 404 Not Found
Downloading http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/multi_v7_ml/Packages.gz.
Downloading http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/multi_v7_ml/Packages.sig.
wget: server returned error: HTTP/1.1 404 Not Found
Collected errors:
 * opkg_download_backend: Failed to download http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/all/Packages.sig, wget returned 1.
 * pkg_src_download_signature: Failed to download signature for uri-all-0.
 * opkg_download_backend: Failed to download http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/armv7at2hf-vfp/Packages.sig, wget returned 1.
 * pkg_src_download_signature: Failed to download signature for uri-armv7at2hf-vfp-0.
 * opkg_download_backend: Failed to download http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/multi_v7_ml/Packages.sig, wget returned 1.
 * pkg_src_download_signature: Failed to download signature for uri-multi_v7_ml-0.
root@multi-v7-ml:/etc/opkg#</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88575</commentid>
    <comment_count>3</comment_count>
    <who name="Robert Berger">pokylinux</who>
    <bug_when>2020-11-08 06:33:46 +0000</bug_when>
    <thetext>I think first of all I would like to know what should work and how it is supposed to work.

1) GPG signed packages 

Are they supposed to work?

How?

2) GPG signed package feed

Is this supposed to work?

How?

At the moment I get something like this when I try to install something:

root@multi-v7-ml:/etc/opkg# opkg update
Downloading http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/all/Packages.gz.
Updated source &apos;uri-all-0&apos;.
Downloading http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/armv7at2hf-vfp/Packages.gz.
Updated source &apos;uri-armv7at2hf-vfp-0&apos;.
Downloading http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/multi_v7_ml/Packages.gz.
Updated source &apos;uri-multi_v7_ml-0&apos;.


root@multi-v7-ml:/etc/opkg# opkg install socat
Installing openssl-conf (1.1.1g) on root
Downloading http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/armv7at2hf-vfp/openssl-conf_1.1.1g-r0.0_armv7at2hf-vfp.ipk.
Downloading http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/armv7at2hf-vfp/openssl-conf_1.1.1g-r0.0_armv7at2hf-vfp.ipk.asc.
Removing corrupt package file /var/cache/opkg/259c9a2b8ab82706cdc12418377ef39a_openssl-conf_1.1.1g-r0.0_armv7at2hf-vfp.ipk.
Collected errors:
 * opkg_verify_gpg_signature: GPG signature checking not supported
 * opkg_install_pkg: Failed to download openssl-conf. Perhaps you need to run &apos;opkg update&apos;?

And there are more dependencies missing.
Even after I install all of them I get:

root@multi-v7-ml:/etc/opkg# opkg install socat
Installing socat (1.7.3.4) on root
Downloading http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/armv7at2hf-vfp/socat_1.7.3.4-r0.0_armv7at2hf-vfp.ipk.
Downloading http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/armv7at2hf-vfp/socat_1.7.3.4-r0.0_armv7at2hf-vfp.ipk.asc.
Removing corrupt package file /var/cache/opkg/e04f6b0b80a178af9a026a426dcc3e2e_socat_1.7.3.4-r0.0_armv7at2hf-vfp.ipk.
Collected errors:
 * opkg_verify_gpg_signature: GPG signature checking not supported
 * opkg_install_pkg: Failed to download socat. Perhaps you need to run &apos;opkg update&apos;?
root@multi-v7-ml:/etc/opkg#</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88576</commentid>
    <comment_count>4</comment_count>
    <who name="Robert Berger">pokylinux</who>
    <bug_when>2020-11-08 06:37:27 +0000</bug_when>
    <thetext>This might explain it:

#ifdef HAVE_GPGME
#include &quot;opkg_gpg.h&quot;
#else
/* Dummy gpg signature verification. */
int opkg_verify_gpg_signature(const char *file, const char *sigfile)
{
    (void)file;
    (void)sigfile;

    opkg_msg(ERROR, &quot;GPG signature checking not supported\n&quot;);
    return -1;
}
#endif


opkg seems to be compiled in a way that does not support GPG signatures.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88577</commentid>
    <comment_count>5</comment_count>
    <who name="Robert Berger">pokylinux</who>
    <bug_when>2020-11-08 07:31:05 +0000</bug_when>
    <thetext>a bbappend with something like this might fix the problem:

PACKAGECONFIG_append += &quot; gpg curl ssl-curl openssl sha256&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88579</commentid>
    <comment_count>6</comment_count>
    <who name="Robert Berger">pokylinux</who>
    <bug_when>2020-11-08 22:05:04 +0000</bug_when>
    <thetext>at the moment I am stuck here:

root@multi-v7-ml:/etc/opkg# opkg-key list
/etc/opkg/gpg/pubring.kbx
-------------------------
pub   rsa4096 2020-11-08 [SC]
      5AF9D0B2D912A43D33D42283DDAF4E22711C5AE8
uid           [ unknown] ipkkey (ipkkey) &lt;ipkkey@reliableembeddedsystems.com&gt;
sub   rsa4096 2020-11-08 [E]

root@multi-v7-ml:/etc/opkg# opkg install strace
Installing strace (5.5) on root
Downloading http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/armv7at2hf-vfp/strace_5.5-r0.0_armv7at2hf-vfp.ipk.
Downloading http://192.168.42.1/imx6q-phytec-mira-rdk-nand/core-image-minimal-package-repo/3.1.2/core-image-minimal-package-ipk/armv7at2hf-vfp/strace_5.5-r0.0_armv7at2hf-vfp.ipk.sig.
Removing corrupt package file /var/cache/opkg/8367fa7a9862abe8862f7896764b7a50_strace_5.5-r0.0_armv7at2hf-vfp.ipk.
Collected errors:
 * opkg_verify_gpg_signature: No sufficently trusted public keys found.
 * opkg_install_pkg: Failed to download strace. Perhaps you need to run &apos;opkg update&apos;?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88580</commentid>
    <comment_count>7</comment_count>
    <who name="Robert Berger">pokylinux</who>
    <bug_when>2020-11-08 23:16:28 +0000</bug_when>
    <thetext>something like this seems to fix it:

vi /usr/bin/opkg-key

echo &quot;  trust               - Trust the key&quot;

   trust)
        (echo trust &amp;echo 5 &amp;echo y &amp;echo quit) | $GPG --command-fd 0 --edit-key ipkkey
        ;;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88581</commentid>
    <comment_count>8</comment_count>
    <who name="Robert Berger">pokylinux</who>
    <bug_when>2020-11-09 01:35:29 +0000</bug_when>
    <thetext>I somehow managed to have signed packages working now by 

*) adding key
*) trusting key
*) etc/opkg.conf changes

which was achieved by 

additions to local.conf 

and 

opkg_%.bbappend  
opkg-keyrings_1.0.bbappend

----

I seriously doubt that this was (ever) tested!

----

Next up are signed package feeds, which do not work by default, most likely because the files produced by default are .asc files and opkg wants .sig by default.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88582</commentid>
    <comment_count>9</comment_count>
    <who name="Robert Berger">pokylinux</who>
    <bug_when>2020-11-09 01:36:11 +0000</bug_when>
    <thetext>forgot:

*) reconfiguring opkg to use gpg</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88597</commentid>
    <comment_count>10</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2020-11-12 15:39:52 +0000</bug_when>
    <thetext>Robert, can you send a patch? Bonus marks if there&apos;s a test to help us detect regressions.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88607</commentid>
    <comment_count>11</comment_count>
    <who name="Robert Berger">pokylinux</who>
    <bug_when>2020-11-12 17:37:23 +0000</bug_when>
    <thetext>Well things are not that simple ;)

That&apos;s what I plan to do:

1) Write a series of articles what I did to get it working.

Hopefully someone can review that and tell me what to improve in order to be upstreamable

2) I don&apos;t think it&apos;s just a patch, but I need:

2.1) a patch to meta/classes/sign_ipk.bbclass to use native-gpg which allows for &quot;parallel&quot; invocation of gpg (from multiple recipes at the same time)

2.2) a custom meta-layer with a .bbappend to 

2.2.1) add the key to the rootfs

2.2.2) add to the opkg-key command a &quot;trust&quot; option (which should go into the main recipe as a patch?)

2.2.3) to tell opkg.conf that package signing should be enabled - maybe by default if the relevant setting in local.conf is made

2.2.4) to tell opkg.conf that package feed signing should be used - maybe by default if the relevant setting in local.conf is made

2.2.5) to tell opkg.conf that signature_type gpg (default) is used .sig - maybe by default if the relevant setting in local.conf is made -&gt; the other option would be ascii keys

The defaults between opkg and bitbake classes are exactly the opposite (ascii the one binary the other)

3) various settings in local.conf which configure package/package feed signing

There are various inconsistencies between the classes and what opkg can do (as far as I understand) e.g. opkg seems to support either binary or ascii keys, but in the config I could choose binary for package signing and ascii for package feed signing.

---------------

Besides I also need:

4) proper date/time on the target for gpg to work e.g. via ntp

5) gpg keys generation/export/import

----------------

So all this is a mix of documentation, configuration and patches/hacks

----------------

Once all this is done I can also have a look into a test similar to the one for rpms.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88608</commentid>
    <comment_count>12</comment_count>
    <who name="Robert Berger">pokylinux</who>
    <bug_when>2020-11-12 17:43:18 +0000</bug_when>
    <thetext>I forgot:

*) a post_install_append file to also trust the key and not just add it to the system.

At the moment I have this in my custom layer, but I guess this should go into the recipe instead of bbappend.

*) gpg needs to be compiled with gpg support, which is not the default, but maybe could be added based on .local.conf (signing) settings.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88609</commentid>
    <comment_count>13</comment_count>
    <who name="Robert Berger">pokylinux</who>
    <bug_when>2020-11-12 17:46:29 +0000</bug_when>
    <thetext>not gpg, but opkg needs to be compiled with gpg support</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89651</commentid>
    <comment_count>14</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2021-03-18 15:04:05 +0000</bug_when>
    <thetext>3.3 development is closed, move to 3.4</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96798</commentid>
    <comment_count>15</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2023-10-24 14:24:20 +0000</bug_when>
    <thetext>Bulk move from 4.99 or 0.00 to 5.99</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105845</commentid>
    <comment_count>16</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2026-06-11 15:38:54 +0000</bug_when>
    <thetext>Did you write the articles? It would be good to put the details here if there is anything further?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106167</commentid>
    <comment_count>17</comment_count>
    <who name="Robert Berger">pokylinux</who>
    <bug_when>2026-07-14 21:58:34 +0000</bug_when>
    <thetext>I did not write any articles. The only thing I have is some layer I hacked together 5 years ago: https://gitlab.com/meta-layers/meta-pkg

Not sure when I will have time to play with this.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>