public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
To: git-commits@fedoraproject.org
Subject: [rpms/rpkg] 1.70-1: Patch: Pass sourcedir to rpmspec when specfile is parsed
Date: Mon, 10 Aug 2026 21:44:20 GMT [thread overview]
Message-ID: <178639826026.1.1259261429242938887.rpms-rpkg-43e65a934252@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/rpkg
Branch : 1.70-1
Commit : 43e65a934252be7d7be28adde3d4f5fb31650452
Author : Ondřej Nosek <onosek@redhat.com>
Date : 2021-09-01T11:06:02+00:00
Stats : +114/-1 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/rpkg/c/43e65a934252be7d7be28adde3d4f5fb31650452?branch=1.70-1
Log:
Patch: Pass sourcedir to rpmspec when specfile is parsed
Signed-off-by: Ondřej Nosek <onosek@redhat.com>
---
diff --git a/0003-Pass-sourcedir-to-rpmspec-when-specfile-is-parsed.patch b/0003-Pass-sourcedir-to-rpmspec-when-specfile-is-parsed.patch
new file mode 100644
index 0000000..7ae93e8
--- /dev/null
+++ b/0003-Pass-sourcedir-to-rpmspec-when-specfile-is-parsed.patch
@@ -0,0 +1,109 @@
+From e0bf13817fc4e9d2ec56f2780bf88d9cfd5a1f27 Mon Sep 17 00:00:00 2001
+From: Otto Urpelainen <oturpe@iki.fi>
+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 <oturpe@iki.fi>
+---
+ 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<val>.*)\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/rpkg.spec b/rpkg.spec
index 6e68f2a..40dc68d 100644
--- a/rpkg.spec
+++ b/rpkg.spec
@@ -1,6 +1,6 @@
Name: rpkg
Version: 1.63
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: Python library for interacting with rpm+git
License: GPLv2+ and LGPLv2
@@ -19,6 +19,7 @@ Source0: https://pagure.io/releases/rpkg/%{name}-%{version}.tar.gz
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
# RHEL7 is currently the only release that is built for Python 2.
%if 0%{?fedora} || 0%{?rhel} > 7
@@ -238,6 +239,9 @@ example_cli_dir=$RPM_BUILD_ROOT%{_datadir}/%{name}/examples/cli
%changelog
+* Wed Sep 01 2021 Ondřej Nosek <onosek@redhat.com> - 1.63-2
+- Patch: Pass sourcedir to rpmspec when specfile is parsed
+
* Tue Aug 24 2021 Dominik Rumian <drumian@redhat.com> - 1.63-1
- Do not download unused sources during command 'sources' - #559 (oturpe)
- Added 'x-pkg verrel' for containers - #547 (jkunstle)
reply other threads:[~2026-08-10 21:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=178639826026.1.1259261429242938887.rpms-rpkg-43e65a934252@fedoraproject.org \
--to=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox