X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=blobdiff_plain;f=install.py;h=cf0a74ba0a2add810f6a55fa69243df76cb7d91c;hp=0d44ceb9506817ba5a157f4b90bc7655fed75946;hb=85a66c95194d3c608040bc93bd7c241ec323c095;hpb=70fe5a7feb56241108699fc89c8db4fccf66a3c4 diff --git a/install.py b/install.py index 0d44ceb9..cf0a74ba 100644 --- a/install.py +++ b/install.py @@ -1,125 +1,48 @@ -# Copyright (C) 2001-2006 William Joseph. -# -# This file is part of GtkRadiant. -# -# GtkRadiant is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# GtkRadiant is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GtkRadiant; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -""" -Builds the ./install directory. - -Copies files from various locations: -./setup/data/tools/ -./games// -./include/version.default is used to generate RADIANT_MAJOR and RADIANT_MINOR -""" - -import os -import sys -import shutil - -def assertMessage(condition, message): - if not condition: - raise Exception(message) - -def copyFile(source, target): - assertMessage(os.path.isfile(source), "failed to find file: " + source) - print source, "->", target - shutil.copy2(source, target) - -def copyFileIfExists(source, target): - if os.path.exists(source): - copyFile(source, target) - -def copySvn(source, target): - assertMessage(os.path.isdir(source), "failed to find directory: " + source) - if not os.path.exists(target): - os.mkdir(target) - for name in os.listdir(source): - absolute = os.path.join(source, name) - absTarget = os.path.join(target, name) - if os.path.isdir(absolute): - if name != ".svn": - copySvn(absolute, absTarget) - else: - copyFile(absolute, absTarget) - -def copyGame(source, game, target): - assertMessage(os.path.isdir(source), "failed to find directory: " + source) - assertMessage(os.path.isdir(target), "failed to find directory: " + target) - root = os.path.join(source, os.path.normpath(game[0])) - if os.path.exists(root): - gamename = game[1] + ".game" - copySvn(os.path.join(root, gamename), os.path.join(target, gamename)) - gamesDir = os.path.join(target, "games") - if not os.path.exists(gamesDir): - os.mkdir(gamesDir) - copyFile(os.path.join(root, "games", gamename), os.path.join(gamesDir, gamename)) - -thisDir = os.path.dirname(__file__) -gamesRoot = os.path.join(thisDir, "games") -installRoot = os.path.join(thisDir, "install") - -if not os.path.exists(installRoot): - os.mkdir(installRoot) - -# copy generic data -copySvn(os.path.join(thisDir, os.path.normpath("setup/data/tools")), installRoot) - -# root, gamename -games = [ - ("Doom3Pack/tools", "doom3"), - ("ETPack", "et"), - ("HalfLifePack", "hl"), - ("Her2Pack", "heretic2"), - ("JAPack/Tools", "ja"), - ("JK2Pack", "jk2"), - ("Q1Pack", "q1"), - ("Q2Pack", "q2"), - ("Q3Pack/tools", "q3"), - ("Q4Pack/tools", "q4"), - ("Sof2Pack", "sof2"), - ("STVEFPack", "stvef"), - ("WolfPack/bin", "wolf"), - ("NexuizPack", "nexuiz"), - ("DarkPlacesPack", "darkplaces"), - ("WarsowPack/tools", "warsow"), - ("TremulousPack/tools", "trem") -] - -# copy games -for game in games: - copyGame(gamesRoot, game, installRoot) - -# copy win32 dlls -gtk2Root = os.path.normpath(os.path.join(thisDir, "../gtk2-2.10/install")) -if os.path.exists(gtk2Root): - copySvn(gtk2Root, installRoot) - -libxml2 = os.path.normpath(os.path.join(thisDir, "../libxml2-2.6/bin/libxml2.dll")) -copyFileIfExists(libxml2, installRoot) - -libmhash = os.path.normpath(os.path.join(thisDir, "../mhash-0.9/win32/libmhash/Release/libmhash.dll")) -copyFileIfExists(libmhash, installRoot) - -if sys.platform[:3] == "win" : - copySvn("../msvc_redist", installRoot) - dbghelp = os.path.normpath(os.path.join(thisDir, "../msvc_redist/dbghelp.dll")) - copyFileIfExists(dbghelp, installRoot) - -# create version files -version = open(os.path.join(thisDir, "include/version.default"), "rt").readline().split(".") -assertMessage(len(version) == 3, "failed to parse include/version.default") -open(os.path.join(thisDir, "install/RADIANT_MAJOR"), "wt").write(str(version[1])) -open(os.path.join(thisDir, "install/RADIANT_MINOR"), "wt").write(str(version[2])) +#!/usr/bin/env python + +import os.path, sys, shutil + +def install_file( path, src_path, f ): + src = os.path.join( src_path, f ) + dst = os.path.join( path, f ) + print '%s -> %s' % ( src, dst ) + shutil.copyfile( src, dst ) + +def install( path, src_path ): + for f in [ 'radiant.exe', 'radiant.pdb' ]: + install_file( path, src_path, f ) + + modules_path = os.path.join( path, 'modules' ) + try: + os.makedirs( modules_path ) + except: + pass + assert( os.path.exists( modules_path ) ) + + modules_src = os.path.join( src_path, 'modules' ) + assert( os.path.exists( modules_src ) ) + + for e in os.listdir( modules_src ): + if ( e[-4:] == '.dll' or e[-4:] == '.pdb' ): + install_file( modules_path, modules_src, e ) + + plugins_path = os.path.join( path, 'plugins' ) + try: + os.makedirs( plugins_path ) + except: + pass + assert( os.path.exists( plugins_path ) ) + + plugins_src = os.path.join( src_path, 'plugins' ) + assert( os.path.exists( plugins_src ) ) + + for e in os.listdir( plugins_src ): + if ( e[-4:] == '.dll' or e[-4:] == '.pdb' ): + install_file( plugins_path, plugins_src, e ) + +if __name__ == '__main__': + if ( len( sys.argv ) <= 2 or not os.path.exists( sys.argv[1] ) or not os.path.exists( sys.argv[2] ) ): + print 'usage: install [target directory] [source directory]' + sys.exit(1) + print 'Install %s into %s' % ( sys.argv[2], sys.argv[1] ) + install( sys.argv[1], sys.argv[2] )