[infra] Remove old Debian package building scripts.

Change-Id: I46f00aa913e9dddb3f75b38ca384d126ffe9a265
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445786
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
This commit is contained in:
Ryan Macnak
2025-08-19 08:15:11 -07:00
committed by Commit Queue
parent 30fbb28714
commit fd091ab155
12 changed files with 1 additions and 605 deletions
+1 -2
View File
@@ -61,8 +61,7 @@ $ ./tools/build.py --mode=release --arch=riscv64 --os=android create_sdk
You can create Debian packages targeting ARM or RISC-V as follows:
```
$ ./tools/linux_dist_support/create_tarball.py
$ ./tools/linux_dist_support/create_debian_packages.py -a {x64, arm, arm64, riscv64}
$ ./tools/build.py --mode=release --arch=arm,arm64,riscv64 debian_package
```
# Testing
@@ -1,10 +0,0 @@
# Copyright (c) 2021, 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.
FROM marketplace.gcr.io/google/debian11:latest
ARG depot_tools
RUN apt-get update \
&& apt-get install -y build-essential debhelper git python3 \
&& rm -rf /var/lib/apt/lists/*
ENV PATH="$depot_tools:${PATH}"
ENTRYPOINT python3 tools/linux_dist_support/linux_distribution_support.py
@@ -1,129 +0,0 @@
#!/usr/bin/env python3
#
# 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 optparse
import os
import sys
import tarfile
import subprocess
from os.path import join, exists, abspath, dirname
sys.path.append(join(dirname(__file__), '..'))
import utils
from shutil import copyfile
HOST_OS = utils.GuessOS()
HOST_CPUS = utils.GuessCpus()
DART_DIR = abspath(join(dirname(__file__), '..', '..'))
GN_ARCH_TO_DEBIAN_ARCH = {
"ia32": "i386",
"x64": "amd64",
"arm": "armhf",
"arm64": "arm64",
"riscv64": "riscv64",
}
def BuildOptions():
result = optparse.OptionParser()
result.add_option("--tar_filename",
default=None,
help="The tar file to build from.")
result.add_option("--out_dir",
default=None,
help="Where to put the packages.")
result.add_option("-a",
"--arch",
help='Target architectures (comma-separated).',
metavar='[all,ia32,x64,arm,arm64,riscv64]',
default='x64')
result.add_option("-t",
"--toolchain",
help='Cross-compilation toolchain prefix',
default=None)
return result
def RunBuildPackage(opt, cwd, toolchain=None):
env = os.environ.copy()
if toolchain != None:
env["TOOLCHAIN"] = '--toolchain=' + toolchain
cmd = ['dpkg-buildpackage', '-j%d' % HOST_CPUS]
cmd.extend(opt)
process = subprocess.check_call(cmd, cwd=cwd, env=env)
def BuildDebianPackage(tarball, out_dir, arches, toolchain):
version = utils.GetVersion()
tarroot = 'dart-%s' % version
origtarname = 'dart_%s.orig.tar.gz' % version
if not exists(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 binary package(s).
for arch in arches:
print("Building %s package" % arch)
RunBuildPackage(
['-B', '-a', GN_ARCH_TO_DEBIAN_ARCH[arch], '-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.xz' % debbase
]
for name in source_package:
copyfile(join(temp_dir, name), join(out_dir, name))
for arch in arches:
name = '%s-1_%s.deb' % (debbase, GN_ARCH_TO_DEBIAN_ARCH[arch])
copyfile(join(temp_dir, name), join(out_dir, name))
def Main():
if HOST_OS != 'linux':
print('Debian build only supported on linux')
return -1
options, args = BuildOptions().parse_args()
out_dir = options.out_dir
tar_filename = options.tar_filename
if options.arch == 'all':
options.arch = 'ia32,x64,arm,arm64,riscv64'
arch = options.arch.split(',')
if not options.out_dir:
out_dir = join(DART_DIR, utils.GetBuildDir(HOST_OS))
if not tar_filename:
tar_filename = join(DART_DIR, utils.GetBuildDir(HOST_OS),
'dart-%s.tar.gz' % utils.GetVersion())
BuildDebianPackage(tar_filename, out_dir, arch, options.toolchain)
if __name__ == '__main__':
sys.exit(Main())
-209
View File
@@ -1,209 +0,0 @@
#!/usr/bin/env python3
#
# 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 tarball of the Dart source.
#
# The tarball includes all the source needed to build Dart. This
# includes source in third_party. As part of creating the tarball the
# files used to build Debian packages are copied to a top-level debian
# directory. This makes it easy to build Debian packages from the
# tarball.
#
# For building a Debian package one need to the tarball to follow the
# Debian naming rules upstream tar files.
#
# $ mv dart-XXX.tar.gz dart_XXX.orig.tar.gz
# $ tar xf dart_XXX.orig.tar.gz
# $ cd dart_XXX
# $ debuild -us -uc
import datetime
import optparse
import sys
import tarfile
from os import listdir
from os.path import join, split, abspath, dirname
sys.path.append(join(dirname(__file__), '..'))
import utils
HOST_OS = utils.GuessOS()
DART_DIR = abspath(join(dirname(__file__), '..', '..'))
# Flags.
verbose = False
# Name of the dart directory when unpacking the tarball.
versiondir = ''
# Ignore Git/SVN files, checked-in binaries, backup files, etc..
ignoredPaths = [
'buildtools/linux-x64/go',
'buildtools/linux-x64/rust',
'third_party/7zip',
'third_party/android_tools',
'third_party/clang',
'third_party/d8',
'third_party/firefox_jsshell',
'third_party/gsutil',
'third_party/llvm-build',
'third_party/mdn',
]
ignoredDirs = [
'.cipd',
'.git',
'benchmarks',
'docs',
'fuchsia',
'parser_testcases',
'testcases',
'tests',
]
ignoredEndings = ['.mk', '.pyc', 'Makefile', '~']
def BuildOptions():
result = optparse.OptionParser()
result.add_option("-v",
"--verbose",
help='Verbose output.',
default=False,
action="store_true")
result.add_option("--tar_filename", default=None, help="The output file.")
return result
def Filter(tar_info):
# Get the name of the file relative to the dart directory. Note the
# name from the TarInfo does not include a leading slash.
assert tar_info.name.startswith(DART_DIR[1:])
original_name = tar_info.name[len(DART_DIR):]
_, tail = split(original_name)
if tail in ignoredDirs:
return None
for path in ignoredPaths:
if original_name.startswith(path):
return None
for ending in ignoredEndings:
if original_name.endswith(ending):
return None
# Add the dart directory name with version. Place the debian
# directory one level over the rest which are placed in the
# directory 'dart'. This enables building the Debian packages
# out-of-the-box.
tar_info.name = join(versiondir, 'dart', original_name)
if verbose:
print('Adding %s as %s' % (original_name, tar_info.name))
return tar_info
def GenerateCopyright(filename):
with open(join(DART_DIR, 'LICENSE')) as lf:
license_lines = lf.readlines()
with open(filename, 'w') as f:
f.write('Name: dart\n')
f.write('Maintainer: Dart Team <misc@dartlang.org>\n')
f.write('Source: https://dart.googlesource.com/sdk\n')
f.write('License:\n')
for line in license_lines:
f.write(' %s' % line) # Line already contains trailing \n.
def GenerateChangeLog(filename, version):
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> %s\n' %
datetime.datetime.utcnow().strftime('%a, %d %b %Y %X +0000'))
def GenerateEmpty(filename):
f = open(filename, 'w')
f.close()
def GenerateGitRevision(filename, git_revision):
with open(filename, 'w') as f:
f.write(str(git_revision))
def GenerateGitTimestamp(filename, git_timestamp):
with open(filename, 'w') as f:
f.write(str(git_timestamp))
def CreateTarball(tarfilename):
global ignoredPaths # Used for adding the output directory.
# Generate the name of the tarfile
version = utils.GetVersion()
global versiondir
versiondir = 'dart-%s' % version
debian_dir = 'tools/linux_dist_support/debian'
# Don't include the build directory in the tarball (ignored paths
# are relative to DART_DIR).
builddir = utils.GetBuildDir(HOST_OS)
ignoredPaths.append(builddir)
print('Creating tarball: %s' % tarfilename)
with tarfile.open(tarfilename, mode='w:gz') as tar:
for f in listdir(DART_DIR):
tar.add(join(DART_DIR, f), filter=Filter)
for f in listdir(join(DART_DIR, debian_dir)):
tar.add(join(DART_DIR, debian_dir, f),
arcname='%s/debian/%s' % (versiondir, f))
with utils.TempDir() as temp_dir:
# Generate and add debian/copyright
copyright_file = join(temp_dir, 'copyright')
GenerateCopyright(copyright_file)
tar.add(copyright_file, arcname='%s/debian/copyright' % versiondir)
# Generate and add debian/changelog
change_log = join(temp_dir, 'changelog')
GenerateChangeLog(change_log, version)
tar.add(change_log, arcname='%s/debian/changelog' % versiondir)
# For generated version file build dependency, add fake git reflog.
empty = join(temp_dir, 'empty')
GenerateEmpty(empty)
tar.add(empty, arcname='%s/dart/.git/logs/HEAD' % versiondir)
# For main, add the GIT_REVISION file.
if utils.GetChannel() in ['main', 'be']:
git_revision = join(temp_dir, 'GIT_REVISION')
GenerateGitRevision(git_revision, utils.GetGitRevision())
tar.add(git_revision,
arcname='%s/dart/tools/GIT_REVISION' % versiondir)
# Add GIT_TIMESTAMP file as git is not available in tarball.
git_timestamp = join(temp_dir, 'GIT_TIMESTAMP')
GenerateGitTimestamp(git_timestamp, utils.GetGitTimestamp())
tar.add(git_timestamp,
arcname='%s/dart/tools/GIT_TIMESTAMP' % versiondir)
def Main():
if HOST_OS != 'linux':
print('Tarball can only be created on linux')
return -1
# Parse the options.
parser = BuildOptions()
(options, args) = parser.parse_args()
if options.verbose:
global verbose
verbose = True
tar_filename = options.tar_filename
if not tar_filename:
tar_filename = join(DART_DIR, utils.GetBuildDir(HOST_OS),
'dart-%s.tar.gz' % utils.GetVersion())
CreateTarball(tar_filename)
if __name__ == '__main__':
sys.exit(Main())
-1
View File
@@ -1 +0,0 @@
10
-11
View File
@@ -1,11 +0,0 @@
Source: dart
Maintainer: William Hesse <whesse@google.com>
Section: misc
Priority: optional
Standards-Version: 3.9.2
Build-Depends: debhelper (>= 10), python3:native
Package: dart
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Dart SDK
@@ -1,2 +0,0 @@
debian/tmp/out/dart usr/lib
@@ -1,2 +0,0 @@
usr/lib/dart/bin/dart usr/bin/dart
-94
View File
@@ -1,94 +0,0 @@
#!/usr/bin/make -f
export DH_VERBOSE = 1
# Use DEB_BUILD_OPTIONS's parallel=n option (see Policy 4.9.1)
ifneq (,$(findstring parallel,$(DEB_BUILD_OPTIONS)))
PARALLEL_JOBS := $(shell echo $(DEB_BUILD_OPTIONS) | \
sed -e 's/.*parallel=\([0-9]\+\).*/\1/')
else
PARALLEL_JOBS := 1
endif
ifeq (amd64,$(DEB_HOST_ARCH_CPU))
BUILD_TYPE += ReleaseX64
BUILD_FLAGS += --arch=x64
LIBS_DIR := $(CURDIR)/dart/buildtools/sysroot/linux/lib/x86_64-linux-gnu
else
ifeq (i386,$(DEB_HOST_ARCH_CPU))
BUILD_TYPE += ReleaseIA32
BUILD_FLAGS += --arch=ia32
LIBS_DIR := $(CURDIR)/dart/buildtools/sysroot/linux/lib/i386-linux-gnu
else
ifeq (arm,$(DEB_HOST_ARCH_CPU))
ifeq ($(DEB_BUILD_ARCH_CPU),$(DEB_HOST_ARCH_CPU))
BUILD_TYPE += ReleaseARM
else
BUILD_TYPE += ReleaseXARM
endif
BUILD_FLAGS += --arch=arm
LIBS_DIR := $(CURDIR)/dart/buildtools/sysroot/linux/lib/arm-linux-gnueabihf
else
ifeq (arm64,$(DEB_HOST_ARCH_CPU))
ifeq ($(DEB_BUILD_ARCH_CPU),$(DEB_HOST_ARCH_CPU))
BUILD_TYPE += ReleaseARM64
else
BUILD_TYPE += ReleaseXARM64
endif
BUILD_FLAGS += --arch=arm64
LIBS_DIR := $(CURDIR)/dart/buildtools/sysroot/linux/lib/aarch64-linux-gnu
else
ifeq (riscv64,$(DEB_HOST_ARCH_CPU))
ifeq ($(DEB_BUILD_ARCH_CPU),$(DEB_HOST_ARCH_CPU))
BUILD_TYPE += ReleaseRISCV64
else
BUILD_TYPE += ReleaseXRISCV64
endif
BUILD_FLAGS += --arch=riscv64
LIBS_DIR := $(CURDIR)/dart/buildtools/sysroot/focal/lib/riscv64-linux-gnu
else
$(error unsupported target arch '$(DEB_HOST_ARCH_CPU)')
endif
endif
endif
endif
endif
# Verbose?
ifeq (1,$(DH_VERBOSE))
BUILD_FLAGS += --verbose
endif
%:
dh $@
override_dh_auto_clean:
echo $(DEB_BUILD_OPTIONS)
rm -fr dart/out dart/Makefile
find . -name *.tmp -execdir rm -f {} \;
find . -name *.pyc -execdir rm -f {} \;
find . -name *.mk -execdir rm -f {} \;
find . -name *.Makefile -execdir rm -f {} \;
override_dh_auto_configure:
python3 dart/tools/generate_buildfiles.py
override_dh_auto_build:
cd dart; \
python3 tools/build.py --mode release \
$(BUILD_FLAGS) $(TOOLCHAIN) create_sdk; \
cd ..
# Building the Dart SDK will already strip all binaries.
override_dh_strip:
# This override allows us to ignore spurious missing library errors when
# cross-compiling.
override_dh_shlibdeps:
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info -l $(LIBS_DIR)
override_dh_auto_install:
mkdir -p debian/tmp/out
cp -R dart/out/$(BUILD_TYPE)/dart-sdk debian/tmp/out
mv debian/tmp/out/dart-sdk debian/tmp/out/dart
dh_install
dh_link
@@ -1 +0,0 @@
3.0 (quilt)
@@ -1,130 +0,0 @@
#!/usr/bin/env python3
# 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.
"""
Buildbot steps for src tarball generation and debian package generation
Package up the src of the dart repo and create a debian package.
Archive tarball and debian package to google cloud storage.
"""
import os
import subprocess
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'bots'))
import bot_utils
utils = bot_utils.GetUtils()
HOST_OS = utils.GuessOS()
def InstallFromDep(builddir):
for entry in os.listdir(builddir):
if entry.endswith("_amd64.deb"):
path = os.path.join(builddir, entry)
Run(['dpkg', '-i', path])
def UninstallDart():
Run(['dpkg', '-r', 'dart'])
def CreateDartTestFile(tempdir):
filename = os.path.join(tempdir, 'test.dart')
with open(filename, 'w') as f:
f.write('void main() {\n')
f.write(' print("Hello world");\n')
f.write('}')
return filename
def Run(command):
print("Running: %s" % ' '.join(command))
sys.stdout.flush()
no_color_env = dict(os.environ)
no_color_env['TERM'] = 'nocolor'
subprocess.check_call(command, env=no_color_env)
def TestInstallation(assume_installed=True):
paths = ['/usr/bin/dart', '/usr/lib/dart/bin/dart']
for path in paths:
if os.path.exists(path):
if not assume_installed:
print('Assumed not installed, found %s' % path)
sys.exit(1)
else:
if assume_installed:
print('Assumed installed, but could not find %s' % path)
sys.exit(1)
def SrcSteps():
version = utils.GetVersion()
builddir = os.path.join(bot_utils.DART_DIR, utils.GetBuildDir(HOST_OS),
'src_and_installation')
if not os.path.exists(builddir):
os.makedirs(builddir)
tarfilename = 'dart-%s.tar.gz' % version
tarfile = os.path.join(builddir, tarfilename)
print('Validating that we are on debian bullseye')
args = ['cat', '/etc/os-release']
(stdout, stderr, exitcode) = bot_utils.run(args)
if exitcode != 0:
print("Could not find linux system, exiting")
sys.exit(1)
if not "bullseye" in stdout:
print("Trying to build Debian bits but not on Debian Bullseye")
print("You can't fix this, please contact dart-engprod@")
sys.exit(1)
print('Building src tarball')
Run([
sys.executable, 'tools/linux_dist_support/create_tarball.py',
'--tar_filename', tarfile
])
print('Building Debian packages')
Run([
sys.executable, 'tools/linux_dist_support/create_debian_packages.py',
'--tar_filename', tarfile, '--out_dir', builddir
])
if os.path.exists('/usr/bin/dart') or os.path.exists(
'/usr/lib/dart/bin/dart'):
print("Dart already installed, removing")
UninstallDart()
TestInstallation(assume_installed=False)
InstallFromDep(builddir)
TestInstallation(assume_installed=True)
# We build the runtime target to get everything we need to test the
# standalone target.
Run([
sys.executable, 'tools/build.py', '--mode=release', '--arch=x64',
'runtime'
])
# Copy in the installed binary to avoid polluting /usr/bin (and having to
# run as root)
Run(['cp', '/usr/bin/dart', 'out/ReleaseX64/dart'])
# Check dart, dart compile js, and dart analyze against a hello world program
with utils.TempDir() as temp_dir:
test_file = CreateDartTestFile(temp_dir)
Run(['/usr/lib/dart/bin/dart', 'compile', 'js', test_file])
Run(['/usr/lib/dart/bin/dart', 'analyze', test_file])
Run(['/usr/lib/dart/bin/dart', test_file])
UninstallDart()
TestInstallation(assume_installed=False)
if __name__ == '__main__':
SrcSteps()
@@ -1,14 +0,0 @@
#!/usr/bin/env bash
# Copyright (c) 2019, 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.
set -x
fetch=$(which fetch)
depot_tools=$(dirname $fetch)
image="debian-package:0.1"
dockerfile=tools/linux_dist_support/Debian.dockerfile
docker build --build-arg depot_tools=$depot_tools -t $image - < $dockerfile
checkout=$(pwd)
docker run -e BUILDBOT_BUILDERNAME -v $depot_tools:$depot_tools\
-v $checkout:$checkout -w $checkout -i --rm $image