#132 write-repo-file: add --gpgcheck and --gpgkey options
Merged 9 months ago by lsedlar. Opened 9 months ago by ktdreyer.
ktdreyer/compose-utils write-repo-gpgcheck  into  master

file modified
+14 -2
@@ -13,7 +13,7 @@ 

  name = {name}

  baseurl = {baseurl}

  enabled = {enabled}

- gpgcheck = 0

+ gpgcheck = {gpgcheck}

  """

  

  CONTENT_TYPES = {
@@ -86,7 +86,10 @@ 

          if not is_url(baseurl):

              baseurl = "file://" + baseurl

  

-     content = REPO.format(name=name, enabled=enabled, baseurl=baseurl)

+     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)

  

  
@@ -160,6 +163,15 @@ 

          default="{release_short}-{release_version}-{variant}",

          help="Pattern for repository names.",

      )

+     parser.add_argument(

+         "--gpgcheck",

+         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:

@@ -0,0 +1,12 @@ 

+ [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

+ 

+ [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

+ 

@@ -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

+ 

file modified
+9
@@ -101,6 +101,15 @@ 

              "/Client/$basearch/os does not start with /foo/bar.\n", mock_err.getvalue()

          )

  

+     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'))

This is a simpler, declarative approach to my initial implementation in #119.

--gpgcheck is a boolean and causes the repo to have gpgcheck = 1 for all variants.
--gpgkey takes an arbitrary string.

Oh yeah, this is much simpler and nicer! Thank you for the patch!

Pull-Request has been merged by lsedlar

9 months ago

PR #133 adds the options to the man page.