tools/buildbot/PackageScript
changeset 2784 8903397125e6
child 2791 432647ef3529
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/buildbot/PackageScript	Sun Aug 30 00:46:56 2009 -0700
     1.3 @@ -0,0 +1,234 @@
     1.4 +# vim: set ts=2 sw=2 tw=99 noet ft=python: 
     1.5 +import os
     1.6 +import shutil
     1.7 +import ambuild.osutil as osutil
     1.8 +from ambuild.command import Command
     1.9 +
    1.10 +job = AMBuild.AddJob('package')
    1.11 +
    1.12 +class DestroyPath(Command):
    1.13 +	def __init__(self, folder):
    1.14 +		Command.__init__(self)
    1.15 +		self.folder = folder
    1.16 +
    1.17 +	def destroy(self, path):
    1.18 +		entries = os.listdir(path)
    1.19 +		for entry in entries:
    1.20 +			newpath = os.path.join(path, entry)
    1.21 +			if os.path.isdir(newpath):
    1.22 +				self.destroy(newpath)
    1.23 +				os.rmdir(newpath)
    1.24 +			elif os.path.isfile(newpath):
    1.25 +				os.remove(newpath)
    1.26 +
    1.27 +	def run(self, runner, job):
    1.28 +		runner.PrintOut('rm -rf {0}/*'.format(self.folder))
    1.29 +		self.destroy(self.folder)
    1.30 +
    1.31 +class CreateFolders(Command):
    1.32 +	def __init__(self, folders):
    1.33 +		Command.__init__(self)
    1.34 +		self.folders = folders
    1.35 +	
    1.36 +	def run(self, runner, job):
    1.37 +		for folder in self.folders:
    1.38 +			path = os.path.join(*folder)
    1.39 +			runner.PrintOut('mkdir {0}'.format(path))
    1.40 +			os.makedirs(path)
    1.41 +
    1.42 +#Shallow folder copy
    1.43 +class CopyFolder(Command):
    1.44 +	def __init__(self, fromList, toList, excludes = []):
    1.45 +		Command.__init__(self)
    1.46 +		self.fromPath = os.path.join(AMBuild.sourceFolder, *fromList)
    1.47 +		self.toPath = os.path.join(*toList) 
    1.48 +		self.excludes = excludes
    1.49 +	
    1.50 +	def run(self, runner, job):
    1.51 +		entries = os.listdir(self.fromPath)
    1.52 +		for entry in entries:
    1.53 +			if entry in self.excludes:
    1.54 +				continue
    1.55 +			path = os.path.join(self.fromPath, entry)
    1.56 +			if not os.path.isfile(path):
    1.57 +				continue
    1.58 +			runner.PrintOut('copy {0} to {1}'.format(path, self.toPath))
    1.59 +			shutil.copy(path, self.toPath)
    1.60 +
    1.61 +#Single file copy
    1.62 +class CopyFile(Command):
    1.63 +	def __init__(self, fromFile, toPath):
    1.64 +		Command.__init__(self)
    1.65 +		self.fromFile = fromFile
    1.66 +		self.toPath = toPath
    1.67 +
    1.68 +	def run(self, runner, job):
    1.69 +		runner.PrintOut('copy {0} to {1}'.format(self.fromFile, self.toPath))
    1.70 +		shutil.copy(self.fromFile, self.toPath)
    1.71 +
    1.72 +
    1.73 +folders = [['addons', 'sourcemod', 'bin'],
    1.74 +           ['addons', 'sourcemod', 'plugins', 'disabled'],
    1.75 +           ['addons', 'sourcemod', 'gamedata'],
    1.76 +           ['addons', 'sourcemod', 'gamedata', 'core.games'],
    1.77 +           ['addons', 'sourcemod', 'gamedata', 'sdktools.games'],
    1.78 +           ['addons', 'sourcemod', 'configs', 'geoip'],
    1.79 +           ['addons', 'sourcemod', 'translations'],
    1.80 +           ['addons', 'sourcemod', 'logs'],
    1.81 +           ['addons', 'sourcemod', 'extensions'],
    1.82 +           ['addons', 'sourcemod', 'data'],
    1.83 +           ['addons', 'sourcemod', 'scripting', 'include'],
    1.84 +           ['addons', 'sourcemod', 'scripting', 'admin-flatfile'],
    1.85 +           ['addons', 'sourcemod', 'scripting', 'adminmenu'],
    1.86 +           ['addons', 'sourcemod', 'scripting', 'testsuite'],
    1.87 +           ['cfg', 'sourcemod'],
    1.88 +           ['addons', 'sourcemod', 'configs', 'sql-init-scripts'],
    1.89 +           ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'mysql'],
    1.90 +           ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'sqlite'],
    1.91 +           ['addons', 'sourcemod', 'scripting', 'basecommands'],
    1.92 +           ['addons', 'sourcemod', 'scripting', 'basecomm'],
    1.93 +           ['addons', 'sourcemod', 'scripting', 'funvotes'],
    1.94 +           ['addons', 'sourcemod', 'scripting', 'basevotes'],
    1.95 +           ['addons', 'sourcemod', 'scripting', 'basebans'],
    1.96 +           ['addons', 'sourcemod', 'scripting', 'funcommands'],
    1.97 +           ['addons', 'sourcemod', 'scripting', 'playercommands'],
    1.98 +           ['addons', 'metamod'],
    1.99 +          ]
   1.100 +
   1.101 +#Setup
   1.102 +job.AddCommand(DestroyPath(os.path.join(AMBuild.outputFolder, 'package')))
   1.103 +job.AddCommand(CreateFolders(folders))
   1.104 +
   1.105 +#Copy Folders
   1.106 +job.AddCommand(CopyFolder(['configs'], ['addons', 'sourcemod', 'configs']))
   1.107 +job.AddCommand(CopyFolder(['configs', 'geoip'], ['addons', 'sourcemod', 'configs', 'geoip']))
   1.108 +job.AddCommand(CopyFolder(['configs', 'cfg'], ['cfg', 'sourcemod']))
   1.109 +job.AddCommand(CopyFolder(['configs', 'metamod'], ['addons', 'metamod']))
   1.110 +job.AddCommand(CopyFolder(['configs', 'sql-init-scripts'],
   1.111 +	['addons', 'sourcemod', 'configs', 'sql-init-scripts']))
   1.112 +job.AddCommand(CopyFolder(['configs', 'sql-init-scripts', 'mysql'],
   1.113 +	['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'mysql']))
   1.114 +job.AddCommand(CopyFolder(['configs', 'sql-init-scripts', 'sqlite'],
   1.115 +	['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'sqlite']))
   1.116 +job.AddCommand(CopyFolder(['gamedata'], ['addons', 'sourcemod', 'gamedata']))
   1.117 +job.AddCommand(CopyFolder(['gamedata', 'sdktools.games'],
   1.118 +	['addons', 'sourcemod', 'gamedata', 'sdktools.games']))
   1.119 +job.AddCommand(CopyFolder(['gamedata', 'core.games'],
   1.120 +	['addons', 'sourcemod', 'gamedata', 'core.games']))
   1.121 +job.AddCommand(CopyFolder(['plugins'], ['addons', 'sourcemod', 'scripting'], ['AMBuilder']))
   1.122 +job.AddCommand(CopyFolder(['plugins', 'include'],
   1.123 +	['addons', 'sourcemod', 'scripting', 'include']))
   1.124 +job.AddCommand(CopyFolder(['translations'], ['addons', 'sourcemod', 'translations']))
   1.125 +job.AddCommand(CopyFolder(['public', 'licenses'], ['addons', 'sourcemod']))
   1.126 +job.AddCommand(CopyFolder(['plugins', 'admin-flatfile'],
   1.127 +	['addons', 'sourcemod', 'scripting', 'admin-flatfile']))
   1.128 +job.AddCommand(CopyFolder(['plugins', 'adminmenu'],
   1.129 +	['addons', 'sourcemod', 'scripting', 'adminmenu']))
   1.130 +job.AddCommand(CopyFolder(['plugins', 'testsuite'],
   1.131 +	['addons', 'sourcemod', 'scripting', 'testsuite']))
   1.132 +job.AddCommand(CopyFolder(['plugins', 'basecommands'],
   1.133 +	['addons', 'sourcemod', 'scripting', 'basecommands']))
   1.134 +job.AddCommand(CopyFolder(['plugins', 'basecomm'],
   1.135 +	['addons', 'sourcemod', 'scripting', 'basecomm']))
   1.136 +job.AddCommand(CopyFolder(['plugins', 'funvotes'],
   1.137 +	['addons', 'sourcemod', 'scripting', 'funvotes']))
   1.138 +job.AddCommand(CopyFolder(['plugins', 'basevotes'],
   1.139 +	['addons', 'sourcemod', 'scripting', 'basevotes']))
   1.140 +job.AddCommand(CopyFolder(['plugins', 'basebans'],
   1.141 +	['addons', 'sourcemod', 'scripting', 'basebans']))
   1.142 +job.AddCommand(CopyFolder(['plugins', 'funcommands'],
   1.143 +	['addons', 'sourcemod', 'scripting', 'funcommands']))
   1.144 +job.AddCommand(CopyFolder(['plugins', 'playercommands'],
   1.145 +	['addons', 'sourcemod', 'scripting', 'playercommands']))
   1.146 +
   1.147 +defPlugins = [
   1.148 +	'admin-flatfile',
   1.149 +	'adminhelp',
   1.150 +	'antiflood',
   1.151 +	'basecommands',
   1.152 +	'reservedslots',
   1.153 +	'basetriggers',
   1.154 +	'nextmap',
   1.155 +	'basechat',
   1.156 +	'funcommands',
   1.157 +	'basevotes',
   1.158 +	'funvotes',
   1.159 +	'basebans',
   1.160 +	'basecomm',
   1.161 +	'adminmenu',
   1.162 +	'playercommands',
   1.163 +	'clientprefs',
   1.164 +	'sounds'
   1.165 +]
   1.166 +
   1.167 +disPlugins = [
   1.168 +	'admin-sql-prefetch',
   1.169 +	'admin-sql-threaded',
   1.170 +	'sql-admin-manager',
   1.171 +	'mapchooser',
   1.172 +	'randomcycle',
   1.173 +	'rockthevote',
   1.174 +	'nominations'
   1.175 +]
   1.176 +
   1.177 +commands = []
   1.178 +for plugin in defPlugins:
   1.179 +	commands.append(CopyFile(os.path.join('..', 'plugins', plugin + '.smx'),
   1.180 +	                         os.path.join('addons', 'sourcemod', 'plugins')))
   1.181 +
   1.182 +for plugin in disPlugins:
   1.183 +	commands.append(CopyFile(os.path.join('..', 'plugins', plugin + '.smx'),
   1.184 +	                         os.path.join('addons', 'sourcemod', 'plugins', 'disabled')))
   1.185 +job.AddCommandGroup(commands)
   1.186 +
   1.187 +bincopies = []
   1.188 +
   1.189 +def AddNormalLibrary(name, dest):
   1.190 +	dest = os.path.join('addons', 'sourcemod', dest)
   1.191 +	bincopies.append(CopyFile(os.path.join('..', name, name + osutil.SharedLibSuffix()), dest))
   1.192 +	pdb_list.append(name + '\\' + name + '.pdb')
   1.193 +
   1.194 +def AddHL2Library(name, dest):
   1.195 +	for i in SM.sdkInfo:
   1.196 +		sdk = SM.sdkInfo[i]
   1.197 +		AddNormalLibrary(name + '.' + sdk['ext'], dest)
   1.198 +
   1.199 +pdb_list = []
   1.200 +
   1.201 +if AMBuild.target['platform'] == 'linux':
   1.202 +	bincopies.append(CopyFile(os.path.join('..', 'loader', 'sourcemod_mm_i486.so'),
   1.203 +	                 os.path.join('addons', 'sourcemod', 'bin')))
   1.204 +elif AMBuild.target['platform'] == 'windows':
   1.205 +	bincopies.append(CopyFile(os.path.join('..', 'loader', 'sourcemod_mm.dll'),
   1.206 +	                 os.path.join('addons', 'sourcemod', 'bin')))
   1.207 +	pdb_list.append('loader\\sourcemod_mm.pdb')
   1.208 +
   1.209 +AddHL2Library('sourcemod', 'bin')
   1.210 +AddNormalLibrary('sourcepawn.jit.x86', 'bin')
   1.211 +AddNormalLibrary('geoip.ext', 'extensions')
   1.212 +AddNormalLibrary('dbi.mysql.ext', 'extensions')
   1.213 +AddNormalLibrary('dbi.sqlite.ext', 'extensions')
   1.214 +AddNormalLibrary('game.cstrike.ext.1.ep1', 'extensions')
   1.215 +AddNormalLibrary('game.tf2.ext.2.ep2v', 'extensions')
   1.216 +AddNormalLibrary('topmenus.ext', 'extensions')
   1.217 +AddNormalLibrary('regex.ext', 'extensions')
   1.218 +AddNormalLibrary('webternet.ext', 'extensions')
   1.219 +AddNormalLibrary('clientprefs.ext', 'extensions')
   1.220 +AddNormalLibrary('updater.ext', 'extensions')
   1.221 +AddHL2Library('bintools.ext', 'extensions')
   1.222 +AddHL2Library('sdktools.ext', 'extensions')
   1.223 +
   1.224 +bincopies.append(CopyFile(os.path.join('..', 'spcomp', 'spcomp' + osutil.ExecutableSuffix()),
   1.225 +                          os.path.join('addons', 'sourcemod', 'scripting')))
   1.226 +
   1.227 +job.AddCommandGroup(bincopies)
   1.228 +
   1.229 +if AMBuild.target['platform'] == 'windows':
   1.230 +	job.AddCommand(CopyFile(
   1.231 +		os.path.join(AMBuild.sourceFolder, 'sourcepawn', 'batchtool', 'compile.exe'),
   1.232 +		os.path.join('addons', 'sourcemod', 'scripting')))
   1.233 +	pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'wt')
   1.234 +	for pdb in pdb_list:
   1.235 +		pdblog.write(pdb + '\n')
   1.236 +	pdblog.close()
   1.237 +