[build] Fix building the Debian package on Resolute.

dpkg-buildpackage now wants a timestamp in the changelog.

Also remove --git-revision-file and --git-timestamp-file, which were part of the previous way to build Debian packages.

Change-Id: Idbcf418571889ad7588424e6d8ae6e81ec79942b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504280
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak
2026-05-19 07:18:47 -07:00
committed by dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent 6613ac694e
commit a8419fb546
5 changed files with 51 additions and 40 deletions
+2
View File
@@ -5,6 +5,7 @@
if (is_linux) {
action("debian_package") {
version = exec_script("get_version.py", [], "trim string")
timestamp = exec_script("get_timestamp.py", [], "trim string")
if (target_cpu == "x86" || target_cpu == "ia32") {
debian_arch = "i386"
lib_dir = "//buildtools/sysroot/linux/lib/i386-linux-gnu"
@@ -40,6 +41,7 @@ if (is_linux) {
"compiled_action",
rebase_path("create_debian_package.py"),
"--version=$version",
"--timestamp=$timestamp",
"--arch=$debian_arch",
"--lib_dir=" + rebase_path(lib_dir),
]
@@ -20,6 +20,7 @@ DART_DIR = abspath(join(dirname(__file__), '..', '..'))
def BuildOptions():
result = optparse.OptionParser()
result.add_option("--version", default=None)
result.add_option("--timestamp", default=None)
result.add_option("--arch", default=None)
result.add_option("--lib_dir", default=None)
return result
@@ -38,13 +39,13 @@ def GenerateCopyright(filename):
f.write(' %s' % line) # Line already contains trailing \n.
def GenerateChangeLog(filename, version):
def GenerateChangeLog(filename, version, timestamp):
with open(filename, 'w') as f:
f.write('dart (%s-1) UNRELEASED; urgency=low\n' % version)
f.write('\n')
f.write(' * Generated file.\n')
f.write('\n')
f.write(' -- Dart Team <misc@dartlang.org>\n')
f.write(' -- Dart Team <misc@dartlang.org> %s\n' % timestamp)
def Main():
@@ -52,12 +53,14 @@ def Main():
(options, args) = parser.parse_args()
version = options.version
timestamp = options.timestamp
versiondir = 'dart-%s' % version
shutil.copytree(join(DART_DIR, 'tools', 'debian_package', 'debian'),
join(versiondir, 'debian'),
dirs_exist_ok=True)
GenerateCopyright(join(versiondir, 'debian', 'copyright'))
GenerateChangeLog(join(versiondir, 'debian', 'changelog'), version)
GenerateChangeLog(join(versiondir, 'debian', 'changelog'), version,
timestamp)
cmd = ['dpkg-buildpackage', '-B', '-a', options.arch, '-us', '-uc']
env = os.environ.copy()
+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env python3
#
# Copyright (c) 2026, 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.
import sys
from os import listdir
from os.path import join, split, abspath, dirname
sys.path.append(join(dirname(__file__), '..'))
import utils
def Main():
print(utils.GetGitTimestampForDpkg())
if __name__ == '__main__':
sys.exit(Main())
+4 -16
View File
@@ -50,14 +50,8 @@ def GetSemanticVersionFormat(no_git_hash):
return version_format
def FormatVersionString(version,
no_git_hash,
no_sdk_hash,
version_file=None,
git_revision_file=None,
git_timestamp_file=None):
semantic_sdk_version = utils.GetVersion(no_git_hash, version_file,
git_revision_file)
def FormatVersionString(version, no_git_hash, no_sdk_hash, version_file=None):
semantic_sdk_version = utils.GetVersion(no_git_hash, version_file)
semantic_version_format = GetSemanticVersionFormat(no_git_hash)
version_str = (semantic_sdk_version
if version_file else semantic_version_format)
@@ -79,7 +73,7 @@ def FormatVersionString(version,
version_time = None
if not no_git_hash:
version_time = utils.GetGitTimestamp(git_timestamp_file)
version_time = utils.GetGitTimestamp()
if version_time == None:
version_time = 'Unknown timestamp'
version = version.replace('{{COMMIT_TIME}}', version_time)
@@ -113,10 +107,6 @@ def main():
default=False,
help='DEPRECATED: Does nothing!')
parser.add_argument('--version-file', help='Path to the VERSION file.')
parser.add_argument('--git-revision-file',
help='Path to the GIT_REVISION file.')
parser.add_argument('--git-timestamp-file',
help='Path to the GIT_TIMESTAMP file.')
parser.add_argument(
'--format',
default='{{VERSION_STR}}',
@@ -137,9 +127,7 @@ def main():
raise 'No version template given! Set either --input or --format.'
version = FormatVersionString(version_template, args.no_git_hash,
args.no_sdk_hash, args.version_file,
args.git_revision_file,
args.git_timestamp_file)
args.no_sdk_hash, args.version_file)
if args.output:
with open(args.output, 'w') as fh:
+19 -21
View File
@@ -359,15 +359,14 @@ def GetBuildRoot(host_os, mode=None, arch=None, target_os=None, sanitizer=None):
return build_root
def GetVersion(no_git_hash=False, version_file=None, git_revision_file=None):
def GetVersion(no_git_hash=False, version_file=None):
version = ReadVersionFile(version_file)
if not version:
return None
suffix = ''
if version.channel in ['main', 'be']:
suffix = '-edge' if no_git_hash else '-edge.{}'.format(
GetGitRevision(git_revision_file))
suffix = '-edge' if no_git_hash else '-edge.{}'.format(GetGitRevision())
elif version.channel in ('beta', 'dev'):
suffix = '-{}.{}.{}'.format(version.prerelease,
version.prerelease_patch, version.channel)
@@ -417,15 +416,7 @@ def ReadVersionFile(version_file=None):
return None
def GetGitRevision(git_revision_file=None, repo_path=DART_DIR):
# When building from tarball use tools/GIT_REVISION
if git_revision_file is None:
git_revision_file = os.path.join(repo_path, 'tools', 'GIT_REVISION')
try:
with open(git_revision_file) as fd:
return fd.read().strip()
except:
pass
def GetGitRevision(repo_path=DART_DIR):
p = subprocess.Popen(['git', 'rev-parse', 'HEAD'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
@@ -460,15 +451,7 @@ def GetShortGitHash(repo_path=DART_DIR):
return revision
def GetGitTimestamp(git_timestamp_file=None, repo_path=DART_DIR):
# When building from tarball use tools/GIT_TIMESTAMP
if git_timestamp_file is None:
git_timestamp_file = os.path.join(repo_path, 'tools', 'GIT_TIMESTAMP')
try:
with open(git_timestamp_file) as fd:
return fd.read().strip()
except:
pass
def GetGitTimestamp(repo_path=DART_DIR):
p = subprocess.Popen(['git', 'log', '-n', '1', '--pretty=format:%cd'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
@@ -483,6 +466,21 @@ def GetGitTimestamp(git_timestamp_file=None, repo_path=DART_DIR):
return timestamp
def GetGitTimestampForDpkg(repo_path=DART_DIR):
p = subprocess.Popen(['git', 'log', '-n', '1', '--pretty=format:%cD'],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=IsWindows(),
cwd=repo_path)
out, err = p.communicate()
if p.wait() != 0:
# TODO(https://github.com/dart-lang/sdk/issues/51865): Don't ignore errors.
# raise Exception('git log failed: ' + str(err))
return None
timestamp = out.decode('utf-8').strip()
return timestamp
# TODO(42528): Can we remove this? It's basically just an alias for Exception.
class Error(Exception):
pass