aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Dolbec <dolsen@gentoo.org>2015-01-06 12:20:30 -0800
committerBrian Dolbec <dolsen@gentoo.org>2015-01-06 13:19:39 -0800
commit7bfa40a4b350767ec8e8d2812620bb8be6ce48a4 (patch)
tree073db41c91bb62006a565709f13dd1609022ac99 /gkeys-gen
parentpy2man/options.py: Add missed '1name' option (diff)
downloadgentoo-keys-7bfa40a4b350767ec8e8d2812620bb8be6ce48a4.tar.gz
gentoo-keys-7bfa40a4b350767ec8e8d2812620bb8be6ce48a4.tar.bz2
gentoo-keys-7bfa40a4b350767ec8e8d2812620bb8be6ce48a4.zip
gkeys-gen: Setup.py updates for man page generation
Diffstat (limited to 'gkeys-gen')
-rw-r--r--gkeys-gen/gkeygen/__init__.py20
-rwxr-xr-xgkeys-gen/setup.py80
2 files changed, 95 insertions, 5 deletions
diff --git a/gkeys-gen/gkeygen/__init__.py b/gkeys-gen/gkeygen/__init__.py
index 7e8b64e..495f798 100644
--- a/gkeys-gen/gkeygen/__init__.py
+++ b/gkeys-gen/gkeygen/__init__.py
@@ -1,5 +1,25 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
+from collections import OrderedDict
+
+from gkeygen.actions import Action_Map, Available_Actions
+
+
__version__ = 'Git'
__license__ = 'GPLv2'
+
+
+subdata = OrderedDict()
+for cmd in Available_Actions:
+ subdata[cmd] = Action_Map[cmd]['desc']
+
+Gkeys_Map = {
+ 'options': ['help', 'config', 'debug'],
+ 'desc': 'OpenPGP/GPG key generator tool',
+ 'long_desc': '''Gentoo Keys (gkeys) is a Python based project that aims to manage
+the GPG keys used for validation on users and Gentoo's infrastracutre servers.
+Gkeys-gen is a tool for generating OpnPGP/GPG keys according to a selected spec.''',
+ 'sub-cmds': subdata,
+ 'authors': ['Brian Dolbec <dolsen@gentoo.org>', 'Pavlos Ratis <dastergon@gentoo.org>'],
+}
diff --git a/gkeys-gen/setup.py b/gkeys-gen/setup.py
index 063bff1..fc93bf0 100755
--- a/gkeys-gen/setup.py
+++ b/gkeys-gen/setup.py
@@ -1,11 +1,26 @@
#!/usr/bin/env python
+
+import collections
import os
import sys
-from distutils.core import setup
+from distutils.core import setup, Command
+from distutils.command.build import build
+
from gkeygen import __version__, __license__
+from gkeygen import Gkeys_Map
+from gkeygen.actions import Action_Map, Available_Actions
+
+try:
+ from py2man import manpages
+except ImportError:
+ print('creating py2man symlink')
+ os.symlink('../py2man', 'py2man')
+ from py2man import manpages
+
+
# this affects the names of all the directories we do stuff with
sys.path.insert(0, './')
@@ -18,10 +33,61 @@ except ImportError:
EPREFIX=''
+class x_build(build):
+ """ Build command with extra build_man call. """
+
+ def run(self):
+ build.run(self)
+ self.run_command('build_man')
+
+
+class build_man(Command):
+ """ Perform substitutions in manpages. """
+
+ user_options = [
+ ]
+
+ def initialize_options(self):
+ self.build_base = None
+
+ def finalize_options(self):
+ self.set_undefined_options('build',
+ ('build_base', 'build_base'))
+
+ def run(self):
+ # create the main page
+ basepath = os.path.dirname(__file__)
+ docpath = os.path.join(basepath, 'doc')
+ templatepath = os.path.dirname(manpages.__file__)
+ man = manpages.ManPage('gkey-gen', __version__, None,
+ docpath, Gkeys_Map['authors'])
+ man.read_template(templatepath, 'command.template')
+ man.make_prog(Gkeys_Map)
+ man.read_template(templatepath, 'sub-command.template')
+ man.make_subpages(Action_Map, Available_Actions)
+
+
+def get_manpages():
+ linguas = os.environ.get('LINGUAS')
+ if linguas is not None:
+ linguas = linguas.split()
+
+ for dirpath, dirnames, filenames in os.walk('doc'):
+ groups = collections.defaultdict(list)
+ for f in filenames:
+ fn, suffix = f.rsplit('.', 1)
+ groups[suffix].append(os.path.join(dirpath, f))
+
+ topdir = dirpath[len('doc/'):]
+ if not topdir or linguas is None or topdir in linguas:
+ for g, mans in groups.items():
+ yield [os.path.join('$mandir', topdir, 'man%s' % g), mans]
+
+
setup(
- name='gkeygen',
+ name='gkeys-gen',
version=__version__,
- description="Gentoo gpg key management key generator",
+ description="OpenPGP/GPG key generator",
author='',
author_email='',
maintainer='Gentoo-Keys Team',
@@ -30,12 +96,16 @@ setup(
download_url='',
packages=['gkeygen'],
scripts=['bin/gkey-gen'],
- data_files=(
+ data_files=list(get_manpages()) + [
(os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'etc/gkeys/'), ['etc/gkeys-gen.conf']),
- ),
+ ],
license=__license__,
long_description=open('README.md').read(),
keywords='gpg',
+ cmdclass = {
+ 'build': x_build,
+ 'build_man': build_man,
+ },
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers, Users',