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