From: Christian Herdtweck Date: Mon, 28 Jan 2019 10:26:18 +0000 (+0100) Subject: Avoid modifying wrong rpm from make_dist X-Git-Tag: v1.4~4^2 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=36eadbed76256bdb7329c3850f2b2f409c54d2f9;p=pyi2ncommon Avoid modifying wrong rpm from make_dist Bughunting before was complicated by usage of wrong rpm files. Make tests more strict to avoid finding wrong rpm --- diff --git a/make_dist.py b/make_dist.py index 6122245..683b1f6 100755 --- a/make_dist.py +++ b/make_dist.py @@ -13,6 +13,8 @@ This script relies on one feature I accidentally stumbled over: it appears that setting install-lib to /usr/lib/pythonVERSION/site-packages is translated by setup.py to installation requirement python(abi) = VERSION +TODO: allow modification of release string from cmd line args (e.g. "testing") + .. codeauthor:: Intra2net AG """ @@ -23,6 +25,7 @@ from subprocess import call from tempfile import mkstemp from configparser import ConfigParser from glob import iglob +import time INSTALL_DIR_PATTERN = '/usr/lib/python{}/site-packages' @@ -103,21 +106,31 @@ def create_rpm(py_version): py_version.startswith('3.3') or py_version.startswith('3.4') # create rpm + start_time = time.time() run_setup('bdist_rpm', install_options=install_options, need_zip35=need_zip35) # find rpm and rename it - newest_name = None + newest_names = [] newest_time = 0 for filename in iglob(join(DIST_DIR, 'pyi2ncommon-*.noarch.rpm')): filetime = os.stat(filename).st_mtime if filetime > newest_time: newest_time = filetime - newest_name = filename + newest_names = [filename, ] + elif filetime == newest_time: + newest_names.append(filename) - if newest_name is None: + if not newest_names: raise RuntimeError('No pyi2ncommon rpm file found in {}' .format(DIST_DIR)) + elif newest_time < start_time: + raise RuntimeError('Newest pyi2ncommon rpm file in {} is too old' + .format(DIST_DIR)) + elif len(newest_names) > 1: + raise RuntimeError('Multiple newest pyi2ncommon rpm files: {}' + .format(newest_names)) + newest_name = newest_names[0] mod_name = newest_name[:-11] + '.py' + py_version.replace('.', '') + \ newest_name[-11:] os.rename(newest_name, mod_name)