From 133ed8968f7e4c16bd6ece7c475d2c36cc006a3d Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 30 Aug 2019 13:59:11 +0530 Subject: [PATCH] Add a plist to the utils bundle Also move it to where it is easy to sign --- bypy/macos/__main__.py | 22 ++++++++++++++++++++-- bypy/macos/sign.py | 7 ++++--- src/calibre/ebooks/pdf/pdftohtml.py | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/bypy/macos/__main__.py b/bypy/macos/__main__.py index ec777ecb12..021580cf10 100644 --- a/bypy/macos/__main__.py +++ b/bypy/macos/__main__.py @@ -168,7 +168,7 @@ class Freeze(object): self.resources_dir = join(self.contents_dir, 'Resources') self.frameworks_dir = join(self.contents_dir, 'Frameworks') self.exe_dir = join(self.contents_dir, 'MacOS') - self.helpers_dir = join(self.build_dir, 'Helpers', 'utils.app', 'Contents', 'MacOS') + self.helpers_dir = join(self.contents_dir, 'utils.app', 'Contents', 'MacOS') self.site_packages = join(self.resources_dir, 'Python', 'site-packages') self.to_strip = [] self.warnings = [] @@ -375,6 +375,24 @@ class Freeze(object): dest = join(cdir, 'Resources') src = self.resources_dir os.symlink(os.path.relpath(src, cdir), dest) + pl = dict( + CFBundleDevelopmentRegion='English', + CFBundleDisplayName=APPNAME + ' - utils', + CFBundleName=APPNAME + '-utils', + CFBundleIdentifier='com.calibre-ebook.utils', + LSBackgroundOnly='1', + CFBundleVersion=VERSION, + CFBundleShortVersionString=VERSION, + CFBundlePackageType='APPL', + CFBundleSignature='????', + CFBundleExecutable='pdftohtml', + LSMinimumSystemVersion='10.14.0', + LSRequiresNativeExecution=True, + NSAppleScriptEnabled=False, + CFBundleIconFile='', + ) + with open(join(cdir, 'Info.plist'), 'wb') as p: + plistlib.dump(pl, p) @flush def add_calibre_plugins(self): @@ -412,7 +430,7 @@ class Freeze(object): CFBundleSignature='????', CFBundleExecutable='calibre', CFBundleDocumentTypes=docs, - LSMinimumSystemVersion='10.9.5', + LSMinimumSystemVersion='10.14.0', LSRequiresNativeExecution=True, NSAppleScriptEnabled=False, NSHumanReadableCopyright=time.strftime('Copyright %Y, Kovid Goyal'), diff --git a/bypy/macos/sign.py b/bypy/macos/sign.py index e545c2d5bc..ec6d68feb6 100644 --- a/bypy/macos/sign.py +++ b/bypy/macos/sign.py @@ -109,9 +109,10 @@ def do_sign_app(appdir): # Sign everything in MacOS except the main executables of the various # app bundles which will be signed automatically by codesign when # signing the app bundles - with current_dir('MacOS'): - items = set(os.listdir('.')) - executables - codesign(expand_dirs(items)) + for MacOS in ('MacOS', 'utils.app/Contents/MacOS'): + with current_dir(MacOS): + items = set(os.listdir('.')) - executables + codesign(expand_dirs(items)) # Sign everything in Frameworks with current_dir('Frameworks'): diff --git a/src/calibre/ebooks/pdf/pdftohtml.py b/src/calibre/ebooks/pdf/pdftohtml.py index 848f42921a..57dce5b42b 100644 --- a/src/calibre/ebooks/pdf/pdftohtml.py +++ b/src/calibre/ebooks/pdf/pdftohtml.py @@ -34,7 +34,7 @@ def popen(cmd, **kw): if isosx and hasattr(sys, 'frameworks_dir'): - base = os.path.join(os.path.dirname(os.path.dirname(sys.frameworks_dir)), 'Helpers', 'utils.app', 'Contents', 'MacOS') + base = os.path.join(os.path.dirname(sys.frameworks_dir), 'utils.app', 'Contents', 'MacOS') PDFTOHTML = os.path.join(base, PDFTOHTML) if iswindows and hasattr(sys, 'frozen'): base = sys.extensions_location if hasattr(sys, 'new_app_layout') else os.path.dirname(sys.executable)