[virt-tools-list] [PATCH-v6.1 2/5] automate @VERSION@ in virt-manager.spec

Gene Czarcinski gene at czarc.net
Wed Apr 17 00:44:14 UTC 2013


This update renames virt-manager.spec to be
virt-manager.spec.in and changes the version-id to
@VERSION@ ... setup.py is modified to copy the
virt-manager-spec.in file to virt-manager.spec and
replace @VERSION@ with the current/actual version id.

.gitignore is updated to ignore virt-manager.spec
.
Signed-off-by: Gene Czarcinski <gene at czarc.net>
---
 .gitignore                                |  1 +
 setup.py                                  | 17 ++++++++++++++++-
 virt-manager.spec => virt-manager.spec.in |  2 +-
 3 files changed, 18 insertions(+), 2 deletions(-)
 rename virt-manager.spec => virt-manager.spec.in (99%)

diff --git a/.gitignore b/.gitignore
index c90bdd4..b2e57a3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,4 +21,5 @@ virt-installc
 /man/virt-convert.1
 /man/virt-image.5
 
+/virt-manager.spec
 /virtcli/cli.cfg
diff --git a/setup.py b/setup.py
index eecdecf..f8ad290 100644
--- a/setup.py
+++ b/setup.py
@@ -10,6 +10,7 @@ import sys
 import unittest
 
 from distutils.core import Command, setup
+from distutils.command.sdist import sdist
 from distutils.command.install import install
 from distutils.command.install_egg_info import install_egg_info
 from distutils.sysconfig import get_config_var
@@ -180,6 +181,20 @@ class my_install(install):
 
         install.finalize_options(self)
 
+class my_sdist(sdist_auto, sdist):
+    user_option = []
+    description = "Update virt-manager.spec; build sdist-tarball."
+
+    def run(self):
+        ver = cliconfig.__version__
+        f1 = open('virt-manager.spec.in', 'r')
+        f2 = open('virt-manager.spec', 'w')
+        for line in f1:
+            f2.write(line.replace('@VERSION@', ver))
+        f1.close()
+        f2.close()
+        sdist.run(self)
+
 
 ###################
 # Custom commands #
@@ -474,7 +489,7 @@ setup(
         'build_i18n': my_build_i18n,
         'build_icons': my_build_icons,
 
-        'sdist': sdist_auto,
+        'sdist': my_sdist,
         'install': my_install,
         'install_egg_info': my_egg_info,
 
diff --git a/virt-manager.spec b/virt-manager.spec.in
similarity index 99%
rename from virt-manager.spec
rename to virt-manager.spec.in
index 99a35e3..c4cb779 100644
--- a/virt-manager.spec
+++ b/virt-manager.spec.in
@@ -1,6 +1,6 @@
 # -*- rpm-spec -*-
 
-%define _version 0.9.4
+%define _version @VERSION@
 %define _release 1
 
 %define qemu_user                  ""
-- 
1.8.1.4




More information about the virt-tools-list mailing list