This commit is contained in:
Kovid Goyal 2009-09-27 10:42:02 -06:00
parent ef06fbee81
commit 18dc1ce656
2 changed files with 25 additions and 34 deletions

View File

@ -95,9 +95,19 @@ class Develop(Command):
if self.staging_sharedir is None:
self.staging_sharedir = opts.staging_sharedir = self.j(opts.staging_root, 'share')
self.staging_libdir = opts.staging_libdir = self.j(self.staging_libdir, 'calibre')
self.staging_sharedir = opts.staging_sharedir = self.j(self.staging_sharedir, 'calibre')
if self.__class__.__name__ == 'Develop':
self.libdir = self.SRC
self.sharedir = self.RESOURCES
else:
self.libdir = self.j(self.libdir, 'calibre')
self.sharedir = self.j(self.sharedir, 'calibre')
self.info('INSTALL paths:')
self.info('\tLIB:', self.staging_libdir)
self.info('\tSHARE:', self.staging_sharedir)
def pre_sub_commands(self, opts):
if not islinux:
@ -113,6 +123,7 @@ class Develop(Command):
c
def run(self, opts):
self.manifest = []
self.opts = opts
self.regain_privileges()
self.consolidate_paths()
@ -140,6 +151,7 @@ class Develop(Command):
os.chown(dest, 0, 0)
os.chmod(dest, stat.S_ISUID|stat.S_ISGID|stat.S_IRUSR|stat.S_IWUSR|\
stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH)
self.manifest.append(dest)
return dest
def install_files(self):
@ -148,7 +160,8 @@ class Develop(Command):
def run_postinstall(self):
if self.opts.postinstall:
from calibre.linux import PostInstall
PostInstall(self.opts, info=self.info, warn=self.warn)
PostInstall(self.opts, info=self.info, warn=self.warn,
manifest=self.manifest)
def success(self):
self.info('\nDevelopment environment successfully setup')
@ -171,6 +184,7 @@ class Develop(Command):
self.info('Installing binary:', path)
open(path, 'wb').write(script)
os.chmod(path, self.MODE)
self.manifest.append(path)
class Install(Develop):
@ -224,6 +238,7 @@ class Install(Develop):
if os.path.exists(dest):
shutil.rmtree(dest)
shutil.copytree(self.RESOURCES, dest)
self.manifest.extend([self.staging_libdir, self.staging_sharedir])
def success(self):
self.info('\n\ncalibre successfully installed. You can start'

View File

@ -87,7 +87,7 @@ class PostInstall:
'bin')
if not self.opts.staging_sharedir:
self.opts.staging_sharedir = os.path.join(self.opts.staging_root,
'etc')
'share', 'calibre')
self.opts.staging_etc = '/etc' if self.opts.staging_root == '/usr' else \
os.path.join(self.opts.staging_root, 'etc')
@ -143,16 +143,16 @@ class PostInstall:
from calibre.utils.smtp import option_parser as smtp_op
any_formats = ['epub', 'htm', 'html', 'xhtml', 'xhtm', 'rar', 'zip',
'txt', 'lit', 'rtf', 'pdf', 'prc', 'mobi', 'fb2', 'odt']
if os.path.exists(os.path.join(self.opts.staging_sharedir,
'bash-completion')):
f = os.path.join(self.opts.staging_sharedir,
'bash-completion', 'calibre')
bc = os.path.join(os.path.dirname(self.opts.staging_sharedir),
'bash-completion')
if os.path.exists(bc):
f = os.path.join(bc, 'calibre')
else:
f = os.path.join(self.opts.staging_etc,
'bash_completion.d/calibre')
f = os.path.join(self.opts.staging_etc, 'bash_completion.d/calibre')
if not os.path.exists(os.path.dirname(f)):
os.makedirs(os.path.dirname(f))
self.manifest.append(f)
self.info('Installing bash completion to', f)
with open(f, 'wb') as f:
f.write('# calibre Bash Shell Completion\n')
f.write(opts_and_exts('calibre', guiop, any_formats))
@ -359,9 +359,9 @@ def option_parser():
parser.add_option('--root', dest='staging_root', default='/usr',
help='Prefix under which to install files')
parser.add_option('--bindir', default=None, dest='staging_bindir',
help='Location where calibre launcher scripts were installed')
help='Location where calibre launcher scripts were installed. Typically /usr/bin')
parser.add_option('--sharedir', default=None, dest='staging_sharedir',
help='Location where calibre resources were installed')
help='Location where calibre resources were installed, typically /usr/share/calibre')
return parser
@ -447,30 +447,6 @@ def opts_and_exts(name, op, exts):
complete -o filenames -F _'''%(opts,exts) + name + ' ' + name +"\n\n"
def post_install():
parser = option_parser()
opts = parser.parse_args()[0]
global use_destdir
use_destdir = opts.destdir
manifest = []
try:
from PyQt4 import Qt
if Qt.PYQT_VERSION < int('0x40402', 16):
print 'WARNING: You need PyQt >= 4.4.2 for the GUI. You have', Qt.PYQT_VERSION_STR, '\nYou may experience crashes or other strange behavior.'
except ImportError:
print 'WARNING: You do not have PyQt4 installed. The GUI will not work.'
if opts.save_manifest_to:
open(opts.save_manifest_to, 'wb').write('\n'.join(manifest)+'\n')
def binary_install():
manifest = os.path.join(getattr(sys, 'frozen_path'), 'manifest')
post_install()
return 0
VIEWER = '''\
[Desktop Entry]
Version=%s