From e0450dccf82773222a26f07920bdb0e88e8dd522 Mon Sep 17 00:00:00 2001 From: Kevin Lyda <kevin@ie.suberic.net> Date: Sun, 27 May 2012 01:27:18 +0100 Subject: [PATCH] Manpage edits and installer. --- doc/chkcrontab.1 | 6 ++++-- doc/chkcrontab.1.rst | 8 ++++---- setup.py | 46 ++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/doc/chkcrontab.1 b/doc/chkcrontab.1 index 5299ec9..511eec1 100644 --- a/doc/chkcrontab.1 +++ b/doc/chkcrontab.1 @@ -61,8 +61,10 @@ Reports any bare \fB%\fP in a command. .UNINDENT .SH BUGS .sp -Quite possibly. Report them via the \fI\%issue tracker\fP at the project -website. +Quite possibly. Report them via the issue tracker at the project +website: +.sp +\fI\%http://code.google.com/p/chkcrontab/issues/list\fP .SH SEE ALSO .sp \fBlint\fP (1) diff --git a/doc/chkcrontab.1.rst b/doc/chkcrontab.1.rst index 32393f7..814f567 100644 --- a/doc/chkcrontab.1.rst +++ b/doc/chkcrontab.1.rst @@ -36,8 +36,10 @@ The following check are run against the given crontab file. Bugs ---- -Quite possibly. Report them via the `issue tracker`_ at the project -website. +Quite possibly. Report them via the issue tracker at the project +website: + +http://code.google.com/p/chkcrontab/issues/list See Also -------- @@ -52,5 +54,3 @@ Copying Copyright (C) 2012 Kevin Lyda. Free use of this software is granted under the terms of the GNU General Public License version 3 or any later version. - -.. _`issue tracker`: http://code.google.com/p/chkcrontab/issues/list diff --git a/setup.py b/setup.py index 41af5f8..5bc4732 100755 --- a/setup.py +++ b/setup.py @@ -20,7 +20,9 @@ This installs the chkcrontab command and the crontab.check module. import os import sys +from distutils import file_util from distutils import log +from distutils.command.install import install from distutils.core import setup from distutils.core import Command if sys.version_info < (2, 7): @@ -31,7 +33,7 @@ else: BASE_DIR = os.path.dirname(globals().get('__file__', os.getcwd())) -class TestCommand(Command): +class TestCmd(Command): description = 'Runs all available tests.' user_options = [ ] @@ -50,7 +52,7 @@ class TestCommand(Command): if not result.wasSuccessful(): sys.exit(1) -class CleanCommand(Command): +class CleanCmd(Command): description = 'Remove all generated files.' user_options = [ ] @@ -117,9 +119,45 @@ class CleanCommand(Command): except: log.warn('unable to remove "%s"', os.path.normpath(accused)) + +class InstallCmd(install): + user_options = install.user_options[:] + user_options.extend([('manprefix=', None, + 'installation prefix for man pages')]) + + def initialize_options(self): + self.manprefix = None + install.initialize_options(self) + + def finalize_options(self): + install.finalize_options(self) + if self.manprefix is None : + self.manprefix = os.path.join(self.install_scripts, + '..', 'share', 'man') + + def run(self): + install.run(self) + manpages=['doc/chkcrontab.1'] + if self.manprefix: + for manpage in manpages: + section = manpage.split('/')[-1].split('.')[-1] + manpage_file = manpage.split('/')[-1] + manpage_dir = os.path.realpath(os.path.join(self.manprefix, + 'man%s' % section)) + if not self.dry_run: + try: + os.makedirs(manpage_dir) + except OSError: + pass + file_util.copy_file(manpage, + os.path.join(manpage_dir, manpage_file), + dry_run=self.dry_run) + setup( - cmdclass={'test': TestCommand, - 'dist_clean': CleanCommand + cmdclass={'test': TestCmd, + 'dist_clean': CleanCmd, + 'dist_clean': CleanCmd, + 'install': InstallCmd, }, name='chkcrontab', version='1.2', -- GitLab