Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
| 5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 # | 6 # |
| 7 | 7 |
| 8 # Script to build a Debian packages from a Dart tarball. The script | 8 # Script to build a Debian packages from a Dart tarball. The script |
| 9 # will build a source package and a 32-bit (i386) and 64-bit (amd64) | 9 # will build a source package and a 32-bit (i386) and 64-bit (amd64) |
| 10 # binary packages. | 10 # binary packages. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 def BuildOptions(): | 26 def BuildOptions(): |
| 27 result = optparse.OptionParser() | 27 result = optparse.OptionParser() |
| 28 result.add_option("--tar_filename", | 28 result.add_option("--tar_filename", |
| 29 default=None, | 29 default=None, |
| 30 help="The tar file to build from.") | 30 help="The tar file to build from.") |
| 31 result.add_option("--out_dir", | 31 result.add_option("--out_dir", |
| 32 default=None, | 32 default=None, |
| 33 help="Where to put the packages.") | 33 help="Where to put the packages.") |
| 34 result.add_option("-a", "--arch", | 34 result.add_option("-a", "--arch", |
| 35 help='Target architectures (comma-separated).', | 35 help='Target architectures (comma-separated).', |
| 36 metavar='[all,ia32,x64]', | 36 metavar='[all,ia32,x64,arm]', |
| 37 default='x64') | 37 default='x64') |
| 38 result.add_option("-t", "--toolchain", | |
| 39 help='Cross-compilation toolchain prefix', | |
| 40 default=None) | |
| 38 | 41 |
| 39 return result | 42 return result |
| 40 | 43 |
| 41 def RunBuildPackage(opt, cwd): | 44 def RunBuildPackage(opt, cwd, toolchain=None): |
| 45 env = os.environ.copy() | |
| 46 if toolchain != None: | |
| 47 env["TOOLCHAIN"] = '--toolchain=' + toolchain | |
| 42 cmd = ['dpkg-buildpackage', '-j%d' % HOST_CPUS] | 48 cmd = ['dpkg-buildpackage', '-j%d' % HOST_CPUS] |
| 43 cmd.extend(opt) | 49 cmd.extend(opt) |
| 44 process = subprocess.Popen(cmd, | 50 process = subprocess.Popen(cmd, |
| 45 stdout=subprocess.PIPE, stderr=subprocess.PIPE, | 51 stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
| 46 cwd=cwd) | 52 cwd=cwd, env=env) |
| 47 (stdout, stderr) = process.communicate() | 53 (stdout, stderr) = process.communicate() |
| 48 if process.returncode != 0: | 54 if process.returncode != 0: |
| 49 raise Exception('Command \'%s\' failed: %s\nSTDOUT: %s' % | 55 raise Exception('Command \'%s\' failed: %s\nSTDOUT: %s' % |
| 50 (' '.join(cmd), stderr, stdout)) | 56 (' '.join(cmd), stderr, stdout)) |
| 51 | 57 |
| 52 def BuildDebianPackage(tarball, out_dir, arch): | 58 def BuildDebianPackage(tarball, out_dir, arch, toolchain): |
| 53 version = utils.GetVersion() | 59 version = utils.GetVersion() |
| 54 tarroot = 'dart-%s' % version | 60 tarroot = 'dart-%s' % version |
| 55 origtarname = 'dart_%s.orig.tar.gz' % version | 61 origtarname = 'dart_%s.orig.tar.gz' % version |
| 56 | 62 |
| 57 if not exists(tarball): | 63 if not exists(tarball): |
| 58 print 'Source tarball not found' | 64 print 'Source tarball not found' |
| 59 return -1 | 65 return -1 |
| 60 | 66 |
| 61 with utils.TempDir() as temp_dir: | 67 with utils.TempDir() as temp_dir: |
| 62 origtarball = join(temp_dir, origtarname) | 68 origtarball = join(temp_dir, origtarname) |
| 63 copyfile(tarball, origtarball) | 69 copyfile(tarball, origtarball) |
| 64 | 70 |
| 65 with tarfile.open(origtarball) as tar: | 71 with tarfile.open(origtarball) as tar: |
| 66 tar.extractall(path=temp_dir) | 72 tar.extractall(path=temp_dir) |
| 67 | 73 |
| 68 # Build source package. | 74 # Build source package. |
| 69 print "Building source package" | 75 print "Building source package" |
| 70 RunBuildPackage(['-S', '-us', '-uc'], join(temp_dir, tarroot)); | 76 RunBuildPackage(['-S', '-us', '-uc'], join(temp_dir, tarroot)); |
| 71 | 77 |
| 72 # Build 32-bit binary package. | 78 # Build 32-bit binary package. |
| 73 if ('ia32' in arch): | 79 if ('ia32' in arch): |
| 74 print "Building i386 package" | 80 print "Building i386 package" |
| 75 RunBuildPackage(['-B', '-ai386', '-us', '-uc'], join(temp_dir, tarroot)); | 81 RunBuildPackage(['-B', '-ai386', '-us', '-uc'], join(temp_dir, tarroot)) |
| 76 | 82 |
| 77 # Build 64-bit binary package. | 83 # Build 64-bit binary package. |
| 78 if ('x64' in arch): | 84 if ('x64' in arch): |
| 79 print "Building amd64 package" | 85 print "Building amd64 package" |
| 80 RunBuildPackage(['-B', '-aamd64', '-us', '-uc'], join(temp_dir, tarroot)); | 86 RunBuildPackage(['-B', '-aamd64', '-us', '-uc'], join(temp_dir, tarroot)) |
| 87 | |
| 88 # Build armv binary package. | |
|
Søren Gjesse
2014/08/05 15:20:29
armv -> arm?
zra
2014/08/14 20:42:52
Done.
| |
| 89 if ('arm' in arch): | |
| 90 print "Building arm package" | |
| 91 RunBuildPackage( | |
| 92 ['-B', '-aarm', '-us', '-uc'], join(temp_dir, tarroot), toolchain) | |
|
Søren Gjesse
2014/08/05 15:20:29
Is arm the right architectue here? Shouldn't it be
zra
2014/08/14 20:42:52
We currently support both hard and soft fp, which
| |
| 81 | 93 |
| 82 # Copy the Debian package files to the build directory. | 94 # Copy the Debian package files to the build directory. |
| 83 debbase = 'dart_%s' % version | 95 debbase = 'dart_%s' % version |
| 84 source_package = [ | 96 source_package = [ |
| 85 '%s-1.dsc' % debbase, | 97 '%s-1.dsc' % debbase, |
| 86 '%s.orig.tar.gz' % debbase, | 98 '%s.orig.tar.gz' % debbase, |
| 87 '%s-1.debian.tar.gz' % debbase | 99 '%s-1.debian.tar.gz' % debbase |
| 88 ] | 100 ] |
| 89 i386_package = [ | 101 i386_package = [ |
| 90 '%s-1_i386.deb' % debbase | 102 '%s-1_i386.deb' % debbase |
| 91 ] | 103 ] |
| 92 amd64_package = [ | 104 amd64_package = [ |
| 93 '%s-1_amd64.deb' % debbase | 105 '%s-1_amd64.deb' % debbase |
| 94 ] | 106 ] |
| 107 arm_package = [ | |
| 108 '%s-1_arm.deb' % debbase | |
|
Søren Gjesse
2014/08/05 15:20:29
armhf here as well?
zra
2014/08/14 20:42:52
Acknowledged.
| |
| 109 ] | |
| 95 | 110 |
| 96 for name in source_package: | 111 for name in source_package: |
| 97 copyfile(join(temp_dir, name), join(out_dir, name)) | 112 copyfile(join(temp_dir, name), join(out_dir, name)) |
| 98 if ('ia32' in arch): | 113 if ('ia32' in arch): |
| 99 for name in i386_package: | 114 for name in i386_package: |
| 100 copyfile(join(temp_dir, name), join(out_dir, name)) | 115 copyfile(join(temp_dir, name), join(out_dir, name)) |
| 101 if ('x64' in arch): | 116 if ('x64' in arch): |
| 102 for name in amd64_package: | 117 for name in amd64_package: |
| 103 copyfile(join(temp_dir, name), join(out_dir, name)) | 118 copyfile(join(temp_dir, name), join(out_dir, name)) |
| 119 if ('arm' in arch): | |
| 120 for name in arm_package: | |
| 121 copyfile(join(temp_dir, name), join(out_dir, name)) | |
| 122 | |
| 104 | 123 |
| 105 def Main(): | 124 def Main(): |
| 106 if HOST_OS != 'linux': | 125 if HOST_OS != 'linux': |
| 107 print 'Debian build only supported on linux' | 126 print 'Debian build only supported on linux' |
| 108 return -1 | 127 return -1 |
| 109 | 128 |
| 110 options, args = BuildOptions().parse_args() | 129 options, args = BuildOptions().parse_args() |
| 111 out_dir = options.out_dir | 130 out_dir = options.out_dir |
| 112 tar_filename = options.tar_filename | 131 tar_filename = options.tar_filename |
| 113 if options.arch == 'all': | 132 if options.arch == 'all': |
| 114 options.arch = 'ia32,x64' | 133 options.arch = 'ia32,x64,arm' |
| 115 arch = options.arch.split(',') | 134 arch = options.arch.split(',') |
| 116 | 135 |
| 117 if not options.out_dir: | 136 if not options.out_dir: |
| 118 out_dir = join(DART_DIR, utils.GetBuildDir(HOST_OS, HOST_OS)) | 137 out_dir = join(DART_DIR, utils.GetBuildDir(HOST_OS, HOST_OS)) |
| 119 | 138 |
| 120 if not tar_filename: | 139 if not tar_filename: |
| 121 tar_filename = join(DART_DIR, | 140 tar_filename = join(DART_DIR, |
| 122 utils.GetBuildDir(HOST_OS, HOST_OS), | 141 utils.GetBuildDir(HOST_OS, HOST_OS), |
| 123 'dart-%s.tar.gz' % utils.GetVersion()) | 142 'dart-%s.tar.gz' % utils.GetVersion()) |
| 124 | 143 |
| 125 BuildDebianPackage(tar_filename, out_dir, arch) | 144 BuildDebianPackage(tar_filename, out_dir, arch, options.toolchain) |
| 126 | 145 |
| 127 if __name__ == '__main__': | 146 if __name__ == '__main__': |
| 128 sys.exit(Main()) | 147 sys.exit(Main()) |
| OLD | NEW |