#291 Add --with and --without options to 'local'
Merged 5 years ago by cqi. Opened 6 years ago by tmz.

file modified
+4 -3
@@ -2197,10 +2197,11 @@ 

          # Run the command

          self._run_command(cmd, shell=True)

  

-     def local(self, arch=None, hashtype=None, builddir=None):

+     def local(self, localargs, arch=None, hashtype=None, builddir=None):

          """rpmbuild locally for given arch.

  

-         Takes arch to build for, and hashtype to build with.

+         Takes localargs (passed to rpmbuild), arch to build for, and hashtype

+         to build with.

  

          Writes output to a log file and logs it to the logger

  
@@ -2211,7 +2212,7 @@ 

          # Get the sources

          # build up the rpm command

          cmd = ['rpmbuild']

-         cmd.extend(self.rpmdefines)

+         cmd.extend(self.rpmdefines + localargs)

          if builddir:

              # Tack on a new builddir to the end of the defines

              cmd.append("--define '_builddir %s'" % os.path.abspath(builddir))

file modified
+19 -1
@@ -649,6 +649,13 @@ 

          local_parser.add_argument(

              '--md5', action='store_const', const='md5', default=None,

              dest='hash', help='Use md5 checksums (for older rpm hosts)')

+         # Pass --with/without options to rpmbuild

+         local_parser.add_argument(

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

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

+         local_parser.add_argument(

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

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

          local_parser.set_defaults(command=self.local)

  

      def register_new(self):
@@ -1385,7 +1392,18 @@ 

  

      def local(self):

          self.sources()

-         self.cmd.local(arch=self.args.arch, hashtype=self.args.hash,

+ 

+         localargs = []

+ 

+         if self.args.bcond_with:

+             for arg in self.args.bcond_with:

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

+ 

+         if self.args.bcond_without:

+             for arg in self.args.bcond_without:

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

+ 

+         self.cmd.local(localargs, arch=self.args.arch, hashtype=self.args.hash,

                         builddir=self.args.builddir)

  

      def mockbuild(self):

file modified
+3 -2
@@ -603,7 +603,7 @@ 

          builddir = os.path.join(self.cloned_repo_path, 'this-builddir')

  

          cli_cmd = ['rpkg', '--path', self.cloned_repo_path, '--release', 'rhel-6', '-q', 'local',

-                    '--builddir', builddir, '--arch', 'i686']

+                    '--builddir', builddir, '--arch', 'i686', '--with', 'a', '--without', 'b']

  

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

              cli = self.new_cli()
@@ -611,7 +611,8 @@ 

  

          spec = os.path.join(cli.cmd.path, cli.cmd.spec)

          rpmbuild = ['rpmbuild'] + cli.cmd.rpmdefines + \

-             ["--define '_builddir %s'" % builddir, '--target', 'i686', '--quiet', '-ba', spec]

+             ['--with', 'a', '--without', 'b', "--define '_builddir %s'" % builddir,

+              '--target', 'i686', '--quiet', '-ba', spec]

          tee = ['tee', '.build-%s-%s.log' % (cli.cmd.ver, cli.cmd.rel)]

  

          cmd = '%s | %s; exit "${PIPESTATUS[0]} ${pipestatus[1]}"' % (

The 'mockbuild' command learned these options in 69b3864 ("Add --with
and --without options to mockbuild", 2017-08-17).

Resolves: rhbz#1533416
Signed-off-by: Todd Zullinger tmz@pobox.com

I ran across https://bugzilla.redhat.com/show_bug.cgi?id=1533416 and thought it might be a relatively easy-fix. I don't have a particular use for it, but if it helps others that's good too. I didn't add a separate test for this as it didn't seem to warrant one. But it shouldn't be too hard to split it out and test separately if desired.

With the localargs support we could also now easily add things like --nocheck or other commonly used rpmbuild options.

pretty please pagure-ci rebuild

@tmz Can you fix the errors? Thanks.

@cqi, the errors are on master, after #295 was merged. I ran git bisect, which tells me " 3f93433 is the first bad commit." I should have just run the tests on master first. I didn't expect that master would be broken. But it appears to be the problem.

@tmz Sorry. That failure test is not relative to your patch. Only the flake8 error needs to be fixed.

rebased onto d94c870

5 years ago

Ahh, well that's easy. :)

I wrapped the line and updated my local-with-without-support branch.

@tmz Thank you very much. :thumbsup:

Commit bd3fb01 fixes this pull-request

Pull-Request has been merged by cqi

5 years ago

Pull-Request has been merged by cqi

5 years ago