summaryrefslogtreecommitdiffstats
path: root/Lib/distutils
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2000-06-01 00:40:25 (GMT)
committerGreg Ward <gward@python.net>2000-06-01 00:40:25 (GMT)
commit01a4694dce866bfa1162e6a918be6cfbe916559d (patch)
tree6d568199a4f260d201ec529c47addec97096521d /Lib/distutils
parent69413da74993ff6728b72be4b4290fc705e9cbc1 (diff)
downloadcpython-01a4694dce866bfa1162e6a918be6cfbe916559d.zip
cpython-01a4694dce866bfa1162e6a918be6cfbe916559d.tar.gz
cpython-01a4694dce866bfa1162e6a918be6cfbe916559d.tar.bz2
More tweaking to make this command act like other Distutils commands:
* added "--bdist-base" option to parameterize where we build the RPM (comes from "bdist" by default: "build/bdist.<plat>") * simplified/cleaned up some code in 'run()' in the process of removing (most) hard-coded directory names * if "--spec-only", drop spec file in "dist" rather than "redhat" (directory name still hard-coded, though) * use 'reinitialize_command()' to fetch the "sdist" object to tweak before running "sdist" command * use 'self.copy_file()' method rather than 'copy_file()' function * cosmetic tweaks to comments, error messages
Diffstat (limited to 'Lib/distutils')
-rw-r--r--Lib/distutils/command/bdist_rpm.py55
1 files changed, 29 insertions, 26 deletions
diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py
index e7e4ca7..c84fda8 100644
--- a/Lib/distutils/command/bdist_rpm.py
+++ b/Lib/distutils/command/bdist_rpm.py
@@ -10,7 +10,7 @@ __revision__ = "$Id$"
import os, string
from types import *
from distutils.core import Command
-from distutils.util import mkpath, write_file, copy_file
+from distutils.util import get_platform, write_file
from distutils.errors import *
class bdist_rpm (Command):
@@ -18,6 +18,8 @@ class bdist_rpm (Command):
description = "create an RPM distribution"
user_options = [
+ ('bdist-base', None,
+ "base directory for creating built distributions"),
('spec-only', None,
"only regenerate spec file"),
('source-only', None,
@@ -41,6 +43,7 @@ class bdist_rpm (Command):
def initialize_options (self):
+ self.bdist_base = None
self.spec_only = None
self.binary_only = None
self.source_only = None
@@ -52,13 +55,14 @@ class bdist_rpm (Command):
def finalize_options (self):
+ self.set_undefined_options('bdist', ('bdist_base', 'bdist_base'))
if os.name != 'posix':
raise DistutilsPlatformError, \
("don't know how to create RPM "
"distributions on platform %s" % os.name)
if self.binary_only and self.source_only:
raise DistutilsOptionsError, \
- "Cannot supply both '--source-only' and '--binary-only'"
+ "cannot supply both '--source-only' and '--binary-only'"
# don't pass CFLAGS to pure python distributions
if not self.distribution.has_ext_modules():
self.use_rpm_opt_flags = 0
@@ -69,50 +73,49 @@ class bdist_rpm (Command):
def run (self):
self._get_package_data() # get packaging info
-
# make directories
if self.spec_only:
- self.mkpath('redhat')
+ spec_dir = "dist"
+ self.mkpath(spec_dir) # XXX should be configurable
else:
+ rpm_base = os.path.join(self.bdist_base, "rpm")
+ rpm_dir = {}
for d in ('SOURCES', 'SPECS', 'BUILD', 'RPMS', 'SRPMS'):
- self.mkpath(os.path.join('build/rpm', d))
-
- # spec file goes into .redhat directory if '--spec-only specified',
- # into build/rpm/spec otherwise
- if self.spec_only:
- spec_path = 'redhat/%s.spec' % self.distribution.get_name()
- else:
- spec_path = ('build/rpm/SPECS/%s.spec' %
- self.distribution.get_name())
+ rpm_dir[d] = os.path.join(rpm_base, d)
+ self.mkpath(rpm_dir[d])
+ spec_dir = rpm_dir['SPECS']
+
+ # Spec file goes into 'dist' directory if '--spec-only specified',
+ # into build/rpm.<plat> otherwise.
+ spec_path = os.path.join(spec_dir,
+ "%s.spec" % self.distribution.get_name())
self.execute(write_file,
(spec_path,
self._make_spec_file()),
- 'Writing .spec file')
+ "writing '%s'" % spec_path)
if self.spec_only: # stop if requested
return
- # make a source distribution and copy to SOURCES directory with
- # optional icon
- sdist = self.get_finalized_command ('sdist')
+ # Make a source distribution and copy to SOURCES directory with
+ # optional icon.
+ sdist = self.reinitialize_command ('sdist')
if self.use_bzip2:
sdist.formats = ['bztar']
else:
sdist.formats = ['gztar']
self.run_command('sdist')
- if self.use_bzip2:
- source = self.distribution.get_fullname() + '.tar.bz2'
- else:
- source = self.distribution.get_fullname() + '.tar.gz'
- self.execute(copy_file, (source, 'build/rpm/SOURCES'),
- 'Copying source distribution to SOURCES')
+
+ source = sdist.get_archive_files()[0]
+ source_dir = rpm_dir['SOURCES']
+ self.copy_file(source, source_dir)
+
if self.icon:
if os.path.exists(self.icon):
- self.execute(copy_file, (self.icon, 'build/rpm/SOURCES'),
- 'Copying icon to SOURCES')
+ self.copy_file(self.icon, source_dir)
else:
raise DistutilsFileError, \
- "Unable to find icon file '%s'" % self.icon
+ "icon file '%s' does not exist" % self.icon
# build package