Newer
Older
"""\
@file viewer_manifest.py
@author Ryan Williams
@brief Description of all installer viewer files, and methods for packaging
them into installers for all supported platforms.
$LicenseInfo:firstyear=2006&license=viewerlgpl$
Second Life Viewer Source Code
Copyright (C) 2006-2014, Linden Research, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation;
version 2.1 of the License only.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
$/LicenseInfo$
"""
import errno
Glenn Glazer
committed
import json
import os
import os.path
import random
import stat
import subprocess
# 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, MissingError
Oz Linden
committed
from llbase import llsd
class ViewerManifest(LLManifest):
def is_packaging_viewer(self):
# Some commands, files will only be included
# if we are packaging the viewer on windows.
# This manifest is also used to copy
# files during the build (see copy_w_viewer_manifest
# and copy_l_viewer_manifest targets)
return 'package' in self.args['actions']
def construct(self):
super(ViewerManifest, self).construct()
self.path(src="../../scripts/messages/message_template.msg", dst="app_settings/message_template.msg")
self.path(src="../../etc/message.xml", dst="app_settings/message.xml")
if self.is_packaging_viewer():
with self.prefix(src_dst="app_settings"):
self.exclude("logcontrol.xml")
self.exclude("logcontrol-dev.xml")
self.path("*.ini")
self.path("*.xml")
self.path("*.db2")
# include the entire shaders directory recursively
self.path("shaders")
# include the extracted list of contributors
contributions_path = "../../doc/contributions.txt"
contributor_names = self.extract_names(contributions_path)
self.put_in_file(contributor_names, "contributors.txt", src=contributions_path)
# ... and the default camera position settings
self.path("camera")
# ... and the entire windlight directory
self.path("windlight")
Merov Linden
committed
# ... and the entire image filters directory
self.path("filters")
# ... and the included spell checking dictionaries
pkgdir = os.path.join(self.args['build'], os.pardir, 'packages')
with self.prefix(src=pkgdir):
self.path("dictionaries")
# include the extracted packages information (see BuildPackagesInfo.cmake)
self.path(src=os.path.join(self.args['build'],"packages-info.txt"), dst="packages-info.txt")
# CHOP-955: If we have "sourceid" or "viewer_channel" in the
# build process environment, generate it into
# settings_install.xml.
settings_template = dict(
sourceid=dict(Comment='Identify referring agency to Linden web servers',
Persist=1,
Type='String',
Value=''),
Oz Linden
committed
CmdLineGridChoice=dict(Comment='Default grid',
Persist=0,
Type='String',
Value=''),
CmdLineChannel=dict(Comment='Command line specified channel name',
Persist=0,
Type='String',
Value=''))
settings_install = {}
sourceid = self.args.get('sourceid')
if sourceid:
settings_install['sourceid'] = settings_template['sourceid'].copy()
settings_install['sourceid']['Value'] = sourceid
print "Set sourceid in settings_install.xml to '%s'" % sourceid
if self.args.get('channel_suffix'):
settings_install['CmdLineChannel'] = settings_template['CmdLineChannel'].copy()
settings_install['CmdLineChannel']['Value'] = self.channel_with_pkg_suffix()
print "Set CmdLineChannel in settings_install.xml to '%s'" % self.channel_with_pkg_suffix()
if self.args.get('grid'):
Oz Linden
committed
settings_install['CmdLineGridChoice'] = settings_template['CmdLineGridChoice'].copy()
settings_install['CmdLineGridChoice']['Value'] = self.grid()
print "Set CmdLineGridChoice in settings_install.xml to '%s'" % self.grid()
# put_in_file(src=) need not be an actual pathname; it
# only needs to be non-empty
self.put_in_file(llsd.format_pretty_xml(settings_install),
"settings_install.xml",
src="environment")
Nat Goodspeed
committed
with self.prefix(src_dst="character"):
self.path("*.llm")
self.path("*.xml")
self.path("*.tga")
# Include our fonts
with self.prefix(src_dst="fonts"):
with self.prefix(src_dst="skins"):
with self.prefix(src_dst="*/textures"):
self.path("*/*.jpg")
self.path("*/*.png")
self.path("*.tga")
self.path("*.j2c")
self.path("*.png")
self.path("textures.xml")
self.path("*/xui/*/*.xml")
self.path("*/xui/*/widgets/*.xml")
self.path("*/*.xml")
self.path("*/*.json")
# The claim is that we never use local html files any
# longer. But rather than commenting out this block, let's
# rename every html subdirectory as html.old. That way, if
# 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.
with self.prefix(src="*/html", dst="*/html.old"):
self.path("*.png")
self.path("*/*/*.html")
self.path("*/*/*.gif")
#build_data.json. Standard with exception handling is fine. If we can't open a new file for writing, we have worse problems
Glenn Glazer
committed
#platform is computed above with other arg parsing
build_data_dict = {"Type":"viewer","Version":'.'.join(self.args['version']),
"Channel Base": CHANNEL_VENDOR_BASE,
Glenn Glazer
committed
"Channel":self.channel_with_pkg_suffix(),
"Platform":self.build_data_json_platform,
"Address Size":self.address_size,
"Update Service":"https://app.alchemyviewer.org/update",
# Only store this if it's both present and non-empty
bugsplat_db = self.args.get('bugsplat')
if bugsplat_db:
build_data_dict["BugSplat DB"] = bugsplat_db
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)
Glenn Glazer
committed
#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, "build_data.json"):
print "No build_data.json file"
def finish_build_data_dict(self, build_data_dict):
return build_data_dict
def channel_with_pkg_suffix(self):
fullchannel=self.channel()
channel_suffix = self.args.get('channel_suffix')
if channel_suffix:
fullchannel+=' '+channel_suffix
return fullchannel
def channel_variant(self):
global CHANNEL_VENDOR_BASE
return self.channel().replace(CHANNEL_VENDOR_BASE, "").strip()
def channel_type(self): # returns 'release', 'beta', 'project', or 'test'
channel_qualifier=self.channel_variant().lower()
if channel_qualifier.startswith('release'):
channel_type='release'
elif channel_qualifier.startswith('beta'):
channel_type='beta'
elif channel_qualifier.startswith('project'):
channel_type='project'
else:
channel_type='test'
return channel_type
def channel_variant_app_suffix(self):
Glenn Glazer
committed
# 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':
suffix=suffix.replace('Release', '').strip()
# for the base release viewer, suffix will now be null - for any other, append what remains
if suffix:
suffix = "_".join([''] + suffix.split())
# the additional_packages mechanism adds more to the installer name (but not to the app name itself)
# ''.split() produces empty list, so suffix only changes if
# channel_suffix is non-empty
suffix = "_".join([suffix] + self.args.get('channel_suffix', '').split())
return suffix
def installer_base_name(self):
global CHANNEL_VENDOR_BASE
# a standard map of strings for replacing in the templates
substitution_strings = {
'channel_vendor_base' : '_'.join(CHANNEL_VENDOR_BASE.split()),
'channel_variant_underscores':self.channel_variant_app_suffix(),
'version_underscores' : '_'.join(self.args['version']),
'arch':self.args['arch']
}
return "%(channel_vendor_base)s%(channel_variant_underscores)s_%(version_underscores)s_%(arch)s" % substitution_strings
Oz Linden
committed
def app_name(self):
global CHANNEL_VENDOR_BASE
channel_type=self.channel_type()
if channel_type == 'release':
Oz Linden
committed
app_suffix='Viewer'
else:
app_suffix=self.channel_variant()
return CHANNEL_VENDOR_BASE + ' ' + app_suffix
def app_name_oneword(self):
return ''.join(self.app_name().split())
def icon_path(self):
return "icons/" + self.channel_type()
def extract_names(self,src):
try:
contrib_file = open(src,'r')
except IOError:
print "Failed to open '%s'" % src
raise
lines = contrib_file.readlines()
contrib_file.close()
# All lines up to and including the first blank line are the file header; skip them
lines.reverse() # so that pop will pull from first to last line
while not re.match("\s*$", lines.pop()) :
pass # do nothing
# A line that starts with a non-whitespace character is a name; all others describe contributions, so collect the names
names = []
for line in lines :
if re.match("\S", line) :
names.append(line.rstrip())
# It's not fair to always put the same people at the head of the list
random.shuffle(names)
return ', '.join(names)
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
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)
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
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'
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['Executable'] = self.final_exe()
build_data_dict['AppName'] = self.app_name()
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))
self.created_paths.append(dst)
if not os.path.isdir(src):
if(self.args['configuration'].lower() == 'debug'):
test_assembly_binding(src, "Microsoft.VC80.DebugCRT", "8.0.50727.4053")
else:
test_assembly_binding(src, "Microsoft.VC80.CRT", "8.0.50727.4053")
self.ccopy(src,dst)
else:
raise Exception("Directories are not supported by test_CRT_and_copy_action()")
else:
print "Doesn't exist:", src
def test_for_no_msvcrt_manifest_and_copy_action(self, src, dst):
# This is used to test that no manifest for the msvcrt exists.
# 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))
self.created_paths.append(dst)
if not os.path.isdir(src):
try:
if(self.args['configuration'].lower() == 'debug'):
test_assembly_binding(src, "Microsoft.VC80.DebugCRT", "")
else:
test_assembly_binding(src, "Microsoft.VC80.CRT", "")
raise Exception("Unknown condition")
except NoManifestException as err:
except NoMatchingAssemblyException as err:
self.ccopy(src,dst)
else:
raise Exception("Directories are not supported by test_CRT_and_copy_action()")
else:
print "Doesn't exist:", src
def construct(self):
super(WindowsManifest, self).construct()
pkgdir = os.path.join(self.args['build'], os.pardir, 'packages')
relpkgdir = os.path.join(pkgdir, "lib", "release")
debpkgdir = os.path.join(pkgdir, "lib", "debug")
# Find alchemy-bin.exe in the 'configuration' dir, then rename it to the result of final_exe.
self.path(src='%s/alchemy-bin.exe' % self.args['configuration'], dst=self.final_exe())
with self.prefix(src=os.path.join(pkgdir, "VMP")):
# include the compiled launcher scripts so that it gets included in the file_list
self.path('SLVersionChecker.exe')
with self.prefix(dst="vmp_icons"):
with self.prefix(src=self.icon_path()):
self.path(src="alchemy.ico", dst="secondlife.ico")
#VMP Tkinter icons
with self.prefix(src="vmp_icons"):
self.path("*.png")
self.path("*.gif")
self.path2basename(os.path.join(os.pardir,
'llplugin', 'slplugin', self.args['configuration']),
"slplugin.exe")
with self.prefix(src=os.path.join(self.args['build'], os.pardir,
'sharedlibs', self.args['configuration'])):
# APR Libraries
self.path("libapr-1.dll")
self.path("libapriconv-1.dll")
self.path("libaprutil-1.dll")
# Boost Libraries
self.path("boost_context-mt*.dll")
self.path("boost_fiber-mt*.dll")
self.path("boost_filesystem-mt*.dll")
self.path("boost_program_options-mt*.dll")
self.path("boost_regex-mt*.dll")
self.path("boost_stacktrace_windbg-mt*.dll")
self.path("boost_thread-mt*.dll")
# Mesh 3rd party libs needed for auto LOD and collada reading
self.path("jpeg8.dll")
self.path("libpng16*.dll")
self.path("libwebp.dll")
self.path("openjpeg.dll")
# For OpenGL extensions
self.path("epoxy-0.dll")
# Security
self.path("ssleay32.dll")
self.path("libeay32.dll")
# HTTP and Network
self.path("libcurl*.dll")
self.path("nghttp2.dll")
self.path("xmlrpc-epi.dll")
# Hunspell
self.path("libhunspell.dll")
# Audio
self.path("libogg.dll")
self.path("libvorbis.dll")
self.path("libvorbisfile.dll")
self.path("libxml2.dll")
self.path("minizip*.dll")
self.path("uriparser.dll")
self.path("zlib*1.dll")
# Get openal dll for audio engine, continue if missing
if self.args['openal'] == 'ON' or self.args['openal'] == 'TRUE':
# Get openal dll
self.path("OpenAL32.dll")
self.path("alut.dll")
# Get fmodstudio dll for audio engine, continue if missing
if self.args['fmodstudio'] == 'ON' or self.args['fmodstudio'] == 'TRUE':
if self.args['configuration'].lower() == 'debug':
self.path("fmodL.dll", "fmodL.dll")
else:
self.path(src="fmod.dll", dst="fmod.dll")
if self.args['kdu'] == 'ON' or self.args['kdu'] == 'TRUE':
if self.args['configuration'].lower() == 'debug':
self.path("kdud.dll", "kdud.dll")
else:
self.path(src="kdu.dll", dst="kdu.dll")
Oz Linden
committed
# SLVoice executable
with self.prefix(src=os.path.join(pkgdir, 'bin', 'release')):
self.path("SLVoice.exe")
# Vivox libraries
if (self.address_size == 64):
self.path("vivoxsdk_x64.dll")
self.path("ortp_x64.dll")
else:
self.path("vivoxsdk.dll")
self.path("ortp.dll")
# BugSplat
if self.args.get('bugsplat'):
if(self.address_size == 64):
self.path("BsSndRpt64.exe")
self.path("BugSplat64.dll")
self.path("BugSplatRc64.dll")
else:
self.path("BsSndRpt.exe")
self.path("BugSplat.dll")
self.path("BugSplatRc.dll")
self.path(src="licenses-win32.txt", dst="licenses.txt")
self.path("featuretable.txt")
with self.prefix(src=pkgdir):
andreykproductengine
committed
self.path("ca-bundle.crt")
callum_linden
committed
# Media plugins - CEF
with self.prefix(dst="llplugin"):
with self.prefix(src=os.path.join(self.args['build'], os.pardir, 'media_plugins')):
with self.prefix(src=os.path.join('cef', self.args['configuration'])):
self.path("media_plugin_cef.dll")
# Media plugins - LibVLC
with self.prefix(src=os.path.join('libvlc', self.args['configuration'])):
self.path("media_plugin_libvlc.dll")
# Media plugins - Example (useful for debugging - not shipped with release viewer)
if self.channel_type() != 'release':
with self.prefix(src=os.path.join('example', self.args['configuration'])):
self.path("media_plugin_example.dll")
# CEF runtime files - debug
# CEF runtime files - not debug (release, relwithdebinfo etc.)
config = 'debug' if self.args['configuration'].lower() == 'debug' else 'release'
with self.prefix(src=os.path.join(pkgdir, 'bin', config)):
self.path("chrome_elf.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("snapshot_blob.bin")
callum_linden
committed
self.path("v8_context_snapshot.bin")
# CEF software renderer files
with self.prefix(src=os.path.join(pkgdir, 'bin', config, 'swiftshader'), dst='swiftshader'):
self.path("libEGL.dll")
self.path("libGLESv2.dll")
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
# CEF files common to all configurations
with self.prefix(src=os.path.join(pkgdir, 'resources')):
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")
with self.prefix(src=os.path.join(pkgdir, 'resources', 'locales'), dst='locales'):
self.path("am.pak")
self.path("ar.pak")
self.path("bg.pak")
self.path("bn.pak")
self.path("ca.pak")
self.path("cs.pak")
self.path("da.pak")
self.path("de.pak")
self.path("el.pak")
self.path("en-GB.pak")
self.path("en-US.pak")
self.path("es-419.pak")
self.path("es.pak")
self.path("et.pak")
self.path("fa.pak")
self.path("fi.pak")
self.path("fil.pak")
self.path("fr.pak")
self.path("gu.pak")
self.path("he.pak")
self.path("hi.pak")
self.path("hr.pak")
self.path("hu.pak")
self.path("id.pak")
self.path("it.pak")
self.path("ja.pak")
self.path("kn.pak")
self.path("ko.pak")
self.path("lt.pak")
self.path("lv.pak")
self.path("ml.pak")
self.path("mr.pak")
self.path("ms.pak")
self.path("nb.pak")
self.path("nl.pak")
self.path("pl.pak")
self.path("pt-BR.pak")
self.path("pt-PT.pak")
self.path("ro.pak")
self.path("ru.pak")
self.path("sk.pak")
self.path("sl.pak")
self.path("sr.pak")
self.path("sv.pak")
self.path("sw.pak")
self.path("ta.pak")
self.path("te.pak")
self.path("th.pak")
self.path("tr.pak")
self.path("uk.pak")
self.path("vi.pak")
self.path("zh-CN.pak")
self.path("zh-TW.pak")
with self.prefix(src=os.path.join(pkgdir, 'bin', 'release')):
self.path("libvlc.dll")
self.path("libvlccore.dll")
self.path("plugins/")
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
if not self.is_packaging_viewer():
self.package_file = "copied_deps"
def nsi_file_commands(self, install=True):
def wpath(path):
if path.endswith('/') or path.endswith(os.path.sep):
path = path[:-1]
path = path.replace('/', '\\')
return path
result = ""
dest_files = [pair[1] for pair in self.file_list if pair[0] and os.path.isfile(pair[1])]
# sort deepest hierarchy first
dest_files.sort(lambda a,b: cmp(a.count(os.path.sep),b.count(os.path.sep)) or cmp(a,b))
dest_files.reverse()
out_path = None
for pkg_file in dest_files:
rel_file = os.path.normpath(pkg_file.replace(self.get_dst_prefix()+os.path.sep,''))
installed_dir = wpath(os.path.join('$INSTDIR', os.path.dirname(rel_file)))
pkg_file = wpath(os.path.normpath(pkg_file))
if installed_dir != out_path:
if install:
out_path = installed_dir
result += 'SetOutPath ' + out_path + '\n'
if install:
result += 'File ' + pkg_file + '\n'
else:
result += 'Delete ' + wpath(os.path.join('$INSTDIR', rel_file)) + '\n'
# at the end of a delete, just rmdir all the directories
if not install:
deleted_file_dirs = [os.path.dirname(pair[1].replace(self.get_dst_prefix()+os.path.sep,'')) for pair in self.file_list]
# find all ancestors so that we don't skip any dirs that happened to have no non-dir children
deleted_dirs = []
for d in deleted_file_dirs:
deleted_dirs.extend(path_ancestors(d))
# sort deepest hierarchy first
deleted_dirs.sort(lambda a,b: cmp(a.count(os.path.sep),b.count(os.path.sep)) or cmp(a,b))
deleted_dirs.reverse()
prev = None
for d in deleted_dirs:
if d != prev: # skip duplicates
result += 'RMDir ' + wpath(os.path.join('$INSTDIR', os.path.normpath(d))) + '\n'
prev = d
return result
def package_finish(self):
# a standard map of strings for replacing in the templates
substitution_strings = {
'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),
Nat Goodspeed
committed
'flags':'',
'app_name':self.app_name(),
'app_name_oneword':self.app_name_oneword()
installer_file = self.installer_base_name() + '_Setup.exe'
substitution_strings['installer_file'] = installer_file
!define INSTEXE "SLVersionChecker.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"
if self.channel_type() == 'release':
substitution_strings['caption'] = CHANNEL_VENDOR_BASE
substitution_strings['caption'] = self.app_name() + ' ${VERSION}'
Oz Linden
committed
inst_vars_template = """
!define INSTNAME "%(app_name_oneword)s"
!define SHORTCUT "%(app_name)s"
Caption "%(caption)s"
if(self.address_size == 64):
Callum Prentice
committed
engage_registry="SetRegView 64"
program_files="!define MULTIUSER_USE_PROGRAMFILES64"
Callum Prentice
committed
else:
Callum Prentice
committed
engage_registry="SetRegView 32"
program_files=""
Callum Prentice
committed
tempfile = "alchemy_setup_tmp.nsi"
# the following replaces strings in the nsi template
# it also does python-style % substitution
self.replace_in("installers/windows/installer_template.nsi", tempfile, {
"%%VERSION%%":version_vars,
"%%SOURCE%%":self.get_src_prefix(),
Oz Linden
committed
"%%INST_VARS%%":inst_vars_template % substitution_strings,
Callum Prentice
committed
"%%PROGRAMFILES%%":program_files,
Callum Prentice
committed
"%%ENGAGEREGISTRY%%":engage_registry,
# 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 (
self.final_exe(),
"SLVersionChecker.exe",
Callum Prentice
committed
"llplugin/dullahan_host.exe",
):
self.sign(exe)
# Check two paths, one for Program Files, and one for Program Files (x86).
# Yay 64bit windows.
for ProgramFiles in 'ProgramFiles', 'ProgramFiles(x86)':
NSIS_path = os.path.expandvars(r'${%s}\NSIS\makensis.exe' % ProgramFiles)
if os.path.exists(NSIS_path):
break
JJ Linden
committed
installer_created=False
nsis_attempts=3
nsis_retry_wait=15
for attempt in xrange(nsis_attempts):
JJ Linden
committed
try:
self.run_command([NSIS_path, '/V2', self.dst_path_of(tempfile)])
except ManifestError as err:
if attempt+1 < nsis_attempts:
JJ Linden
committed
print >> sys.stderr, "nsis failed, waiting %d seconds before retrying" % nsis_retry_wait
time.sleep(nsis_retry_wait)
nsis_retry_wait*=2
else:
# NSIS worked! Done!
break
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')
Callum Prentice
committed
python = os.environ.get('PYTHON', sys.executable)
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:
Callum Prentice
committed
print "Skipping code signing of %s %s: %s not found" % (self.dst_path_of(exe), 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
def is_packaging_viewer(self):
# darwin requires full app bundle packaging even for debugging.
return True
def is_rearranging(self):
# That said, some stuff should still only be performed once.
# Are either of these actions in 'actions'? Is the set intersection
# non-empty?
return bool(set(["package", "unpacked"]).intersection(self.args['actions']))
# copy over the build result (this is a no-op if run within the xcode script)
self.path(os.path.join(self.args['configuration'], self.channel()+".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")
libdir = debpkgdir if self.args['configuration'].lower() == 'debug' else relpkgdir
with self.prefix(src="", dst="Contents"): # everything goes in Contents
bugsplat_db = self.args.get('bugsplat')
if bugsplat_db:
# Inject BugsplatServerURL into Info.plist if provided.
Info_plist = self.dst_path_of("Info.plist")
Info = plistlib.readPlist(Info_plist)
# https://www.bugsplat.com/docs/platforms/os-x#configuration
Info["BugsplatServerURL"] = \
"https://{}.bugsplat.com/".format(bugsplat_db)
self.put_in_file(
plistlib.writePlistToString(Info),
os.path.basename(Info_plist),
"Info.plist")
# CEF framework goes inside Contents/Frameworks.
# Remember where we parked this car.
with self.prefix(src=libdir, dst="Frameworks"):
CEF_framework = "Chromium Embedded Framework.framework"
self.path2basename(libdir, CEF_framework)
CEF_framework = self.dst_path_of(CEF_framework)

Rye Mutt
committed
'libapr-1.*.dylib',
'libaprutil-1.*.dylib',
'libjpeg.*.dylib',
'libepoxy.*.dylib',
'libhunspell-*.dylib',
'libndofdev.dylib',
'libopenjpeg.*.dylib',
'liburiparser.*.dylib',
'libvorbis.*.dylib',
'libvorbisenc.*.dylib',
'libvorbisfile.*.dylib',

Rye Mutt
committed
'libxmlrpc-epi.*.dylib',
):
self.path(libfile)
if self.args.get('bugsplat'):
self.path("BugsplatMac.framework")
if self.args['openal'] == 'ON' or self.args['openal'] == 'TRUE':
for libfile in (
'libopenal.*.dylib',
'libalut.*.dylib',
):
self.path(libfile)
if self.args['fmodstudio'] == 'ON' or self.args['fmodstudio'] == 'TRUE':
if self.args['configuration'].lower() == 'debug':
self.path("libfmodL.dylib")
else:
self.path("libfmod.dylib")
with self.prefix(dst="MacOS"):
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
executable = self.dst_path_of(self.channel())
if self.args.get('bugsplat'):
# According to Apple Technical Note TN2206:
# https://developer.apple.com/library/archive/technotes/tn2206/_index.html#//apple_ref/doc/uid/DTS40007919-CH1-TNTAG207
# "If an app uses @rpath or an absolute path to link to a
# dynamic library outside of the app, the app will be
# rejected by Gatekeeper. ... Neither the codesign nor the
# spctl tool will show the error."
# (Thanks, Apple. Maybe fix spctl to warn?)
# The BugsplatMac framework embeds @rpath, which is
# causing scary Gatekeeper popups at viewer start. Work
# around this by changing the reference baked into our
# viewer. The install_name_tool -change option needs the
# previous value. Instead of guessing -- which might
# silently be defeated by a BugSplat SDK update that
# changes their baked-in @rpath -- ask for the path
# stamped into the framework.
# Let exception, if any, propagate -- if this doesn't
# work, we need the build to noisily fail!
oldpath = subprocess.check_output(
['objdump', '-macho', '-dylib-id', '-non-verbose',
os.path.join(relpkgdir, "BugsplatMac.framework", "BugsplatMac")]
).splitlines()[-1] # take the last line of output
self.run_command(
['install_name_tool', '-change', oldpath,
'@executable_path/../Frameworks/BugsplatMac.framework/BugsplatMac',
executable])
# 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', executable])