#1533 rpmbuild: use mock --srpmbuild for spec file uploads
Merged 3 years ago by praiskup. Opened 3 years ago by praiskup.

file modified
+2 -2
@@ -222,7 +222,7 @@

  install -m 644 main.ini %{buildroot}%{_sysconfdir}/copr-rpmbuild/main.ini

  install -m 644 mock.cfg.j2 %{buildroot}%{_sysconfdir}/copr-rpmbuild/mock.cfg.j2

  install -m 644 rpkg.conf.j2 %{buildroot}%{_sysconfdir}/copr-rpmbuild/rpkg.conf.j2

- install -m 644 make_srpm_mock.cfg %{buildroot}%{_sysconfdir}/copr-rpmbuild/make_srpm_mock.cfg

+ install -m 644 mock-source-build.cfg %{buildroot}%{_sysconfdir}/copr-rpmbuild/

  

  cat <<EOF > %buildroot%mock_config_overrides/README

  Contents of this directory is used by %_bindir/copr-update-builder script.
@@ -284,7 +284,7 @@

  %config(noreplace) %{_sysconfdir}/copr-rpmbuild/main.ini

  %config(noreplace) %{_sysconfdir}/copr-rpmbuild/mock.cfg.j2

  %config(noreplace) %{_sysconfdir}/copr-rpmbuild/rpkg.conf.j2

- %config(noreplace) %{_sysconfdir}/copr-rpmbuild/make_srpm_mock.cfg

+ %config(noreplace) %{_sysconfdir}/copr-rpmbuild/mock-source-build.cfg

  

  %files -n copr-builder

  %license LICENSE

@@ -107,7 +107,7 @@

              .format(mock_cwd, makefile_path, mock_outdir, mock_spec_path)

  

          return ['mock', '--uniqueext', get_mock_uniqueext(),

-                 '-r', '/etc/copr-rpmbuild/make_srpm_mock.cfg',

+                 '-r', '/etc/copr-rpmbuild/mock-source-build.cfg',

                  mock_bind_mount_cmd_part, '--chroot', make_srpm_cmd_part]

  

      def produce_srpm(self):

@@ -24,7 +24,10 @@

  

      def build_srpm_from_spec(self):

          spec_path = self.save_spec()

-         cmd = ["rpkg", "srpm", "--outdir", self.outdir, '--spec', spec_path]

+         cmd = ["mock", "-r", "/etc/copr-rpmbuild/mock-source-build.cfg",

+                "--srpmbuild", "--spec", spec_path,

+                "--define", "_disable_source_fetch 0",

I am thinking whether we shouldn't put this into the mock-source-build.cfg

The thing is that we use it for make srpm, and I'm not sure it is correct to enable it there. Opinions?

+                "--resultdir", self.outdir]

          return run_cmd(cmd, cwd=self.workdir)

  

      def download_srpm(self):

rpmbuild/mock-source-build.cfg rpmbuild/make_srpm_mock.cfg
file renamed
file was moved with no change to the file
file modified
+1 -1
@@ -124,7 +124,7 @@

          make_srpm_cmd_part = 'cd /mnt{0}/somerepo/subpkg; make -f /mnt{1}/somerepo/.copr/Makefile srpm '\

                               'outdir="/mnt{2}" spec="/mnt{3}/somerepo/subpkg/pkg.spec"'\

                               .format(provider.workdir, provider.workdir, self.resultdir, provider.workdir)

-         assert_cmd = ['mock', '--uniqueext', '2', '-r', '/etc/copr-rpmbuild/make_srpm_mock.cfg',

+         assert_cmd = ['mock', '--uniqueext', '2', '-r', '/etc/copr-rpmbuild/mock-source-build.cfg',

                        bind_mount_cmd_part, '--chroot', make_srpm_cmd_part]

  

          self.assertEqual(provider.get_make_srpm_command(), assert_cmd)

file modified
+7 -3
@@ -46,9 +46,13 @@

      def test_produce_srpm(self, mock_mkdir, mock_open, run_cmd, mock_get):

          provider = UrlProvider(self.source_json, self.resultdir, self.config)

          provider.produce_srpm()

-         run_cmd.assert_called_with(["rpkg", "srpm", "--outdir", self.resultdir,

-                                     "--spec", '{0}/somepackage.spec'.format(provider.workdir)],

-                                    cwd=provider.workdir)

+         args = [

+             'mock', '-r', '/etc/copr-rpmbuild/mock-source-build.cfg',

+             '--srpmbuild',

+             '--spec', '{0}/somepackage.spec'.format(provider.workdir),

+             '--define', '_disable_source_fetch 0',

+             '--resultdir', self.resultdir]

+         run_cmd.assert_called_with(args, cwd=provider.workdir)

  

      @mock.patch('requests.get')

      @mock.patch('{0}.open'.format(builtins), new_callable=mock.mock_open())

rebased onto 18a1c1802741afcb888c7d622433daf173acda2d

3 years ago

I am thinking whether we shouldn't put this into the mock-source-build.cfg

Just a small thing to think about, otherwise LGTM

The thing is that we use it for make srpm, and I'm not sure it is correct to enable it there. Opinions?

The thing is that we use it for make srpm, and I'm not sure it is correct to enable it there. Opinions?

I think I'd prefer if we could keep make_srpm method unaffected by automatic tarball downloading for now, so unless you are against ... does it invalidate the LGTM above?

I think I'd prefer if we could keep make_srpm method unaffected by automatic tarball downloading for now, so unless you are against ...

No, no, I am fine with that. I think it should be fine either way because make_srpm can override the value that we set by default.

rebased onto 8efff4c

3 years ago

Pull-Request has been merged by praiskup

3 years ago