Skip to content

Commit efda4af

Browse files
rmacnak-googleCommit Queue
authored andcommitted
Add GN target to build Debian package from regular output.
Bug: #26953 Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-arm64-try,dart-sdk-linux-riscv64-try,dart-sdk-linux-try Change-Id: I38dfcadee836733c2e8824c2da21b9619dd2fc77 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281307 Reviewed-by: Alexander Thomas <[email protected]> Commit-Queue: Ryan Macnak <[email protected]>
1 parent 0f15e32 commit efda4af

File tree

10 files changed

+191
-0
lines changed

10 files changed

+191
-0
lines changed

BUILD.gn

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ group("runtime_precompiled") {
119119

120120
group("create_sdk") {
121121
public_deps = [ "sdk:create_sdk" ]
122+
if (is_linux) {
123+
public_deps += [ "tools/debian_package" ]
124+
}
122125
}
123126

124127
group("create_platform_sdk") {

tools/debian_package/BUILD.gn

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
# for details. All rights reserved. Use of this source code is governed by a
3+
# BSD-style license that can be found in the LICENSE file.
4+
5+
if (is_linux) {
6+
action("debian_package") {
7+
version = exec_script("get_version.py", [], "trim string")
8+
if (target_cpu == "x86" || target_cpu == "ia32") {
9+
debian_arch = "i386"
10+
lib_dir = "//buildtools/sysroot/linux/lib/i386-linux-gnu"
11+
} else if (target_cpu == "x64") {
12+
debian_arch = "amd64"
13+
lib_dir = "//buildtools/sysroot/linux/lib/x86_64-linux-gnu"
14+
} else if (target_cpu == "arm") {
15+
debian_arch = "armhf"
16+
lib_dir = "//buildtools/sysroot/linux/lib/arm-linux-gnueabihf"
17+
} else if (target_cpu == "arm64") {
18+
debian_arch = "arm64"
19+
lib_dir = "//buildtools/sysroot/linux/lib/aarch64-linux-gnu"
20+
} else if (target_cpu == "riscv64") {
21+
debian_arch = "riscv64"
22+
lib_dir = "//buildtools/sysroot/focal/lib/riscv64-linux-gnu/"
23+
} else {
24+
assert(false, "Don't know Debian name for $target_cpu")
25+
}
26+
27+
deps = [ "../../sdk:create_sdk" ]
28+
inputs = [
29+
"create_debian_package.py",
30+
"debian/compat",
31+
"debian/control",
32+
"debian/dart.install",
33+
"debian/dart.links",
34+
"debian/rules",
35+
"debian/source/format",
36+
]
37+
outputs = [ "$root_out_dir/dart_${version}-1_${debian_arch}.deb" ]
38+
script = "../../build/gn_run_binary.py"
39+
args = [
40+
"compiled_action",
41+
rebase_path("create_debian_package.py"),
42+
"--version=$version",
43+
"--arch=$debian_arch",
44+
"--lib_dir=" + rebase_path(lib_dir),
45+
]
46+
}
47+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Copyright (c) 2023, 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+
import optparse
8+
import os
9+
import shutil
10+
import subprocess
11+
import sys
12+
from os.path import join, split, abspath, dirname
13+
14+
sys.path.append(join(dirname(__file__), '..'))
15+
import utils
16+
17+
DART_DIR = abspath(join(dirname(__file__), '..', '..'))
18+
19+
20+
def BuildOptions():
21+
result = optparse.OptionParser()
22+
result.add_option("--version", default=None)
23+
result.add_option("--arch", default=None)
24+
result.add_option("--lib_dir", default=None)
25+
return result
26+
27+
28+
def GenerateCopyright(filename):
29+
with open(join(DART_DIR, 'LICENSE')) as lf:
30+
license_lines = lf.readlines()
31+
32+
with open(filename, 'w') as f:
33+
f.write('Name: dart\n')
34+
f.write('Maintainer: Dart Team <[email protected]>\n')
35+
f.write('Source: https://dart.googlesource.com/sdk\n')
36+
f.write('License:\n')
37+
for line in license_lines:
38+
f.write(' %s' % line) # Line already contains trailing \n.
39+
40+
41+
def GenerateChangeLog(filename, version):
42+
with open(filename, 'w') as f:
43+
f.write('dart (%s-1) UNRELEASED; urgency=low\n' % version)
44+
f.write('\n')
45+
f.write(' * Generated file.\n')
46+
f.write('\n')
47+
f.write(' -- Dart Team <[email protected]>\n')
48+
49+
50+
def Main():
51+
parser = BuildOptions()
52+
(options, args) = parser.parse_args()
53+
54+
version = options.version
55+
versiondir = 'dart-%s' % version
56+
shutil.copytree(join(DART_DIR, 'tools', 'debian_package', 'debian'),
57+
join(versiondir, 'debian'),
58+
dirs_exist_ok=True)
59+
GenerateCopyright(join(versiondir, 'debian', 'copyright'))
60+
GenerateChangeLog(join(versiondir, 'debian', 'changelog'), version)
61+
62+
cmd = ['dpkg-buildpackage', '-B', '-a', options.arch, '-us', '-uc']
63+
env = os.environ.copy()
64+
env["LIB_DIR"] = options.lib_dir
65+
process = subprocess.check_call(cmd, cwd=versiondir, env=env)
66+
67+
68+
if __name__ == '__main__':
69+
sys.exit(Main())

tools/debian_package/debian/compat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
10
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Source: dart
2+
Maintainer: Dart Team <[email protected]>
3+
Section: misc
4+
Priority: optional
5+
Standards-Version: 3.9.2
6+
Build-Depends: python3:native
7+
8+
Package: dart
9+
Architecture: any
10+
Depends: ${shlibs:Depends}, ${misc:Depends}
11+
Description: Dart SDK
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
debian/tmp/out/dart usr/lib
2+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
usr/lib/dart/bin/dart usr/bin/dart
2+

tools/debian_package/debian/rules

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/make -f
2+
export DH_VERBOSE = 1
3+
4+
%:
5+
dh $@
6+
7+
# Nop
8+
override_dh_auto_clean:
9+
10+
# Nop
11+
override_dh_auto_configure:
12+
13+
# Nop
14+
override_dh_auto_build:
15+
16+
# Nop
17+
override_dh_auto_test:
18+
19+
# Nop
20+
override_dh_strip:
21+
22+
# Nop
23+
override_dh_strip_nondeterminism:
24+
25+
# This override allows us to ignore spurious missing library errors when
26+
# cross-compiling.
27+
override_dh_shlibdeps:
28+
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info -l "${LIB_DIR}"
29+
30+
override_dh_auto_install:
31+
mkdir -p debian/tmp/out
32+
cp -R ../dart-sdk debian/tmp/out
33+
mv debian/tmp/out/dart-sdk debian/tmp/out/dart
34+
dh_install
35+
dh_link
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0 (quilt)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Copyright (c) 2023, 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+
import sys
8+
from os import listdir
9+
from os.path import join, split, abspath, dirname
10+
11+
sys.path.append(join(dirname(__file__), '..'))
12+
import utils
13+
14+
15+
def Main():
16+
print(utils.GetVersion())
17+
18+
19+
if __name__ == '__main__':
20+
sys.exit(Main())

0 commit comments

Comments
 (0)