]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/create-release.py
OvmfPkg/create-release.py: Remove '-alpha' from filename
[mirror_edk2.git] / OvmfPkg / create-release.py
CommitLineData
267865e8 1#!/usr/bin/python\r
2#\r
4272d1a7 3# Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>\r
267865e8 4#\r
5# This program and the accompanying materials\r
6# are licensed and made available under the terms and conditions of the BSD License\r
7# which accompanies this distribution. The full text of the license may be found at\r
8# http://opensource.org/licenses/bsd-license.php\r
9#\r
10# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12#\r
13\r
267865e8 14import os\r
15import re\r
16import StringIO\r
17import subprocess\r
18import sys\r
19import zipfile\r
20\r
21is_unix = not sys.platform.startswith('win')\r
22\r
23if not is_unix:\r
24 print "This script currently only supports unix-like systems"\r
25 sys.exit(-1)\r
26\r
27if os.path.exists('OvmfPkgX64.dsc'):\r
28 os.chdir('..')\r
29\r
30if not os.path.exists(os.path.join('OvmfPkg', 'OvmfPkgX64.dsc')):\r
31 print "OvmfPkg/OvmfPkgX64.dsc doesn't exist"\r
32 sys.exit(-1)\r
33\r
34if 'TOOLCHAIN' in os.environ:\r
35 TOOLCHAIN = os.environ['TOOLCHAIN']\r
36else:\r
37 TOOLCHAIN = 'GCC44'\r
38\r
39def run_and_capture_output(args, checkExitCode = True):\r
40 p = subprocess.Popen(args=args, stdout=subprocess.PIPE)\r
41 stdout = p.stdout.read()\r
42 ret_code = p.wait()\r
43 if checkExitCode:\r
44 assert ret_code == 0\r
45 return stdout\r
46\r
47def git_svn_info():\r
48 dir = os.getcwd()\r
49 os.chdir('OvmfPkg')\r
50 stdout = run_and_capture_output(args=('git', 'svn', 'info'))\r
51 os.chdir(dir)\r
52 return stdout\r
53\r
54def svn_info():\r
55 dir = os.getcwd()\r
56 os.chdir('OvmfPkg')\r
57 stdout = run_and_capture_output(args=('svn', 'info'))\r
58 os.chdir(dir)\r
59 return stdout\r
60\r
61def get_svn_info_output():\r
62 if os.path.exists(os.path.join('OvmfPkg', '.svn')):\r
63 return svn_info()\r
64 else:\r
65 return git_svn_info()\r
66\r
67def get_revision():\r
68 buf = get_svn_info_output()\r
69 revision_re = re.compile('^Revision\:\s*(\d+)$', re.MULTILINE)\r
70 mo = revision_re.search(buf)\r
71 if mo is not None:\r
72 return int(mo.group(1))\r
73\r
74revision = get_revision()\r
75\r
76newline_re = re.compile(r'(\n|\r\n|\r(?!\n))', re.MULTILINE)\r
77def to_dos_text(str):\r
78 return newline_re.sub('\r\n', str)\r
79\r
80def gen_build_info():\r
81 distro = run_and_capture_output(args=('lsb_release', '-sd')).strip()\r
82\r
83 machine = run_and_capture_output(args=('uname', '-m')).strip()\r
84\r
85 gcc_version = run_and_capture_output(args=('gcc', '--version'))\r
86 gcc_version = gcc_version.split('\n')[0].split()[-1]\r
87\r
88 ld_version = run_and_capture_output(args=('ld', '--version'))\r
89 ld_version = ld_version.split('\n')[0].split()[-1]\r
90\r
91 iasl_version = run_and_capture_output(args=('iasl'), checkExitCode=False)\r
92 iasl_version = filter(lambda s: s.find(' version ') >= 0, iasl_version.split('\n'))[0]\r
93 iasl_version = iasl_version.split(' version ')[1].strip()\r
94\r
95 sb = StringIO.StringIO()\r
96 print >> sb, 'edk2: ', 'r%d' % revision\r
97 print >> sb, 'compiler: GCC', gcc_version\r
98 print >> sb, 'binutils:', ld_version\r
99 print >> sb, 'iasl: ', iasl_version\r
100 print >> sb, 'system: ', distro, machine.replace('_', '-')\r
101 return to_dos_text(sb.getvalue())\r
102\r
103LICENSE = to_dos_text(\r
104'''This OVMF binary release is built from source code licensed under\r
105the BSD open source license. The BSD license is documented at\r
106http://opensource.org/licenses/bsd-license.php, and a copy is\r
107shown below.\r
108\r
109One sub-component of the OVMF project is a FAT filesystem driver. The FAT\r
110filesystem driver code is also BSD licensed, but the code license contains\r
111one additional term. This license can be found at\r
112http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=Edk2-fat-driver,\r
113and a copy is shown below (following the normal BSD license).\r
114\r
115=== BSD license: START ===\r
116\r
117Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.\r
118\r
119Redistribution and use in source and binary forms, with or without\r
120modification, are permitted provided that the following conditions\r
121are met:\r
122\r
123* Redistributions of source code must retain the above copyright\r
124 notice, this list of conditions and the following disclaimer.\r
125* Redistributions in binary form must reproduce the above copyright\r
126 notice, this list of conditions and the following disclaimer in\r
127 the documentation and/or other materials provided with the\r
128 distribution.\r
129* Neither the name of the Intel Corporation nor the names of its\r
130 contributors may be used to endorse or promote products derived\r
131 from this software without specific prior written permission.\r
132\r
133THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
134"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
135LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
136FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
137COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
138INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
139BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
140LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
141CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
142LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
143ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
144POSSIBILITY OF SUCH DAMAGE.\r
145\r
146=== BSD license: END ===\r
147\r
148=== FAT filesystem driver license: START ===\r
149\r
150Copyright (c) 2004, Intel Corporation. All rights reserved.\r
151\r
152Redistribution and use in source and binary forms, with or without\r
153modification, are permitted provided that the following conditions\r
154are met:\r
155\r
156* Redistributions of source code must retain the above copyright\r
157 notice, this list of conditions and the following disclaimer.\r
158* Redistributions in binary form must reproduce the above copyright\r
159 notice, this list of conditions and the following disclaimer in\r
160 the documentation and/or other materials provided with the\r
161 distribution.\r
162* Neither the name of Intel nor the names of its\r
163 contributors may be used to endorse or promote products derived\r
164 from this software without specific prior written permission.\r
165\r
166THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
167"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
168LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
169FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
170COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
171INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
172BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
173LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
174CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
175LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
176ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
177POSSIBILITY OF SUCH DAMAGE.\r
178\r
179Additional terms:\r
180In addition to the forgoing, redistribution and use of the code is\r
181conditioned upon the FAT 32 File System Driver and all derivative\r
182works thereof being used for and designed only to read and/or write\r
183to a file system that is directly managed by an Extensible Firmware\r
184Interface (EFI) implementation or by an emulator of an EFI\r
185implementation.\r
186\r
187=== FAT filesystem driver license: END ===\r
188''')\r
189\r
190def build(arch):\r
191 args = (\r
192 'OvmfPkg/build.sh',\r
193 '-t', TOOLCHAIN,\r
194 '-a', arch,\r
195 '-b', 'RELEASE'\r
196 )\r
197 logname = 'build-%s.log' % arch\r
198 build_log = open(logname, 'w')\r
199 print 'Building OVMF for', arch, '(%s)' % logname, '...',\r
200 sys.stdout.flush()\r
201 p = subprocess.Popen(args=args, stdout=build_log, stderr=build_log)\r
202 ret_code = p.wait()\r
203 if ret_code == 0:\r
204 print '[done]'\r
205 else:\r
206 print '[error 0x%x]' % ret_code\r
207 return ret_code\r
208\r
209def create_zip(arch):\r
210 global build_info\r
4272d1a7 211 filename = 'OVMF-%s-r%d.zip' % (arch, revision)\r
267865e8 212 print 'Creating', filename, '...',\r
213 sys.stdout.flush()\r
214 if os.path.exists(filename):\r
215 os.remove(filename)\r
216 zipf = zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED)\r
217\r
218 zipf.writestr('BUILD_INFO', build_info)\r
219 zipf.writestr('LICENSE', LICENSE)\r
220 zipf.write(os.path.join('OvmfPkg', 'README'), 'README')\r
221 FV_DIR = os.path.join(\r
222 'Build',\r
223 'Ovmf' + arch.title(),\r
224 'RELEASE_' + TOOLCHAIN,\r
225 'FV'\r
226 )\r
227 zipf.write(os.path.join(FV_DIR, 'OVMF.fd'), 'OVMF.fd')\r
267865e8 228 zipf.close()\r
229 print '[done]'\r
230\r
231build_info = gen_build_info()\r
232build('IA32')\r
233build('X64')\r
234create_zip('IA32')\r
235create_zip('X64')\r
236\r
237\r