mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Linux install: No longer create MAN pages as all utilities have more comprehensive command line --help anyway
This commit is contained in:
parent
94440f3fc6
commit
3cc83b5e28
@ -3,7 +3,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
''' Post installation script for linux '''
|
||||
|
||||
import sys, os, cPickle, textwrap, stat, importlib
|
||||
import sys, os, cPickle, textwrap, stat
|
||||
from subprocess import check_call
|
||||
|
||||
from calibre import __appname__, prints, guess_type
|
||||
@ -177,7 +177,6 @@ class PostInstall:
|
||||
self.mime_resources = []
|
||||
if islinux or isbsd:
|
||||
self.setup_completion()
|
||||
self.install_man_pages()
|
||||
if islinux or isbsd:
|
||||
self.setup_desktop_integration()
|
||||
self.create_uninstaller()
|
||||
@ -343,38 +342,6 @@ class PostInstall:
|
||||
self.task_failed('Setting up completion failed')
|
||||
# }}}
|
||||
|
||||
def install_man_pages(self): # {{{
|
||||
try:
|
||||
from calibre.utils.help2man import create_man_page
|
||||
if isbsd:
|
||||
manpath = os.path.join(self.opts.staging_root, 'man/man1')
|
||||
else:
|
||||
manpath = os.path.join(self.opts.staging_sharedir, 'man/man1')
|
||||
if not os.path.exists(manpath):
|
||||
os.makedirs(manpath)
|
||||
self.info('Installing MAN pages...')
|
||||
for src in entry_points['console_scripts']:
|
||||
prog, right = src.split('=')
|
||||
prog = prog.strip()
|
||||
module = importlib.import_module(right.split(':')[0].strip())
|
||||
parser = getattr(module, 'option_parser', None)
|
||||
if parser is None:
|
||||
continue
|
||||
parser = parser()
|
||||
raw = create_man_page(prog, parser)
|
||||
if isbsd:
|
||||
manfile = os.path.join(manpath, prog+'.1')
|
||||
else:
|
||||
manfile = os.path.join(manpath, prog+'.1'+__appname__+'.bz2')
|
||||
self.info('\tInstalling MAN page for', prog)
|
||||
open(manfile, 'wb').write(raw)
|
||||
self.manifest.append(manfile)
|
||||
except:
|
||||
if self.opts.fatal_errors:
|
||||
raise
|
||||
self.task_failed('Installing MAN pages failed')
|
||||
# }}}
|
||||
|
||||
def setup_desktop_integration(self): # {{{
|
||||
try:
|
||||
self.info('Setting up desktop integration...')
|
||||
|
@ -1,66 +0,0 @@
|
||||
from __future__ import with_statement
|
||||
__license__ = 'GPL 3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import time, bz2
|
||||
from calibre.constants import isbsd
|
||||
|
||||
from calibre.constants import __version__, __appname__, __author__
|
||||
|
||||
|
||||
def create_man_page(prog, parser):
|
||||
usage = parser.usage.splitlines()
|
||||
for i, line in enumerate(list(usage)):
|
||||
if not line.strip():
|
||||
usage[i] = '.PP'
|
||||
else:
|
||||
usage[i] = line.replace('%prog', prog)
|
||||
lines = [
|
||||
'.TH ' + prog.upper() + ' "1" ' + time.strftime('"%B %Y"') +
|
||||
' "%s (%s %s)" "%s"'%(prog, __appname__, __version__, __appname__),
|
||||
'.SH NAME',
|
||||
prog + r' \- part of '+__appname__,
|
||||
'.SH SYNOPSIS',
|
||||
'.B "%s"'%prog + r'\fR '+' '.join(usage[0].split()[1:]),
|
||||
'.SH DESCRIPTION',
|
||||
]
|
||||
lines += usage[1:]
|
||||
|
||||
lines += [
|
||||
'.SH OPTIONS'
|
||||
]
|
||||
def format_option(opt):
|
||||
ans = ['.TP']
|
||||
opts = []
|
||||
opts += opt._short_opts
|
||||
opts.append(opt.get_opt_string())
|
||||
opts = [r'\fB'+x.replace('-', r'\-')+r'\fR' for x in opts]
|
||||
ans.append(', '.join(opts))
|
||||
help = opt.help if opt.help else ''
|
||||
ans.append(help.replace('%prog', prog).replace('%default', str(opt.default)))
|
||||
return ans
|
||||
|
||||
for opt in parser.option_list:
|
||||
lines.extend(format_option(opt))
|
||||
for group in parser.option_groups:
|
||||
lines.append('.SS '+group.title)
|
||||
if group.description:
|
||||
lines.extend(['.PP', group.description])
|
||||
for opt in group.option_list:
|
||||
lines.extend(format_option(opt))
|
||||
|
||||
lines += ['.SH SEE ALSO',
|
||||
'The User Manual is available at '
|
||||
'http://manual.calibre-ebook.com',
|
||||
'.PP', '.B Created by '+__author__]
|
||||
|
||||
lines = [x if isinstance(x, unicode) else unicode(x, 'utf-8', 'replace') for
|
||||
x in lines]
|
||||
|
||||
if not isbsd:
|
||||
return bz2.compress((u'\n'.join(lines)).encode('utf-8'))
|
||||
else:
|
||||
return (u'\n'.join(lines)).encode('utf-8')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user