Set max-height of video area in media document as 100%
[framework/web/webkit-efl.git] / TizenScripts / release-webkit
1 #!/usr/bin/python
2 #####################################################################
3 # Helper script to release
4 #####################################################################
5 import sys, os
6 import getopt
7 import signal
8 import time
9
10 # defines global options
11 enableDryRun = False
12 enableTizenMain = False
13
14 patchVersion = 0
15 commitId = ""
16
17 def help():
18     print ("""
19 Usage: release-webkit [OPTION]
20
21 [Options]
22    -h, --help        : Print this message.
23    -n, --dry-run     : Don't actually run any commands; just print them.
24    -i, --tizen       : Create Release commit in tizen_2.1 branch and push to Gerrit. (Tizen:2.1:Main)
25 """)
26
27 def checkRepo(repo):
28
29     currentRepo = "RSA"
30     os.system("git remote -v > tmp")
31     inputFile = open("tmp", "r")
32
33     for line in inputFile:
34         if (("origin" in line) and ("magnolia" in line)):
35             print("ERROR : This command can executed only RSA repo.")
36             exit()
37
38 def checkoutBranch(branch):
39     findBranch = False
40     os.system("git branch > tmp")
41     inputFile = open("tmp", "r")
42
43     for line in inputFile:
44         if (line.find(branch) > -1):
45             execute("git checkout " + branch)
46             findBranch = True
47
48     if findBranch == False:
49         execute("git checkout -b " + branch + " origin/" + branch)
50
51     inputFile.close()
52     os.system("rm tmp")
53
54 def execute(command):
55     if enableDryRun:
56         print(command)
57     else:
58         os.system(command)
59
60 def getPath():
61     path = ""
62     if "TizenScripts" in os.getcwd():
63         path = "../"
64     return path
65
66 def getTagMsg(branch):
67     global commitId, patchVersion
68
69     os.system("git log " + branch + " > tmp")
70     #Find commit id, tag msg
71
72     inputFile = open("tmp","r")
73
74     #Find commit Id
75     for line in inputFile:
76         if "commit" in line:
77             commitId = line.replace("commit ","").strip()
78         elif line.find("[Release] Webkit2-efl-123997") == 4:
79             patchVersion = line.replace("[Release] ", "").strip()
80             break
81     inputFile.close()
82
83     tag = ""
84     os.system("git log " + commitId + " > tmp")
85     inputFile = open("tmp","r")
86
87     findFirstCommit = False
88     saveTag = False
89
90     for line in inputFile:
91         if line.find("[") == 4:
92             if "[Release] Webkit2" in line:
93                 if findFirstCommit == False:
94                     findFirstCommit = True
95                 else:
96                    break
97             else:
98                 if "[Title]" in line:
99                     tag +='\n'
100                 elif "[Solution]" in line:
101                     saveTag = True
102                 elif "[Problem]" in line:
103                     saveTag = True
104                 elif "[Cause]" in line:
105                     saveTag = True
106
107             if line.find("[WK2]") == -1:
108                     tag += line.strip() + '\n'
109         else:
110             if "Change-Id" in line:
111                 saveTag = False
112             if "commit" in line:
113                 saveTag = False
114             if len(line.strip()) < 1:
115                 saveTag = False
116             if saveTag:
117                 tag += line.strip() + '\n'
118     outputFile = open("tmp_tag","w")
119     outputFile.write(tag)
120     outputFile.close()
121     inputFile.close()
122
123     os.system("rm tmp")
124
125 def checkNewPatch():
126     os.system("git log > tmp_log")
127     isFirst = False
128     noPatch = False
129
130     inputFile = open("tmp_log", "r")
131     for line in inputFile:
132         if "commit" in line:
133             if isFirst:
134                 break
135             else:
136                 isFirst = True
137         else:
138             if isFirst:
139                 if "[Release] Webkit2" in line:
140                     noPatch = True
141
142     inputFile.close()
143     os.system("rm tmp_log")
144
145     if noPatch:
146         print "There is no new patch after previous release."
147         exit()
148
149 def versionUp(minor):
150     global patchVersion
151     path = getPath()
152
153     # Change version in OptionsTizen.cmake
154     inputFile = open(path + "Source/cmake/OptionsTizen.cmake","r")
155     outputFile = open("tmp","w")
156
157     for line in inputFile:
158         if "SET(PROJECT_VERSION_PATCH" in line:
159             patchVersion = line.replace("SET(PROJECT_VERSION_PATCH ", "")
160             patchVersion = patchVersion.replace(")", "")
161
162             patchVersion = int(patchVersion) + 1
163
164             tmp = "SET(PROJECT_VERSION_PATCH " + str(patchVersion) +")\n"
165             outputFile.write(tmp)
166             print "Modified PROJECT_VERSION_PATCH in OptionsTizen.cmake to " + tmp.strip()
167         else:
168             outputFile.write(line)
169
170     inputFile.close()
171     outputFile.close()
172
173     if enableDryRun:
174         os.system("rm tmp")
175     else:
176         os.system("chmod 644 tmp")
177         os.system("mv tmp " + path + "Source/cmake/OptionsTizen.cmake")
178
179     # Change version in webkit2-efl.spec
180     inputFile = open(path + "packaging/webkit2-efl.spec","r")
181     outputFile = open("tmp","w")
182
183     for line in inputFile:
184         if "Version:" in line:
185             tmp = "Version: 123997_0." + str(minor) + "." + str(patchVersion) + "\n"
186             outputFile.write(tmp)
187             print "Modified Version in webkit2-efl.spec to " + tmp.strip()
188         else:
189             outputFile.write(line)
190
191     inputFile.close()
192     outputFile.close()
193
194     if enableDryRun:
195         os.system("rm tmp")
196     else:
197         os.system("chmod 644 tmp")
198         os.system("mv tmp " + path + "packaging/webkit2-efl.spec")
199
200     execute("git add " + path + "Source/cmake/OptionsTizen.cmake " + path + "packaging/webkit2-efl.spec" )
201
202 def TizenMain():
203     global patchVersion
204     branchName = "tizen_2.1"
205     minorVersion = 11
206     checkRepo("RSA")
207     checkoutBranch(branchName)
208     checkNewPatch()
209
210     versionUp(minorVersion)
211     execute("git commit -m '[Release] Webkit2-efl-123997_0." + str(minorVersion) + "." + str(patchVersion) + "'" )
212     getTagMsg(branchName)
213     execute("git tag -a submit/" + branchName + "/`date --utc +%Y%m%d.%H%M%S` -F tmp_tag")
214     execute("git push --tags origin HEAD:refs/for/" + branchName)
215     
216     print "[Tizen:2.1:Main release] finished."
217
218 def release():
219     count = 0
220
221     if enableTizenMain:
222         count = count + 1
223
224     if count > 1:
225         print "ERROR : Package release is can't executed two branch simultaneously "
226         exit()
227
228     if enableTizenMain:
229         TizenMain()
230
231     if count == 0:
232         help()
233
234 def main():
235     global enableDryRun, enableTizenMain
236     optlist, args = getopt.getopt(sys.argv[1:], 'hdeilnm:o', [ 'help', 'dry-run', 'tizen'])
237     for opt, var in optlist:
238         if opt in ('--help', '-h'):
239             help()
240             exit()
241         if opt in ('--dry-run', '-n'):
242             enableDryRun = True
243         if opt in ('--tizen-main', '-i'):
244             enableTizenMain = True
245     release()
246 main()