File calibre-setup.install.py.diff of Package calibre

diff -Pdpru calibre-5.15.0.orig/setup/install.py calibre-5.15.0/setup/install.py
--- calibre-5.15.0.orig/setup/install.py	2021-04-16 04:20:00.000000000 +0200
+++ calibre-5.15.0/setup/install.py	2021-04-16 11:51:25.550511789 +0200
@@ -87,10 +87,12 @@ class Develop(Command):
         if not opts.prefix:
             opts.prefix = sys.prefix
         for x in ('prefix', 'libdir', 'bindir', 'sharedir', 'staging_root',
-                'staging_libdir', 'staging_bindir', 'staging_sharedir'):
+                'staging_libdir', 'staging_bindir', 'staging_sharedir',
+                'mandir', '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')
@@ -98,6 +100,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):
@@ -111,9 +116,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, '')
         self.system_plugins_loc = opts.system_plugins_location
 
         if self.__class__.__name__ == 'Develop':
@@ -125,6 +138,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):
@@ -250,6 +265,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',
@@ -260,6 +280,49 @@ class Install(Develop):
                 help='Path to a directory from which the installed calibre will load plugins')
         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):
openSUSE Build Service is sponsored by