#237 Add --with and --without options to mockbuild
Merged 6 years ago by lsedlar. Opened 6 years ago by pviktori.
pviktori/rpkg mockbuild-bcond  into  master

file modified
+14
@@ -685,6 +685,12 @@ 

          mockbuild_parser.add_argument(

              '--no-clean-all', '-N', help='Alias for both --no-clean and '

              '--no-cleanup-after', action='store_true')

+         mockbuild_parser.add_argument(

+             '--with', help='Enable configure option (bcond) for the build',

+             dest='bcond_with', action='append')

+         mockbuild_parser.add_argument(

+             '--without', help='Disable configure option (bcond) for the build',

+             dest='bcond_without', action='append')

          mockbuild_parser.set_defaults(command=self.mockbuild)

  

      def register_mock_config(self):
@@ -1298,6 +1304,14 @@ 

          if self.args.no_cleanup_after or self.args.no_clean_all:

              mockargs.append('--no-cleanup-after')

  

+         if self.args.bcond_with:

+             for arg in self.args.bcond_with:

+                 mockargs.extend(['--with', arg])

+ 

+         if self.args.bcond_without:

+             for arg in self.args.bcond_without:

+                 mockargs.extend(['--without', arg])

+ 

          # Pick up any mockargs from the env

          try:

              mockargs += os.environ['MOCKARGS'].split()

file modified
+38
@@ -1022,3 +1022,41 @@ 

      def test_import(self):

          self.assert_import_srpm(self.chaos_repo)

          self.assert_import_srpm(self.cloned_repo_path)

+ 

+ 

+ class TestMockbuild(CliTestCase):

+     """Test mockbuild command"""

+ 

+     @patch('pyrpkg.Commands._run_command')

+     def test_mockbuild(self, _run_command):

+         cli_cmd = ['rpkg', '--path', self.cloned_repo_path,

+                    '--release', 'rhel-6', 'mockbuild',

+                    '--root', '/etc/mock/some-root']

+ 

+         with patch('sys.argv', new=cli_cmd):

+             cli = self.new_cli()

+             cli.mockbuild()

+ 

+         expected_cmd = ['mock', '-r', '/etc/mock/some-root',

+                         '--resultdir', cli.cmd.mock_results_dir, '--rebuild',

+                         cli.cmd.srpmname]

+         _run_command.assert_called_with(expected_cmd)

+ 

+     @patch('pyrpkg.Commands._run_command')

+     def test_with_without(self, _run_command):

+         cli_cmd = ['rpkg', '--path', self.cloned_repo_path,

+                    '--release', 'rhel-6', 'mockbuild',

+                    '--root', '/etc/mock/some-root',

+                    '--with', 'a', '--without', 'b', '--with', 'c',

+                    '--without', 'd']

+ 

+         with patch('sys.argv', new=cli_cmd):

+             cli = self.new_cli()

+             cli.mockbuild()

+ 

+         expected_cmd = ['mock', '--with', 'a', '--with', 'c',

+                         '--without', 'b', '--without', 'd',

+                         '-r', '/etc/mock/some-root',

+                         '--resultdir', cli.cmd.mock_results_dir, '--rebuild',

+                         cli.cmd.srpmname]

+         _run_command.assert_called_with(expected_cmd)

These options are passed through to mock to configure the build.

Test included, along with a general test for mockbuild.

rebased

6 years ago

Jenkins fails because flake8 reports over-indented line here.

Looks good to me. Tests are passing locally for me.

1 new commit added

  • Fix indentation
6 years ago

2 new commits added

  • Fix indentation
  • Add --with and --without options to mockbuild
6 years ago

I've added a commit fixing the whitespace. Sorry for that!

Looks good to me.

In addition, I have an idea about passing argument to underlying command. That is, instead of adding arguments to rpkg or fedpkg and passing to underlying command, how about we add one general argument used to pass any potential required extra command line options? To be clear, here is an example,

fedpkg mockbuild -r fedora-25-x86_64 --addopts "--shell --with"

Maybe --addopts could be --extra_opts or something else that can reflect the meaning as much as possible.

That seems unnecessary to me: I don't view rpkg as a generic front-end to mock, and I'm quite happy doing fedpkg srpm and mock manually for complex cases. Note that in these complex cases, I'll usually want to run mock --shell or mock --install without building a package. I don't think combining that with fedpkg mockbuild would make things straightforward.

My use case for --with is that Python's full optimized build and test suite take half an hour, so my usual local builds need --without optimizations.

I don't think passing arbitrary options is particularly useful. Let's not do it unless someone comes with a use case for it.

Is there anything else I can do to help this get merged?

Pull-Request has been merged by lsedlar

6 years ago