Tarek Ziadé avatar Tarek Ziadé committed ded26ff

allowing the signing of packages

Comments (0)

Files changed (2)


     user_options = bdist_rpm.user_options + [
             ('name=', None, 'Name of the package'),
             ('spec-file=', None, 'Use an existing spec file'),
-            ('tmppath=', None, 'Temporary path for builds (_tmppath variable)')
+            ('tmppath=', None, 'Temporary path for builds (_tmppath variable)'),
+            ('sign', None, 'Sign the RPM package')
+    boolean_options = bdist_rpm.boolean_options + ['sign']
     def __init__ (self, dist):
         self.distribution = dist
         self.name = None
         self.spec_file = None
+        self.sign = 0
     def _make_spec_file(self):
         """Generate the text of an RPM spec file and return it as a
                             "_tmppath %s" % os.path.abspath(self.tmppath)])
+        if self.sign:
+            rpm_cmd.append('--sign')
         if not self.keep_temp:


 _PYTHON = 'python%d%d' % (_MAJOR, _MINOR)
-def _d1_sdist2rpm(dist_dir):
+def _d1_sdist2rpm(dist_dir, sign):
     # grab the name and create a normalized one
     popen = subprocess.Popen('%s setup.py --name' % sys.executable,
                                 stdout=subprocess.PIPE, shell=True)
             cmd += ' --dist-dir=%s' % os.getcwd()
+        if sign:
+            cmd += ' --sign'
         call = '%s setup.py %s --name=%s --python=%s' % \
                 (sys.executable, cmd, name, os.path.basename(sys.executable))
-def _d2_sdist2rpm(dist_dir):
+def _d2_sdist2rpm(dist_dir, sign):
     setup_cfg = ConfigParser()
     name = setup_cfg.get('metadata', 'name')
     cmd = '-m distutils2.run bdist_rpm2 --binary-only'
     if dist_dir is not None:
         cmd += ' --dist-dir=%s' % dist_dir
+    if sign:
+        cmd += ' --sign'
     # run the bdist_rpm2 command
     os.system('%s %s --name=%s' % (sys.executable, cmd, name))
         func(filename, extract_dir, **kwargs)
-def sdist2rpm(sdist, dist_dir=None, version=None):
+def sdist2rpm(sdist, dist_dir=None, version=None, sign=False):
     """Creates a RPM distro out of a Python project."""
     old_dir = os.getcwd()
     if dist_dir is None:
         if not _is_d2():
-            _d1_sdist2rpm(dist_dir)
+            _d1_sdist2rpm(dist_dir, sign)
-            _d2_sdist2rpm(dist_dir)
+            _d2_sdist2rpm(dist_dir, sign)
         if dist_dir is None:
             dist_dir = old_dir
 distutils2.version._PREDICATE = _PREDICATE
-def main(project, dist_dir, version, index_url, download_cache):
+def main(project, dist_dir, version, index_url, download_cache, sign):
     if os.path.isfile(project) or os.path.isdir(project):
         project = os.path.abspath(project)
         return 1
-        res = sdist2rpm(release, dist_dir, version)
+        res = sdist2rpm(release, dist_dir, version, sign)
         if res is None:
             print 'Failed.'
             return 1
                         help='PyPI Simple Index')
     parser.add_argument('--download-cache', type=str, default=None,
                         help='Download cache')
+    parser.add_argument('--sign', default=False, action='store_true',
+                        help='Sign the RPM package')
     parser.add_argument('project', help='project name at PyPI or path')
     args = parser.parse_args()
     sys.exit(main(args.project, args.dist_dir, args.version, args.index,
-                  args.download_cache))
+                  args.download_cache, args.sign))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.