Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 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 | |
| 5 # BSD-style license that can be found in the LICENSE file. | |
| 6 # | |
| 7 | |
| 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) | |
| 10 # binary packages. | |
| 11 | |
| 12 import sys | |
| 13 import tarfile | |
| 14 import subprocess | |
| 15 import utils | |
| 16 | |
| 17 from os.path import join, exists, abspath | |
| 18 from shutil import copyfile | |
| 19 | |
| 20 HOST_OS = utils.GuessOS() | |
| 21 HOST_CPUS = utils.GuessCpus() | |
| 22 DART_DIR = abspath(join(__file__, '..', '..')) | |
| 23 | |
| 24 def RunBuildPackage(opt, cwd): | |
| 25 cmd = ['dpkg-buildpackage', '-j%d' % HOST_CPUS] | |
| 26 cmd.extend(opt) | |
| 27 process = subprocess.Popen(cmd, | |
| 28 stdout=subprocess.PIPE, stderr=subprocess.PIPE, | |
| 29 cwd=cwd) | |
| 30 (stdout, stderr) = process.communicate() | |
| 31 if process.returncode != 0: | |
| 32 raise Exception('Command \'%s\' failed: %s\nSTDOUT: %s' % | |
| 33 (' '.join(cmd), stderr, stdout)) | |
| 34 | |
| 35 def BuildDebianPackage(): | |
| 36 version = utils.GetVersion() | |
| 37 builddir = join(DART_DIR, utils.GetBuildDir(HOST_OS, HOST_OS)) | |
| 38 tarroot = 'dart-%s' % version | |
| 39 tarname = 'dart-%s.tar.gz' % version | |
| 40 origtarname = 'dart_%s.orig.tar.gz' % version | |
| 41 tarball = join(builddir, tarname) | |
| 42 if not exists(join(builddir, tarball)): | |
| 43 print 'Source tarball not found' | |
| 44 return -1 | |
| 45 | |
| 46 with utils.TempDir() as temp_dir: | |
| 47 origtarball = join(temp_dir, origtarname) | |
| 48 copyfile(tarball, origtarball) | |
|
kustermann
2014/02/11 10:33:02
When you extract the tarball, you specify the dest
Søren Gjesse
2014/02/12 08:29:18
The tar-file with the "orig" name needs to be in t
| |
| 49 | |
| 50 with tarfile.open(origtarball) as tar: | |
| 51 tar.extractall(path=temp_dir) | |
| 52 | |
| 53 # Build source package. | |
| 54 print "Building source package" | |
| 55 RunBuildPackage(['-S', '-us', '-uc'], join(temp_dir, tarroot)); | |
| 56 | |
| 57 # Build 32-bit binary package. | |
| 58 print "Building i386 package" | |
| 59 RunBuildPackage(['-B', '-ai386', '-us', '-uc'], join(temp_dir, tarroot)); | |
| 60 | |
| 61 # Build 64-bit binary package. | |
| 62 print "Building amd64 package" | |
| 63 RunBuildPackage(['-B', '-aamd64', '-us', '-uc'], join(temp_dir, tarroot)); | |
| 64 | |
| 65 # Copy the Debian package files to the build directory. | |
| 66 debbase = 'dart_%s' % version | |
| 67 source_package = [ | |
| 68 join('%s-1.dsc' % debbase), | |
| 69 join('%s.orig.tar.gz' % debbase), | |
| 70 join('%s-1.debian.tar.gz' % debbase), | |
| 71 ] | |
| 72 i386_package = [ | |
| 73 join('%s-1_i386.deb' % debbase), | |
| 74 ] | |
| 75 amd64_package = [ | |
| 76 join('%s-1_amd64.deb' % debbase), | |
|
kustermann
2014/02/11 10:33:02
These join() calls do nothing, so you can remove t
Søren Gjesse
2014/02/12 08:29:18
Done.
| |
| 77 ] | |
| 78 for name in source_package: | |
| 79 copyfile(join(temp_dir, name), join(builddir, name)) | |
| 80 for name in i386_package: | |
| 81 copyfile(join(temp_dir, name), join(builddir, name)) | |
| 82 for name in amd64_package: | |
| 83 copyfile(join(temp_dir, name), join(builddir, name)) | |
| 84 | |
| 85 def Main(): | |
| 86 if HOST_OS != 'linux': | |
| 87 print 'Debian build only supported on linux' | |
| 88 return -1 | |
| 89 | |
| 90 BuildDebianPackage() | |
| 91 | |
| 92 if __name__ == '__main__': | |
| 93 sys.exit(Main()) | |
| OLD | NEW |