xref: /OK3568_Linux_fs/yocto/poky/meta/recipes-devtools/opkg/opkg-keyrings_1.0.bb (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunSUMMARY = "Keyrings for verifying opkg packages and feeds"
2*4882a593SmuzhiyunLICENSE = "MIT"
3*4882a593SmuzhiyunLIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun# Distro-specific keys can be added to this package in two ways:
6*4882a593Smuzhiyun#
7*4882a593Smuzhiyun#   1) In a .bbappend, add .gpg and/or .asc files to SRC_URI and install them to
8*4882a593Smuzhiyun#      ${D}${datadir}/opkg/keyrings/ in a do_install:append function. These
9*4882a593Smuzhiyun#      files should not be named 'key-$name.gpg' to ensure they don't conflict
10*4882a593Smuzhiyun#      with keys exported as per (2).
11*4882a593Smuzhiyun#
12*4882a593Smuzhiyun#   2) In a .bbappend, distro config or local.conf, override the variable
13*4882a593Smuzhiyun#      OPKG_KEYRING_KEYS to contain a space-separated list of key names. For
14*4882a593Smuzhiyun#      each name, 'gpg --export $name' will be ran to export the public key to a
15*4882a593Smuzhiyun#      file named 'key-$name.gpg'. The public key must therefore be in the gpg
16*4882a593Smuzhiyun#      keyrings on the build machine.
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunOPKG_KEYRING_KEYS ?= ""
19*4882a593Smuzhiyun
20*4882a593Smuzhiyundo_compile() {
21*4882a593Smuzhiyun    for name in ${OPKG_KEYRING_KEYS}; do
22*4882a593Smuzhiyun        gpg --export ${name} > ${B}/key-${name}.gpg
23*4882a593Smuzhiyun    done
24*4882a593Smuzhiyun}
25*4882a593Smuzhiyun
26*4882a593Smuzhiyundo_install () {
27*4882a593Smuzhiyun    install -d ${D}${datadir}/opkg/keyrings/
28*4882a593Smuzhiyun    for name in ${OPKG_KEYRING_KEYS}; do
29*4882a593Smuzhiyun        install -m 0644 ${B}/key-${name}.gpg ${D}${datadir}/opkg/keyrings/
30*4882a593Smuzhiyun    done
31*4882a593Smuzhiyun}
32*4882a593Smuzhiyun
33*4882a593SmuzhiyunFILES:${PN} = "${datadir}/opkg/keyrings"
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun# We need 'opkg-key' to run the postinst script
36*4882a593SmuzhiyunRDEPENDS:${PN} = "opkg"
37*4882a593Smuzhiyun
38*4882a593Smuzhiyunpkg_postinst_ontarget:${PN} () {
39*4882a593Smuzhiyun    if test -x ${bindir}/opkg-key
40*4882a593Smuzhiyun    then
41*4882a593Smuzhiyun        ${bindir}/opkg-key populate
42*4882a593Smuzhiyun    fi
43*4882a593Smuzhiyun}
44