[virt-tools-list] [virt-install PATCH 1/2] setup: rebuild manpages in build phase
Martin Kletzander
mkletzan at redhat.com
Thu Dec 6 15:47:19 UTC 2012
Until now, the manpages were rebuilt only in sdist phase, this patch
changes it to be part of the build phase as well.
---
setup.py | 96 +++++++++++++++++++++++++++++++++-------------------------------
1 file changed, 50 insertions(+), 46 deletions(-)
diff --git a/setup.py b/setup.py
index 7019ca3..43b0e4e 100755
--- a/setup.py
+++ b/setup.py
@@ -45,6 +45,52 @@ def _build_lang_data():
ret.append((targetpath, [newname]))
return ret
+def _update_manpages():
+ # Update virt-install.1 with latest os type/variant values
+ import virtinst.osdict as osdict
+
+ # Build list first
+ ret = []
+ for t in osdict.sort_helper(osdict.OS_TYPES):
+ for v in osdict.sort_helper(osdict.OS_TYPES[t]["variants"]):
+ label = osdict.OS_TYPES[t]["variants"][v]["label"]
+ if osdict.lookup_osdict_key(None, None, t, v, "supported"):
+ ret.append((v, label))
+
+ output = ""
+ output += "=over 2\n\n"
+
+ for v, label in ret:
+ output += "=item %-20s : %s\n\n" % (v, label)
+
+ output += "=back\n\n"
+
+ infile = "man/en/virt-install.pod.in"
+ outfile = "man/en/virt-install.pod"
+
+ outfd = open(outfile, "w+")
+ origout = outfd.read()
+ outfd.close()
+
+ infd = open(infile, "r")
+ inp = infd.read()
+ infd.close()
+
+ outp = inp.replace("::VARIANT VALUES::", output)
+ if outp != origout or not(os.path.exists(outfile)):
+ outfd = open(outfile, "w")
+ outfd.write(outp)
+ outfd.close()
+
+ # Generate new manpages
+ if os.system("make -C man/en"):
+ raise RuntimeError("Couldn't generate man pages.")
+
+ if os.system("grep -IRq 'Hey!' man/en") == 0:
+ raise RuntimeError("man pages have errors in them! "
+ "(grep for 'Hey!')")
+
+
# Config file building
config_files = ["virtinst/_config.py", "virtconv/_config.py"]
config_template = """
@@ -243,55 +289,10 @@ class mysdist(sdist):
os.system(cmd)
# Update and generate man pages
- self._update_manpages()
+ _update_manpages()
sdist.run(self)
- def _update_manpages(self):
- # Update virt-install.1 with latest os type/variant values
- import virtinst.osdict as osdict
-
- # Build list first
- ret = []
- for t in osdict.sort_helper(osdict.OS_TYPES):
- for v in osdict.sort_helper(osdict.OS_TYPES[t]["variants"]):
- label = osdict.OS_TYPES[t]["variants"][v]["label"]
- if osdict.lookup_osdict_key(None, None, t, v, "supported"):
- ret.append((v, label))
-
- output = ""
- output += "=over 2\n\n"
-
- for v, label in ret:
- output += "=item %-20s : %s\n\n" % (v, label)
-
- output += "=back\n\n"
-
- infile = "man/en/virt-install.pod.in"
- outfile = "man/en/virt-install.pod"
-
- outfd = open(outfile, "w+")
- origout = outfd.read()
- outfd.close()
-
- infd = open(infile, "r")
- inp = infd.read()
- infd.close()
-
- outp = inp.replace("::VARIANT VALUES::", output)
- if outp != origout or not(os.path.exists(outfile)):
- outfd = open(outfile, "w")
- outfd.write(outp)
- outfd.close()
-
- # Generate new manpages
- if os.system("make -C man/en"):
- raise RuntimeError("Couldn't generate man pages.")
-
- if os.system("grep -IRq 'Hey!' man/en") == 0:
- raise RuntimeError("man pages have errors in them! "
- "(grep for 'Hey!')")
-
class mybuild(build):
""" custom build command to compile i18n files"""
@@ -337,6 +338,9 @@ class mybuild(build):
build.run(self)
+ # Update and generate man pages, but not before the build is done!
+ _update_manpages()
+
setup(
name='virtinst',
version=VERSION,
--
1.8.0
More information about the virt-tools-list
mailing list