|
| 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()) |
0 commit comments