diff options
author | AndreyL ProductEngine <alihatskiy@productengine.com> | 2018-01-17 03:20:12 +0200 |
---|---|---|
committer | AndreyL ProductEngine <alihatskiy@productengine.com> | 2018-01-17 03:20:12 +0200 |
commit | 57a99273ed023bd71c54399969e66ffc23eebc57 (patch) | |
tree | d8569d41eaf78348e458f550f382375cac47924d /indra/newview/viewer_manifest.py | |
parent | 6ac2b2bb4f569b6663607894034b4ec64804e905 (diff) | |
parent | 7acbd8ed8d73c507675d45360df07d232c431a8b (diff) |
Merged in lindenlab/viewer-release
Diffstat (limited to 'indra/newview/viewer_manifest.py')
-rwxr-xr-x | indra/newview/viewer_manifest.py | 1243 |
1 files changed, 793 insertions, 450 deletions
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py index 66d730d1ac..e0c332681e 100755 --- a/indra/newview/viewer_manifest.py +++ b/indra/newview/viewer_manifest.py @@ -27,24 +27,26 @@ Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA $/LicenseInfo$ """ import sys +import os import os.path import shutil import errno import json +import plistlib +import random import re +import stat +import subprocess import tarfile import time -import random + viewer_dir = os.path.dirname(__file__) # Add indra/lib/python to our path so we don't have to muck with PYTHONPATH. # Put it FIRST because some of our build hosts have an ancient install of # indra.util.llmanifest under their system Python! sys.path.insert(0, os.path.join(viewer_dir, os.pardir, "lib", "python")) from indra.util.llmanifest import LLManifest, main, path_ancestors, CHANNEL_VENDOR_BASE, RELEASE_CHANNEL, ManifestError -try: - from llbase import llsd -except ImportError: - from indra.base import llsd +from llbase import llsd class ViewerManifest(LLManifest): def is_packaging_viewer(self): @@ -61,7 +63,7 @@ class ViewerManifest(LLManifest): self.path(src="../../etc/message.xml", dst="app_settings/message.xml") if self.is_packaging_viewer(): - if self.prefix(src="app_settings"): + with self.prefix(src="app_settings"): self.exclude("logcontrol.xml") self.exclude("logcontrol-dev.xml") self.path("*.pem") @@ -84,9 +86,8 @@ class ViewerManifest(LLManifest): # ... and the included spell checking dictionaries pkgdir = os.path.join(self.args['build'], os.pardir, 'packages') - if self.prefix(src=pkgdir,dst=""): + with self.prefix(src=pkgdir,dst=""): self.path("dictionaries") - self.end_prefix(pkgdir) # include the extracted packages information (see BuildPackagesInfo.cmake) self.path(src=os.path.join(self.args['build'],"packages-info.txt"), dst="packages-info.txt") @@ -129,24 +130,21 @@ class ViewerManifest(LLManifest): "settings_install.xml", src="environment") - self.end_prefix("app_settings") - if self.prefix(src="character"): + with self.prefix(src="character"): self.path("*.llm") self.path("*.xml") self.path("*.tga") - self.end_prefix("character") # Include our fonts - if self.prefix(src="fonts"): + with self.prefix(src="fonts"): self.path("*.ttf") self.path("*.txt") - self.end_prefix("fonts") # skins - if self.prefix(src="skins"): + with self.prefix(src="skins"): # include the entire textures directory recursively - if self.prefix(src="*/textures"): + with self.prefix(src="*/textures"): self.path("*/*.tga") self.path("*/*.j2c") self.path("*/*.jpg") @@ -156,7 +154,6 @@ class ViewerManifest(LLManifest): self.path("*.jpg") self.path("*.png") self.path("textures.xml") - self.end_prefix("*/textures") self.path("*/xui/*/*.xml") self.path("*/xui/*/widgets/*.xml") self.path("*/*.xml") @@ -168,32 +165,40 @@ class ViewerManifest(LLManifest): # we're wrong, a user actually does have the relevant # files; s/he just needs to rename every html.old # directory back to html to recover them. - if self.prefix(src="*/html", dst="*/html.old"): + with self.prefix(src="*/html", dst="*/html.old"): self.path("*.png") self.path("*/*/*.html") self.path("*/*/*.gif") - self.end_prefix("*/html") - self.end_prefix("skins") # local_assets dir (for pre-cached textures) - if self.prefix(src="local_assets"): + with self.prefix(src="local_assets"): self.path("*.j2c") self.path("*.tga") - self.end_prefix("local_assets") # File in the newview/ directory self.path("gpu_table.txt") - #summary.json. Standard with exception handling is fine. If we can't open a new file for writing, we have worse problems - summary_dict = {"Type":"viewer","Version":'.'.join(self.args['version']),"Channel":self.channel_with_pkg_suffix()} - with open(os.path.join(os.pardir,'summary.json'), 'w') as summary_handle: - json.dump(summary_dict,summary_handle) + #build_data.json. Standard with exception handling is fine. If we can't open a new file for writing, we have worse problems + #platform is computed above with other arg parsing + build_data_dict = {"Type":"viewer","Version":'.'.join(self.args['version']), + "Channel Base": CHANNEL_VENDOR_BASE, + "Channel":self.channel_with_pkg_suffix(), + "Platform":self.build_data_json_platform, + "Address Size":self.address_size, + "Update Service":"https://update.secondlife.com/update", + } + build_data_dict = self.finish_build_data_dict(build_data_dict) + with open(os.path.join(os.pardir,'build_data.json'), 'w') as build_data_handle: + json.dump(build_data_dict,build_data_handle) #we likely no longer need the test, since we will throw an exception above, but belt and suspenders and we get the #return code for free. - if not self.path2basename(os.pardir, "summary.json"): - print "No summary.json file" + if not self.path2basename(os.pardir, "build_data.json"): + print "No build_data.json file" + + def finish_build_data_dict(self, build_data_dict): + return build_data_dict def grid(self): return self.args['grid'] @@ -225,7 +230,7 @@ class ViewerManifest(LLManifest): return channel_type def channel_variant_app_suffix(self): - # get any part of the compiled channel name after the CHANNEL_VENDOR_BASE + # get any part of the channel name after the CHANNEL_VENDOR_BASE suffix=self.channel_variant() # by ancient convention, we don't use Release in the app name if self.channel_type() == 'release': @@ -287,14 +292,149 @@ class ViewerManifest(LLManifest): random.shuffle(names) return ', '.join(names) -class Windows_i686_Manifest(ViewerManifest): + def relsymlinkf(self, src, dst=None, catch=True): + """ + relsymlinkf() is just like symlinkf(), but instead of requiring the + caller to pass 'src' as a relative pathname, this method expects 'src' + to be absolute, and creates a symlink whose target is the relative + path from 'src' to dirname(dst). + """ + dstdir, dst = self._symlinkf_prep_dst(src, dst) + + # Determine the relative path starting from the directory containing + # dst to the intended src. + src = self.relpath(src, dstdir) + + self._symlinkf(src, dst, catch) + return dst + + def symlinkf(self, src, dst=None, catch=True): + """ + Like ln -sf, but uses os.symlink() instead of running ln. This creates + a symlink at 'dst' that points to 'src' -- see: + https://docs.python.org/2/library/os.html#os.symlink + + If you omit 'dst', this creates a symlink with basename(src) at + get_dst_prefix() -- in other words: put a symlink to this pathname + here at the current dst prefix. + + 'src' must specifically be a *relative* symlink. It makes no sense to + create an absolute symlink pointing to some path on the build machine! + + Also: + - We prepend 'dst' with the current get_dst_prefix(), so it has similar + meaning to associated self.path() calls. + - We ensure that the containing directory os.path.dirname(dst) exists + before attempting the symlink. + + If you pass catch=False, exceptions will be propagated instead of + caught. + """ + dstdir, dst = self._symlinkf_prep_dst(src, dst) + self._symlinkf(src, dst, catch) + return dst + + def _symlinkf_prep_dst(self, src, dst): + # helper for relsymlinkf() and symlinkf() + if dst is None: + dst = os.path.basename(src) + dst = os.path.join(self.get_dst_prefix(), dst) + # Seems silly to prepend get_dst_prefix() to dst only to call + # os.path.dirname() on it again, but this works even when the passed + # 'dst' is itself a pathname. + dstdir = os.path.dirname(dst) + self.cmakedirs(dstdir) + return (dstdir, dst) + + def _symlinkf(self, src, dst, catch): + # helper for relsymlinkf() and symlinkf() + # the passed src must be relative + if os.path.isabs(src): + raise ManifestError("Do not symlinkf(absolute %r, asis=True)" % src) + + # The outer catch is the one that reports failure even after attempted + # recovery. + try: + # At the inner layer, recovery may be possible. + try: + os.symlink(src, dst) + except OSError as err: + if err.errno != errno.EEXIST: + raise + # We could just blithely attempt to remove and recreate the target + # file, but that strategy doesn't work so well if we don't have + # permissions to remove it. Check to see if it's already the + # symlink we want, which is the usual reason for EEXIST. + elif os.path.islink(dst): + if os.readlink(dst) == src: + # the requested link already exists + pass + else: + # dst is the wrong symlink; attempt to remove and recreate it + os.remove(dst) + os.symlink(src, dst) + elif os.path.isdir(dst): + print "Requested symlink (%s) exists but is a directory; replacing" % dst + shutil.rmtree(dst) + os.symlink(src, dst) + elif os.path.exists(dst): + print "Requested symlink (%s) exists but is a file; replacing" % dst + os.remove(dst) + os.symlink(src, dst) + else: + # out of ideas + raise + except Exception as err: + # report + print "Can't symlink %r -> %r: %s: %s" % \ + (dst, src, err.__class__.__name__, err) + # if caller asked us not to catch, re-raise this exception + if not catch: + raise + + def relpath(self, path, base=None, symlink=False): + """ + Return the relative path from 'base' to the passed 'path'. If base is + omitted, self.get_dst_prefix() is assumed. In other words: make a + same-name symlink to this path right here in the current dest prefix. + + Normally we resolve symlinks. To retain symlinks, pass symlink=True. + """ + if base is None: + base = self.get_dst_prefix() + + # Since we use os.path.relpath() for this, which is purely textual, we + # must ensure that both pathnames are absolute. + if symlink: + # symlink=True means: we know path is (or indirects through) a + # symlink, don't resolve, we want to use the symlink. + abspath = os.path.abspath + else: + # symlink=False means to resolve any symlinks we may find + abspath = os.path.realpath + + return os.path.relpath(abspath(path), abspath(base)) + + +class WindowsManifest(ViewerManifest): + # We want the platform, per se, for every Windows build to be 'win'. The + # VMP will concatenate that with the address_size. + build_data_json_platform = 'win' + def final_exe(self): return self.app_name_oneword()+".exe" + def finish_build_data_dict(self, build_data_dict): + #MAINT-7294: Windows exe names depend on channel name, so write that in also + build_data_dict.update({'Executable':self.final_exe()}) + return build_data_dict + def test_msvcrt_and_copy_action(self, src, dst): # This is used to test a dll manifest. # It is used as a temporary override during the construct method from test_win32_manifest import test_assembly_binding + # TODO: This is redundant with LLManifest.copy_action(). Why aren't we + # calling copy_action() in conjunction with test_assembly_binding()? if src and (os.path.exists(src) or os.path.islink(src)): # ensure that destination path exists self.cmakedirs(os.path.dirname(dst)) @@ -315,6 +455,8 @@ class Windows_i686_Manifest(ViewerManifest): # It is used as a temporary override during the construct method from test_win32_manifest import test_assembly_binding from test_win32_manifest import NoManifestException, NoMatchingAssemblyException + # TODO: This is redundant with LLManifest.copy_action(). Why aren't we + # calling copy_action() in conjunction with test_assembly_binding()? if src and (os.path.exists(src) or os.path.islink(src)): # ensure that destination path exists self.cmakedirs(os.path.dirname(dst)) @@ -326,9 +468,9 @@ class Windows_i686_Manifest(ViewerManifest): else: test_assembly_binding(src, "Microsoft.VC80.CRT", "") raise Exception("Unknown condition") - except NoManifestException, err: + except NoManifestException as err: pass - except NoMatchingAssemblyException, err: + except NoMatchingAssemblyException as err: pass self.ccopy(src,dst) @@ -338,7 +480,7 @@ class Windows_i686_Manifest(ViewerManifest): print "Doesn't exist:", src def construct(self): - super(Windows_i686_Manifest, self).construct() + super(WindowsManifest, self).construct() pkgdir = os.path.join(self.args['build'], os.pardir, 'packages') relpkgdir = os.path.join(pkgdir, "lib", "release") @@ -348,14 +490,32 @@ class Windows_i686_Manifest(ViewerManifest): # Find secondlife-bin.exe in the 'configuration' dir, then rename it to the result of final_exe. self.path(src='%s/secondlife-bin.exe' % self.args['configuration'], dst=self.final_exe()) + with self.prefix(src=os.path.join(pkgdir, "VMP"), dst=""): + # include the compiled launcher scripts so that it gets included in the file_list + self.path('SL_Launcher.exe') + #IUM is not normally executed directly, just imported. No exe needed. + self.path("InstallerUserMessage.py") + + with self.prefix(src=self.icon_path(), dst="vmp_icons"): + self.path("secondlife.ico") + + #VMP Tkinter icons + with self.prefix("vmp_icons"): + self.path("*.png") + self.path("*.gif") + + #before, we only needed llbase at build time. With VMP, we need it at run time. + with self.prefix(src=os.path.join(pkgdir, "lib", "python", "llbase"), dst="llbase"): + self.path("*.py") + self.path("_cllsd.so") + # Plugin host application self.path2basename(os.path.join(os.pardir, 'llplugin', 'slplugin', self.args['configuration']), "slplugin.exe") - self.path2basename("../viewer_components/updater/scripts/windows", "update_install.bat") # Get shared libs from the shared libs staging directory - if self.prefix(src=os.path.join(os.pardir, 'sharedlibs', self.args['configuration']), + with self.prefix(src=os.path.join(os.pardir, 'sharedlibs', self.args['configuration']), dst=""): # Get llcommon and deps. If missing assume static linkage and continue. @@ -365,44 +525,41 @@ class Windows_i686_Manifest(ViewerManifest): self.path('libaprutil-1.dll') self.path('libapriconv-1.dll') - except RuntimeError, err: + except RuntimeError as err: print err.message print "Skipping llcommon.dll (assuming llcommon was linked statically)" # Mesh 3rd party libs needed for auto LOD and collada reading try: self.path("glod.dll") - except RuntimeError, err: + except RuntimeError as err: print err.message print "Skipping GLOD library (assumming linked statically)" # Get fmodex dll, continue if missing try: - if self.args['configuration'].lower() == 'debug': - self.path("fmodexL.dll") + if(self.address_size == 64): + self.path("fmodex64.dll") else: self.path("fmodex.dll") except: print "Skipping fmodex audio library(assuming other audio engine)" # For textures - if self.args['configuration'].lower() == 'debug': - self.path("openjpegd.dll") - else: - self.path("openjpeg.dll") + self.path("openjpeg.dll") # These need to be installed as a SxS assembly, currently a 'private' assembly. # See http://msdn.microsoft.com/en-us/library/ms235291(VS.80).aspx if self.args['configuration'].lower() == 'debug': - self.path("msvcr120d.dll") - self.path("msvcp120d.dll") - self.path("msvcr100d.dll") - self.path("msvcp100d.dll") + self.path("msvcr120d.dll") + self.path("msvcp120d.dll") + self.path("msvcr100d.dll") + self.path("msvcp100d.dll") else: - self.path("msvcr120.dll") - self.path("msvcp120.dll") - self.path("msvcr100.dll") - self.path("msvcp100.dll") + self.path("msvcr120.dll") + self.path("msvcp120.dll") + self.path("msvcr100.dll") + self.path("msvcp100.dll") # Vivox runtimes self.path("SLVoice.exe") @@ -410,12 +567,14 @@ class Windows_i686_Manifest(ViewerManifest): self.path("ortp.dll") self.path("libsndfile-1.dll") self.path("vivoxoal.dll") - self.path("ca-bundle.crt") # Security self.path("ssleay32.dll") self.path("libeay32.dll") + # HTTP/2 + self.path("nghttp2.dll") + # Hunspell self.path("libhunspell.dll") @@ -428,78 +587,54 @@ class Windows_i686_Manifest(ViewerManifest): except: print "Skipping libtcmalloc_minimal.dll" - self.end_prefix() self.path(src="licenses-win32.txt", dst="licenses.txt") self.path("featuretable.txt") - self.path("featuretable_xp.txt") - - # Media plugins - QuickTime - if self.prefix(src='../media_plugins/quicktime/%s' % self.args['configuration'], dst="llplugin"): - self.path("media_plugin_quicktime.dll") - self.end_prefix() + self.path("ca-bundle.crt") # Media plugins - CEF - if self.prefix(src='../media_plugins/cef/%s' % self.args['configuration'], dst="llplugin"): + with self.prefix(src='../media_plugins/cef/%s' % self.args['configuration'], dst="llplugin"): self.path("media_plugin_cef.dll") - self.end_prefix() # Media plugins - LibVLC - if self.prefix(src='../media_plugins/libvlc/%s' % self.args['configuration'], dst="llplugin"): + with self.prefix(src='../media_plugins/libvlc/%s' % self.args['configuration'], dst="llplugin"): self.path("media_plugin_libvlc.dll") - self.end_prefix() - # winmm.dll shim - if self.prefix(src='../media_plugins/winmmshim/%s' % self.args['configuration'], dst=""): - self.path("winmm.dll") - self.end_prefix() + # Media plugins - Example (useful for debugging - not shipped with release viewer) + if self.channel_type() != 'release': + with self.prefix(src='../media_plugins/example/%s' % self.args['configuration'], dst="llplugin"): + self.path("media_plugin_example.dll") # CEF runtime files - debug - if self.args['configuration'].lower() == 'debug': - if self.prefix(src=os.path.join(os.pardir, 'packages', 'bin', 'debug'), dst="llplugin"): - self.path("d3dcompiler_43.dll") - self.path("d3dcompiler_47.dll") - self.path("libcef.dll") - self.path("libEGL.dll") - self.path("libGLESv2.dll") - self.path("llceflib_host.exe") - self.path("natives_blob.bin") - self.path("snapshot_blob.bin") - self.path("widevinecdmadapter.dll") - self.path("wow_helper.exe") - self.end_prefix() - else: # CEF runtime files - not debug (release, relwithdebinfo etc.) - if self.prefix(src=os.path.join(os.pardir, 'packages', 'bin', 'release'), dst="llplugin"): - self.path("d3dcompiler_43.dll") - self.path("d3dcompiler_47.dll") - self.path("libcef.dll") - self.path("libEGL.dll") - self.path("libGLESv2.dll") - self.path("llceflib_host.exe") - self.path("natives_blob.bin") - self.path("snapshot_blob.bin") - self.path("widevinecdmadapter.dll") - self.path("wow_helper.exe") - self.end_prefix() + config = 'debug' if self.args['configuration'].lower() == 'debug' else 'release' + with self.prefix(src=os.path.join(pkgdir, 'bin', config), dst="llplugin"): + self.path("chrome_elf.dll") + self.path("d3dcompiler_43.dll") + self.path("d3dcompiler_47.dll") + self.path("libcef.dll") + self.path("libEGL.dll") + self.path("libGLESv2.dll") + self.path("dullahan_host.exe") + self.path("natives_blob.bin") + self.path("snapshot_blob.bin") + self.path("widevinecdmadapter.dll") # MSVC DLLs needed for CEF and have to be in same directory as plugin - if self.prefix(src=os.path.join(os.pardir, 'sharedlibs', 'Release'), dst="llplugin"): + with self.prefix(src=os.path.join(os.pardir, 'sharedlibs', 'Release'), dst="llplugin"): self.path("msvcp120.dll") self.path("msvcr120.dll") - self.end_prefix() # CEF files common to all configurations - if self.prefix(src=os.path.join(os.pardir, 'packages', 'resources'), dst="llplugin"): + with self.prefix(src=os.path.join(pkgdir, 'resources'), dst="llplugin"): self.path("cef.pak") self.path("cef_100_percent.pak") self.path("cef_200_percent.pak") self.path("cef_extensions.pak") self.path("devtools_resources.pak") self.path("icudtl.dat") - self.end_prefix() - if self.prefix(src=os.path.join(os.pardir, 'packages', 'resources', 'locales'), dst=os.path.join('llplugin', 'locales')): + with self.prefix(src=os.path.join(pkgdir, 'resources', 'locales'), dst=os.path.join('llplugin', 'locales')): self.path("am.pak") self.path("ar.pak") self.path("bg.pak") @@ -553,13 +688,11 @@ class Windows_i686_Manifest(ViewerManifest): self.path("vi.pak") self.path("zh-CN.pak") self.path("zh-TW.pak") - self.end_prefix() - if self.prefix(src=os.path.join(os.pardir, 'packages', 'bin', 'release'), dst="llplugin"): - self.path("libvlc.dll") - self.path("libvlccore.dll") - self.path("plugins/") - self.end_prefix() + with self.prefix(src=os.path.join(pkgdir, 'bin', 'release'), dst="llplugin"): + self.path("libvlc.dll") + self.path("libvlccore.dll") + self.path("plugins/") # pull in the crash logger and updater from other projects # tag:"crash-logger" here as a cue to the exporter @@ -619,6 +752,8 @@ class Windows_i686_Manifest(ViewerManifest): 'version' : '.'.join(self.args['version']), 'version_short' : '.'.join(self.args['version'][:-1]), 'version_dashes' : '-'.join(self.args['version']), + 'version_registry' : '%s(%s)' % + ('.'.join(self.args['version']), self.address_size), 'final_exe' : self.final_exe(), 'flags':'', 'app_name':self.app_name(), @@ -629,10 +764,12 @@ class Windows_i686_Manifest(ViewerManifest): substitution_strings['installer_file'] = installer_file version_vars = """ - !define INSTEXE "%(final_exe)s" + !define INSTEXE "SL_Launcher.exe" !define VERSION "%(version_short)s" !define VERSION_LONG "%(version)s" !define VERSION_DASHES "%(version_dashes)s" + !define VERSION_REGISTRY "%(version_registry)s" + !define VIEWER_EXE "%(final_exe)s" """ % substitution_strings if self.channel_type() == 'release': @@ -648,6 +785,13 @@ class Windows_i686_Manifest(ViewerManifest): Caption "%(caption)s" """ + if(self.address_size == 64): + engage_registry="SetRegView 64" + program_files="$PROGRAMFILES64" + else: + engage_registry="SetRegView 32" + program_files="$PROGRAMFILES32" + tempfile = "secondlife_setup_tmp.nsi" # the following replaces strings in the nsi template # it also does python-style % substitution @@ -656,257 +800,468 @@ class Windows_i686_Manifest(ViewerManifest): "%%SOURCE%%":self.get_src_prefix(), "%%INST_VARS%%":inst_vars_template % substitution_strings, "%%INSTALL_FILES%%":self.nsi_file_commands(True), + "%%PROGRAMFILES%%":program_files, + "%%ENGAGEREGISTRY%%":engage_registry, "%%DELETE_FILES%%":self.nsi_file_commands(False)}) + # If we're on a build machine, sign the code using our Authenticode certificate. JC + # note that the enclosing setup exe is signed later, after the makensis makes it. + # Unlike the viewer binary, the VMP filenames are invariant with respect to version, os, etc. + for exe in ( + "SL_Launcher.exe", + ): + self.sign(exe) + # We use the Unicode version of NSIS, available from # http://www.scratchpaper.com/ # Check two paths, one for Program Files, and one for Program Files (x86). # Yay 64bit windows. - NSIS_path = os.path.expandvars('${ProgramFiles}\\NSIS\\Unicode\\makensis.exe') - if not os.path.exists(NSIS_path): - NSIS_path = os.path.expandvars('${ProgramFiles(x86)}\\NSIS\\Unicode\\makensis.exe') + for ProgramFiles in 'ProgramFiles', 'ProgramFiles(x86)': + NSIS_path = os.path.expandvars(r'${%s}\NSIS\Unicode\makensis.exe' % ProgramFiles) + if os.path.exists(NSIS_path): + break installer_created=False nsis_attempts=3 nsis_retry_wait=15 - while (not installer_created) and (nsis_attempts > 0): + for attempt in xrange(nsis_attempts): try: - nsis_attempts-=1; - self.run_command('"' + NSIS_path + '" ' + self.dst_path_of(tempfile)) - installer_created=True # if no exception was raised, the codesign worked - except ManifestError, err: - if nsis_attempts: + self.run_command([NSIS_path, '/V2', self.dst_path_of(tempfile)]) + except ManifestError as err: + if attempt+1 < nsis_attempts: print >> sys.stderr, "nsis failed, waiting %d seconds before retrying" % nsis_retry_wait time.sleep(nsis_retry_wait) nsis_retry_wait*=2 - else: - print >> sys.stderr, "Maximum nsis attempts exceeded; giving up" - raise - # self.remove(self.dst_path_of(tempfile)) - # If we're on a build machine, sign the code using our Authenticode certificate. JC - sign_py = os.path.expandvars("${SIGN}") - if not sign_py or sign_py == "${SIGN}": - sign_py = 'C:\\buildscripts\\code-signing\\sign.py' - else: - sign_py = sign_py.replace('\\', '\\\\\\\\') - python = os.path.expandvars("${PYTHON}") - if not python or python == "${PYTHON}": - python = 'python' - if os.path.exists(sign_py): - self.run_command("%s %s %s" % (python, sign_py, self.dst_path_of(installer_file).replace('\\', '\\\\\\\\'))) + else: + # NSIS worked! Done! + break else: - print "Skipping code signing,", sign_py, "does not exist" + print >> sys.stderr, "Maximum nsis attempts exceeded; giving up" + raise + + self.sign(installer_file) self.created_path(self.dst_path_of(installer_file)) self.package_file = installer_file + def sign(self, exe): + sign_py = os.environ.get('SIGN', r'C:\buildscripts\code-signing\sign.py') + python = os.environ.get('PYTHON', 'python') + if os.path.exists(sign_py): + dst_path = self.dst_path_of(exe) + print "about to run signing of: ", dst_path + self.run_command([python, sign_py, dst_path]) + else: + print "Skipping code signing of %s: %s not found" % (exe, sign_py) + + def escape_slashes(self, path): + return path.replace('\\', '\\\\\\\\') + +class Windows_i686_Manifest(WindowsManifest): + # Although we aren't literally passed ADDRESS_SIZE, we can infer it from + # the passed 'arch', which is used to select the specific subclass. + address_size = 32 + +class Windows_x86_64_Manifest(WindowsManifest): + address_size = 64 + + +class DarwinManifest(ViewerManifest): + build_data_json_platform = 'mac' + + def finish_build_data_dict(self, build_data_dict): + build_data_dict.update({'Bundle Id':self.args['bundleid']}) + return build_data_dict -class Darwin_i386_Manifest(ViewerManifest): def is_packaging_viewer(self): # darwin requires full app bundle packaging even for debugging. return True def construct(self): + # These are the names of the top-level application and the embedded + # applications for the VMP and for the actual viewer, respectively. + # These names, without the .app suffix, determine the flyover text for + # their corresponding Dock icons. + toplevel_app, toplevel_icon = "Second Life.app", "secondlife.icns" + launcher_app, launcher_icon = "Second Life Launcher.app", "secondlife.icns" + viewer_app, viewer_icon = "Second Life Viewer.app", "secondlife.icns" + # copy over the build result (this is a no-op if run within the xcode script) - self.path(self.args['configuration'] + "/Second Life.app", dst="") + self.path(os.path.join(self.args['configuration'], toplevel_app), dst="") pkgdir = os.path.join(self.args['build'], os.pardir, 'packages') relpkgdir = os.path.join(pkgdir, "lib", "release") debpkgdir = os.path.join(pkgdir, "lib", "debug") - if self.prefix(src="", dst="Contents"): # everything goes in Contents - self.path("Info.plist", dst="Info.plist") - - # copy additional libs in <bundle>/Contents/MacOS/ - self.path(os.path.join(relpkgdir, "libndofdev.dylib"), dst="Resources/libndofdev.dylib") - self.path(os.path.join(relpkgdir, "libhunspell-1.3.0.dylib"), dst="Resources/libhunspell-1.3.0.dylib") - - if self.prefix(dst="MacOS"): - self.path2basename("../viewer_components/updater/scripts/darwin", "*.py") - self.end_prefix() - - # most everything goes in the Resources directory - if self.prefix(src="", dst="Resources"): - super(Darwin_i386_Manifest, self).construct() - - if self.prefix("cursors_mac"): - self.path("*.tif") - self.end_prefix("cursors_mac") - - self.path("licenses-mac.txt", dst="licenses.txt") - self.path("featuretable_mac.txt") - self.path("SecondLife.nib") - - icon_path = self.icon_path() - if self.prefix(src=icon_path, dst="") : - self.path("secondlife.icns") - self.end_prefix(icon_path) - - self.path("SecondLife.nib") - - # Translations - self.path("English.lproj/language.txt") - self.replace_in(src="English.lproj/InfoPlist.strings", - dst="English.lproj/InfoPlist.strings", - searchdict={'%%VERSION%%':'.'.join(self.args['version'])} - ) - self.path("German.lproj") - self.path("Japanese.lproj") - self.path("Korean.lproj") - self.path("da.lproj") - self.path("es.lproj") - self.path("fr.lproj") - self.path("hu.lproj") - self.path("it.lproj") - self.path("nl.lproj") - self.path("pl.lproj") - self.path("pt.lproj") - self.path("ru.lproj") - self.path("tr.lproj") - self.path("uk.lproj") - self.path("zh-Hans.lproj") - - def path_optional(src, dst): - """ - For a number of our self.path() calls, not only do we want - to deal with the absence of src, we also want to remember - which were present. Return either an empty list (absent) - or a list containing dst (present). Concatenate these - return values to get a list of all libs that are present. - """ - if self.path(src, dst): - return [dst] - print "Skipping %s" % dst - return [] - - # dylibs is a list of all the .dylib files we expect to need - # in our bundled sub-apps. For each of these we'll create a - # symlink from sub-app/Contents/Resources to the real .dylib. - # Need to get the llcommon dll from any of the build directories as well. - libfile = "libllcommon.dylib" - dylibs = path_optional(self.find_existing_file(os.path.join(os.pardir, - "llcommon", - self.args['configuration'], - libfile), - os.path.join(relpkgdir, libfile)), - dst=libfile) - - for libfile in ( - "libapr-1.0.dylib", - "libaprutil-1.0.dylib", - "libcollada14dom.dylib", - "libexpat.1.5.2.dylib", - "libexception_handler.dylib", - "libGLOD.dylib", - ): - dylibs += path_optional(os.path.join(relpkgdir, libfile), libfile) - - # SLVoice and vivox lols, no symlinks needed - for libfile in ( - 'libortp.dylib', - 'libsndfile.dylib', - 'libvivoxoal.dylib', - 'libvivoxsdk.dylib', - 'libvivoxplatform.dylib', - 'ca-bundle.crt', - 'SLVoice', - ): - self.path2basename(relpkgdir, libfile) - - # dylibs that vary based on configuration - if self.args['configuration'].lower() == 'debug': - for libfile in ( - "libfmodexL.dylib", - ): - dylibs += path_optional(os.path.join(debpkgdir, libfile), libfile) - else: - for libfile in ( - "libfmodex.dylib", - ): - dylibs += path_optional(os.path.join(relpkgdir, libfile), libfile) - - # our apps - for app_bld_dir, app in (("mac_crash_logger", "mac-crash-logger.app"), - # plugin launcher - (os.path.join("llplugin", "slplugin"), "SLPlugin.app"), - ): - self.path2basename(os.path.join(os.pardir, - app_bld_dir, self.args['configuration']), - app) - - # our apps dependencies on shared libs - # for each app, for each dylib we collected in dylibs, - # create a symlink to the real copy of the dylib. - resource_path = self.dst_path_of(os.path.join(app, "Contents", "Resources")) - for libfile in dylibs: - src = os.path.join(os.pardir, os.pardir, os.pardir, libfile) - dst = os.path.join(resource_path, libfile) - try: - symlinkf(src, dst) - except OSError as err: - print "Can't symlink %s -> %s: %s" % (src, dst, err) - - # LLCefLib helper apps go inside SLPlugin.app - if self.prefix(src="", dst="SLPlugin.app/Contents/Frameworks"): - for helperappfile in ('LLCefLib Helper.app', - 'LLCefLib Helper EH.app'): - self.path2basename(relpkgdir, helperappfile) - - pluginframeworkpath = self.dst_path_of('Chromium Embedded Framework.framework'); - - self.end_prefix() - - # SLPlugin plugins - if self.prefix(src="", dst="llplugin"): - self.path2basename("../media_plugins/quicktime/" + self.args['configuration'], - "media_plugin_quicktime.dylib") - self.path2basename("../media_plugins/cef/" + self.args['configuration'], - "media_plugin_cef.dylib") - self.end_prefix("llplugin") - - self.end_prefix("Resources") - - # CEF framework goes inside Second Life.app/Contents/Frameworks - if self.prefix(src="", dst="Frameworks"): - frameworkfile="Chromium Embedded Framework.framework" - self.path2basename(relpkgdir, frameworkfile) - self.end_prefix("Frameworks") - - # This code constructs a relative path from the - # target framework folder back to the location of the symlink. - # It needs to be relative so that the symlink still works when - # (as is normal) the user moves the app bundle out of the DMG - # and into the /Applications folder. Note we also call 'raise' - # to terminate the process if we get an error since without - # this symlink, Second Life web media can't possibly work. - # Real Framework folder: - # Second Life.app/Contents/Frameworks/Chromium Embedded Framework.framework/ - # Location of symlink and why it'ds relative - # Second Life.app/Contents/Resources/SLPlugin.app/Contents/Frameworks/Chromium Embedded Framework.framework/ - # Real Frameworks folder, with the symlink inside the bundled SLPlugin.app (and why it's relative) - # <top level>.app/Contents/Frameworks/Chromium Embedded Framework.framework/ - # <top level>.app/Contents/Resources/SLPlugin.app/Contents/Frameworks/Chromium Embedded Framework.framework -> - frameworkpath = os.path.join(os.pardir, os.pardir, os.pardir, os.pardir, "Frameworks", "Chromium Embedded Framework.framework") - try: - symlinkf(frameworkpath, pluginframeworkpath) - except OSError as err: - print "Can't symlink %s -> %s: %s" % (frameworkpath, pluginframeworkpath, err) - raise - - self.end_prefix("Contents") + # -------------------- top-level Second Life.app --------------------- + # top-level Second Life application is only a container + with self.prefix(src="", dst="Contents"): # everything goes in Contents + # top-level Info.plist is as generated by CMake + Info_plist = "Info.plist" + ## This self.path() call reports 0 files... skip? + self.path(Info_plist) + Info_plist = self.dst_path_of(Info_plist) + + # the one file in top-level MacOS directory is the trampoline to + # our nested launcher_app + with self.prefix(dst="MacOS"): + toplevel_MacOS = self.get_dst_prefix() + trampoline = self.put_in_file("""\ +#!/bin/bash +open "%s" --args "$@" +""" % + # up one directory from MacOS to its sibling Resources directory + os.path.join('$(dirname "$0")', os.pardir, 'Resources', launcher_app), + "SL_Launcher", # write this file + "trampoline") # flag to add to list of copied files + # Script must be executable + self.run_command(["chmod", "+x", trampoline]) + + # Make a symlink to a nested app Frameworks directory that doesn't + # yet exist. We shouldn't need this; the only things that need + # Frameworks are nested apps under viewer_app, and they should + # simply find its Contents/Frameworks by relative pathnames. But + # empirically, we do: if we omit this symlink, CEF doesn't work -- + # the login splash screen doesn't even display. SIIIIGH. + # We're passing a path that's already relative, hence symlinkf() + # rather than relsymlinkf(). + self.symlinkf(os.path.join("Resources", viewer_app, "Contents", "Frameworks")) + + with self.prefix(src="", dst="Resources"): + # top-level Resources directory should be pretty sparse + # need .icns file referenced by top-level Info.plist + with self.prefix(src=self.icon_path(), dst="") : + self.path(toplevel_icon) + + # ------------------- nested launcher_app -------------------- + with self.prefix(dst=os.path.join(launcher_app, "Contents")): + # Info.plist is just like top-level one... + Info = plistlib.readPlist(Info_plist) + # except for these replacements: + Info["CFBundleExecutable"] = "SL_Launcher" + Info["CFBundleIconFile"] = launcher_icon + self.put_in_file( + plistlib.writePlistToString(Info), + os.path.basename(Info_plist), + "Info.plist") + + # copy VMP libs to MacOS + with self.prefix(dst="MacOS"): + #this copies over the python wrapper script, + #associated utilities and required libraries, see + #SL-321, SL-322, SL-323 + with self.prefix(src=os.path.join(pkgdir, "VMP"), dst=""): + self.path("SL_Launcher") + self.path("*.py") + # certifi will be imported by requests; this is + # our custom version to get our ca-bundle.crt + self.path("certifi") + with self.prefix(src=os.path.join(pkgdir, "lib", "python"), dst=""): + # llbase provides our llrest service layer and llsd decoding + with self.prefix("llbase"): + # (Why is llbase treated specially here? What + # DON'T we want to copy out of lib/python/llbase?) + self.path("*.py") + self.path("_cllsd.so") + #requests module needed by llbase/llrest.py + #this is only needed on POSIX, because in Windows + #we compile it into the EXE + for pypkg in "chardet", "idna", "requests", "urllib3": + self.path(pypkg) + + # launcher_app/Contents/Resources + with self.prefix(dst="Resources"): + with self.prefix(src=self.icon_path(), dst="") : + self.path(launcher_icon) + with self.prefix(dst="vmp_icons"): + self.path("secondlife.ico") + #VMP Tkinter icons + with self.prefix("vmp_icons"): + self.path("*.png") + self.path("*.gif") + + # -------------------- nested viewer_app --------------------- + with self.prefix(dst=os.path.join(viewer_app, "Contents")): + # Info.plist is just like top-level one... + Info = plistlib.readPlist(Info_plist) + # except for these replacements: + # (CFBundleExecutable may be moot: SL_Launcher directly + # runs the executable, instead of launching the app) + Info["CFBundleExecutable"] = "Second Life" + Info["CFBundleIconFile"] = viewer_icon + self.put_in_file( + plistlib.writePlistToString(Info), + os.path.basename(Info_plist), + "Info.plist") + + # CEF framework goes inside viewer_app/Contents/Frameworks. + # Remember where we parked this car. + with self.prefix(src="", dst="Frameworks"): + CEF_framework = "Chromium Embedded Framework.framework" + self.path2basename(relpkgdir, CEF_framework) + CEF_framework = self.dst_path_of(CEF_framework) + + with self.prefix(dst="MacOS"): + # CMake constructs the Second Life executable in the + # MacOS directory belonging to the top-level Second + # Life.app. Move it here. + here = self.get_dst_prefix() + relbase = os.path.realpath(os.path.dirname(Info_plist)) + self.cmakedirs(here) + for f in os.listdir(toplevel_MacOS): + if f == os.path.basename(trampoline): + # don't move the trampoline script we just made! + continue + fromwhere = os.path.join(toplevel_MacOS, f) + towhere = os.path.join(here, f) + print "Moving %s => %s" % \ + (self.relpath(fromwhere, relbase), + self.relpath(towhere, relbase)) + # now do it, only without relativizing paths + os.rename(fromwhere, towhere) + + # NOTE: the -S argument to strip causes it to keep + # enough info for annotated backtraces (i.e. function + # names in the crash log). 'strip' with no arguments + # yields a slightly smaller binary but makes crash + # logs mostly useless. This may be desirable for the + # final release. Or not. + if ("package" in self.args['actions'] or + "unpacked" in self.args['actions']): + self.run_command( + ['strip', '-S', self.dst_path_of('Second Life')]) + + with self.prefix(dst="Resources"): + # defer cross-platform file copies until we're in the right + # nested Resources directory + super(DarwinManifest, self).construct() + + with self.prefix(src=self.icon_path(), dst="") : + self.path(viewer_icon) + + with self.prefix(src=relpkgdir, dst=""): + self.path("libndofdev.dylib") + self.path("libhunspell-1.3.0.dylib") + + with self.prefix("cursors_mac"): + self.path("*.tif") + + self.path("licenses-mac.txt", dst="licenses.txt") + self.path("featuretable_mac.txt") + self.path("SecondLife.nib") + self.path("ca-bundle.crt") + + self.path("SecondLife.nib") + + # Translations + self.path("English.lproj/language.txt") + self.replace_in(src="English.lproj/InfoPlist.strings", + dst="English.lproj/InfoPlist.strings", + searchdict={'%%VERSION%%':'.'.join(self.args['version'])} + ) + self.path("German.lproj") + self.path("Japanese.lproj") + self.path("Korean.lproj") + self.path("da.lproj") + self.path("es.lproj") + self.path("fr.lproj") + self.path("hu.lproj") + self.path("it.lproj") + self.path("nl.lproj") + self.path("pl.lproj") + self.path("pt.lproj") + self.path("ru.lproj") + self.path("tr.lproj") + self.path("uk.lproj") + self.path("zh-Hans.lproj") + + def path_optional(src, dst): + """ + For a number of our self.path() calls, not only do we want + to deal with the absence of src, we also want to remember + which were present. Return either an empty list (absent) + or a list containing dst (present). Concatenate these + return values to get a list of all libs that are present. + """ + # This was simple before we started needing to pass + # wildcards. Fortunately, self.path() ends up appending a + # (source, dest) pair to self.file_list for every expanded + # file processed. Remember its size before the call. + oldlen = len(self.file_list) + self.path(src, dst) + # The dest appended to self.file_list has been prepended + # with self.get_dst_prefix(). Strip it off again. + added = [os.path.relpath(d, self.get_dst_prefix()) + for s, d in self.file_list[oldlen:]] + if not added: + print "Skipping %s" % dst + return added + + # dylibs is a list of all the .dylib files we expect to need + # in our bundled sub-apps. For each of these we'll create a + # symlink from sub-app/Contents/Resources to the real .dylib. + # Need to get the llcommon dll from any of the build directories as well. + libfile_parent = self.get_dst_prefix() + libfile = "libllcommon.dylib" + dylibs = path_optional(self.find_existing_file(os.path.join(os.pardir, + "llcommon", + self.args['configuration'], + libfile), + os.path.join(relpkgdir, libfile)), + dst=libfile) + + for libfile in ( + "libapr-1.0.dylib", + "libaprutil-1.0.dylib", + "libcollada14dom.dylib", + "libexpat.1.dylib", + "libexception_handler.dylib", + "libGLOD.dylib", + # libnghttp2.dylib is a symlink to + # libnghttp2.major.dylib, which is a symlink to + # libnghttp2.version.dylib. Get all of them. + "libnghttp2.*dylib", + ): + dylibs += path_optional(os.path.join(relpkgdir, libfile), libfile) + + # SLVoice and vivox lols, no symlinks needed + for libfile in ( + 'libortp.dylib', + 'libsndfile.dylib', + 'libvivoxoal.dylib', + 'libvivoxsdk.dylib', + 'libvivoxplatform.dylib', + 'SLVoice', + ): + self.path2basename(relpkgdir, libfile) + + # dylibs that vary based on configuration + if self.args['configuration'].lower() == 'debug': + for libfile in ( + "libfmodexL.dylib", + ): + dylibs += path_optional(os.path.join(debpkgdir, libfile), libfile) + else: + for libfile in ( + "libfmodex.dylib", + ): + dylibs += path_optional(os.path.join(relpkgdir, libfile), libfile) + + # our apps + executable_path = {} + for app_bld_dir, app in (("mac_crash_logger", "mac-crash-logger.app"), + # plugin launcher + (os.path.join("llplugin", "slplugin"), "SLPlugin.app"), + ): + self.path2basename(os.path.join(os.pardir, + app_bld_dir, self.args['configuration']), + app) + executable_path[app] = \ + self.dst_path_of(os.path.join(app, "Contents", "MacOS")) + + # our apps dependencies on shared libs + # for each app, for each dylib we collected in dylibs, + # create a symlink to the real copy of the dylib. + with self.prefix(dst=os.path.join(app, "Contents", "Resources")): + for libfile in dylibs: + self.relsymlinkf(os.path.join(libfile_parent, libfile)) + + # Dullahan helper apps go inside SLPlugin.app + with self.prefix(dst=os.path.join( + "SLPlugin.app", "Contents", "Frameworks")): + + frameworkname = 'Chromium Embedded Framework' + + # This code constructs a relative symlink from the + # target framework folder back to the real CEF framework. + # It needs to be relative so that the symlink still works when + # (as is normal) the user moves the app bundle out of the DMG + # and into the /Applications folder. Note we pass catch=False, + # letting the uncaught exception terminate the process, since + # without this symlink, Second Life web media can't possibly work. + + # It might seem simpler just to symlink Frameworks back to + # the parent of Chromimum Embedded Framework.framework. But + # that would create a symlink cycle, which breaks our + # packaging step. So make a symlink from Chromium Embedded + # Framework.framework to the directory of the same name, which + # is NOT an ancestor of the symlink. + + # from SLPlugin.app/Contents/Frameworks/Chromium Embedded + # Framework.framework back to + # $viewer_app/Contents/Frameworks/Chromium Embedded Framework.framework + SLPlugin_framework = self.relsymlinkf(CEF_framework, catch=False) + + # copy DullahanHelper.app + self.path2basename(relpkgdir, 'DullahanHelper.app') + + # and fix that up with a Frameworks/CEF symlink too + with self.prefix(dst=os.path.join( + 'DullahanHelper.app', 'Contents', 'Frameworks')): + # from Dullahan Helper.app/Contents/Frameworks/Chromium Embedded + # Framework.framework back to + # SLPlugin.app/Contents/Frameworks/Chromium Embedded Framework.framework + # Since SLPlugin_framework is itself a + # symlink, don't let relsymlinkf() resolve -- + # explicitly call relpath(symlink=True) and + # create that symlink here. + DullahanHelper_framework = \ + self.symlinkf(self.relpath(SLPlugin_framework, symlink=True), + catch=False) + + # change_command includes install_name_tool, the + # -change subcommand and the old framework rpath + # stamped into the executable. To use it with + # run_command(), we must still append the new + # framework path and the pathname of the + # executable to change. + change_command = [ + 'install_name_tool', '-change', + '@rpath/Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework'] + + with self.prefix(dst=os.path.join( + 'DullahanHelper.app', 'Contents', 'MacOS')): + # Now self.get_dst_prefix() is, at runtime, + # @executable_path. Locate the helper app + # framework (which is a symlink) from here. + newpath = os.path.join( + '@executable_path', + self.relpath(DullahanHelper_framework, symlink=True), + frameworkname) + # and restamp the DullahanHelper executable + self.run_command( + change_command + + [newpath, self.dst_path_of('DullahanHelper')]) + + # SLPlugin plugins + with self.prefix(dst="llplugin"): + dylibexecutable = 'media_plugin_cef.dylib' + self.path2basename("../media_plugins/cef/" + self.args['configuration'], + dylibexecutable) + + # Do this install_name_tool *after* media plugin is copied over. + # Locate the framework lib executable -- relative to + # SLPlugin.app/Contents/MacOS, which will be our + # @executable_path at runtime! + newpath = os.path.join( + '@executable_path', + self.relpath(SLPlugin_framework, executable_path["SLPlugin.app"], + symlink=True), + frameworkname) + # restamp media_plugin_cef.dylib + self.run_command( + change_command + + [newpath, self.dst_path_of(dylibexecutable)]) - # NOTE: the -S argument to strip causes it to keep enough info for - # annotated backtraces (i.e. function names in the crash log). 'strip' with no - # arguments yields a slightly smaller binary but makes crash logs mostly useless. - # This may be desirable for the final release. Or not. - if ("package" in self.args['actions'] or - "unpacked" in self.args['actions']): - self.run_command('strip -S %(viewer_binary)r' % - { 'viewer_binary' : self.dst_path_of('Contents/MacOS/Second Life')}) + # copy LibVLC plugin itself + self.path2basename("../media_plugins/libvlc/" + self.args['configuration'], + "media_plugin_libvlc.dylib") - def copy_finish(self): - # Force executable permissions to be set for scripts - # see CHOP-223 and http://mercurial.selenic.com/bts/issue1802 - for script in 'Contents/MacOS/update_install.py',: - self.run_command("chmod +x %r" % os.path.join(self.get_dst_prefix(), script)) + # copy LibVLC dynamic libraries + with self.prefix(src=relpkgdir, dst="lib"): + self.path( "libvlc*.dylib*" ) + # copy LibVLC plugins folder + with self.prefix(src='plugins', dst=""): + self.path( "*.dylib" ) + self.path( "plugins.dat" ) def package_finish(self): global CHANNEL_VENDOR_BASE @@ -922,12 +1277,17 @@ class Darwin_i386_Manifest(ViewerManifest): # make sure we don't have stale files laying about self.remove(sparsename, finalname) - self.run_command('hdiutil create %(sparse)r -volname %(vol)r -fs HFS+ -type SPARSE -megabytes 1000 -layout SPUD' % { - 'sparse':sparsename, - 'vol':volname}) + self.run_command(['hdiutil', 'create', sparsename, + '-volname', volname, '-fs', 'HFS+', + '-type', 'SPARSE', '-megabytes', '1300', + '-layout', 'SPUD']) # mount the image and get the name of the mount point and device node - hdi_output = self.run_command('hdiutil attach -private %r' % sparsename) + try: + hdi_output = subprocess.check_output(['hdiutil', 'attach', '-private', sparsename]) + except subprocess.CalledProcessError as err: + sys.exit("failed to mount image at '%s'" % sparsename) + try: devfile = re.search("/dev/disk([0-9]+)[^s]", hdi_output).group(0).strip() volpath = re.search('HFS\s+(.+)', hdi_output).group(1).strip() @@ -979,18 +1339,18 @@ class Darwin_i386_Manifest(ViewerManifest): # well, possibly we've mistaken the nature of the problem. In any # case, don't hang up the whole build looping indefinitely, let # the original problem manifest by executing the desired command. - self.run_command('SetFile -a V %r' % pathname) + self.run_command(['SetFile', '-a', 'V', pathname]) # Create the alias file (which is a resource file) from the .r - self.run_command('Rez %r -o %r' % - (self.src_path_of("installers/darwin/release-dmg/Applications-alias.r"), - os.path.join(volpath, "Applications"))) + self.run_command( + ['Rez', self.src_path_of("installers/darwin/release-dmg/Applications-alias.r"), + '-o', os.path.join(volpath, "Applications")]) # Set the alias file's alias and custom icon bits - self.run_command('SetFile -a AC %r' % os.path.join(volpath, "Applications")) + self.run_command(['SetFile', '-a', 'AC', os.path.join(volpath, "Applications")]) # Set the disk image root's custom icon bit - self.run_command('SetFile -a C %r' % volpath) + self.run_command(['SetFile', '-a', 'C', volpath]) # Sign the app if requested; # do this in the copy that's in the .dmg so that the extended attributes used by @@ -1014,7 +1374,22 @@ class Darwin_i386_Manifest(ViewerManifest): keychain_pwd_path = os.path.join(build_secrets_checkout,'code-signing-osx','password.txt') keychain_pwd = open(keychain_pwd_path).read().rstrip() - self.run_command('security unlock-keychain -p "%s" "%s/Library/Keychains/viewer.keychain"' % ( keychain_pwd, home_path ) ) + # Note: As of macOS Sierra, keychains are created with names postfixed with '-db' so for example, the + # SL Viewer keychain would by default be found in ~/Library/Keychains/viewer.keychain-db instead of + # just ~/Library/Keychains/viewer.keychain in earlier versions. + # + # Because we have old OS files from previous versions of macOS on the build hosts, the configurations + # are different on each host. Some have viewer.keychain, some have viewer.keychain-db and some have both. + # As you can see in the line below, this script expects the Linden Developer cert/keys to be in viewer.keychain. + # + # To correctly sign builds you need to make sure ~/Library/Keychains/viewer.keychain exists on the host + # and that it contains the correct cert/key. If a build host is set up with a clean version of macOS Sierra (or later) + # then you will need to change this line (and the one for 'codesign' command below) to point to right place or else + # pull in the cert/key into the default viewer keychain 'viewer.keychain-db' and export it to 'viewer.keychain' + viewer_keychain = os.path.join(home_path, 'Library', + 'Keychains', 'viewer.keychain') + self.run_command(['security', 'unlock-keychain', + '-p', keychain_pwd, viewer_keychain]) signed=False sign_attempts=3 sign_retry_wait=15 @@ -1022,13 +1397,12 @@ class Darwin_i386_Manifest(ViewerManifest): try: sign_attempts-=1; self.run_command( - 'codesign --verbose --deep --force --keychain "%(home_path)s/Library/Keychains/viewer.keychain" --sign %(identity)r %(bundle)r' % { - 'home_path' : home_path, - 'identity': identity, - 'bundle': app_in_dmg - }) + # Note: See blurb above about names of keychains + ['codesign', '--verbose', '--deep', '--force', + '--keychain', viewer_keychain, '--sign', identity, + app_in_dmg]) signed=True # if no exception was raised, the codesign worked - except ManifestError, err: + except ManifestError as err: if sign_attempts: print >> sys.stderr, "codesign failed, waiting %d seconds before retrying" % sign_retry_wait time.sleep(sign_retry_wait) @@ -1036,23 +1410,40 @@ class Darwin_i386_Manifest(ViewerManifest): else: print >> sys.stderr, "Maximum codesign attempts exceeded; giving up" raise - self.run_command('spctl -a -texec -vv %(bundle)r' % { 'bundle': app_in_dmg }) + self.run_command(['spctl', '-a', '-texec', '-vv', app_in_dmg]) imagename="SecondLife_" + '_'.join(self.args['version']) finally: # Unmount the image even if exceptions from any of the above - self.run_command('hdiutil detach -force %r' % devfile) + self.run_command(['hdiutil', 'detach', '-force', devfile]) print "Converting temp disk image to final disk image" - self.run_command('hdiutil convert %(sparse)r -format UDZO -imagekey zlib-level=9 -o %(final)r' % {'sparse':sparsename, 'final':finalname}) - self.run_command('hdiutil internet-enable -yes %(final)r' % {'final':finalname}) + self.run_command(['hdiutil', 'convert', sparsename, '-format', 'UDZO', + '-imagekey', 'zlib-level=9', '-o', finalname]) + self.run_command(['hdiutil', 'internet-enable', '-yes', finalname]) # get rid of the temp file self.package_file = finalname self.remove(sparsename) + +class Darwin_i386_Manifest(DarwinManifest): + address_size = 32 + + +class Darwin_i686_Manifest(DarwinManifest): + """alias in case arch is passed as i686 instead of i386""" + pass + + +class Darwin_x86_64_Manifest(DarwinManifest): + address_size = 64 + + class LinuxManifest(ViewerManifest): + build_data_json_platform = 'lnx' + def construct(self): super(LinuxManifest, self).construct() @@ -1061,68 +1452,60 @@ class LinuxManifest(ViewerManifest): debpkgdir = os.path.join(pkgdir, "lib", "debug") self.path("licenses-linux.txt","licenses.txt") - if self.prefix("linux_tools", dst=""): + with self.prefix("linux_tools", dst=""): self.path("client-readme.txt","README-linux.txt") self.path("client-readme-voice.txt","README-linux-voice.txt") self.path("client-readme-joystick.txt","README-linux-joystick.txt") self.path("wrapper.sh","secondlife") - if self.prefix(src="", dst="etc"): + with self.prefix(src="", dst="etc"): self.path("handle_secondlifeprotocol.sh") self.path("register_secondlifeprotocol.sh") self.path("refresh_desktop_app_entry.sh") self.path("launch_url.sh") - self.end_prefix("etc") self.path("install.sh") - self.end_prefix("linux_tools") - if self.prefix(src="", dst="bin"): + with self.prefix(src="", dst="bin"): self.path("secondlife-bin","do-not-directly-run-secondlife-bin") self.path("../linux_crash_logger/linux-crash-logger","linux-crash-logger.bin") - self.path2basename("../llplugin/slplugin", "SLPlugin") - self.path2basename("../viewer_components/updater/scripts/linux", "update_install") - self.end_prefix("bin") - - if self.prefix("res-sdl"): - self.path("*") - # recurse - self.end_prefix("res-sdl") + self.path2basename("../llplugin/slplugin", "SLPlugin") + #this copies over the python wrapper script, associated utilities and required libraries, see SL-321, SL-322 and SL-323 + with self.prefix(src="../viewer_components/manager", dst=""): + self.path("SL_Launcher") + self.path("*.py") + with self.prefix(src=os.path.join("lib", "python", "llbase"), dst="llbase"): + self.path("*.py") + self.path("_cllsd.so") + + # recurses, packaged again + self.path("res-sdl") # Get the icons based on the channel type icon_path = self.icon_path() print "DEBUG: icon_path '%s'" % icon_path - if self.prefix(src=icon_path, dst="") : + with self.prefix(src=icon_path, dst="") : self.path("secondlife_256.png","secondlife_icon.png") - if self.prefix(src="",dst="res-sdl") : + with self.prefix(src="",dst="res-sdl") : self.path("secondlife_256.BMP","ll_icon.BMP") - self.end_prefix("res-sdl") - self.end_prefix(icon_path) # plugins - if self.prefix(src="", dst="bin/llplugin"): - self.path("../media_plugins/gstreamer010/libmedia_plugin_gstreamer010.so", "libmedia_plugin_gstreamer.so") - self.path("../media_plugins/libvlc/libmedia_plugin_libvlc.so", "libmedia_plugin_libvlc.so") - self.end_prefix("bin/llplugin") + with self.prefix(src="../media_plugins", dst="bin/llplugin"): + self.path("gstreamer010/libmedia_plugin_gstreamer010.so", + "libmedia_plugin_gstreamer.so") + self.path2basename("libvlc", "libmedia_plugin_libvlc.so") - if self.prefix(src=os.path.join(os.pardir, 'packages', 'lib', 'vlc', 'plugins'), dst="bin/llplugin/vlc/plugins"): + with self.prefix(src=os.path.join(pkgdir, 'lib', 'vlc', 'plugins'), dst="bin/llplugin/vlc/plugins"): self.path( "plugins.dat" ) self.path( "*/*.so" ) - self.end_prefix() - if self.prefix(src=os.path.join(os.pardir, 'packages', 'lib' ), dst="lib"): + with self.prefix(src=os.path.join(pkgdir, 'lib' ), dst="lib"): self.path( "libvlc*.so*" ) - self.end_prefix() # llcommon if not self.path("../llcommon/libllcommon.so", "lib/libllcommon.so"): print "Skipping llcommon.so (assuming llcommon was linked statically)" self.path("featuretable_linux.txt") - - def copy_finish(self): - # Force executable permissions to be set for scripts - # see CHOP-223 and http://mercurial.selenic.com/bts/issue1802 - for script in 'secondlife', 'bin/update_install': - self.run_command("chmod +x %r" % os.path.join(self.get_dst_prefix(), script)) + self.path("ca-bundle.crt") def package_finish(self): installer_name = self.installer_base_name() @@ -1130,44 +1513,46 @@ class LinuxManifest(ViewerManifest): self.strip_binaries() # Fix access permissions - self.run_command(""" - find %(dst)s -type d | xargs --no-run-if-empty chmod 755; - find %(dst)s -type f -perm 0700 | xargs --no-run-if-empty chmod 0755; - find %(dst)s -type f -perm 0500 | xargs --no-run-if-empty chmod 0555; - find %(dst)s -type f -perm 0600 | xargs --no-run-if-empty chmod 0644; - find %(dst)s -type f -perm 0400 | xargs --no-run-if-empty chmod 0444; - true""" % {'dst':self.get_dst_prefix() }) + self.run_command(['find', self.get_dst_prefix(), + '-type', 'd', '-exec', 'chmod', '755', '{}', ';']) + for old, new in ('0700', '0755'), ('0500', '0555'), ('0600', '0644'), ('0400', '0444'): + self.run_command(['find', self.get_dst_prefix(), + '-type', 'f', '-perm', old, + '-exec', 'chmod', new, '{}', ';']) self.package_file = installer_name + '.tar.bz2' # temporarily move directory tree so that it has the right # name in the tarfile - self.run_command("mv %(dst)s %(inst)s" % { - 'dst': self.get_dst_prefix(), - 'inst': self.build_path_of(installer_name)}) + realname = self.get_dst_prefix() + tempname = self.build_path_of(installer_name) + self.run_command(["mv", realname, tempname]) try: # only create tarball if it's a release build. if self.args['buildtype'].lower() == 'release': # --numeric-owner hides the username of the builder for # security etc. - self.run_command('tar -C %(dir)s --numeric-owner -cjf ' - '%(inst_path)s.tar.bz2 %(inst_name)s' % { - 'dir': self.get_build_prefix(), - 'inst_name': installer_name, - 'inst_path':self.build_path_of(installer_name)}) + self.run_command(['tar', '-C', self.get_build_prefix(), + '--numeric-owner', '-cjf', + tempname + '.tar.bz2', installer_name]) else: print "Skipping %s.tar.bz2 for non-Release build (%s)" % \ (installer_name, self.args['buildtype']) finally: - self.run_command("mv %(inst)s %(dst)s" % { - 'dst': self.get_dst_prefix(), - 'inst': self.build_path_of(installer_name)}) + self.run_command(["mv", tempname, realname]) def strip_binaries(self): if self.args['buildtype'].lower() == 'release' and self.is_packaging_viewer(): print "* Going strip-crazy on the packaged binaries, since this is a RELEASE build" - self.run_command(r"find %(d)r/bin %(d)r/lib -type f \! -name update_install \! -name *.dat | xargs --no-run-if-empty strip -S" % {'d': self.get_dst_prefix()} ) # makes some small assumptions about our packaged dir structure + # makes some small assumptions about our packaged dir structure + self.run_command( + ["find"] + + [os.path.join(self.get_dst_prefix(), dir) for dir in ('bin', 'lib')] + + ['-type', 'f', '!', '-name', '*.py', '!', '-name', 'SL_Launcher', + '!', '-name', 'update_install', '-exec', 'strip', '-S', '{}', ';']) class Linux_i686_Manifest(LinuxManifest): + address_size = 32 + def construct(self): super(Linux_i686_Manifest, self).construct() @@ -1175,7 +1560,7 @@ class Linux_i686_Manifest(LinuxManifest): relpkgdir = os.path.join(pkgdir, "lib", "release") debpkgdir = os.path.join(pkgdir, "lib", "debug") - if self.prefix(relpkgdir, dst="lib"): + with self.prefix(relpkgdir, dst="lib"): self.path("libapr-1.so") self.path("libapr-1.so.0") self.path("libapr-1.so.0.4.5") @@ -1235,24 +1620,23 @@ class Linux_i686_Manifest(LinuxManifest): print "Skipping libfmodex.so - not found" pass - self.end_prefix("lib") - # Vivox runtimes - if self.prefix(src=relpkgdir, dst="bin"): - self.path("SLVoice") - self.end_prefix() - if self.prefix(src=relpkgdir, dst="lib"): - self.path("libortp.so") - self.path("libsndfile.so.1") - #self.path("libvivoxoal.so.1") # no - we'll re-use the viewer's own OpenAL lib - self.path("libvivoxsdk.so") - self.path("libvivoxplatform.so") - self.end_prefix("lib") + # Vivox runtimes + with self.prefix(src=relpkgdir, dst="bin"): + self.path("SLVoice") + with self.prefix(src=relpkgdir, dst="lib"): + self.path("libortp.so") + self.path("libsndfile.so.1") + #self.path("libvivoxoal.so.1") # no - we'll re-use the viewer's own OpenAL lib + self.path("libvivoxsdk.so") + self.path("libvivoxplatform.so") - self.strip_binaries() + self.strip_binaries() class Linux_x86_64_Manifest(LinuxManifest): + address_size = 64 + def construct(self): super(Linux_x86_64_Manifest, self).construct() @@ -1261,46 +1645,5 @@ class Linux_x86_64_Manifest(LinuxManifest): ################################################################ -def symlinkf(src, dst): - """ - Like ln -sf, but uses os.symlink() instead of running ln. - """ - try: - os.symlink(src, dst) - except OSError, err: - if err.errno != errno.EEXIST: - raise - # We could just blithely attempt to remove and recreate the target - # file, but that strategy doesn't work so well if we don't have - # permissions to remove it. Check to see if it's already the - # symlink we want, which is the usual reason for EEXIST. - elif os.path.islink(dst): - if os.readlink(dst) == src: - # the requested link already exists - pass - else: - # dst is the wrong symlink; attempt to remove and recreate it - os.remove(dst) - os.symlink(src, dst) - elif os.path.isdir(dst): - print "Requested symlink (%s) exists but is a directory; replacing" % dst - shutil.rmtree(dst) - os.symlink(src, dst) - elif os.path.exists(dst): - print "Requested symlink (%s) exists but is a file; replacing" % dst - os.remove(dst) - os.symlink(src, dst) - else: - # see if the problem is that the parent directory does not exist - # and try to explain what is missing - (parent, tail) = os.path.split(dst) - while not os.path.exists(parent): - (parent, tail) = os.path.split(parent) - if tail: - raise Exception("Requested symlink (%s) cannot be created because %s does not exist" - % os.path.join(parent, tail)) - else: - raise - if __name__ == "__main__": main() |