]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: Add create-release.py script
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 23 Feb 2011 22:21:00 +0000 (22:21 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 23 Feb 2011 22:21:00 +0000 (22:21 +0000)
This script builds OVMF IA32 and X64, and packages
both versions for release.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11337 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/create-release.py [new file with mode: 0755]

diff --git a/OvmfPkg/create-release.py b/OvmfPkg/create-release.py
new file mode 100755 (executable)
index 0000000..6677424
--- /dev/null
@@ -0,0 +1,240 @@
+#!/usr/bin/python\r
+#\r
+# Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
+#\r
+# This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+\r
+release_type = 'alpha'\r
+\r
+import os\r
+import re\r
+import StringIO\r
+import subprocess\r
+import sys\r
+import zipfile\r
+\r
+is_unix = not sys.platform.startswith('win')\r
+\r
+if not is_unix:\r
+    print "This script currently only supports unix-like systems"\r
+    sys.exit(-1)\r
+\r
+if os.path.exists('OvmfPkgX64.dsc'):\r
+    os.chdir('..')\r
+\r
+if not os.path.exists(os.path.join('OvmfPkg', 'OvmfPkgX64.dsc')):\r
+    print "OvmfPkg/OvmfPkgX64.dsc doesn't exist"\r
+    sys.exit(-1)\r
+\r
+if 'TOOLCHAIN' in os.environ:\r
+    TOOLCHAIN = os.environ['TOOLCHAIN']\r
+else:\r
+    TOOLCHAIN = 'GCC44'\r
+\r
+def run_and_capture_output(args, checkExitCode = True):\r
+    p = subprocess.Popen(args=args, stdout=subprocess.PIPE)\r
+    stdout = p.stdout.read()\r
+    ret_code = p.wait()\r
+    if checkExitCode:\r
+        assert ret_code == 0\r
+    return stdout\r
+\r
+def git_svn_info():\r
+    dir = os.getcwd()\r
+    os.chdir('OvmfPkg')\r
+    stdout = run_and_capture_output(args=('git', 'svn', 'info'))\r
+    os.chdir(dir)\r
+    return stdout\r
+\r
+def svn_info():\r
+    dir = os.getcwd()\r
+    os.chdir('OvmfPkg')\r
+    stdout = run_and_capture_output(args=('svn', 'info'))\r
+    os.chdir(dir)\r
+    return stdout\r
+\r
+def get_svn_info_output():\r
+    if os.path.exists(os.path.join('OvmfPkg', '.svn')):\r
+        return svn_info()\r
+    else:\r
+        return git_svn_info()\r
+\r
+def get_revision():\r
+    buf = get_svn_info_output()\r
+    revision_re = re.compile('^Revision\:\s*(\d+)$', re.MULTILINE)\r
+    mo = revision_re.search(buf)\r
+    if mo is not None:\r
+        return int(mo.group(1))\r
+\r
+revision = get_revision()\r
+\r
+newline_re = re.compile(r'(\n|\r\n|\r(?!\n))', re.MULTILINE)\r
+def to_dos_text(str):\r
+    return newline_re.sub('\r\n', str)\r
+\r
+def gen_build_info():\r
+    distro = run_and_capture_output(args=('lsb_release', '-sd')).strip()\r
+\r
+    machine = run_and_capture_output(args=('uname', '-m')).strip()\r
+\r
+    gcc_version = run_and_capture_output(args=('gcc', '--version'))\r
+    gcc_version = gcc_version.split('\n')[0].split()[-1]\r
+\r
+    ld_version = run_and_capture_output(args=('ld', '--version'))\r
+    ld_version = ld_version.split('\n')[0].split()[-1]\r
+\r
+    iasl_version = run_and_capture_output(args=('iasl'), checkExitCode=False)\r
+    iasl_version = filter(lambda s: s.find(' version ') >= 0, iasl_version.split('\n'))[0]\r
+    iasl_version = iasl_version.split(' version ')[1].strip()\r
+\r
+    sb = StringIO.StringIO()\r
+    print >> sb, 'edk2:    ', 'r%d' % revision\r
+    print >> sb, 'compiler: GCC', gcc_version\r
+    print >> sb, 'binutils:', ld_version\r
+    print >> sb, 'iasl:    ', iasl_version\r
+    print >> sb, 'system:  ', distro, machine.replace('_', '-')\r
+    return to_dos_text(sb.getvalue())\r
+\r
+LICENSE = to_dos_text(\r
+'''This OVMF binary release is built from source code licensed under\r
+the BSD open source license.  The BSD license is documented at\r
+http://opensource.org/licenses/bsd-license.php, and a copy is\r
+shown below.\r
+\r
+One sub-component of the OVMF project is a FAT filesystem driver.  The FAT\r
+filesystem driver code is also BSD licensed, but the code license contains\r
+one additional term.  This license can be found at\r
+http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=Edk2-fat-driver,\r
+and a copy is shown below (following the normal BSD license).\r
+\r
+=== BSD license: START ===\r
+\r
+Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.\r
+\r
+Redistribution and use in source and binary forms, with or without\r
+modification, are permitted provided that the following conditions\r
+are met:\r
+\r
+* Redistributions of source code must retain the above copyright\r
+  notice, this list of conditions and the following disclaimer.\r
+* Redistributions in binary form must reproduce the above copyright\r
+  notice, this list of conditions and the following disclaimer in\r
+  the documentation and/or other materials provided with the\r
+  distribution.\r
+* Neither the name of the Intel Corporation nor the names of its\r
+  contributors may be used to endorse or promote products derived\r
+  from this software without specific prior written permission.\r
+\r
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+POSSIBILITY OF SUCH DAMAGE.\r
+\r
+=== BSD license: END ===\r
+\r
+=== FAT filesystem driver license: START ===\r
+\r
+Copyright (c) 2004, Intel Corporation. All rights reserved.\r
+\r
+Redistribution and use in source and binary forms, with or without\r
+modification, are permitted provided that the following conditions\r
+are met:\r
+\r
+* Redistributions of source code must retain the above copyright\r
+  notice, this list of conditions and the following disclaimer.\r
+* Redistributions in binary form must reproduce the above copyright\r
+  notice, this list of conditions and the following disclaimer in\r
+  the documentation and/or other materials provided with the\r
+  distribution.\r
+* Neither the name of Intel nor the names of its\r
+  contributors may be used to endorse or promote products derived\r
+  from this software without specific prior written permission.\r
+\r
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\r
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\r
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
+POSSIBILITY OF SUCH DAMAGE.\r
+\r
+Additional terms:\r
+In addition to the forgoing, redistribution and use of the code is\r
+conditioned upon the FAT 32 File System Driver and all derivative\r
+works thereof being used for and designed only to read and/or write\r
+to a file system that is directly managed by an Extensible Firmware\r
+Interface (EFI) implementation or by an emulator of an EFI\r
+implementation.\r
+\r
+=== FAT filesystem driver license: END ===\r
+''')\r
+\r
+def build(arch):\r
+    args = (\r
+        'OvmfPkg/build.sh',\r
+        '-t', TOOLCHAIN,\r
+        '-a', arch,\r
+        '-b', 'RELEASE'\r
+        )\r
+    logname = 'build-%s.log' % arch\r
+    build_log = open(logname, 'w')\r
+    print 'Building OVMF for', arch, '(%s)' % logname, '...',\r
+    sys.stdout.flush()\r
+    p = subprocess.Popen(args=args, stdout=build_log, stderr=build_log)\r
+    ret_code = p.wait()\r
+    if ret_code == 0:\r
+        print '[done]'\r
+    else:\r
+        print '[error 0x%x]' % ret_code\r
+    return ret_code\r
+\r
+def create_zip(arch):\r
+    global build_info\r
+    filename = 'OVMF-%s-r%d-%s.zip' % (arch, revision, release_type)\r
+    print 'Creating', filename, '...',\r
+    sys.stdout.flush()\r
+    if os.path.exists(filename):\r
+        os.remove(filename)\r
+    zipf = zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED)\r
+\r
+    zipf.writestr('BUILD_INFO', build_info)\r
+    zipf.writestr('LICENSE', LICENSE)\r
+    zipf.write(os.path.join('OvmfPkg', 'README'), 'README')\r
+    FV_DIR = os.path.join(\r
+        'Build',\r
+        'Ovmf' + arch.title(),\r
+        'RELEASE_' + TOOLCHAIN,\r
+        'FV'\r
+        )\r
+    zipf.write(os.path.join(FV_DIR, 'OVMF.fd'), 'OVMF.fd')\r
+    zipf.write(os.path.join(FV_DIR, 'CirrusLogic5446.rom'), 'CirrusLogic5446.rom')\r
+    zipf.close()\r
+    print '[done]'\r
+\r
+build_info = gen_build_info()\r
+build('IA32')\r
+build('X64')\r
+create_zip('IA32')\r
+create_zip('X64')\r
+\r
+\r