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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: tools/create_debian_packages.py
diff --git a/tools/create_debian_packages.py b/tools/create_debian_packages.py
new file mode 100755
index 0000000000000000000000000000000000000000..dd773a75ec3b843ba891ccc420739bf2a1336dcb
--- /dev/null
+++ b/tools/create_debian_packages.py
@@ -0,0 +1,94 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+# for details. All rights reserved. Use of this source code is governed by a
+# BSD-style license that can be found in the LICENSE file.
+#
+
+# Script to build a Debian packages from a Dart tarball. The script
+# will build a source package and a 32-bit (i386) and 64-bit (amd64)
+# binary packages.
+
+import sys
+import tarfile
+import subprocess
+import utils
+
+from os.path import join, exists, abspath
+from shutil import copyfile
+
+HOST_OS = utils.GuessOS()
+HOST_CPUS = utils.GuessCpus()
+DART_DIR = abspath(join(__file__, '..', '..'))
+
+def RunBuildPackage(opt, cwd):
+ cmd = ['dpkg-buildpackage', '-j%d' % HOST_CPUS]
+ cmd.extend(opt)
+ 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.
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ cwd=cwd)
+ (stdout, stderr) = pipe.communicate()
+ if pipe.returncode != 0:
+ raise Exception('Command \'%s\' failed: %s\nSTDOUT: %s' %
+ (' '.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
+
+def BuildDebianPackage():
+ version = utils.GetVersion()
+ builddir = join(DART_DIR, utils.GetBuildDir(HOST_OS, HOST_OS))
+ tarroot = 'dart-%s' % version
+ tarname = 'dart-%s.tar.gz' % version
+ tarball = join(builddir, tarname)
+ origtarball = join(builddir, 'dart_%s.orig.tar.gz' % version)
+ if not exists(join(builddir, tarball)):
+ print 'Source tarball not found'
+ return -1
+
+ copyfile(tarball, origtarball)
+
+ with tarfile.open(origtarball) as tar:
+ 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
+
+ # Build source package.
+ print "Building source package"
+ 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
+
+ # Build 32-bit binary package.
+ print "Building i386 package"
+ RunBuildPackage(['-B', '-ai386', '-us', '-uc'],
+ join(DART_DIR, builddir, tarroot));
+
+ # Build 64-bit binary package.
+ print "Building amd64 package"
+ RunBuildPackage(['-B', '-aamd64', '-us', '-uc'],
+ join(DART_DIR, builddir, tarroot));
+
+ # Check the existence of the expected files.
+ debbase = 'dart_%s' % version
+ source_package = [
+ join(builddir, '%s-1.dsc' % debbase),
+ join(builddir, '%s.orig.tar.gz' % debbase),
+ join(builddir, '%s-1.debian.tar.gz' % debbase),
+ ]
+ i386_package = [
+ join(builddir, '%s-1_i386.deb' % debbase),
+ ]
+ amd64_package = [
+ join(builddir, '%s-1_amd64.deb' % debbase),
+ ]
+
+ for name in source_package:
+ assert exists(name)
+ for name in i386_package:
+ assert exists(name)
+ for name in amd64_package:
+ assert exists(name)
+
+def Main():
+ if HOST_OS != 'linux':
+ print 'Debian build only supported on linux'
+ return -1
+
+ BuildDebianPackage()
+
+if __name__ == '__main__':
+ sys.exit(Main())

Powered by Google App Engine
This is Rietveld 408576698