mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:41:41 +00:00
Add script to build Debian packages
The script create_debian_packages.py will build source and binary Debian packages from the generated tarball. R=kustermann@google.com, ricow@google.com BUG= Review URL: https://codereview.chromium.org//159003002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32550 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
78fbacbd87
commit
3b353731f6
|
@ -36,6 +36,9 @@ def SrcSteps(build_info):
|
|||
args = [sys.executable, './tools/create_tarball.py']
|
||||
print 'Building src tarball'
|
||||
bot.RunProcess(args)
|
||||
print 'Building Debian packages'
|
||||
args = [sys.executable, './tools/create_debian_packages.py']
|
||||
bot.RunProcess(args)
|
||||
|
||||
if __name__ == '__main__':
|
||||
# We pass in None for build_step to avoid building the sdk.
|
||||
|
|
93
tools/create_debian_packages.py
Executable file
93
tools/create_debian_packages.py
Executable file
|
@ -0,0 +1,93 @@
|
|||
#!/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)
|
||||
process = subprocess.Popen(cmd,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
cwd=cwd)
|
||||
(stdout, stderr) = process.communicate()
|
||||
if process.returncode != 0:
|
||||
raise Exception('Command \'%s\' failed: %s\nSTDOUT: %s' %
|
||||
(' '.join(cmd), stderr, stdout))
|
||||
|
||||
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
|
||||
origtarname = 'dart_%s.orig.tar.gz' % version
|
||||
tarball = join(builddir, tarname)
|
||||
if not exists(join(builddir, tarball)):
|
||||
print 'Source tarball not found'
|
||||
return -1
|
||||
|
||||
with utils.TempDir() as temp_dir:
|
||||
origtarball = join(temp_dir, origtarname)
|
||||
copyfile(tarball, origtarball)
|
||||
|
||||
with tarfile.open(origtarball) as tar:
|
||||
tar.extractall(path=temp_dir)
|
||||
|
||||
# Build source package.
|
||||
print "Building source package"
|
||||
RunBuildPackage(['-S', '-us', '-uc'], join(temp_dir, tarroot));
|
||||
|
||||
# Build 32-bit binary package.
|
||||
print "Building i386 package"
|
||||
RunBuildPackage(['-B', '-ai386', '-us', '-uc'], join(temp_dir, tarroot));
|
||||
|
||||
# Build 64-bit binary package.
|
||||
print "Building amd64 package"
|
||||
RunBuildPackage(['-B', '-aamd64', '-us', '-uc'], join(temp_dir, tarroot));
|
||||
|
||||
# Copy the Debian package files to the build directory.
|
||||
debbase = 'dart_%s' % version
|
||||
source_package = [
|
||||
'%s-1.dsc' % debbase,
|
||||
'%s.orig.tar.gz' % debbase,
|
||||
'%s-1.debian.tar.gz' % debbase
|
||||
]
|
||||
i386_package = [
|
||||
'%s-1_i386.deb' % debbase
|
||||
]
|
||||
amd64_package = [
|
||||
'%s-1_amd64.deb' % debbase
|
||||
]
|
||||
for name in source_package:
|
||||
copyfile(join(temp_dir, name), join(builddir, name))
|
||||
for name in i386_package:
|
||||
copyfile(join(temp_dir, name), join(builddir, name))
|
||||
for name in amd64_package:
|
||||
copyfile(join(temp_dir, name), join(builddir, name))
|
||||
|
||||
def Main():
|
||||
if HOST_OS != 'linux':
|
||||
print 'Debian build only supported on linux'
|
||||
return -1
|
||||
|
||||
BuildDebianPackage()
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(Main())
|
|
@ -43,6 +43,9 @@ override_dh_auto_build:
|
|||
make -C dart -j$(PARALLEL_JOBS) \
|
||||
BUILDTYPE=$(BUILD_TYPE) $(BUILD_ARGS) create_sdk
|
||||
|
||||
# Building the Dart SDK will already strip all binaries.
|
||||
override_dh_strip:
|
||||
|
||||
override_dh_auto_install:
|
||||
mkdir -p debian/tmp/out
|
||||
cp -R dart/out/$(BUILD_TYPE)/dart-sdk debian/tmp/out
|
||||
|
|
Loading…
Reference in a new issue