#430 Pass --disablerepo and --enablerepo to mock
Merged 2 years ago by onosek. Opened 2 years ago by onosek.
onosek/rpkg mock_disablerepo  into  master

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

              help='Run commands interactively within chroot. Before going into'

                   ' chroot, mockbuild needs to run with --no-cleanup-after '

                   'in advanced.')

+         mockbuild_parser.add_argument(

+             '--enablerepo', action='append',

+             help='Pass enablerepo option to yum/dnf (may be used more than once)')

+         mockbuild_parser.add_argument(

+             '--disablerepo', action='append',

+             help='Pass disablerepo option to yum/dnf (may be used more than once)')

          mockbuild_parser.set_defaults(command=self.mockbuild)

  

      def register_mock_config(self):
@@ -1988,6 +1994,14 @@ 

              for arg in self.args.bcond_without:

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

  

+         if self.args.enablerepo:

+             for repo_value in self.args.enablerepo:

+                 mockargs.extend(['--enablerepo', repo_value])

+ 

+         if self.args.disablerepo:

+             for repo_value in self.args.disablerepo:

+                 mockargs.extend(['--disablerepo', repo_value])

+ 

          # Pick up any mockargs from the env

          try:

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

file modified
+7 -2
@@ -1445,10 +1445,15 @@ 

      def test_mockbuild(self):

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

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

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

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

+                    '--enablerepo', 'FAVOURITE_REPO', '--disablerepo', 'UNWANTED_REPO',

+                    '--enablerepo', 'ANOTHER_FAVOURITE_REPO']

          cli = self.mockbuild(cli_cmd)

  

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

+         expected_cmd = ['mock', '--enablerepo', 'FAVOURITE_REPO',

+                         '--enablerepo', 'ANOTHER_FAVOURITE_REPO',

+                         '--disablerepo', 'UNWANTED_REPO',

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

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

                          cli.cmd.srpmname]

          self.mock_run_command.assert_called_with(expected_cmd)

Mockbuild: pass arguments '--disablerepo' and '--enablerepo' to 'mock'
command.

JIRA: COMPOSE-3367
Fixes: https://pagure.io/fedpkg/issue/313

Signed-off-by: Ondrej Nosek onosek@redhat.com

Looks good. I think it would be nice to enable passing this option multiple times. Mock supports it as well.

As an alternative, would it make sense to accept any arguments to mockbuild commands, and whatever is not consumed by *pkg would be passed to mock?

rebased onto 03e7e44789420f2158936ae2cb8ddd6eef295210

2 years ago

Thanks for notifying me about argument repetition. I submitted a new version to implement this.
But I am afraid to do the second suggestion. It could be quite tough as parse_args call is in the code just once.

rebased onto f0d0f57

2 years ago

Pull-Request has been merged by onosek

2 years ago