Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: tools/create_debian_packages.py

Issue 159003002: Add script to build Debian packages (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed additional review comments Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/bots/src-tarball.py ('k') | tools/linux_dist_support/debian/rules » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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)
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 '%s-1.dsc' % debbase,
69 '%s.orig.tar.gz' % debbase,
70 '%s-1.debian.tar.gz' % debbase
71 ]
72 i386_package = [
73 '%s-1_i386.deb' % debbase
74 ]
75 amd64_package = [
76 '%s-1_amd64.deb' % debbase
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())
OLDNEW
« no previous file with comments | « tools/bots/src-tarball.py ('k') | tools/linux_dist_support/debian/rules » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698