mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Get rid of install command line tool, since Apple has deprecated the API's it used to obtain root
This commit is contained in:
parent
2de0a442e4
commit
0e8bc340eb
@ -38,9 +38,9 @@ the directory in which you created :file:`__init__.py`::
|
||||
calibre-customize -b .
|
||||
|
||||
.. note::
|
||||
On OS X you have to first install the |app| command line tools, by
|
||||
going to :guilabel:`Preferences->Miscellaneous` and clicking the
|
||||
:guilabel:`Install command line tools` button.
|
||||
On OS X, the command line tools are inside the |app| bundle, for example,
|
||||
if you installed calibre in :file:`/Applications` the command line tools
|
||||
are in :file:`/Applications/calibre.app/Contents/MacOS/calibre`.
|
||||
|
||||
You can download the Hello World plugin from
|
||||
`helloworld_plugin.zip <http://calibre-ebook.com/downloads/helloworld_plugin.zip>`_.
|
||||
|
@ -29,9 +29,10 @@ Command Line Interface
|
||||
|
||||
.. image:: ../images/cli.png
|
||||
|
||||
On OS X you have to go to Preferences->Advanced->Miscellaneous and click install command line
|
||||
tools to make the command line tools available. On other platforms, just start
|
||||
a terminal and type the command.
|
||||
.. note::
|
||||
On OS X, the command line tools are inside the |app| bundle, for example,
|
||||
if you installed calibre in :file:`/Applications` the command line tools
|
||||
are in :file:`/Applications/calibre.app/Contents/MacOS/calibre`.
|
||||
|
||||
Documented Commands
|
||||
--------------------
|
||||
|
@ -295,7 +295,10 @@ Once the download is complete, you can look at the downloaded :term:`HTML` by op
|
||||
|
||||
If you're satisfied with your recipe, and you feel there is enough demand to justify its inclusion into the set of built-in recipes, post your recipe in the `calibre recipes forum <http://www.mobileread.com/forums/forumdisplay.php?f=228>`_ to share it with other calibre users.
|
||||
|
||||
.. note:: On OS X, the ebook-convert command will not be available by default. Go to Preferences->Miscellaneous and click the install command line tools button to make it available.
|
||||
.. note::
|
||||
On OS X, the command line tools are inside the |app| bundle, for example,
|
||||
if you installed calibre in :file:`/Applications` the command line tools
|
||||
are in :file:`/Applications/calibre.app/Contents/MacOS/calibre`.
|
||||
|
||||
.. seealso::
|
||||
|
||||
|
@ -9,9 +9,7 @@ import textwrap
|
||||
|
||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget, Setting
|
||||
from calibre.gui2.preferences.misc_ui import Ui_Form
|
||||
from calibre.gui2 import (error_dialog, config, open_local_file, info_dialog,
|
||||
gprefs)
|
||||
from calibre.constants import isosx
|
||||
from calibre.gui2 import (config, open_local_file, gprefs)
|
||||
from calibre import get_proxies
|
||||
|
||||
class WorkersSetting(Setting):
|
||||
@ -40,8 +38,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
self.device_detection_button.clicked.connect(self.debug_device_detection)
|
||||
self.button_open_config_dir.clicked.connect(self.open_config_dir)
|
||||
self.user_defined_device_button.clicked.connect(self.user_defined_device)
|
||||
self.button_osx_symlinks.clicked.connect(self.create_symlinks)
|
||||
self.button_osx_symlinks.setVisible(isosx)
|
||||
proxies = get_proxies(debug=False)
|
||||
txt = _('No proxies used')
|
||||
if proxies:
|
||||
@ -64,21 +60,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
from calibre.utils.config import config_dir
|
||||
open_local_file(config_dir)
|
||||
|
||||
def create_symlinks(self):
|
||||
from calibre.utils.osx_symlinks import create_symlinks
|
||||
loc, paths = create_symlinks()
|
||||
if loc is None:
|
||||
error_dialog(self, _('Error'),
|
||||
_('Failed to install command line tools.'),
|
||||
det_msg=paths, show=True)
|
||||
else:
|
||||
info_dialog(self, _('Command line tools installed'),
|
||||
'<p>'+_('Command line tools installed in')+' '+loc+
|
||||
'<br>'+ _('If you move calibre.app, you have to re-install '
|
||||
'the command line tools.'),
|
||||
det_msg='\n'.join(paths), show=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from PyQt5.Qt import QApplication
|
||||
app = QApplication([])
|
||||
|
@ -91,13 +91,6 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="button_open_config_dir">
|
||||
<property name="text">
|
||||
<string>Open calibre &configuration directory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<spacer name="verticalSpacer_8">
|
||||
<property name="orientation">
|
||||
@ -111,14 +104,14 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="10" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="button_osx_symlinks">
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="button_open_config_dir">
|
||||
<property name="text">
|
||||
<string>&Install command line tools</string>
|
||||
<string>Open calibre &configuration directory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="22" column="0">
|
||||
<item row="21" column="0">
|
||||
<spacer name="verticalSpacer_9">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -131,7 +124,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="11" column="0" colspan="2">
|
||||
<item row="10" column="0" colspan="2">
|
||||
<widget class="QLabel" name="proxies">
|
||||
<property name="text">
|
||||
<string/>
|
||||
|
@ -1,93 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||
from __future__ import with_statement
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import sys, os, cPickle
|
||||
from calibre.constants import isnewosx
|
||||
|
||||
AUTHTOOL="""#!/usr/bin/python
|
||||
import os
|
||||
scripts = %s
|
||||
links = %s
|
||||
os.setuid(0)
|
||||
for s, l in zip(scripts, links):
|
||||
try:
|
||||
os.remove(l)
|
||||
except:
|
||||
pass
|
||||
print 'Creating link:', l, '->', s
|
||||
omask = os.umask(022)
|
||||
os.symlink(s, l)
|
||||
os.umask(omask)
|
||||
"""
|
||||
|
||||
DEST_PATH = '/usr/bin'
|
||||
|
||||
def create_symlinks():
|
||||
return create_symlinks_new() if isnewosx else create_symlinks_old()
|
||||
|
||||
def get_scripts():
|
||||
return cPickle.load(open(P('scripts.pickle'), 'rb'))
|
||||
|
||||
def create_symlinks_new():
|
||||
scripts = get_scripts()
|
||||
|
||||
links = [os.path.join(DEST_PATH, i) for i in scripts]
|
||||
scripts = [os.path.join(
|
||||
sys.binaries_path if scripts[i] == 'gui' else sys.console_binaries_path, i) for i in scripts]
|
||||
|
||||
return do_it(scripts, links)
|
||||
|
||||
|
||||
def create_symlinks_old():
|
||||
scripts = get_scripts()
|
||||
|
||||
resources_path = os.environ['RESOURCEPATH']
|
||||
links = [os.path.join(DEST_PATH, i) for i in scripts]
|
||||
scripts = [os.path.join(resources_path, 'loaders', i) for i in scripts]
|
||||
|
||||
return do_it(scripts, links)
|
||||
|
||||
def do_it(scripts, links):
|
||||
import os, tempfile, traceback
|
||||
from Authorization import Authorization, kAuthorizationFlagDestroyRights
|
||||
r1, r2 = DEST_PATH, links
|
||||
bad = False
|
||||
for s, l in zip(scripts, links):
|
||||
if os.path.exists(l) and os.path.exists(os.path.realpath(l)):
|
||||
continue
|
||||
bad = True
|
||||
break
|
||||
if bad:
|
||||
ph, pp = os.environ.get('PYTHONHOME', None), os.environ.get('PYTHONPATH', None)
|
||||
auth = Authorization(destroyflags=(kAuthorizationFlagDestroyRights,))
|
||||
fd, name = tempfile.mkstemp('.py')
|
||||
os.write(fd, AUTHTOOL % (repr(scripts), repr(links)))
|
||||
os.close(fd)
|
||||
os.chmod(name, 0700)
|
||||
try:
|
||||
if pp:
|
||||
del os.environ['PYTHONPATH']
|
||||
if ph:
|
||||
del os.environ['PYTHONHOME']
|
||||
pipe = auth.executeWithPrivileges(name)
|
||||
try:
|
||||
sys.stdout.write(pipe.read())
|
||||
except:
|
||||
sys.stdout.write(pipe.read()) # Probably EINTR
|
||||
pipe.close()
|
||||
except:
|
||||
r1, r2 = None, traceback.format_exc()
|
||||
finally:
|
||||
os.unlink(name)
|
||||
if pp:
|
||||
os.environ['PYTHONPATH'] = pp
|
||||
if ph:
|
||||
os.environ['PYTHONHOME'] = ph
|
||||
|
||||
return r1, r2
|
||||
|
Loading…
x
Reference in New Issue
Block a user