diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-29 12:17:42 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-29 12:17:42 +0000 |
commit | 32b09cdd8fcfe7c5d49db5dc9964be987ce5a0a9 (patch) | |
tree | c0e3b2d4d05680f57d6521d85a7396b7580acc23 /0014-import_srpm-allow-pre-generated-srpms.patch | |
parent | 42c179873afdc4ea9634b0e0fbaf391298880998 (diff) |
automatic import of rpkg
Diffstat (limited to '0014-import_srpm-allow-pre-generated-srpms.patch')
-rw-r--r-- | 0014-import_srpm-allow-pre-generated-srpms.patch | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/0014-import_srpm-allow-pre-generated-srpms.patch b/0014-import_srpm-allow-pre-generated-srpms.patch deleted file mode 100644 index f596265..0000000 --- a/0014-import_srpm-allow-pre-generated-srpms.patch +++ /dev/null @@ -1,105 +0,0 @@ -From d87cb37fa2fea2ed535b9085a1f4c607083e1c2e Mon Sep 17 00:00:00 2001 -From: Ondrej Nosek <onosek@redhat.com> -Date: Tue, 4 Apr 2023 01:40:23 +0200 -Subject: [PATCH 1/6] import_srpm: allow pre-generated srpms - -When active, do not care specfile in the srpm is processed by -rpmautospec. Can be activated only directly via pyrpkg 'Commands' -object. - -Relates: https://github.com/fedora-copr/copr/issues/2317 -Fixes: #655 -RHELCMP-11085 - -Signed-off-by: Ondrej Nosek <onosek@redhat.com> ---- - pyrpkg/__init__.py | 6 +++++- - tests/test_cli.py | 41 +++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 46 insertions(+), 1 deletion(-) - -diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py -index 9996402..ecb99c9 100644 ---- a/pyrpkg/__init__.py -+++ b/pyrpkg/__init__.py -@@ -110,7 +110,7 @@ class Commands(object): - build_client, user=None, - dist=None, target=None, quiet=False, - distgit_namespaced=False, realms=None, lookaside_namespaced=False, -- git_excludes=None, results_dir='root'): -+ git_excludes=None, results_dir='root', allow_pre_generated_srpm=False): - """Init the object and some configuration details.""" - - # Path to operate on, most often pwd -@@ -239,6 +239,9 @@ class Commands(object): - # Layout setup - self.layout = layout.build(self.path, - 'resultsdir' if self.results_dir == 'subdir' else None) -+ # A Configuration value used in 'import_srpm' command (comes from the Copr team) -+ # If pre-generated srpms are allowed, don't care specfile is processed by rpmautospec -+ self.allow_pre_generated_srpm = allow_pre_generated_srpm - - # Define properties here - # Properties allow us to "lazy load" various attributes, which also means -@@ -1471,6 +1474,7 @@ class Commands(object): - # the dist-git repo without any specfiles - right after initialization) we are - # not able determine which the main specfile is. - if file.endswith('.spec') and not file.startswith('.') \ -+ and not self.allow_pre_generated_srpm \ - and spec_file_processed_by_rpmautospec(file, target_dir): - raise rpkgError('SRPM was processed by rpmautospec ' - '(specfile "{}" was analyzed)'.format(file)) -diff --git a/tests/test_cli.py b/tests/test_cli.py -index 868ad1f..02620ef 100644 ---- a/tests/test_cli.py -+++ b/tests/test_cli.py -@@ -1784,6 +1784,47 @@ class TestImportSrpm(LookasideCacheMock, CliTestCase): - self.assertFilesExist(['package.rpmlintrc'], search_dir=self.chaos_repo) - self.assertFilesNotExist(['the_file_is_not_in_reserved.yaml'], search_dir=self.chaos_repo) - -+ @patch('pyrpkg.spec_file_processed_by_rpmautospec') -+ def test_import_srpm_not_processed_by_rpmautospec(self, rpmautospec_processed): -+ cli_cmd = ['rpkg', '--path', self.chaos_repo, '--name', 'docpkg', -+ 'import', '--skip-diffs', self.srpm_file] -+ -+ rpmautospec_processed.return_value = False -+ with patch('sys.argv', new=cli_cmd): -+ cli = self.new_cli() -+ with patch('pyrpkg.lookaside.CGILookasideCache.upload', self.lookasidecache_upload): -+ cli.import_srpm() # no exception should be raised -+ rpmautospec_processed.assert_called_once() -+ -+ @patch('pyrpkg.spec_file_processed_by_rpmautospec') -+ def test_import_srpm_processed_by_rpmautospec(self, rpmautospec_processed): -+ cli_cmd = ['rpkg', '--path', self.chaos_repo, '--name', 'docpkg', -+ 'import', '--skip-diffs', self.srpm_file] -+ -+ rpmautospec_processed.return_value = True -+ with patch('sys.argv', new=cli_cmd): -+ cli = self.new_cli() -+ with patch('pyrpkg.lookaside.CGILookasideCache.upload', self.lookasidecache_upload): -+ six.assertRaisesRegex( -+ self, -+ rpkgError, -+ 'SRPM was processed by rpmautospec', -+ cli.import_srpm) -+ rpmautospec_processed.assert_called_once() -+ -+ @patch('pyrpkg.spec_file_processed_by_rpmautospec') -+ def test_import_srpm_processed_by_rpmautospec_allowed(self, rpmautospec_processed): -+ cli_cmd = ['rpkg', '--path', self.chaos_repo, '--name', 'docpkg', -+ 'import', '--skip-diffs', self.srpm_file] -+ -+ rpmautospec_processed.return_value = True -+ with patch('sys.argv', new=cli_cmd): -+ cli = self.new_cli() -+ cli.cmd.allow_pre_generated_srpm = True -+ with patch('pyrpkg.lookaside.CGILookasideCache.upload', self.lookasidecache_upload): -+ cli.import_srpm() # no exception should be raised -+ rpmautospec_processed.assert_not_called() -+ - - class TestMockbuild(CliTestCase): - """Test mockbuild command""" --- -2.39.2 - |