📄 rsrztbld.py
字号:
# # ***** BEGIN LICENSE BLOCK *****# Source last modified: $Id: rsrztbld.py,v 1.5 2004/07/07 22:00:04 hubbe Exp $# # Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved.# # The contents of this file, and the files included with this file,# are subject to the current version of the RealNetworks Public# Source License (the "RPSL") available at# http://www.helixcommunity.org/content/rpsl unless you have licensed# the file under the current version of the RealNetworks Community# Source License (the "RCSL") available at# http://www.helixcommunity.org/content/rcsl, in which case the RCSL# will apply. You may also obtain the license terms directly from# RealNetworks. You may not use this file except in compliance with# the RPSL or, if you have a valid RCSL with RealNetworks applicable# to this file, the RCSL. Please see the applicable RPSL or RCSL for# the rights, obligations and limitations governing use of the# contents of the file.# # Alternatively, the contents of this file may be used under the# terms of the GNU General Public License Version 2 or later (the# "GPL") in which case the provisions of the GPL are applicable# instead of those above. If you wish to allow use of your version of# this file only under the terms of the GPL, and not to allow others# to use your version of this file under the terms of either the RPSL# or RCSL, indicate your decision by deleting the provisions above# and replace them with the notice and other provisions required by# the GPL. If you do not delete the provisions above, a recipient may# use your version of this file under the terms of any one of the# RPSL, the RCSL or the GPL.# # This file is part of the Helix DNA Technology. RealNetworks is the# developer of the Original Code and owns the copyrights in the# portions it created.# # This file, and the files included with this file, is distributed# and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY# KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS# ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET# ENJOYMENT OR NON-INFRINGEMENT.# # Technology Compatibility Kit Test Suite(s) Location:# http://www.helixcommunity.org/content/tck# # Contributor(s):# # ***** END LICENSE BLOCK *****# """This is a fork of the consumer installer functions for the server.This is no longer used on newer branches of the server, but RealServer 8.xuses it."""import osimport stringimport structimport ascriptimport sysinfotemp_dir_name = 'temp'product_distcode = ''product_executable = ''mac_path_translation_table = string.maketrans('\\', ':')unix_path_translation_table = string.maketrans('\\', '/')g_rzt_apple_script = None# By default we use Xtreme compression for all installers, and the rztbld# module resets this to 1 so that RUP files use ICTUSE_XTR_COMPRESSION = 0def Initialize(platform, project): if project.module_dir == '' or project.module_dir == ':': project.module_dir = project.target_name if platform.name == 'mac': project.src_root_path = os.environ['SOURCE_ROOT'] if (project.build_choices.count('release') > 0): debug_release = 'release' else: debug_release = 'debug' project.target_dir = os.path.join(project.src_root_path, debug_release) if platform.name == 'mac': global g_rzt_apple_script g_rzt_apple_script = ascript.CreateAppleScript('on all()') g_rzt_apple_script.Append( 'verify path "%s"' % (project.target_dir)) # Copy pncrt*.dll which is needed for pnpkg.exe on win32 if platform.name == 'win32': if project.IsDefined("HELIX_CONFIG_RN_CRT"): project.writeln('\t' + platform.mkdir.execute(project.target_dir)) pncrt_path = os.path.join(os.pardir, 'pncrt') if (project.build_choices.count('release') > 0): pncrt_path = os.path.join(pncrt_path, 'pncrt.dll') else: pncrt_path = os.path.join(pncrt_path, 'pncrtd.dll') project.writeln('\t' + platform.copy.cmd + ' ' + pncrt_path + ' ' + project.target_dir) pnpkg_path = os.path.join(os.pardir, 'pnpkg', project.output_dir) project.writeln('\t' + platform.copy.cmd + ' ' + pnpkg_path + ' ' + project.target_dir)def CreateProductHeader(header_name, product_name, main_component): file = open(header_name + '.hdr', 'w') file.write('PRODUCT ' + product_name + '|' + main_component[0] + '\n') file.close()def AddHeader(platform, project, header_name, component, add_options): specfile_path = os.path.join(project.src_root_path, component[2]) verfile_path = os.path.join(project.src_root_path, component[1]) if platform.type == 'unix': verfile_path = string.translate(verfile_path, unix_path_translation_table) specfile_path = string.translate(specfile_path, unix_path_translation_table) if (platform.type == 'unix'): index = string.rfind(specfile_path, '/') else: index = string.rfind(specfile_path, '\\') specfile_name = specfile_path[index+1:] if platform.name == 'mac': verfile_path = string.translate(verfile_path, mac_path_translation_table) specfile_path = string.translate(specfile_path, mac_path_translation_table) out_file = open(header_name + '.hdr', add_options) in_file = open(verfile_path, 'r') try: lines = in_file.readlines() except: raise VersionError, 'Error opening ' + verfile_path for line in lines: if string.find(line, '#define TARVER_STRING_VERSION') == 0: index = string.find(line, '"') line = line[ index + 1 : ] index = string.find(line, '"') line = line[ : index ] out_file.write('COMPONENT ' + component[0] + '|' + line + '|' + specfile_name + '\n') out_file.close() in_file.close() if project.target_name != project.module_dir: specfile_name = specfile_name + '_' + project.target_name out_file = open(specfile_name, 'w') in_file = open(specfile_path, 'r') try: lines = in_file.readlines() except: raise VersionError, 'Error opening ' + specfile_path for line in lines: ## Exclude other platform's commands include_line = 1 if (string.find(line, '#') == 0): include_line = 0 line = line[ 1 : ] index = string.find(line, '#') platform_index = string.find(line, platform.name) if(platform_index != -1 and platform_index < index): include_line = 1 line = line[ index + 1 : ] line = string.lstrip(line) if (include_line == 1): output_line = '' ## Insert platform specific dll names index = string.find(line, 'dll_name(') while index != -1: output_line = output_line + line[ : index ] line = line[ index + 9 : ] index = string.find(line, ')') platform.versioning.version = '' output_line = output_line + platform.versioning.create_dll_name(line[ : index ], line[ : index ]) platform.versioning.version = '' line = line[ index + 1 : ] index = string.find(line, 'dll_name(') output_line = output_line + line out_file.write(output_line) out_file.close() in_file.close()def Cleanup(platform, project): ## CLEANUP TEMP if platform.name == 'win32' or platform.name == 'win16': project.writeln('\trm -f -r ' + temp_dir_name) ## Remove installer executable installer_exe = os.path.join(project.src_root_path, "rssetshell") installer_exe = os.path.join(installer_exe, project.output_dir + 's') installer_exe = os.path.join(installer_exe, "setup.exe") project.writeln('\trm -f ' + installer_exe) elif platform.type == 'unix': project.writeln('\trm -f -r ' + temp_dir_name) elif platform.name == 'mac': temp_dir = os.path.join(project.src_root_path, project.module_dir) temp_dir = os.path.join(temp_dir, temp_dir_name) global g_rzt_apple_script g_rzt_apple_script.Append( 'tell application "Finder"', 'with timeout of 99999 seconds', 'if folder "%s" exists then' % (temp_dir), 'delete folder "%s"' % (temp_dir), 'set result to ""', 'end if', 'end timeout', 'end tell' )def AddComponent(platform, project, component, dirs, files, dlls): temp_dir = os.path.join(project.src_root_path, project.module_dir) copydir = temp_dir temp_dir = os.path.join(temp_dir, temp_dir_name) ## Create directories for files to copy if platform.name == 'mac': global g_rzt_apple_script g_rzt_apple_script.Append( 'verify path "%s"' % (temp_dir)) else: project.writeln('\t' + platform.mkdir.execute(temp_dir_name)) for dir in dirs: if platform.name == 'mac': global g_rzt_apple_script g_rzt_apple_script.Append( 'verify path "%s"' % (os.path.join(temp_dir, dir))) else: project.writeln('\t' + platform.mkdir.execute(os.path.join(temp_dir_name, dir))) str_copycommand = '\t' + platform.copy.cmd + ' ' if (platform.name == 'win16'): str_copycommand = '\tdrpog /noerr_copy ' project.writeln('\tdel CopyLogFile.txt') specfile_path = os.path.join(project.src_root_path, component[2]) if platform.type == 'unix': specfile_path = string.translate(specfile_path, unix_path_translation_table) index = string.rfind(specfile_path, '/') else: index = string.rfind(specfile_path, '\\') specfile_name = specfile_path[index+1:] specfile_out_path = os.path.join(temp_dir, specfile_name) if project.target_name != project.module_dir: specfile_name = specfile_name + '_' + project.target_name ## Copy spec file of a component if platform.name == 'mac': spec_path = os.path.join(project.src_root_path, component[2]) index = string.rfind(temp_dir, ':') spec_path = temp_dir[:index] spec_path = os.path.join(spec_path, specfile_name) corrected_file = string.translate(spec_path, mac_path_translation_table) global g_rzt_apple_script g_rzt_apple_script.Append( '-- Copy Files and Folders into Temporary Directory', 'tell application "Finder"', 'with timeout of 99999 seconds', 'AkuaCopy file "%s" to folder "%s" with overwriting' % (corrected_file, temp_dir) ) else: project.writeln(str_copycommand + specfile_name + ' ' + specfile_out_path) for dll in dlls: platform.versioning.version = '' dll_name = platform.versioning.create_dll_name(dll[0], dll[2]) dll_location = os.path.join(dll[2], project.output_dir) dll_location = os.path.join(dll_location, dll_name) if dll[1] == '': dest = temp_dir else: dest = os.path.join(temp_dir, dll[1]) if platform.name == 'mac': global g_rzt_apple_script g_rzt_apple_script.Append( 'AkuaCopy file "%s" to folder "%s" with overwriting' % (os.path.join(project.src_root_path, dll_location), dest) ) else: project.writeln(str_copycommand + os.path.join(project.src_root_path, dll_location) + ' ' + dest) for file in files: if file[1] == '': dest = temp_dir else: dest = os.path.join(temp_dir, file[1]) if platform.name == 'mac': srcfile = string.translate(file[0], mac_path_translation_table) srcfile = project.src_root_path + ':' + srcfile corrected_dest = string.translate(dest, mac_path_translation_table) if os.path.isdir(srcfile): # copy entire folder global g_rzt_apple_script g_rzt_apple_script.Append( 'Copy folder "%s" to folder "%s"' % (srcfile, corrected_dest) ) else: global g_rzt_apple_script g_rzt_apple_script.Append( 'AkuaCopy file "%s" to folder "%s" with overwriting' % (srcfile, corrected_dest) ) else: if platform.type == 'unix': srcfile = string.translate(file[0], unix_path_translation_table) temp = str_copycommand + '"' + os.path.join(project.src_root_path, srcfile) + '"' + ' ' + dest project.writeln(string.replace(temp, '*', '"*"')) else: project.writeln(str_copycommand + '"' + os.path.join(project.src_root_path, file[0]) + '"' + ' ' + dest) if platform.name == 'mac': global g_rzt_apple_script
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -