commit:     17d7bb459ad2ac78b56298c966203ec389b3b745
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Dec  7 21:45:49 2016 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Dec  7 21:46:39 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=17d7bb45

repoman: Fix installed lib version, update commit version info

Re-add code from portage setup.py which updates the VERSION in __init__.py.
Add repoman version to "Package Manager" in the commit message footer.

 repoman/pym/repoman/actions.py |  4 +++-
 repoman/setup.py               | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/repoman/pym/repoman/actions.py b/repoman/pym/repoman/actions.py
index 796dbaf..189580e 100644
--- a/repoman/pym/repoman/actions.py
+++ b/repoman/pym/repoman/actions.py
@@ -27,6 +27,7 @@ from repoman.copyrights import update_copyright
 from repoman.gpg import gpgsign, need_signature
 from repoman import utilities
 from repoman.modules.vcs.vcs import vcs_files_to_cps
+from repoman import VERSION
 
 bad = create_color_func("BAD")
 
@@ -336,7 +337,8 @@ class Actions(object):
                        portage_version = "Unknown"
                # Use new footer only for git (see bug #438364).
                if self.vcs_settings.vcs in ["git"]:
-                       commit_footer = "\n\nPackage-Manager: portage-%s" % 
portage_version
+                       commit_footer = "\n\nPackage-Manager: Portage-%s, 
Repoman-%s" % (
+                                                       portage.VERSION, 
VERSION)
                        if report_options:
                                commit_footer += "\nRepoMan-Options: " + " 
".join(report_options)
                        if self.repo_settings.sign_manifests:

diff --git a/repoman/setup.py b/repoman/setup.py
index dfa33fb..1c148c6 100755
--- a/repoman/setup.py
+++ b/repoman/setup.py
@@ -10,6 +10,7 @@ from distutils.command.build_scripts import build_scripts
 from distutils.command.clean import clean
 from distutils.command.install import install
 from distutils.command.install_data import install_data
+from distutils.command.install_lib import install_lib
 from distutils.command.install_scripts import install_scripts
 from distutils.command.sdist import sdist
 from distutils.dep_util import newer
@@ -20,6 +21,7 @@ import codecs
 import collections
 import os
 import os.path
+import re
 import subprocess
 import sys
 
@@ -266,6 +268,43 @@ class x_install_data(install_data):
                self.data_files = old_data_files
 
 
+class x_install_lib(install_lib):
+       """ install_lib command with Portage path substitution """
+
+       user_options = install_lib.user_options
+
+       def initialize_options(self):
+               install_lib.initialize_options(self)
+
+       def finalize_options(self):
+               install_lib.finalize_options(self)
+               self.set_undefined_options('install',)
+
+       def install(self):
+               ret = install_lib.install(self)
+
+               def rewrite_file(path, val_dict):
+                       path = os.path.join(self.install_dir, path)
+                       print('Rewriting %s' % path)
+                       with codecs.open(path, 'r', 'utf-8') as f:
+                               data = f.read()
+
+                       for varname, val in val_dict.items():
+                               regexp = r'(?m)^(%s\s*=).*$' % varname
+                               repl = r'\1 %s' % repr(val)
+
+                               data = re.sub(regexp, repl, data)
+
+                       with codecs.open(path, 'w', 'utf-8') as f:
+                               f.write(data)
+
+               rewrite_file('repoman/__init__.py', {
+                       'VERSION': self.distribution.get_version(),
+               })
+
+               return ret
+
+
 class x_install_scripts_custom(install_scripts):
        def initialize_options(self):
                install_scripts.initialize_options(self)
@@ -431,6 +470,7 @@ setup(
                'clean': x_clean,
                'install': x_install,
                'install_data': x_install_data,
+               'install_lib': x_install_lib,
                'install_scripts': x_install_scripts,
                'install_scripts_bin': x_install_scripts_bin,
                'sdist': x_sdist,

Reply via email to