write-repo-file: add --gpgkey argument

Support "gpgkey = file://path/to/key"
This commit is contained in:
Ken Dreyer 2023-07-06 23:25:49 -04:00
commit 7bacb715f5
3 changed files with 26 additions and 0 deletions

View file

@ -88,6 +88,8 @@ def emit(compose, opts, variant, output, content_type="repository"):
content = REPO.format(name=name, enabled=enabled, baseurl=baseurl,
gpgcheck=int(opts.gpgcheck))
if opts.gpgkey:
content += "gpgkey = %s\n" % opts.gpgkey
print(content, file=output)
@ -166,6 +168,10 @@ def main(args=None):
action="store_true",
help="Enable gpgcheck = 1. Default is gpgcheck = 0.",
)
parser.add_argument(
"--gpgkey",
help="gpgkey value (public key URL). Multiple key URLs should be comma-separated. Use --gpgcheck with this option.",
)
opts = parser.parse_args(args)
try:

14
tests/fixtures/gpgkey.repo vendored Normal file
View file

@ -0,0 +1,14 @@
[DP-1.0-Client-rpms]
name = DP-1.0-Client-rpms
baseurl = file:///composes/DP-1.0-20160315.t.0/compose/Client/$basearch/os
enabled = 1
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-DummyProduct
[DP-1.0-Server-rpms]
name = DP-1.0-Server-rpms
baseurl = file:///composes/DP-1.0-20160315.t.0/compose/Server/$basearch/os
enabled = 1
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-DummyProduct

View file

@ -104,6 +104,12 @@ class TestRepoFile(unittest.TestCase):
def test_gpgcheck(self):
self.success_run(["--gpgcheck"], "DP-1.0-20160315.t.0", "gpgcheck.repo")
def test_gpgkey(self):
self.success_run(
["--gpgcheck",
"--gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-DummyProduct"],
"DP-1.0-20160315.t.0", "gpgkey.repo")
def test_is_url(self):
self.assertTrue(repo_file.is_url('http://example.com/foobar'))
self.assertTrue(repo_file.is_url('https://example.com/foobar'))