File calibre-setup.install.py.diff of Package calibre
diff -Pdpru calibre-2.79.0.orig/setup/install.py calibre-2.79.0/setup/install.py
--- calibre-2.79.0.orig/setup/install.py 2017-02-10 04:09:41.000000000 +0100
+++ calibre-2.79.0/setup/install.py 2017-02-10 19:47:38.648066452 +0100
@@ -75,11 +75,13 @@ class Develop(Command):
opts = self.opts
if not opts.prefix:
opts.prefix = sys.prefix
- for x in ('prefix', 'libdir', 'bindir', 'sharedir', 'staging_root',
- 'staging_libdir', 'staging_bindir', 'staging_sharedir'):
+ for x in ('prefix', 'libdir', 'bindir', 'sharedir', 'mandir',
+ 'staging_root', 'staging_libdir',
+ 'staging_bindir', 'staging_sharedir', 'locale_dir'):
o = getattr(opts, x, None)
if o:
setattr(opts, x, os.path.abspath(o))
+ self.info( "****", opts, self )
self.libdir = getattr(opts, 'libdir', None)
if self.libdir is None:
self.libdir = self.j(opts.prefix, 'lib')
@@ -87,6 +89,9 @@ class Develop(Command):
if self.bindir is None:
self.bindir = self.j(opts.prefix, 'bin')
self.sharedir = getattr(opts, 'sharedir', None)
+ self.mandir = getattr(opts, 'mandir', None)
+ if self.mandir is None:
+ self.mandir = self.j(opts.prefix, 'share')
if self.sharedir is None:
self.sharedir = self.j(opts.prefix, 'share')
if not getattr(opts, 'staging_root', None):
@@ -100,9 +105,17 @@ class Develop(Command):
self.staging_sharedir = getattr(opts, 'staging_sharedir', None)
if self.staging_sharedir is None:
self.staging_sharedir = opts.staging_sharedir = self.j(opts.staging_root, 'share')
+ self.staging_mandir = getattr(opts, 'staging_mandir', None)
+ if self.staging_mandir is None:
+ self.staging_mandir = opts.staging_mandir = self.j(opts.staging_root, 'man')
+ self.staging_localedir = getattr(opts, 'staging_localedir', None)
+ if self.staging_localedir is None:
+ self.staging_localedir = opts.staging_localedir = self.j(opts.staging_root, 'usr/share/locale')
self.staging_libdir = opts.staging_libdir = self.j(self.staging_libdir, 'calibre')
self.staging_sharedir = opts.staging_sharedir = self.j(self.staging_sharedir, 'calibre')
+ self.staging_mandir = opts.staging_mandir = self.j(self.staging_mandir, '')
+ self.staging_localedir = opts.staging_localedir = self.j(self.staging_localedir, '')
if self.__class__.__name__ == 'Develop':
self.libdir = self.SRC
@@ -113,6 +126,8 @@ class Develop(Command):
self.info('INSTALL paths:')
self.info('\tLIB:', self.staging_libdir)
self.info('\tSHARE:', self.staging_sharedir)
+ self.staging_mandir =self.j(self.mandir, '')
+ # self.mandir = self.j(opts.staging_root, 'man')
def pre_sub_commands(self, opts):
if not (islinux or isbsd or ishaiku):
@@ -232,6 +247,11 @@ class Install(Develop):
'the launcher scripts. This option controls the prefix '
'to which the install will actually copy files. By default '
'it is set to the value of --prefix.'))
+ parser.add_option('--staging-mandir',
+ help='Where to put the calibre manpage files. Default is <root>/man')
+ parser.add_option('--staging-locale-dir',
+ dest="staging_localedir",
+ help="Where to put the calibre locale files. Default is <root>/share/locale")
parser.add_option('--staging-libdir',
help='Where to put calibre library files. Default is <root>/lib')
parser.add_option('--staging-bindir',
@@ -240,6 +260,49 @@ class Install(Develop):
help='Where to put the calibre data files. Default is <root>/share')
self.add_postinstall_options(parser)
+ def install_localefiles(self):
+ """Install the .mo files"""
+ #if not self.locale_dir.startswith( sys.prefix ):
+ # # We don't want to disturb installation when option --locale-dir is not set
+ # return
+ locale = os.path.join(self.RESOURCES, "localization/locales")
+ dest = self.staging_localedir
+ self.info("Installing locale files...")
+ self.info("*** locale_dir:", dest)
+ self.info("*** SRC:", self.SRC)
+ self.info("*** DEST:", dest)
+ if not os.path.exists(dest):
+ os.makedirs(dest)
+ for lang in os.listdir( locale ):
+ j = os.path.join(locale, lang)
+ dd = os.path.join(dest, lang)
+ if os.path.exists(dd):
+ shutil.rmtree(dd)
+ lc_message_dest = os.path.join(dest, lang, 'LC_MESSAGES')
+ lc_message = os.path.join(locale, lang, "LC_MESSAGES")
+ self.info("Creating locale directory %s " % lc_message_dest)
+ os.makedirs( lc_message_dest )
+ filedict = {
+ 'iso639.mo': 'iso639.mo',
+ 'messages.mo': 'calibre.mo',
+ 'qt.qm': '',
+ }
+ for f in os.listdir(lc_message):
+ destfile = filedict.get(f)
+ if destfile != '':
+ self.info("Moving %s -> %s" % (lang, dd))
+ shutil.move(os.path.join(lc_message, f),
+ os.path.join(dest, lang, 'LC_MESSAGES', destfile ))
+
+
+ #shutil.move(os.path.join(locale,i), dest)
+ # Rename that beast:
+ #shutil.move(os.path.join(dest, i, 'LC_MESSAGES/messages.mo'),
+ # os.path.join(dest, i, 'LC_MESSAGES/calibre.mo'))
+ #os.remove( os.path.join(dest, i, 'LC_MESSAGES/qt.qm' )
+ #shutil.copytree(j, dd )
+ shutil.rmtree(os.path.join(self.RESOURCES, "localization/locales") )
+
def install_files(self):
dest = self.staging_libdir
if os.path.exists(dest):