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 pipe = subprocess.Popen(cmd, | |
kustermann
2014/02/10 18:04:48
It's not really a "pipe", maybe "process" would fi
Søren Gjesse
2014/02/11 10:21:57
Done.
| |
28 stdout=subprocess.PIPE, stderr=subprocess.PIPE, | |
29 cwd=cwd) | |
30 (stdout, stderr) = pipe.communicate() | |
31 if pipe.returncode != 0: | |
32 raise Exception('Command \'%s\' failed: %s\nSTDOUT: %s' % | |
33 (' '.join(cmd), str(stderr), str(stdout))) | |
kustermann
2014/02/10 18:04:48
Are these str() conversions needed? Isn't it alrea
Søren Gjesse
2014/02/11 10:21:57
Removed (I copied the str() part from someplace el
| |
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 tarball = join(builddir, tarname) | |
41 origtarball = join(builddir, 'dart_%s.orig.tar.gz' % version) | |
42 if not exists(join(builddir, tarball)): | |
43 print 'Source tarball not found' | |
44 return -1 | |
45 | |
46 copyfile(tarball, origtarball) | |
47 | |
48 with tarfile.open(origtarball) as tar: | |
49 tar.extractall(path=builddir) | |
kustermann
2014/02/10 18:04:48
I'd actually prefer if you used a temporary direct
Søren Gjesse
2014/02/11 10:21:57
OK, changed
| |
50 | |
51 # Build source package. | |
52 print "Building source package" | |
53 RunBuildPackage(['-S', '-us', '-uc'], join(DART_DIR, builddir, tarroot)); | |
kustermann
2014/02/10 18:04:48
I think you're constructing the wrong directory he
Søren Gjesse
2014/02/11 10:21:57
Absolutely - fixed. As os.path.join "restarts" whe
| |
54 | |
55 # Build 32-bit binary package. | |
56 print "Building i386 package" | |
57 RunBuildPackage(['-B', '-ai386', '-us', '-uc'], | |
58 join(DART_DIR, builddir, tarroot)); | |
59 | |
60 # Build 64-bit binary package. | |
61 print "Building amd64 package" | |
62 RunBuildPackage(['-B', '-aamd64', '-us', '-uc'], | |
63 join(DART_DIR, builddir, tarroot)); | |
64 | |
65 # Check the existence of the expected files. | |
66 debbase = 'dart_%s' % version | |
67 source_package = [ | |
68 join(builddir, '%s-1.dsc' % debbase), | |
69 join(builddir, '%s.orig.tar.gz' % debbase), | |
70 join(builddir, '%s-1.debian.tar.gz' % debbase), | |
71 ] | |
72 i386_package = [ | |
73 join(builddir, '%s-1_i386.deb' % debbase), | |
74 ] | |
75 amd64_package = [ | |
76 join(builddir, '%s-1_amd64.deb' % debbase), | |
77 ] | |
78 | |
79 for name in source_package: | |
80 assert exists(name) | |
81 for name in i386_package: | |
82 assert exists(name) | |
83 for name in amd64_package: | |
84 assert exists(name) | |
85 | |
86 def Main(): | |
87 if HOST_OS != 'linux': | |
88 print 'Debian build only supported on linux' | |
89 return -1 | |
90 | |
91 BuildDebianPackage() | |
92 | |
93 if __name__ == '__main__': | |
94 sys.exit(Main()) | |
OLD | NEW |