]>
Commit | Line | Data |
---|---|---|
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 | 14 | import os\r |
15 | import re\r | |
16 | import StringIO\r | |
17 | import subprocess\r | |
18 | import sys\r | |
19 | import zipfile\r | |
20 | \r | |
21 | is_unix = not sys.platform.startswith('win')\r | |
22 | \r | |
23 | if not is_unix:\r | |
24 | print "This script currently only supports unix-like systems"\r | |
25 | sys.exit(-1)\r | |
26 | \r | |
27 | if os.path.exists('OvmfPkgX64.dsc'):\r | |
28 | os.chdir('..')\r | |
29 | \r | |
30 | if 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 | |
34 | if 'TOOLCHAIN' in os.environ:\r | |
35 | TOOLCHAIN = os.environ['TOOLCHAIN']\r | |
36 | else:\r | |
37 | TOOLCHAIN = 'GCC44'\r | |
38 | \r | |
39 | def 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 | |
47 | def 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 | |
54 | def 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 | |
61 | def 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 | |
67 | def 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 | |
74 | revision = get_revision()\r | |
75 | \r | |
76 | newline_re = re.compile(r'(\n|\r\n|\r(?!\n))', re.MULTILINE)\r | |
77 | def to_dos_text(str):\r | |
78 | return newline_re.sub('\r\n', str)\r | |
79 | \r | |
80 | def 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 | |
103 | LICENSE = to_dos_text(\r | |
104 | '''This OVMF binary release is built from source code licensed under\r | |
105 | the BSD open source license. The BSD license is documented at\r | |
106 | http://opensource.org/licenses/bsd-license.php, and a copy is\r | |
107 | shown below.\r | |
108 | \r | |
109 | One sub-component of the OVMF project is a FAT filesystem driver. The FAT\r | |
110 | filesystem driver code is also BSD licensed, but the code license contains\r | |
111 | one additional term. This license can be found at\r | |
112 | http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=Edk2-fat-driver,\r | |
113 | and a copy is shown below (following the normal BSD license).\r | |
114 | \r | |
115 | === BSD license: START ===\r | |
116 | \r | |
117 | Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.\r | |
118 | \r | |
119 | Redistribution and use in source and binary forms, with or without\r | |
120 | modification, are permitted provided that the following conditions\r | |
121 | are 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 | |
133 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r | |
134 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r | |
135 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r | |
136 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r | |
137 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r | |
138 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r | |
139 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r | |
140 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r | |
141 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r | |
142 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r | |
143 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r | |
144 | POSSIBILITY OF SUCH DAMAGE.\r | |
145 | \r | |
146 | === BSD license: END ===\r | |
147 | \r | |
148 | === FAT filesystem driver license: START ===\r | |
149 | \r | |
150 | Copyright (c) 2004, Intel Corporation. All rights reserved.\r | |
151 | \r | |
152 | Redistribution and use in source and binary forms, with or without\r | |
153 | modification, are permitted provided that the following conditions\r | |
154 | are 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 | |
166 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r | |
167 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r | |
168 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r | |
169 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r | |
170 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r | |
171 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r | |
172 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r | |
173 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r | |
174 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r | |
175 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r | |
176 | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r | |
177 | POSSIBILITY OF SUCH DAMAGE.\r | |
178 | \r | |
179 | Additional terms:\r | |
180 | In addition to the forgoing, redistribution and use of the code is\r | |
181 | conditioned upon the FAT 32 File System Driver and all derivative\r | |
182 | works thereof being used for and designed only to read and/or write\r | |
183 | to a file system that is directly managed by an Extensible Firmware\r | |
184 | Interface (EFI) implementation or by an emulator of an EFI\r | |
185 | implementation.\r | |
186 | \r | |
187 | === FAT filesystem driver license: END ===\r | |
188 | ''')\r | |
189 | \r | |
190 | def 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 | |
209 | def 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 | |
231 | build_info = gen_build_info()\r | |
232 | build('IA32')\r | |
233 | build('X64')\r | |
234 | create_zip('IA32')\r | |
235 | create_zip('X64')\r | |
236 | \r | |
237 | \r |