diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2016-01-25 14:21:34 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-01-26 22:31:58 +0000 |
commit | bb971577ab308caf7177d4bda290d1fe5ab842db (patch) | |
tree | 49c1811106a9b58717dcfd3c6fe4e4810341c1b3 /meta/lib/oe/package_manager.py | |
parent | aadb879e5b302e405e05443f56611c17868d10b6 (diff) | |
download | poky-bb971577ab308caf7177d4bda290d1fe5ab842db.tar.gz |
meta/lib: new module for handling GPG signing
Add a new Python module (oe.gpg_sign) for handling GPG signing
operations, i.e. currently package and package feed signing. The purpose
is to be able to more easily support various signing backends and to be
able to centralise signing functionality into one place (e.g. package
signing and sstate signing). Currently, only local signing with gpg is
implemented.
[YOCTO #8755]
(From OE-Core rev: 9b3dc1bd4b8336423a3f8f7db0ab5fa6fa0e7257)
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe/package_manager.py')
-rw-r--r-- | meta/lib/oe/package_manager.py | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py index 5b87f45127..3f9e4e3b60 100644 --- a/meta/lib/oe/package_manager.py +++ b/meta/lib/oe/package_manager.py | |||
@@ -9,6 +9,7 @@ import bb | |||
9 | import tempfile | 9 | import tempfile |
10 | import oe.utils | 10 | import oe.utils |
11 | import string | 11 | import string |
12 | from oe.gpg_sign import get_signer | ||
12 | 13 | ||
13 | # this can be used by all PM backends to create the index files in parallel | 14 | # this can be used by all PM backends to create the index files in parallel |
14 | def create_index(arg): | 15 | def create_index(arg): |
@@ -109,16 +110,14 @@ class RpmIndexer(Indexer): | |||
109 | 110 | ||
110 | rpm_createrepo = bb.utils.which(os.getenv('PATH'), "createrepo") | 111 | rpm_createrepo = bb.utils.which(os.getenv('PATH'), "createrepo") |
111 | if self.d.getVar('PACKAGE_FEED_SIGN', True) == '1': | 112 | if self.d.getVar('PACKAGE_FEED_SIGN', True) == '1': |
112 | pkgfeed_gpg_name = self.d.getVar('PACKAGE_FEED_GPG_NAME', True) | 113 | signer = get_signer(self.d, |
113 | pkgfeed_gpg_pass = self.d.getVar('PACKAGE_FEED_GPG_PASSPHRASE_FILE', True) | 114 | self.d.getVar('PACKAGE_FEED_GPG_BACKEND', True), |
115 | self.d.getVar('PACKAGE_FEED_GPG_NAME', True), | ||
116 | self.d.getVar('PACKAGE_FEED_GPG_PASSPHRASE_FILE', True)) | ||
114 | else: | 117 | else: |
115 | pkgfeed_gpg_name = None | 118 | signer = None |
116 | pkgfeed_gpg_pass = None | ||
117 | gpg_bin = self.d.getVar('GPG_BIN', True) or \ | ||
118 | bb.utils.which(os.getenv('PATH'), "gpg") | ||
119 | |||
120 | index_cmds = [] | 119 | index_cmds = [] |
121 | repo_sign_cmds = [] | 120 | repomd_files = [] |
122 | rpm_dirs_found = False | 121 | rpm_dirs_found = False |
123 | for arch in archs: | 122 | for arch in archs: |
124 | dbpath = os.path.join(self.d.getVar('WORKDIR', True), 'rpmdb', arch) | 123 | dbpath = os.path.join(self.d.getVar('WORKDIR', True), 'rpmdb', arch) |
@@ -130,15 +129,7 @@ class RpmIndexer(Indexer): | |||
130 | 129 | ||
131 | index_cmds.append("%s --dbpath %s --update -q %s" % \ | 130 | index_cmds.append("%s --dbpath %s --update -q %s" % \ |
132 | (rpm_createrepo, dbpath, arch_dir)) | 131 | (rpm_createrepo, dbpath, arch_dir)) |
133 | if pkgfeed_gpg_name: | 132 | repomd_files.append(os.path.join(arch_dir, 'repodata', 'repomd.xml')) |
134 | repomd_file = os.path.join(arch_dir, 'repodata', 'repomd.xml') | ||
135 | gpg_cmd = "%s --detach-sign --armor --batch --no-tty --yes " \ | ||
136 | "--passphrase-file '%s' -u '%s' " % \ | ||
137 | (gpg_bin, pkgfeed_gpg_pass, pkgfeed_gpg_name) | ||
138 | if self.d.getVar('GPG_PATH', True): | ||
139 | gpg_cmd += "--homedir %s " % self.d.getVar('GPG_PATH', True) | ||
140 | gpg_cmd += repomd_file | ||
141 | repo_sign_cmds.append(gpg_cmd) | ||
142 | 133 | ||
143 | rpm_dirs_found = True | 134 | rpm_dirs_found = True |
144 | 135 | ||
@@ -151,9 +142,9 @@ class RpmIndexer(Indexer): | |||
151 | if result: | 142 | if result: |
152 | bb.fatal('%s' % ('\n'.join(result))) | 143 | bb.fatal('%s' % ('\n'.join(result))) |
153 | # Sign repomd | 144 | # Sign repomd |
154 | result = oe.utils.multiprocess_exec(repo_sign_cmds, create_index) | 145 | if signer: |
155 | if result: | 146 | for repomd in repomd_files: |
156 | bb.fatal('%s' % ('\n'.join(result))) | 147 | signer.detach_sign(repomd) |
157 | # Copy pubkey(s) to repo | 148 | # Copy pubkey(s) to repo |
158 | distro_version = self.d.getVar('DISTRO_VERSION', True) or "oe.0" | 149 | distro_version = self.d.getVar('DISTRO_VERSION', True) or "oe.0" |
159 | if self.d.getVar('RPM_SIGN_PACKAGES', True) == '1': | 150 | if self.d.getVar('RPM_SIGN_PACKAGES', True) == '1': |