From 73d7b082bd7c1764be584fa3db6c37a64e888f86 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Wed, 22 Jul 2009 10:32:55 +0200 Subject: [PATCH] Add bdist_rpm option to select the name of the resulting package. --- Lib/distutils/command/bdist_rpm.py | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py index 9cde803..bd85762 100644 --- a/Lib/distutils/command/bdist_rpm.py +++ b/Lib/distutils/command/bdist_rpm.py @@ -51,6 +51,9 @@ class bdist_rpm (Command): ('distribution-name=', None, "name of the (Linux) distribution to which this " "RPM applies (*not* the name of the module distribution!)"), + ('package-name=', None, + "name of the generated rpm package " + "[default: name from the setup script]"), ('group=', None, "package classification [default: \"Development/Libraries\"]"), ('release=', None, @@ -148,6 +151,7 @@ class bdist_rpm (Command): self.use_bzip2 = None self.distribution_name = None + self.package_name = None self.group = None self.release = None self.serial = None @@ -234,6 +238,7 @@ class bdist_rpm (Command): self.ensure_string('serial') # should it be an int? self.ensure_string('distribution_name') + self.ensure_string('package_name', self.distribution.get_name()) self.ensure_string('changelog') # Format changelog correctly @@ -288,7 +293,7 @@ class bdist_rpm (Command): # Spec file goes into 'dist_dir' if '--spec-only specified', # build/rpm. otherwise. spec_path = os.path.join(spec_dir, - "%s.spec" % self.distribution.get_name()) + "%s.spec" % self.package_name) self.execute(write_file, (spec_path, self._make_spec_file()), @@ -395,7 +400,8 @@ class bdist_rpm (Command): """ # definitions and headers spec_file = [ - '%define name ' + self.distribution.get_name(), + '%define name ' + self.package_name, + '%define distutils_name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version().replace('-','_'), '%define unmangled_version ' + self.distribution.get_version(), '%define release ' + self.release.replace('-','_'), @@ -419,9 +425,9 @@ class bdist_rpm (Command): # but only after it has run: and we create the spec file before # running "sdist", in case of --spec-only. if self.use_bzip2: - spec_file.append('Source0: %{name}-%{unmangled_version}.tar.bz2') + spec_file.append('Source0: %{distutils_name}-%{unmangled_version}.tar.bz2') else: - spec_file.append('Source0: %{name}-%{unmangled_version}.tar.gz') + spec_file.append('Source0: %{distutils_name}-%{unmangled_version}.tar.gz') spec_file.extend([ 'License: ' + self.distribution.get_license(), @@ -499,7 +505,7 @@ class bdist_rpm (Command): '--record=INSTALLED_FILES') % def_setup_call script_options = [ - ('prep', 'prep_script', "%setup -n %{name}-%{unmangled_version}"), + ('prep', 'prep_script', "%setup -n %{distutils_name}-%{unmangled_version}"), ('build', 'build_script', def_build), ('install', 'install_script', install_cmd), ('clean', 'clean_script', "rm -rf $RPM_BUILD_ROOT"), -- 1.6.3.3.385.g60647