[Distutils] Proposed patch for bdist_rpm
Mihai Ibanescu
misa at redhat.com
Mon Jun 7 11:15:52 EDT 2004
Hello,
I have attached a patch that fixes a bug present both in Red Hat's bugzilla
and on sourceforge:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=123598
http://sourceforge.net/tracker/index.php?func=detail&aid=957381&group_id=5470&atid=105470
The original, proposed patch only deals with debuginfo packages. Debuginfo
packages are created purely from macros, and there is no guarantee some other
rpm-based packager would not choose to use a similar approach to solve another
problem (or they wouldn't rename debuginfo to something else).
The patch adds the ability to predict which rpms are built out of a spec file
by querying the spec file (rpm -q --specfile foo.spec).
Please consider it and let me know what you think. I have included the patch
in the latest Rawhide hoping to get more feedback. Here's a link to the
patched python:
ftp://people.redhat.com/misa/python/
Thanks,
Misa
-------------- next part --------------
--- Python-2.3.4/Lib/distutils/command/bdist_rpm.py 2004-05-07 10:53:05.000000000 -0400
+++ Python-2.3.4/Lib/distutils/command/bdist_rpm.py 2004-06-06 16:01:37.000000000 -0400
@@ -299,23 +299,47 @@
if not self.keep_temp:
rpm_cmd.append('--clean')
rpm_cmd.append(spec_path)
+ # Determine the binary rpm names that should be built out of this spec
+ # file
+ # Note that some of these may not be really built (if the file
+ # list is empty)
+ nvr_string = "%{name}-%{version}-%{release}"
+ src_rpm = nvr_string + ".src.rpm"
+ non_src_rpm = "%{arch}/" + nvr_string + ".%{arch}.rpm"
+ q_cmd = r"rpm -q --qf '%s %s\n' --specfile '%s'" % (
+ src_rpm, non_src_rpm, spec_path)
+
+ out = os.popen(q_cmd)
+ binary_rpms = []
+ source_rpm = None
+ while 1:
+ line = out.readline()
+ if not line:
+ break
+ l = string.split(string.strip(line))
+ assert(len(l) == 2)
+ binary_rpms.append(l[1])
+ # The source rpm is named after the first entry in the spec file
+ if source_rpm is None:
+ source_rpm = l[0]
+
+ status = out.close()
+ if status:
+ raise DistutilsExecError("Failed to execute: %s" % repr(q_cmd))
+
self.spawn(rpm_cmd)
- # XXX this is a nasty hack -- we really should have a proper way to
- # find out the names of the RPM files created; also, this assumes
- # that RPM creates exactly one source and one binary RPM.
if not self.dry_run:
if not self.binary_only:
- srpms = glob.glob(os.path.join(rpm_dir['SRPMS'], "*.rpm"))
- assert len(srpms) == 1, \
- "unexpected number of SRPM files found: %s" % srpms
- self.move_file(srpms[0], self.dist_dir)
+ srpm = os.path.join(rpm_dir['SRPMS'], source_rpm)
+ assert(os.path.exists(srpm))
+ self.move_file(srpm, self.dist_dir)
if not self.source_only:
- rpms = glob.glob(os.path.join(rpm_dir['RPMS'], "*/*.rpm"))
- assert len(rpms) == 1, \
- "unexpected number of RPM files found: %s" % rpms
- self.move_file(rpms[0], self.dist_dir)
+ for rpm in binary_rpms:
+ rpm = os.path.join(rpm_dir['RPMS'], rpm)
+ if os.path.exists(rpm):
+ self.move_file(rpm, self.dist_dir)
# run()
More information about the Distutils-SIG
mailing list