Merge branch 'main/rendor-staging' into fixes
[ryzomcore.git] / nel / tools / build_gamedata / c1_shard_patch.py
blobe67314cd8bafe22c650b3f301dfb533b931ca164
1 #!/usr/bin/python
2 #
3 # \file c1_shard_patch.py
4 # \brief Create a new patch for the patchman bridge
5 # \date 2014-02-20 00:27GMT
6 # \author Jan Boon (Kaetemi)
7 # Python port of game data build pipeline.
8 # Create a new patch for the patchman bridge
9 #
10 # NeL - MMORPG Framework <http://www.ryzomcore.org/>
11 # Copyright (C) 2014 by authors
13 # This program is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU Affero General Public License as
15 # published by the Free Software Foundation, either version 3 of the
16 # License, or (at your option) any later version.
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU Affero General Public License for more details.
23 # You should have received a copy of the GNU Affero General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
27 import time, sys, os, shutil, subprocess, distutils.dir_util, tarfile, argparse
28 sys.path.append("configuration")
30 parser = argparse.ArgumentParser(description='Ryzom Core - Build Gamedata - Shard Patch')
31 parser.add_argument('--admininstall', '-ai', action='store_true')
32 args = parser.parse_args()
34 if os.path.isfile("log.log"):
35 os.remove("log.log")
36 log = open("log.log", "w")
37 from scripts import *
38 from buildsite import *
39 from tools import *
41 sys.path.append(WorkspaceDirectory)
42 from projects import *
44 # Log error
45 printLog(log, "")
46 printLog(log, "-------")
47 printLog(log, "--- Create a new patch for the patchman bridge")
48 printLog(log, "-------")
49 printLog(log, time.strftime("%Y-%m-%d %H:%MGMT", time.gmtime(time.time())))
50 printLog(log, "")
52 # Find tools
53 SevenZip = findTool(log, ToolDirectories, SevenZipTool, ToolSuffix)
55 # List the directories that will be used
56 archiveDirectories = [ ]
57 for dir in InstallShardDataDirectories:
58 if not dir in archiveDirectories:
59 archiveDirectories += [ dir ]
60 for package in InstallShardDataFiles:
61 dstDir = package[0]
62 if not dstDir in archiveDirectories:
63 archiveDirectories += [ dstDir ]
64 for multiDir in InstallShardDataMultiDirectories:
65 dstDir = multiDir[0]
66 if not dstDir in archiveDirectories:
67 archiveDirectories += [ dstDir ]
68 for multiDir in InstallShardDataPrimitivesDirectories:
69 dstDir = multiDir[0]
70 if not dstDir in archiveDirectories:
71 archiveDirectories += [ dstDir ]
72 for execDir in InstallShardDataExecutables:
73 dstDir = execDir[0]
74 if not dstDir in archiveDirectories:
75 archiveDirectories += [ dstDir ]
77 printLog(log, ">>> Archive new admin_install.tgz <<<")
78 mkPath(log, PatchmanBridgeServerDirectory)
79 adminInstallTgz = PatchmanBridgeServerDirectory + "/admin_install.tgz"
80 patchmanExecutable = LinuxServiceExecutableDirectory + "/ryzom_patchman_service"
81 if needUpdateDirNoSubdirFile(log, PatchmanCfgAdminDirectory + "/bin", adminInstallTgz) or needUpdateDirNoSubdirFile(log, PatchmanCfgAdminDirectory + "/patchman", adminInstallTgz) or needUpdate(log, patchmanExecutable, adminInstallTgz):
82 printLog(log, "WRITE " + adminInstallTgz)
83 if os.path.isfile(adminInstallTgz):
84 os.remove(adminInstallTgz)
85 tar = tarfile.open(adminInstallTgz, "w:gz")
86 tar.add(PatchmanCfgAdminDirectory + "/bin", arcname = "bin")
87 tar.add(PatchmanCfgAdminDirectory + "/patchman", arcname = "patchman")
88 tar.add(patchmanExecutable, arcname = "patchman/ryzom_patchman_service")
89 tar.close()
90 else:
91 printLog(log, "SKIP " + adminInstallTgz)
92 printLog(log, "")
94 if not args.admininstall:
95 if SevenZip == "":
96 toolLogFail(log, SevenZipTool, ToolSuffix)
97 else:
98 printLog(log, ">>> Create new version <<<")
99 newVersion = 1
100 vstr = str(newVersion).zfill(6)
101 vpath = PatchmanBridgeServerDirectory + "/" + vstr
102 while os.path.exists(vpath):
103 newVersion = newVersion + 1
104 vstr = str(newVersion).zfill(6)
105 vpath = PatchmanBridgeServerDirectory + "/" + vstr
106 mkPath(log, vpath)
107 for dir in archiveDirectories:
108 mkPath(log, ShardInstallDirectory + "/" + dir)
109 # tgzPath = vpath + "/" + dir + ".tgz"
110 # printLog(log, "WRITE " + tgzPath)
111 # tar = tarfile.open(tgzPath, "w:gz")
112 # tar.add(ShardInstallDirectory + "/" + dir, arcname = dir)
113 # tar.close()
114 sevenZipPath = vpath + "/" + dir + ".7z"
115 printLog(log, "WRITE " + sevenZipPath)
116 subprocess.call([ SevenZip, "a", sevenZipPath, ShardInstallDirectory + "/" + dir ])
117 printLog(log, "")
119 log.close()
120 if os.path.isfile("c1_shard_patch.log"):
121 os.remove("c1_shard_patch.log")
122 shutil.copy("log.log", time.strftime("%Y-%m-%d-%H-%M-GMT", time.gmtime(time.time())) + "_shard_patch.log")
123 shutil.move("log.log", "c1_shard_patch.log")