2019-10-16 20:42:21 +02:00
|
|
|
#!/usr/bin/python
|
2010-02-28 21:55:10 +01:00
|
|
|
|
2010-03-24 00:11:46 +01:00
|
|
|
# This file is part of Clementine.
|
|
|
|
#
|
|
|
|
# Clementine is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# Clementine is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2016-12-15 12:43:47 +01:00
|
|
|
from distutils import spawn
|
2012-11-24 07:46:25 +01:00
|
|
|
import logging
|
2010-02-28 21:55:10 +01:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import subprocess
|
|
|
|
import sys
|
2012-01-09 12:43:57 +01:00
|
|
|
import traceback
|
2010-02-28 21:55:10 +01:00
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
LOGGER = logging.getLogger('macdeploy')
|
2012-11-24 07:46:25 +01:00
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
FRAMEWORK_SEARCH_PATH = [
|
|
|
|
'/target', '/target/lib', '/Library/Frameworks',
|
2010-03-24 14:45:35 +01:00
|
|
|
os.path.join(os.environ['HOME'], 'Library/Frameworks')
|
|
|
|
]
|
|
|
|
|
2018-12-05 18:16:34 +01:00
|
|
|
STRIP_PREFIX = [
|
|
|
|
'@@HOMEBREW_PREFIX@@/opt/qt5/lib/',
|
|
|
|
'@@HOMEBREW_CELLAR@@/qt5/5.8.0_1/lib/',
|
|
|
|
]
|
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
LIBRARY_SEARCH_PATH = ['/target', '/target/lib', '/usr/local/lib', '/sw/lib']
|
2011-05-07 16:47:33 +02:00
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
GSTREAMER_PLUGINS = [
|
2010-04-12 14:36:30 +02:00
|
|
|
# Core plugins
|
2011-11-30 13:29:18 +01:00
|
|
|
'libgstapp.so',
|
2010-04-12 14:36:30 +02:00
|
|
|
'libgstaudioconvert.so',
|
2010-07-14 13:16:56 +02:00
|
|
|
'libgstaudiofx.so',
|
|
|
|
'libgstaudiotestsrc.so',
|
2010-04-12 14:36:30 +02:00
|
|
|
'libgstaudioresample.so',
|
|
|
|
'libgstautodetect.so',
|
|
|
|
'libgstcoreelements.so',
|
2010-07-13 19:13:33 +02:00
|
|
|
'libgstequalizer.so',
|
2011-11-28 20:53:49 +01:00
|
|
|
'libgstgdp.so',
|
2010-04-12 14:36:30 +02:00
|
|
|
'libgstosxaudio.so',
|
2014-09-30 17:52:51 +02:00
|
|
|
'libgstplayback.so',
|
2011-04-27 00:35:31 +02:00
|
|
|
'libgsttcp.so',
|
2010-04-12 14:36:30 +02:00
|
|
|
'libgsttypefindfunctions.so',
|
2010-06-22 17:50:42 +02:00
|
|
|
'libgstudp.so',
|
2010-04-12 14:36:30 +02:00
|
|
|
'libgstvolume.so',
|
|
|
|
|
|
|
|
# Codecs
|
2010-05-25 13:12:35 +02:00
|
|
|
'libgstapetag.so',
|
2010-08-18 18:12:16 +02:00
|
|
|
'libgstasf.so',
|
2014-09-30 17:52:51 +02:00
|
|
|
'libgstaudioparsers.so',
|
2018-12-05 18:16:34 +01:00
|
|
|
#'libgstfaac.so',
|
2010-04-12 14:36:30 +02:00
|
|
|
'libgstfaad.so',
|
|
|
|
'libgstflac.so',
|
|
|
|
'libgstid3demux.so',
|
2014-09-30 17:52:51 +02:00
|
|
|
'libgstisomp4.so',
|
2010-06-22 17:50:42 +02:00
|
|
|
'libgstlame.so',
|
2014-09-30 17:52:51 +02:00
|
|
|
'libgstlibav.so',
|
2010-06-23 13:07:39 +02:00
|
|
|
'libgstmms.so',
|
2014-09-30 17:52:51 +02:00
|
|
|
# TODO: Bring back Musepack support.
|
2010-04-12 14:36:30 +02:00
|
|
|
'libgstogg.so',
|
2013-07-16 15:52:44 +02:00
|
|
|
'libgstopus.so',
|
2010-06-22 17:50:42 +02:00
|
|
|
'libgstreplaygain.so',
|
|
|
|
'libgstspeex.so',
|
2011-04-04 14:51:38 +02:00
|
|
|
'libgsttaglib.so',
|
2010-04-12 14:36:30 +02:00
|
|
|
'libgstvorbis.so',
|
2010-06-14 16:51:11 +02:00
|
|
|
'libgstwavparse.so',
|
2017-09-17 15:15:13 +02:00
|
|
|
'libgstxingmux.so',
|
2010-04-12 14:36:30 +02:00
|
|
|
|
|
|
|
# HTTP src support
|
2019-10-16 20:42:21 +02:00
|
|
|
'libgstsoup.so',
|
2010-05-25 13:07:06 +02:00
|
|
|
|
|
|
|
# Icecast support
|
|
|
|
'libgsticydemux.so',
|
2011-03-17 15:25:30 +01:00
|
|
|
|
2012-10-09 14:37:21 +02:00
|
|
|
# RTSP streaming
|
|
|
|
'libgstrtp.so',
|
|
|
|
'libgstrtsp.so',
|
2010-04-12 14:36:30 +02:00
|
|
|
]
|
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
GSTREAMER_SEARCH_PATH = [
|
2019-10-16 20:42:21 +02:00
|
|
|
'/usr/local/lib/gstreamer-1.0',
|
2014-09-30 17:30:34 +02:00
|
|
|
'/target/lib/gstreamer-1.0',
|
2014-09-30 17:52:51 +02:00
|
|
|
'/target/libexec/gstreamer-1.0',
|
2019-11-11 18:55:06 +01:00
|
|
|
'/usr/local/opt/gstreamer/libexec/gstreamer-1.0',
|
2010-04-12 14:36:30 +02:00
|
|
|
]
|
|
|
|
|
2010-03-01 13:13:11 +01:00
|
|
|
QT_PLUGINS = [
|
2018-12-05 18:16:34 +01:00
|
|
|
#'accessible/libqtaccessiblewidgets.dylib',
|
|
|
|
#'codecs/libqcncodecs.dylib',
|
|
|
|
#'codecs/libqjpcodecs.dylib',
|
|
|
|
#'codecs/libqkrcodecs.dylib',
|
|
|
|
#'codecs/libqtwcodecs.dylib',
|
2010-03-01 13:13:11 +01:00
|
|
|
'iconengines/libqsvgicon.dylib',
|
|
|
|
'imageformats/libqgif.dylib',
|
|
|
|
'imageformats/libqico.dylib',
|
|
|
|
'imageformats/libqjpeg.dylib',
|
2018-12-05 18:16:34 +01:00
|
|
|
#'imageformats/libqmng.dylib',
|
2010-03-01 13:13:11 +01:00
|
|
|
'imageformats/libqsvg.dylib',
|
2019-10-16 20:42:21 +02:00
|
|
|
'platforms/libqcocoa.dylib',
|
2010-03-01 13:13:11 +01:00
|
|
|
]
|
2016-12-15 12:43:47 +01:00
|
|
|
QT_PLUGINS_SEARCH_PATH = [
|
2019-11-11 18:55:06 +01:00
|
|
|
'/usr/local/opt/qt5/plugins',
|
2013-07-08 18:35:44 +02:00
|
|
|
'/target/plugins',
|
2010-05-17 16:59:44 +02:00
|
|
|
'/usr/local/Trolltech/Qt-4.7.0/plugins',
|
2010-03-01 13:13:11 +01:00
|
|
|
'/Developer/Applications/Qt/plugins',
|
|
|
|
]
|
|
|
|
|
2019-10-16 20:42:21 +02:00
|
|
|
GIO_MODULES_SEARCH_PATH = [
|
|
|
|
'/usr/local/lib/gio/modules',
|
|
|
|
'/target/lib/gio/modules',
|
|
|
|
]
|
2016-12-15 12:43:47 +01:00
|
|
|
|
|
|
|
INSTALL_NAME_TOOL_APPLE = 'install_name_tool'
|
|
|
|
INSTALL_NAME_TOOL_CROSS = 'x86_64-apple-darwin-%s' % INSTALL_NAME_TOOL_APPLE
|
|
|
|
INSTALL_NAME_TOOL = INSTALL_NAME_TOOL_CROSS if spawn.find_executable(
|
|
|
|
INSTALL_NAME_TOOL_CROSS) else INSTALL_NAME_TOOL_APPLE
|
2012-07-30 17:51:45 +02:00
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
OTOOL_APPLE = 'otool'
|
|
|
|
OTOOL_CROSS = 'x86_64-apple-darwin-%s' % OTOOL_APPLE
|
|
|
|
OTOOL = OTOOL_CROSS if spawn.find_executable(OTOOL_CROSS) else OTOOL_APPLE
|
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
|
|
|
|
class Error(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class CouldNotFindFrameworkError(Error):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class InstallNameToolError(Error):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class CouldNotFindXinePluginError(Error):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2010-03-01 13:13:11 +01:00
|
|
|
class CouldNotFindQtPluginError(Error):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2010-04-12 14:36:30 +02:00
|
|
|
class CouldNotFindGstreamerPluginError(Error):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2012-07-30 17:51:45 +02:00
|
|
|
class CouldNotFindGioModuleError(Error):
|
2011-01-18 15:02:51 +01:00
|
|
|
pass
|
|
|
|
|
|
|
|
|
2015-12-11 06:31:01 +01:00
|
|
|
class CouldNotParseFrameworkNameError(Error):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
if len(sys.argv) < 2:
|
|
|
|
print 'Usage: %s <bundle.app>' % sys.argv[0]
|
|
|
|
|
|
|
|
bundle_dir = sys.argv[1]
|
|
|
|
|
2010-04-15 21:09:39 +02:00
|
|
|
bundle_name = os.path.basename(bundle_dir).split('.')[0]
|
2010-02-28 21:55:10 +01:00
|
|
|
|
2010-03-01 13:13:11 +01:00
|
|
|
commands = []
|
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
frameworks_dir = os.path.join(bundle_dir, 'Contents', 'Frameworks')
|
2010-03-01 13:13:11 +01:00
|
|
|
commands.append(['mkdir', '-p', frameworks_dir])
|
2010-02-28 21:55:10 +01:00
|
|
|
resources_dir = os.path.join(bundle_dir, 'Contents', 'Resources')
|
2010-03-01 13:13:11 +01:00
|
|
|
commands.append(['mkdir', '-p', resources_dir])
|
2010-02-28 21:55:10 +01:00
|
|
|
plugins_dir = os.path.join(bundle_dir, 'Contents', 'PlugIns')
|
|
|
|
binary = os.path.join(bundle_dir, 'Contents', 'MacOS', bundle_name)
|
|
|
|
|
2015-12-11 06:31:01 +01:00
|
|
|
fixed_libraries = set()
|
|
|
|
fixed_frameworks = set()
|
2010-02-28 21:55:10 +01:00
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
def GetBrokenLibraries(binary):
|
2016-12-19 13:54:23 +01:00
|
|
|
output = subprocess.Popen(
|
|
|
|
[OTOOL, '-L', binary], stdout=subprocess.PIPE).communicate()[0]
|
|
|
|
broken_libs = {'frameworks': [], 'libs': []}
|
2010-02-28 21:55:10 +01:00
|
|
|
for line in [x.split(' ')[0].lstrip() for x in output.split('\n')[1:]]:
|
|
|
|
if not line: # skip empty lines
|
|
|
|
continue
|
|
|
|
if os.path.basename(binary) in line:
|
|
|
|
continue
|
2011-11-07 14:48:27 +01:00
|
|
|
elif re.match(r'^\s*/System/', line):
|
2010-02-28 21:55:10 +01:00
|
|
|
continue # System framework
|
|
|
|
elif re.match(r'^\s*/usr/lib/', line):
|
|
|
|
continue # unix style system library
|
2011-03-25 12:38:03 +01:00
|
|
|
elif re.match(r'Breakpad', line):
|
|
|
|
continue # Manually added by cmake.
|
2016-12-19 13:54:23 +01:00
|
|
|
elif re.match(r'^\s*@executable_path', line) or re.match(
|
|
|
|
r'^\s*@loader_path', line):
|
2010-03-01 13:13:11 +01:00
|
|
|
# Potentially already fixed library
|
|
|
|
relative_path = os.path.join(*line.split('/')[3:])
|
|
|
|
if not os.path.exists(os.path.join(frameworks_dir, relative_path)):
|
|
|
|
broken_libs['frameworks'].append(relative_path)
|
2010-03-24 14:45:35 +01:00
|
|
|
elif re.search(r'\w+\.framework', line):
|
|
|
|
broken_libs['frameworks'].append(line)
|
2010-02-28 21:55:10 +01:00
|
|
|
else:
|
|
|
|
broken_libs['libs'].append(line)
|
|
|
|
|
|
|
|
return broken_libs
|
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
def FindFramework(path):
|
2018-12-05 18:16:34 +01:00
|
|
|
for prefix in STRIP_PREFIX:
|
|
|
|
if path.startswith(prefix):
|
|
|
|
path = path[len(prefix):]
|
|
|
|
break
|
2010-02-28 21:55:10 +01:00
|
|
|
for search_path in FRAMEWORK_SEARCH_PATH:
|
|
|
|
abs_path = os.path.join(search_path, path)
|
|
|
|
if os.path.exists(abs_path):
|
2012-11-24 07:46:25 +01:00
|
|
|
LOGGER.debug("Found framework '%s' in '%s'", path, search_path)
|
2010-02-28 21:55:10 +01:00
|
|
|
return abs_path
|
|
|
|
|
|
|
|
raise CouldNotFindFrameworkError(path)
|
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
def FindLibrary(path):
|
|
|
|
if os.path.exists(path):
|
|
|
|
return path
|
|
|
|
for search_path in LIBRARY_SEARCH_PATH:
|
|
|
|
abs_path = os.path.join(search_path, path)
|
|
|
|
if os.path.exists(abs_path):
|
2012-11-24 07:46:25 +01:00
|
|
|
LOGGER.debug("Found library '%s' in '%s'", path, search_path)
|
2010-02-28 21:55:10 +01:00
|
|
|
return abs_path
|
|
|
|
|
|
|
|
raise CouldNotFindFrameworkError(path)
|
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
def FixAllLibraries(broken_libs):
|
|
|
|
for framework in broken_libs['frameworks']:
|
|
|
|
FixFramework(framework)
|
|
|
|
for lib in broken_libs['libs']:
|
|
|
|
FixLibrary(lib)
|
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
def FixFramework(path):
|
2015-12-11 06:31:01 +01:00
|
|
|
if path in fixed_frameworks:
|
2010-02-28 21:55:10 +01:00
|
|
|
return
|
|
|
|
else:
|
2015-12-11 06:31:01 +01:00
|
|
|
fixed_frameworks.add(path)
|
2010-02-28 21:55:10 +01:00
|
|
|
abs_path = FindFramework(path)
|
|
|
|
broken_libs = GetBrokenLibraries(abs_path)
|
|
|
|
FixAllLibraries(broken_libs)
|
|
|
|
|
|
|
|
new_path = CopyFramework(abs_path)
|
2010-03-24 14:45:35 +01:00
|
|
|
id = os.sep.join(new_path.split(os.sep)[3:])
|
|
|
|
FixFrameworkId(new_path, id)
|
2010-02-28 21:55:10 +01:00
|
|
|
for framework in broken_libs['frameworks']:
|
|
|
|
FixFrameworkInstallPath(framework, new_path)
|
|
|
|
for library in broken_libs['libs']:
|
|
|
|
FixLibraryInstallPath(library, new_path)
|
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
def FixLibrary(path):
|
2016-12-19 13:54:23 +01:00
|
|
|
if path in fixed_libraries or FindSystemLibrary(os.path.basename(
|
|
|
|
path)) is not None:
|
2010-02-28 21:55:10 +01:00
|
|
|
return
|
|
|
|
else:
|
2015-12-11 06:31:01 +01:00
|
|
|
fixed_libraries.add(path)
|
2010-02-28 21:55:10 +01:00
|
|
|
abs_path = FindLibrary(path)
|
|
|
|
broken_libs = GetBrokenLibraries(abs_path)
|
|
|
|
FixAllLibraries(broken_libs)
|
|
|
|
|
|
|
|
new_path = CopyLibrary(abs_path)
|
|
|
|
FixLibraryId(new_path)
|
|
|
|
for framework in broken_libs['frameworks']:
|
|
|
|
FixFrameworkInstallPath(framework, new_path)
|
|
|
|
for library in broken_libs['libs']:
|
|
|
|
FixLibraryInstallPath(library, new_path)
|
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
|
2010-03-01 13:13:11 +01:00
|
|
|
def FixPlugin(abs_path, subdir):
|
2010-02-28 21:55:10 +01:00
|
|
|
broken_libs = GetBrokenLibraries(abs_path)
|
|
|
|
FixAllLibraries(broken_libs)
|
|
|
|
|
2010-03-01 13:13:11 +01:00
|
|
|
new_path = CopyPlugin(abs_path, subdir)
|
2010-02-28 21:55:10 +01:00
|
|
|
for framework in broken_libs['frameworks']:
|
|
|
|
FixFrameworkInstallPath(framework, new_path)
|
|
|
|
for library in broken_libs['libs']:
|
|
|
|
FixLibraryInstallPath(library, new_path)
|
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
def FixBinary(path):
|
|
|
|
broken_libs = GetBrokenLibraries(path)
|
|
|
|
FixAllLibraries(broken_libs)
|
|
|
|
for framework in broken_libs['frameworks']:
|
|
|
|
FixFrameworkInstallPath(framework, path)
|
|
|
|
for library in broken_libs['libs']:
|
|
|
|
FixLibraryInstallPath(library, path)
|
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
def CopyLibrary(path):
|
|
|
|
new_path = os.path.join(frameworks_dir, os.path.basename(path))
|
2016-12-19 13:54:23 +01:00
|
|
|
args = ['cp', path, new_path]
|
2010-03-01 13:13:11 +01:00
|
|
|
commands.append(args)
|
2019-10-16 20:42:21 +02:00
|
|
|
commands.append(['chmod', '+w', new_path])
|
2012-11-24 07:46:25 +01:00
|
|
|
LOGGER.info("Copying library '%s'", path)
|
2010-02-28 21:55:10 +01:00
|
|
|
return new_path
|
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
|
2010-03-01 13:13:11 +01:00
|
|
|
def CopyPlugin(path, subdir):
|
|
|
|
new_path = os.path.join(plugins_dir, subdir, os.path.basename(path))
|
|
|
|
args = ['mkdir', '-p', os.path.dirname(new_path)]
|
|
|
|
commands.append(args)
|
2016-12-15 12:37:01 +01:00
|
|
|
args = ['cp', path, new_path]
|
2010-03-01 13:13:11 +01:00
|
|
|
commands.append(args)
|
2019-10-16 20:42:21 +02:00
|
|
|
commands.append(['chmod', '+w', new_path])
|
2012-11-24 07:46:25 +01:00
|
|
|
LOGGER.info("Copying plugin '%s'", path)
|
2010-02-28 21:55:10 +01:00
|
|
|
return new_path
|
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
|
2015-12-11 06:31:01 +01:00
|
|
|
def CopyFramework(src_binary):
|
|
|
|
while os.path.islink(src_binary):
|
|
|
|
src_binary = os.path.realpath(src_binary)
|
2016-12-19 13:54:23 +01:00
|
|
|
|
2015-12-11 06:31:01 +01:00
|
|
|
m = re.match(r'(.*/([^/]+)\.framework)/Versions/([^/]+)/.*', src_binary)
|
|
|
|
if not m:
|
|
|
|
raise CouldNotParseFrameworkNameError(src_binary)
|
|
|
|
|
|
|
|
src_base = m.group(1)
|
|
|
|
name = m.group(2)
|
|
|
|
version = m.group(3)
|
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
LOGGER.info('Copying framework %s version %s', name, version)
|
2015-12-11 06:31:01 +01:00
|
|
|
|
|
|
|
dest_base = os.path.join(frameworks_dir, '%s.framework' % name)
|
|
|
|
dest_dir = os.path.join(dest_base, 'Versions', version)
|
|
|
|
dest_binary = os.path.join(dest_dir, name)
|
|
|
|
|
|
|
|
commands.append(['mkdir', '-p', dest_dir])
|
2016-12-15 12:37:01 +01:00
|
|
|
commands.append(['cp', src_binary, dest_binary])
|
2019-10-16 20:42:21 +02:00
|
|
|
commands.append(['chmod', '+w', dest_binary])
|
2015-12-11 06:31:01 +01:00
|
|
|
|
|
|
|
# Copy special files from various places:
|
|
|
|
# QtCore has Resources/qt_menu.nib (copy to app's Resources)
|
|
|
|
# Sparkle has Resources/*
|
|
|
|
# Qt* have Resources/Info.plist
|
|
|
|
resources_src = os.path.join(src_base, 'Resources')
|
|
|
|
menu_nib = os.path.join(resources_src, 'qt_menu.nib')
|
2011-05-07 16:47:33 +02:00
|
|
|
if os.path.exists(menu_nib):
|
2015-12-11 06:31:01 +01:00
|
|
|
LOGGER.info("Copying qt_menu.nib '%s'", menu_nib)
|
|
|
|
commands.append(['cp', '-r', menu_nib, resources_dir])
|
|
|
|
elif os.path.exists(resources_src):
|
|
|
|
LOGGER.info("Copying resources dir '%s'", resources_src)
|
|
|
|
commands.append(['cp', '-r', resources_src, dest_dir])
|
|
|
|
|
|
|
|
info_plist = os.path.join(src_base, 'Contents', 'Info.plist')
|
|
|
|
if os.path.exists(info_plist):
|
|
|
|
LOGGER.info("Copying special file '%s'", info_plist)
|
|
|
|
resources_dest = os.path.join(dest_dir, 'Resources')
|
|
|
|
commands.append(['mkdir', resources_dest])
|
|
|
|
commands.append(['cp', '-r', info_plist, resources_dest])
|
|
|
|
|
|
|
|
# Create symlinks in the Framework to make it look like
|
|
|
|
# https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/FrameworkAnatomy.html
|
2016-12-15 12:43:47 +01:00
|
|
|
commands.append([
|
|
|
|
'ln', '-sf', 'Versions/Current/%s' % name, os.path.join(dest_base, name)
|
|
|
|
])
|
|
|
|
commands.append([
|
|
|
|
'ln', '-sf', 'Versions/Current/Resources',
|
|
|
|
os.path.join(dest_base, 'Resources')
|
|
|
|
])
|
|
|
|
commands.append(
|
|
|
|
['ln', '-sf', version, os.path.join(dest_base, 'Versions/Current')])
|
2015-12-11 06:31:01 +01:00
|
|
|
|
|
|
|
return dest_binary
|
2010-02-28 21:55:10 +01:00
|
|
|
|
2016-12-15 12:43:47 +01:00
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
def FixId(path, library_name):
|
|
|
|
id = '@executable_path/../Frameworks/%s' % library_name
|
2016-12-15 12:43:47 +01:00
|
|
|
args = [INSTALL_NAME_TOOL, '-id', id, path]
|
2010-03-01 13:13:11 +01:00
|
|
|
commands.append(args)
|
2011-11-07 14:48:27 +01:00
|
|
|
|
2016-12-15 12:43:47 +01:00
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
def FixLibraryId(path):
|
|
|
|
library_name = os.path.basename(path)
|
|
|
|
FixId(path, library_name)
|
|
|
|
|
2016-12-15 12:43:47 +01:00
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
def FixFrameworkId(path, id):
|
|
|
|
FixId(path, id)
|
|
|
|
|
2016-12-15 12:43:47 +01:00
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
def FixInstallPath(library_path, library, new_path):
|
2016-12-15 12:43:47 +01:00
|
|
|
args = [INSTALL_NAME_TOOL, '-change', library_path, new_path, library]
|
2010-03-01 13:13:11 +01:00
|
|
|
commands.append(args)
|
2010-02-28 21:55:10 +01:00
|
|
|
|
2016-12-15 12:43:47 +01:00
|
|
|
|
2010-04-12 16:37:04 +02:00
|
|
|
def FindSystemLibrary(library_name):
|
|
|
|
for path in ['/lib', '/usr/lib']:
|
|
|
|
full_path = os.path.join(path, library_name)
|
|
|
|
if os.path.exists(full_path):
|
|
|
|
return full_path
|
|
|
|
return None
|
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
def FixLibraryInstallPath(library_path, library):
|
2010-04-12 16:37:04 +02:00
|
|
|
system_library = FindSystemLibrary(os.path.basename(library_path))
|
|
|
|
if system_library is None:
|
2016-12-19 13:54:23 +01:00
|
|
|
new_path = '@executable_path/../Frameworks/%s' % os.path.basename(
|
|
|
|
library_path)
|
2010-04-12 16:37:04 +02:00
|
|
|
FixInstallPath(library_path, library, new_path)
|
|
|
|
else:
|
|
|
|
FixInstallPath(library_path, library, system_library)
|
2010-02-28 21:55:10 +01:00
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
def FixFrameworkInstallPath(library_path, library):
|
2010-03-24 14:45:35 +01:00
|
|
|
parts = library_path.split(os.sep)
|
|
|
|
for i, part in enumerate(parts):
|
|
|
|
if re.match(r'\w+\.framework', part):
|
|
|
|
full_path = os.path.join(*parts[i:])
|
|
|
|
break
|
|
|
|
new_path = '@executable_path/../Frameworks/%s' % full_path
|
2010-02-28 21:55:10 +01:00
|
|
|
FixInstallPath(library_path, library, new_path)
|
|
|
|
|
2016-12-19 13:54:23 +01:00
|
|
|
|
2010-02-28 21:55:10 +01:00
|
|
|
def FindXinePlugin(name):
|
|
|
|
for path in XINEPLUGIN_SEARCH_PATH:
|
|
|
|
if os.path.exists(path):
|
|
|
|
for dir, dirs, files in os.walk(path):
|
|
|
|
if name in files:
|
|
|
|
return os.path.join(dir, name)
|
|
|
|
raise CouldNotFindXinePluginError(name)
|
|
|
|
|
|
|
|
|
2010-03-01 13:13:11 +01:00
|
|
|
def FindQtPlugin(name):
|
|
|
|
for path in QT_PLUGINS_SEARCH_PATH:
|
|
|
|
if os.path.exists(path):
|
|
|
|
if os.path.exists(os.path.join(path, name)):
|
|
|
|
return os.path.join(path, name)
|
|
|
|
raise CouldNotFindQtPluginError(name)
|
|
|
|
|
|
|
|
|
2010-04-12 14:36:30 +02:00
|
|
|
def FindGstreamerPlugin(name):
|
|
|
|
for path in GSTREAMER_SEARCH_PATH:
|
|
|
|
if os.path.exists(path):
|
|
|
|
for dir, dirs, files in os.walk(path):
|
|
|
|
if name in files:
|
|
|
|
return os.path.join(dir, name)
|
|
|
|
raise CouldNotFindGstreamerPluginError(name)
|
|
|
|
|
|
|
|
|
2012-07-30 17:51:45 +02:00
|
|
|
def FindGioModule(name):
|
|
|
|
for path in GIO_MODULES_SEARCH_PATH:
|
|
|
|
if os.path.exists(path):
|
|
|
|
for dir, dirs, files in os.walk(path):
|
|
|
|
if name in files:
|
|
|
|
return os.path.join(dir, name)
|
|
|
|
raise CouldNotFindGioModuleError(name)
|
|
|
|
|
|
|
|
|
2012-11-24 07:46:25 +01:00
|
|
|
def main():
|
2016-12-19 13:54:23 +01:00
|
|
|
logging.basicConfig(
|
|
|
|
filename='macdeploy.log',
|
|
|
|
level=logging.DEBUG,
|
|
|
|
format='%(asctime)s %(levelname)-8s %(message)s')
|
2012-11-24 07:46:25 +01:00
|
|
|
|
|
|
|
FixBinary(binary)
|
|
|
|
|
|
|
|
for plugin in GSTREAMER_PLUGINS:
|
|
|
|
FixPlugin(FindGstreamerPlugin(plugin), 'gstreamer')
|
|
|
|
|
|
|
|
FixPlugin(FindGstreamerPlugin('gst-plugin-scanner'), '.')
|
|
|
|
FixPlugin(FindGioModule('libgiognutls.so'), 'gio-modules')
|
2010-02-28 21:55:10 +01:00
|
|
|
|
2012-11-24 07:46:25 +01:00
|
|
|
try:
|
|
|
|
FixPlugin('clementine-spotifyblob', '.')
|
|
|
|
FixPlugin('clementine-tagreader', '.')
|
|
|
|
except:
|
|
|
|
print 'Failed to find blob: %s' % traceback.format_exc()
|
2010-04-12 14:36:30 +02:00
|
|
|
|
2012-11-24 07:46:25 +01:00
|
|
|
for plugin in QT_PLUGINS:
|
|
|
|
FixPlugin(FindQtPlugin(plugin), os.path.dirname(plugin))
|
2010-03-01 13:13:11 +01:00
|
|
|
|
2012-11-24 07:46:25 +01:00
|
|
|
if len(sys.argv) <= 2:
|
|
|
|
print 'Would run %d commands:' % len(commands)
|
|
|
|
for command in commands:
|
|
|
|
print ' '.join(command)
|
2011-04-28 22:37:13 +02:00
|
|
|
|
2012-11-24 07:46:25 +01:00
|
|
|
print 'OK?'
|
|
|
|
raw_input()
|
2010-03-01 13:13:11 +01:00
|
|
|
|
2010-12-04 21:43:06 +01:00
|
|
|
for command in commands:
|
2012-11-24 07:46:25 +01:00
|
|
|
p = subprocess.Popen(command)
|
|
|
|
os.waitpid(p.pid, 0)
|
2010-12-04 21:43:06 +01:00
|
|
|
|
2010-03-01 13:13:11 +01:00
|
|
|
|
2012-11-24 07:46:25 +01:00
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|