RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
Server: rpm5.org Name: Per Øyvind Karlsen
Root: /v/rpm/cvs Email: pkarl...@rpm5.org
Module: rpm Date: 24-Feb-2011 06:11:23
Branch: HEAD Handle: 2011022405112300
Added files:
rpm/scripts bdist_rpm5.py
Log:
add this rpm5ized version of python's standard distutils bdist_rpm
here for future refence and for possible adoption/integration of
anyone interested...
Summary:
RevisionChanges Path
1.1 +231 -0 rpm/scripts/bdist_rpm5.py
patch -p0 '@@ .'
Index: rpm/scripts/bdist_rpm5.py
$ cvs diff -u -r0 -r1.1 bdist_rpm5.py
--- /dev/null 2011-02-24 06:11:01.0 +0100
+++ bdist_rpm5.py 2011-02-24 06:11:23.295549253 +0100
@@ -0,0 +1,231 @@
+from distutils.command.bdist_rpm import bdist_rpm
+import distutils.command.sdist
+from distutils.sysconfig import get_config_var
+from distutils.filelist import FileList
+import string, os, sys
+from types import *
+from glob import glob
+import rpm
+
+class bdist_rpm5(bdist_rpm):
+def _make_spec_file(self):
+Generate the text of an RPM spec file and return it as a
+list of strings (one per line).
+
+sdist = self.reinitialize_command('sdist')
+sdist.finalize_options()
+sdist.filelist = FileList()
+sdist.get_file_list()
+manifest = sdist.filelist.files
+
+# definitions and headers
+name = self.distribution.get_name()
+version = self.distribution.get_version().replace('-','_')
+release = self.release.replace('-','_')
+summary = self.distribution.get_description().strip().strip('.')
+
+spec_file = [
+'%define\toname\t'+name,
+]
+if name[:2] == py:
+spec_file.append('%define\tmodule\t' + name[2:])
+module = '%{module}'
+else:
+module = '%{oname}'
+
+spec_file.extend([
+'',
+'Name:\t\tpython-' + module,
+'Version:\t' + version,
+'Release:\t%mkrel ' + release,
+'Summary:\t' + summary,
+
'Source0:\thttp://pypi.python.org/packages/source/%c/%%{oname}/%%{oname}-%%{version}.tar'
% name[0],
+])
+# XXX yuck! this filename is available from the sdist command,
+# but only after it has run: and we create the spec file before
+# running sdist, in case of --spec-only.
+if sdist.formats and 'xztar' in sdist.formats:
+spec_file[-1] += '.xz'
+elif sdist.formats and 'bztar' in sdist.formats:
+spec_file[-1] += '.bz2'
+else:
+spec_file[-1] += '.gz'
+
+license = self.distribution.get_license().replace(GPL ,
GPLv).strip()
+spec_file.extend([
+'License:\t' + license,
+'Group:\t\t' + self.group,])
+if self.distribution.get_url() != 'UNKNOWN':
+spec_file.append('Url:\t\t' + self.distribution.get_url())
+
+doc_names = ['README', 'CHANGES','ChangeLog', 'NEWS', 'THANKS',
+'HISTORY', 'AUTHORS', 'BUGS', 'ReleaseNotes', 'DISCLAIMER',
+'TODO', 'TROUBLESHOOTING', 'IDEAS', 'HACKING', 'WISHLIST',
+'CREDITS', 'PROJECTS', 'LEGAL', 'KNOWN_BUGS',
+'MISSING_FEATURES', 'FAQ', 'ANNOUNCE', 'FEATURES',
'WHATSNEW']
+license_names = ['LICENSE', 'COPYRIGHT', 'COPYING']
+common_licenses = glob('/usr/share/common-licenses/*')
+for i in range(len(common_licenses)):
+common_licenses[i] = os.path.basename(common_licenses[i])
+doc_names.extend(license_names)
+doc_suffixes = ('.doc', '.htm', '.txt', '.pdf', '.odt')
+
+self.doc_files = []
+all_files = []
+if self.distribution.data_files:
+all_files.extend(self.distribution.data_files)
+if manifest:
+all_files.extend(manifest)
+if all_files:
+for data_file in all_files:
+done = False
+for doc_name in doc_names:
+if doc_name.lower() in data_file.lower():
+if doc_name in license_names and license in
common_licenses:
+done = True
+break
+self.doc_files.append(data_file)
+done = True
+break
+