diff --git a/.gitignore b/.gitignore index a1d80bd..94bbdab 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,4 @@ /rpkg-1.61.tar.gz /rpkg-1.62.tar.gz /rpkg-1.63.tar.gz +/rpkg-1.64.tar.gz diff --git a/0002-Remove-pytest-coverage-execution.patch b/0002-Remove-pytest-coverage-execution.patch new file mode 100644 index 0000000..1d92183 --- /dev/null +++ b/0002-Remove-pytest-coverage-execution.patch @@ -0,0 +1,26 @@ +From d6a407c80ec2aca51e8bd01e0a133bfa8890946b Mon Sep 17 00:00:00 2001 +From: Ondrej Nosek +Date: Mon, 7 Feb 2022 02:21:55 +0100 +Subject: [PATCH] Remove pytest coverage execution + +Signed-off-by: Ondrej Nosek +--- + setup.cfg | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/setup.cfg b/setup.cfg +index 9299433..4fe73fa 100644 +--- a/setup.cfg ++++ b/setup.cfg +@@ -5,8 +5,6 @@ test = pytest + max-line-length = 100 + + [tool:pytest] +-cover-package = pyrpkg +-addopts = --cov=pyrpkg + testpaths = tests + + [egg_info] +-- +2.34.1 + diff --git a/0002-Use-six-library-in-tests.patch b/0002-Use-six-library-in-tests.patch deleted file mode 100644 index 03c1ead..0000000 --- a/0002-Use-six-library-in-tests.patch +++ /dev/null @@ -1,53 +0,0 @@ -From e40fdf22124f9dbcc5f91578c9fd9f9b14625726 Mon Sep 17 00:00:00 2001 -From: Dominik Rumian -Date: Tue, 24 Aug 2021 13:54:38 +0200 -Subject: [PATCH] [PATCH] Use 'six' library in tests - -Signed-off-by: Dominik Rumian ---- - tests/test_cli.py | 4 ++-- - tests/test_lookaside.py | 6 ++++-- - 2 files changed, 6 insertions(+), 4 deletions(-) - -diff --git a/tests/test_cli.py b/tests/test_cli.py -index 735f4d7..cf4e5b3 100644 ---- a/tests/test_cli.py -+++ b/tests/test_cli.py -@@ -1534,8 +1534,8 @@ class TestImportSrpm(LookasideCacheMock, CliTestCase): - # Exception is not a functionality issue. There is no problem with - # uploading same file twice in a test however, the upload method checks - # if file has been already uploaded. -- self.assertRaisesRegex(AlreadyUploadedError, r'File already uploaded', -- self.assert_import_srpm, self.cloned_repo_path) -+ six.assertRaisesRegex(self, AlreadyUploadedError, r'File already uploaded', -+ self.assert_import_srpm, self.cloned_repo_path) - - def test_import_gating_and_rpmlintrc_exception(self): - # Add three additional files to the repo. Former gating.yaml and package.rpmlintrc are -diff --git a/tests/test_lookaside.py b/tests/test_lookaside.py -index 6946b79..5ad3e7b 100644 ---- a/tests/test_lookaside.py -+++ b/tests/test_lookaside.py -@@ -15,6 +15,8 @@ import unittest - - import mock - import pycurl -+import six -+ - from pyrpkg.errors import (AlreadyUploadedError, DownloadError, - InvalidHashType, UploadError) - from pyrpkg.lookaside import CGILookasideCache -@@ -512,8 +514,8 @@ class CGILookasideCacheTestCase(unittest.TestCase): - with mock.patch.object(lc, 'remote_file_exists', lambda *x: True): - # self.assertRaises(AlreadyUploadedError, lc.upload, 'pyrpkg', - # 'pyrpkg-0.tar.xz', hash) -- self.assertRaisesRegex(AlreadyUploadedError, r'File already uploaded', -- lc.upload, 'pyrpkg', 'pyrpkg-0.tar.xz', hash) -+ six.assertRaisesRegex(self, AlreadyUploadedError, r'File already uploaded', -+ lc.upload, 'pyrpkg', 'pyrpkg-0.tar.xz', hash) - - self.assertEqual(curl.perform.call_count, 0) - self.assertEqual(curl.setopt.call_count, 0) --- -2.31.1 - diff --git a/0003-Pass-sourcedir-to-rpmspec-when-specfile-is-parsed.patch b/0003-Pass-sourcedir-to-rpmspec-when-specfile-is-parsed.patch deleted file mode 100644 index 7ae93e8..0000000 --- a/0003-Pass-sourcedir-to-rpmspec-when-specfile-is-parsed.patch +++ /dev/null @@ -1,109 +0,0 @@ -From e0bf13817fc4e9d2ec56f2780bf88d9cfd5a1f27 Mon Sep 17 00:00:00 2001 -From: Otto Urpelainen -Date: Wed, 1 Sep 2021 07:44:22 +0300 -Subject: [PATCH] Pass sourcedir to rpmspec when specfile is parsed - -In many cases, specfile parsing in class SpecFile failed when -the specfile contained local sources like 'Source2: local.txt'. -This happened because rpm sourcedir configuration was not passed -to utility rpmspec used for parsing, leading it to default -to '~/rpmbuild/SOURCES', which is not correct for many layouts -supported by rpkg. -Fixed by passing sourcedir correctly. - -Fixes: #559 -Relates: https://pagure.io/rpkg/pull-request/564 -Merges: https://pagure.io/rpkg/pull-request/574 - -Signed-off-by: Otto Urpelainen ---- - pyrpkg/__init__.py | 3 ++- - pyrpkg/spec.py | 9 +++++---- - tests/test_spec.py | 16 ++++++++++++---- - 3 files changed, 19 insertions(+), 9 deletions(-) - -diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py -index 5e4831a..23bca5b 100644 ---- a/pyrpkg/__init__.py -+++ b/pyrpkg/__init__.py -@@ -2042,7 +2042,8 @@ class Commands(object): - outdir = self.path - - sourcesf = SourcesFile(self.sources_filename, self.source_entry_type) -- specf = SpecFile(os.path.join(self.layout.specdir, self.spec)) -+ specf = SpecFile(os.path.join(self.layout.specdir, self.spec), -+ self.layout.sourcedir) - - args = dict() - if self.lookaside_request_params: -diff --git a/pyrpkg/spec.py b/pyrpkg/spec.py -index 1aa2500..6341fcd 100644 ---- a/pyrpkg/spec.py -+++ b/pyrpkg/spec.py -@@ -17,15 +17,16 @@ class SpecFile(object): - - sourcefile_expression = re.compile(r'^source[0-9]*:\s*(?P.*)\s*$', re.IGNORECASE) - -- def __init__(self, spec): -+ def __init__(self, spec, sourcedir): - self.spec = spec -+ self.sourcedir = sourcedir - self.sources = [] - - self.parse() - - def parse(self): - """Call rpmspec and find source tags from the result.""" -- stdout = run(self.spec) -+ stdout = run(self.spec, self.sourcedir) - for line in stdout.splitlines(): - m = self.sourcefile_expression.match(line) - if not m: -@@ -36,8 +37,8 @@ class SpecFile(object): - self.sources.append(val) - - --def run(spec): -- cmdline = ['rpmspec', '-P', spec] -+def run(spec, sourcedir): -+ cmdline = ['rpmspec', '--define', "_sourcedir %s" % sourcedir, '-P', spec] - try: - process = subprocess.Popen(cmdline, - stdout=subprocess.PIPE, -diff --git a/tests/test_spec.py b/tests/test_spec.py -index 15e3730..196b470 100644 ---- a/tests/test_spec.py -+++ b/tests/test_spec.py -@@ -36,12 +36,17 @@ class SpecFileTestCase(unittest.TestCase): - spec_fd.write( - "Source0: https://example.com/tarball.tar.gz\n" - "Source1: https://example.com/subdir/LICENSE.txt\n" -- "Source2: https://another.domain.com/source.tar.gz\n") -+ "Source2: https://another.domain.com/source.tar.gz\n" -+ "Source3: local.txt\n") - spec_fd.close() - -- s = spec.SpecFile(self.specfile) -+ s = spec.SpecFile(self.specfile, self.workdir) - actual = s.sources -- expected = ["tarball.tar.gz", "LICENSE.txt", "source.tar.gz"] -+ expected = [ -+ "tarball.tar.gz", -+ "LICENSE.txt", -+ "source.tar.gz", -+ "local.txt"] - self.assertEqual(len(actual), len(expected)) - self.assertTrue(all([a == b for a, b in zip(actual, expected)])) - -@@ -52,4 +57,7 @@ class SpecFileTestCase(unittest.TestCase): - spec_fd.write("Foo: Bar\n") - spec_fd.close() - -- self.assertRaises(rpkgError, spec.SpecFile, [self.specfile]) -+ self.assertRaises(rpkgError, -+ spec.SpecFile, -+ self.specfile, -+ self.workdir) --- -2.31.1 - diff --git a/0004-Print-SpecFile-parsing-debug-info.patch b/0004-Print-SpecFile-parsing-debug-info.patch deleted file mode 100644 index 2a8d22a..0000000 --- a/0004-Print-SpecFile-parsing-debug-info.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 166aaedb9fc92590f5e9364c1cb6f607eaf28876 Mon Sep 17 00:00:00 2001 -From: Ondrej Nosek -Date: Mon, 6 Sep 2021 18:18:17 +0200 -Subject: [PATCH 1/3] Print SpecFile parsing debug info - -The recently added class SpecFile parses a specfile with tool rpmspec. -It provides error messages when parsing failed. This change will show -these messages to user. Without this rhpkg only fails with exception -and simple message. - -Resolves: rhbz#2000556 - -Signed-off-by: Ondrej Nosek ---- - pyrpkg/spec.py | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/pyrpkg/spec.py b/pyrpkg/spec.py -index 6341fcd..a276120 100644 ---- a/pyrpkg/spec.py -+++ b/pyrpkg/spec.py -@@ -49,6 +49,7 @@ def run(spec, sourcedir): - - retcode = process.poll() - if retcode: -+ print(stderr.decode('utf-8')) - raise rpkgError('Error running rpmspec on "%s", return code %s' - % (spec, retcode)) - --- -2.31.1 - diff --git a/0005-Fixes-import-fail-with-sources-already-imported.patch b/0005-Fixes-import-fail-with-sources-already-imported.patch deleted file mode 100644 index c80ff60..0000000 --- a/0005-Fixes-import-fail-with-sources-already-imported.patch +++ /dev/null @@ -1,50 +0,0 @@ -From f1f74e256cde220f04c41d6c86460d64cd3026b2 Mon Sep 17 00:00:00 2001 -From: Dominik Rumian -Date: Wed, 15 Sep 2021 12:10:03 +0200 -Subject: [PATCH] Fixes import fail with sources already imported - -Fixes: #573 -JIRA: RHELCMP-6481 - -Signed-off-by: Dominik Rumian ---- - pyrpkg/cli.py | 5 ++++- - tests/test_cli.py | 6 +----- - 2 files changed, 5 insertions(+), 6 deletions(-) - -diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py -index 6aa8f27..fafada6 100644 ---- a/pyrpkg/cli.py -+++ b/pyrpkg/cli.py -@@ -2144,7 +2144,10 @@ class cliClient(object): - def import_srpm(self): - uploadfiles = self.cmd.import_srpm(self.args.srpm) - if uploadfiles: -- self.cmd.upload(uploadfiles, replace=True, offline=self.args.offline) -+ try: -+ self.cmd.upload(uploadfiles, replace=True, offline=self.args.offline) -+ except AlreadyUploadedError: -+ self.log.info("All sources were already uploaded.") - if not self.args.skip_diffs: - self.cmd.diff(cached=True) - self.log.info('--------------------------------------------') -diff --git a/tests/test_cli.py b/tests/test_cli.py -index 887917c..90c2067 100644 ---- a/tests/test_cli.py -+++ b/tests/test_cli.py -@@ -1531,11 +1531,7 @@ class TestImportSrpm(LookasideCacheMock, CliTestCase): - - def test_import(self): - self.assert_import_srpm(self.chaos_repo) -- # Exception is not a functionality issue. There is no problem with -- # uploading same file twice in a test however, the upload method checks -- # if file has been already uploaded. -- six.assertRaisesRegex(self, AlreadyUploadedError, r'File already uploaded', -- self.assert_import_srpm, self.cloned_repo_path) -+ self.assert_import_srpm(self.cloned_repo_path) - - def test_import_gating_and_rpmlintrc_exception(self): - # Add three additional files to the repo. Former gating.yaml and package.rpmlintrc are --- -2.31.1 - diff --git a/0006-Consider-Patch-tags-in-specfile-parser.patch b/0006-Consider-Patch-tags-in-specfile-parser.patch deleted file mode 100644 index 6b045cb..0000000 --- a/0006-Consider-Patch-tags-in-specfile-parser.patch +++ /dev/null @@ -1,67 +0,0 @@ -From bb12945220cc99e8797bb1ced74cdc0e7efb4df0 Mon Sep 17 00:00:00 2001 -From: Otto Urpelainen -Date: Tue, 5 Oct 2021 08:50:28 +0300 -Subject: [PATCH] Consider Patch tags in specfile parser - -Patch files can be uploaded to the lookaside cache and referred -to by Patch tags in the specfile. -The specfile parser did not consider this case, leading to an error -if a dist-git repo has such confiration. Fixed by parsing -the patch tags. - -Resolves rhbz#2010518 - -Signed-off-by: Otto Urpelainen ---- - pyrpkg/spec.py | 5 +++-- - tests/test_spec.py | 11 ++++++++--- - 2 files changed, 11 insertions(+), 5 deletions(-) - -diff --git a/pyrpkg/spec.py b/pyrpkg/spec.py -index a276120..bd862f1 100644 ---- a/pyrpkg/spec.py -+++ b/pyrpkg/spec.py -@@ -14,8 +14,9 @@ from pyrpkg.errors import rpkgError - - class SpecFile(object): - """Simple specfile parser that finds source file names""" -- -- sourcefile_expression = re.compile(r'^source[0-9]*:\s*(?P.*)\s*$', re.IGNORECASE) -+ sourcefile_expression = re.compile( -+ r'^((source[0-9]*|patch[0-9]*):\s*(?P.*))\s*$', -+ re.IGNORECASE) - - def __init__(self, spec, sourcedir): - self.spec = spec -diff --git a/tests/test_spec.py b/tests/test_spec.py -index 196b470..eefc475 100644 ---- a/tests/test_spec.py -+++ b/tests/test_spec.py -@@ -36,8 +36,11 @@ class SpecFileTestCase(unittest.TestCase): - spec_fd.write( - "Source0: https://example.com/tarball.tar.gz\n" - "Source1: https://example.com/subdir/LICENSE.txt\n" -- "Source2: https://another.domain.com/source.tar.gz\n" -- "Source3: local.txt\n") -+ "source2: https://another.domain.com/source.tar.gz\n" -+ "SOURCE3: local.txt\n" -+ "\n" -+ "patch0: local.patch\n" -+ "PAtch999: https://remote.patch-sourcce.org/another-patch.bz2\n") - spec_fd.close() - - s = spec.SpecFile(self.specfile, self.workdir) -@@ -46,7 +49,9 @@ class SpecFileTestCase(unittest.TestCase): - "tarball.tar.gz", - "LICENSE.txt", - "source.tar.gz", -- "local.txt"] -+ "local.txt", -+ "local.patch", -+ "another-patch.bz2"] - self.assertEqual(len(actual), len(expected)) - self.assertTrue(all([a == b for a, b in zip(actual, expected)])) - --- -2.31.1 - diff --git a/0007-Continue-execution-if-specfile-parsing-fails.patch b/0007-Continue-execution-if-specfile-parsing-fails.patch deleted file mode 100644 index 4e84bb1..0000000 --- a/0007-Continue-execution-if-specfile-parsing-fails.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 7ede78fc7b8fae2e78c700f39eb68df1696e107f Mon Sep 17 00:00:00 2001 -From: Otto Urpelainen -Date: Tue, 12 Oct 2021 20:48:43 +0300 -Subject: [PATCH] Continue execution if specfile parsing fails - -The unused sources detection feature implemented by class SpecFile -is simply an optimization to avoid downloading unused sources. -The parsing is quite different from other steps performed by rpkg, -which also meant it can fail in new ways. -To avoid situations where an error in this optimization step prevents -usage that would otherwise succeed, this commit changes handling -of such errors from exiting to logging the situation and continuing -with the assumption that all sources in the sources file may -be needed. - -Resolves: #583 -JIRA: RHELCMP-7087 -Merges: https://pagure.io/rpkg/pull-request/581 - -Signed-off-by: Otto Urpelainen ---- - pyrpkg/__init__.py | 13 ++++++++++--- - 1 file changed, 10 insertions(+), 3 deletions(-) - -diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py -index 23bca5b..2edcb09 100644 ---- a/pyrpkg/__init__.py -+++ b/pyrpkg/__init__.py -@@ -2042,8 +2042,15 @@ class Commands(object): - outdir = self.path - - sourcesf = SourcesFile(self.sources_filename, self.source_entry_type) -- specf = SpecFile(os.path.join(self.layout.specdir, self.spec), -- self.layout.sourcedir) -+ -+ try: -+ specf = SpecFile(os.path.join(self.layout.specdir, self.spec), -+ self.layout.sourcedir) -+ spec_parsed = True -+ except Exception: -+ self.log.warn("Parsing specfile for used sources failed. " -+ "Falling back to downloading all sources.") -+ spec_parsed = False - - args = dict() - if self.lookaside_request_params: -@@ -2062,7 +2069,7 @@ class Commands(object): - "Error: Attempting a download '{0}' that would override a git tracked file. " - "Either remove the corresponding line from 'sources' file to keep the git " - "tracked one or 'git rm' the file to allow the download.".format(outfile)) -- if (entry.file not in specf.sources): -+ if (spec_parsed and entry.file not in specf.sources): - self.log.info("Not downloading unused %s" % entry.file) - continue - self.lookasidecache.download( --- -2.31.1 - diff --git a/0008-Remove-pytest-coverage-execution.patch b/0008-Remove-pytest-coverage-execution.patch deleted file mode 100644 index 3262d5d..0000000 --- a/0008-Remove-pytest-coverage-execution.patch +++ /dev/null @@ -1,25 +0,0 @@ -From ec996c939b7e9d606c2345019e9ba4548d352ef8 Mon Sep 17 00:00:00 2001 -From: Ondrej Nosek -Date: Tue, 14 Dec 2021 16:19:08 +0100 -Subject: [PATCH] Remove pytest coverage execution - -Signed-off-by: Ondrej Nosek ---- - setup.cfg | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/setup.cfg b/setup.cfg -index 9299433..a80f7c3 100644 ---- a/setup.cfg -+++ b/setup.cfg -@@ -6,7 +6,6 @@ max-line-length = 100 - - [tool:pytest] - cover-package = pyrpkg --addopts = --cov=pyrpkg - testpaths = tests - - [egg_info] --- -2.31.1 - diff --git a/rpkg.spec b/rpkg.spec index b945191..151592c 100644 --- a/rpkg.spec +++ b/rpkg.spec @@ -1,6 +1,6 @@ Name: rpkg -Version: 1.63 -Release: 6%{?dist} +Version: 1.64 +Release: 1%{?dist} Summary: Python library for interacting with rpm+git License: GPLv2+ and LGPLv2 @@ -18,13 +18,7 @@ Source0: https://pagure.io/releases/rpkg/%{name}-%{version}.tar.gz # remove rpm-py-installer for now. Patch0: remove-koji-and-rpm-py-installer-from-requires.patch Patch1: 0001-Do-not-use-pytest-related-dependencies-temporarily.patch -Patch2: 0002-Use-six-library-in-tests.patch -Patch3: 0003-Pass-sourcedir-to-rpmspec-when-specfile-is-parsed.patch -Patch4: 0004-Print-SpecFile-parsing-debug-info.patch -Patch5: 0005-Fixes-import-fail-with-sources-already-imported.patch -Patch6: 0006-Consider-Patch-tags-in-specfile-parser.patch -Patch7: 0007-Continue-execution-if-specfile-parsing-fails.patch -Patch8: 0008-Remove-pytest-coverage-execution.patch +Patch2: 0002-Remove-pytest-coverage-execution.patch # RHEL7 is currently the only release that is built for Python 2. %if 0%{?fedora} || 0%{?rhel} > 7 @@ -61,6 +55,7 @@ BuildRequires: python-pycurl BuildRequires: python-requests BuildRequires: python-requests-kerberos BuildRequires: python-six >= 1.9.0 +BuildRequires: python2-argcomplete BuildRequires: python2-mock BuildRequires: python2-nose BuildRequires: python2-setuptools @@ -69,6 +64,7 @@ Requires: mock Requires: redhat-rpm-config Requires: rpm-build Requires: rpmlint +Requires: python2-argcomplete Requires: python2-cccolutils Requires: python2-koji >= 1.21 Requires: PyYAML @@ -114,9 +110,9 @@ BuildRequires: python3-requests-kerberos %else BuildRequires: python3-libmodulemd %endif +BuildRequires: python3-argcomplete BuildRequires: python3-cccolutils BuildRequires: python3-openidc-client -BuildRequires: python3-mock BuildRequires: python3-pycurl BuildRequires: python3-six >= 1.9.0 BuildRequires: python3-requests @@ -130,6 +126,7 @@ Requires: redhat-rpm-config Requires: rpm-build Requires: rpmlint +Requires: python3-argcomplete Requires: python3-GitPython >= 0.2.0 Requires: python3-cccolutils Requires: python3-koji >= 1.24 @@ -248,6 +245,33 @@ example_cli_dir=$RPM_BUILD_ROOT%{_datadir}/%{name}/examples/cli %changelog +* Tue Jan 25 2022 Ondřej Nosek - 1.64-1 +- Fix: *pkg now takes into account --path parameter while building SRPM - 580 + (drumian) +- 'lint' can run with different 'rpmlint' versions - rhbz#1967821 (onosek) +- Support building SRPMs in target mock - #495 (onosek) +- Use unittest.mock on Python 3 (miro) +- Add support for mockbuild in lint command (oturpe) +- Fix srpm and binary rpm lookup in lint subcommand - #586 (oturpe) +- mockbuild: allow enforcing local mock config in fedpkg (praiskup) +- list-side-tags - fix unavailable username (sergio) +- Accept also ~/.config/mock/.cfg files (praiskup) +- improve srpm --help description (kdreyer) +- Improve how the .spec file is selected (mads) +- Include `fmf` config in the list of reserved files - 452 (psplicha) +- Fix flake8 syntax (onosek) +- Continue execution if specfile parsing fails - #583 (oturpe) +- Consider Patch tags in specfile parser - rhbz#2010518 (oturpe) +- Support for custom completers (onosek) +- Fixes import fail with sources already imported - #573 (drumian) +- Also document Python 3.10 support in the README (miro) +- Test and support Python 3.10 (miro) +- Print SpecFile parsing debug info - rhbz#2000556 (onosek) +- Pass sourcedir to rpmspec when specfile is parsed - #559 (oturpe) +- Fix unittests to be Python 2 compatible (drumian) +- Changing escaping of dash in docs - older releases (onosek) +- Changing escaping of dash in docs. (drumian) + * Tue Dec 14 2021 Ondřej Nosek - 1.63-6 - drop nosetests for Python3 - disable pytest coverage during build diff --git a/sources b/sources index 699f2cf..4549190 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (rpkg-1.63.tar.gz) = 60d276404a585b760edd3e306873e12843c656f3ba80962b198c804bad0d773125cc38878bb8e51e3581ee2f6407409cfb9ec452da1efb859354695d20442892 +SHA512 (rpkg-1.64.tar.gz) = faaf6c913c18bd40260e57007fd130ffaec1dbc617c3cdb165a5650deccd403075d402b5cb6b7b4cb4611bb2f8844173a886de6a151f05ad1fdd126c16f4d2f7