From 2fe22929c2b965d752a142cc12bee068faa36657 Mon Sep 17 00:00:00 2001 From: Julien Blache Date: Fri, 18 Mar 2022 16:01:48 -0700 Subject: [PATCH] Debian packaging for Ubuntu 20.04 --- .../DEB/Ubuntu/focal/debian/README.source | 16 +++ .../Linux/DEB/Ubuntu/focal/debian/changelog | 5 + .../Linux/DEB/Ubuntu/focal/debian/control.in | 47 +++++++ .../Linux/DEB/Ubuntu/focal/debian/copyright | 27 ++++ .../DEB/Ubuntu/focal/debian/getsource.sh | 126 ++++++++++++++++++ .../debian/patches/build-preset-install-dir | 18 +++ .../debian/patches/cmake_parallel_bootstrap | 21 +++ .../fix-integration-tests-package-path | 110 +++++++++++++++ .../focal/debian/patches/fix-toolchain-path | 44 ++++++ .../debian/patches/python3_hwasan_symbolize | 14 ++ .../DEB/Ubuntu/focal/debian/patches/series | 5 + platforms/Linux/DEB/Ubuntu/focal/debian/rules | 85 ++++++++++++ .../Ubuntu/focal/debian/source-versions.sh | 17 +++ .../DEB/Ubuntu/focal/debian/source/format | 1 + .../focal/debian/swiftlang-X.Y.Z.install.in | 1 + .../Ubuntu/focal/debian/swiftlang.links.in | 4 + 16 files changed, 541 insertions(+) create mode 100644 platforms/Linux/DEB/Ubuntu/focal/debian/README.source create mode 100644 platforms/Linux/DEB/Ubuntu/focal/debian/changelog create mode 100644 platforms/Linux/DEB/Ubuntu/focal/debian/control.in create mode 100644 platforms/Linux/DEB/Ubuntu/focal/debian/copyright create mode 100755 platforms/Linux/DEB/Ubuntu/focal/debian/getsource.sh create mode 100644 platforms/Linux/DEB/Ubuntu/focal/debian/patches/build-preset-install-dir create mode 100644 platforms/Linux/DEB/Ubuntu/focal/debian/patches/cmake_parallel_bootstrap create mode 100644 platforms/Linux/DEB/Ubuntu/focal/debian/patches/fix-integration-tests-package-path create mode 100644 platforms/Linux/DEB/Ubuntu/focal/debian/patches/fix-toolchain-path create mode 100644 platforms/Linux/DEB/Ubuntu/focal/debian/patches/python3_hwasan_symbolize create mode 100644 platforms/Linux/DEB/Ubuntu/focal/debian/patches/series create mode 100755 platforms/Linux/DEB/Ubuntu/focal/debian/rules create mode 100644 platforms/Linux/DEB/Ubuntu/focal/debian/source-versions.sh create mode 100644 platforms/Linux/DEB/Ubuntu/focal/debian/source/format create mode 100644 platforms/Linux/DEB/Ubuntu/focal/debian/swiftlang-X.Y.Z.install.in create mode 100644 platforms/Linux/DEB/Ubuntu/focal/debian/swiftlang.links.in diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/README.source b/platforms/Linux/DEB/Ubuntu/focal/debian/README.source new file mode 100644 index 00000000..284273c9 --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/README.source @@ -0,0 +1,16 @@ +swift for Debian +--------------- + +The source package for Swift is composed of several different source components +from different projects. + +The shell fragment debian/source-versions.sh contains the version information +for all source components, and the Debian package upstream version (debversion). + +Fill in debian/source-versions.sh with the correct versions for all components, +then run debian/getsource.sh to fetch the archives to the current directory. +Source archives will be downloaded, renamed, and repacked if needed using +mk-origtargz from devscripts, and any Debian patches will be refreshed; ensure +devscripts and quilt are installed beforehand. + + -- Swift Maintainers Tue, 01 Mar 2022 15:04:23 -0800 diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/changelog b/platforms/Linux/DEB/Ubuntu/focal/debian/changelog new file mode 100644 index 00000000..8d5d499c --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/changelog @@ -0,0 +1,5 @@ +swiftlang (5.6.0-1) focal; urgency=medium + + * Debian packaging introduction for Swift 5.6. + + -- Julien Blache Tue, 15 Mar 2022 16:36:34 -0700 diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/control.in b/platforms/Linux/DEB/Ubuntu/focal/debian/control.in new file mode 100644 index 00000000..5f51b33f --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/control.in @@ -0,0 +1,47 @@ +Source: swiftlang +Section: devel +Priority: optional +Maintainer: Swift Maintainers +Build-Depends: debhelper-compat (= 12), devscripts, + clang, cmake, git, icu-devtools, ninja-build, pkg-config, + libcurl4-openssl-dev, libedit-dev, libicu-dev, libncurses5-dev, + libpython3-dev, libsqlite3-dev, libxml2-dev, + python, python-six, python2-dev, python3-six, python3-distutils, python3-psutil, + rsync, swig, systemtap-sdt-dev, tzdata, unzip, uuid-dev +Standards-Version: 4.4.1 +Homepage: https://www.swift.org + +Package: swiftlang +Architecture: all +Depends: swiftlang-x.y.z, ${misc:Depends} +Description: Swift programming language + Swift is a general-purpose programming language built using + a modern approach to safety, performance, and software design + patterns. + . + The goal of the Swift project is to create the best available + language for uses ranging from systems programming, to mobile + and desktop apps, scaling up to cloud services. Most + importantly, Swift is designed to make writing and maintaining + correct programs easier for the developer. + . + This package contains the convenience symlinks for the latest + version of Swift. + +Package: swiftlang-x.y.z +Architecture: amd64 arm64 +Depends: ${shlibs:Depends}, ${misc:Depends}, + libc6-dev, libcurl4-openssl-dev, libgcc-9-dev, libstdc++-9-dev, libxml2-dev, + libz3-dev, uuid-dev, zlib1g-dev, + binutils, git, pkg-config, tzdata, + python3 +Description: Swift programming language, release x.y.z + Swift is a general-purpose programming language built using + a modern approach to safety, performance, and software design + patterns. + . + The goal of the Swift project is to create the best available + language for uses ranging from systems programming, to mobile + and desktop apps, scaling up to cloud services. Most + importantly, Swift is designed to make writing and maintaining + correct programs easier for the developer. diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/copyright b/platforms/Linux/DEB/Ubuntu/focal/debian/copyright new file mode 100644 index 00000000..a349c152 --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/copyright @@ -0,0 +1,27 @@ +# TODO This copyright file needs to be filled out + +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: swift +Upstream-Contact: +Source: + +Files: * +Copyright: + +License: TBD + +Files: debian/* +Copyright: +License: TBD + +License: TBD + This copyright file is a template and an active TODO item. + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. +# Please avoid picking licenses with terms that are more restrictive than the +# packaged work, as it may make Debian's contributions unacceptable upstream. +# +# If you need, there are some extra license texts available in two places: +# /usr/share/debhelper/dh_make/licenses/ +# /usr/share/common-licenses/ diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/getsource.sh b/platforms/Linux/DEB/Ubuntu/focal/debian/getsource.sh new file mode 100755 index 00000000..10fd9c0a --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/getsource.sh @@ -0,0 +1,126 @@ +#!/bin/sh + +# This helper script will fetch the Swift sources, save the +# tarballs following the appropriate naming convention, and +# build a Debian source package. + +# You will need the devscripts and quilt packages installed +# to run this script and build the packages following these +# instructions. + +# Create swiftlang-X.Y.Z, unpack the debian tarball within, +# proceed to adding the appropriate entry to the Debian +# changelog, edit debian/source-version.sh, then run this +# script from the directory containing swiftlang-X.Y.Z. +# $ mkdir swiftlang-X.Y.Z +# $ cd swiftlang-X.Y.Z +# $ tar xvaf ../swiftlang_A.B.C-D.debian.tar.xz +# $ dch -v X.Y.Z-1 +# $ cd .. +# $ swiftlang-X.Y.Z/debian/getsource.sh +# +# This will download all the necessary sources, unpack them +# as required, refresh any Debian patches, then create the +# Debian source package. + +# If all is well, proceed with building the packages. +# $ cd swiftlang-X.Y.Z +# $ DEB_BUILD_OPTIONS=parallel=64 debuild + +set -eu + +. $(dirname $0)/source-versions.sh + +get_component () +{ + component=$1 + url="$2" + + dest=swiftlang_${debversion}.orig-${component} + + echo "Downloading ${component} from ${url}" + + case "${url}" in + *.zip) + tmpdest=${component}.zip + dest=${dest}.tar.gz + + curl -L -o ${tmpdest} "${url}" + mk-origtargz --package swiftlang -v ${debversion} -c ${component} --rename --compression gzip ${tmpdest} + ;; + + *.tar.gz) + dest=${dest}.tar.gz + curl -L -o ${dest} "${url}" + ;; + + *.tar.xz) + dest=${dest}.tar.xz + curl -L -o ${dest} "${url}" + ;; + + *.tar.bz2) + dest=${dest}.tar.bz2 + curl -L -o ${dest} "${url}" + ;; + + *) + echo "Source archive not in a suitable format for Debian sources: ${url}" >&2 + exit 1 + esac + + mkdir swiftlang-${debversion}/${component} + tar -C swiftlang-${debversion}/${component} --strip-components=1 -axf ${dest} +} + +get_component swift https://github.com/apple/swift/archive/swift-${swift_version}.tar.gz +get_component swift-corelibs-libdispatch https://github.com/apple/swift-corelibs-libdispatch/archive/swift-${swift_version}.tar.gz +get_component swift-corelibs-foundation https://github.com/apple/swift-corelibs-foundation/archive/swift-${swift_version}.tar.gz +get_component swift-integration-tests https://github.com/apple/swift-integration-tests/archive/swift-${swift_version}.tar.gz +get_component swift-corelibs-xctest https://github.com/apple/swift-corelibs-xctest/archive/swift-${swift_version}.tar.gz +get_component swiftpm https://github.com/apple/swift-package-manager/archive/swift-${swift_version}.tar.gz +get_component llbuild https://github.com/apple/swift-llbuild/archive/swift-${swift_version}.tar.gz +get_component cmark https://github.com/apple/swift-cmark/archive/swift-${swift_version}.tar.gz +get_component swift-xcode-playground-support https://github.com/apple/swift-xcode-playground-support/archive/swift-${swift_version}.tar.gz +get_component sourcekit-lsp https://github.com/apple/sourcekit-lsp/archive/swift-${swift_version}.tar.gz +get_component indexstore-db https://github.com/apple/indexstore-db/archive/swift-${swift_version}.tar.gz +get_component llvm-project https://github.com/apple/llvm-project/archive/swift-${swift_version}.tar.gz +get_component swift-tools-support-core https://github.com/apple/swift-tools-support-core/archive/swift-${swift_version}.tar.gz +get_component swift-argument-parser https://github.com/apple/swift-argument-parser/archive/${swift_argument_parser_version}.tar.gz +get_component swift-driver https://github.com/apple/swift-driver/archive/swift-${swift_version}.tar.gz +get_component icu https://github.com/unicode-org/icu/archive/release-${icu_version}.tar.gz +get_component swift-crypto https://github.com/apple/swift-crypto/archive/refs/tags/${swift_crypto_version}.tar.gz +get_component ninja https://github.com/ninja-build/ninja/archive/refs/tags/v${ninja_version}.tar.gz +get_component cmake https://github.com/KitWare/CMake/archive/refs/tags/v${cmake_version}.tar.gz +get_component swift-syntax https://github.com/apple/swift-syntax/archive/swift-${swift_version}.tar.gz +get_component yams https://github.com/jpsim/Yams/archive/${yams_version}.tar.gz +get_component swift-atomics https://github.com/apple/swift-atomics/archive/${swift_atomics_version}.tar.gz +get_component swift-cmark-gfm https://github.com/apple/swift-cmark/archive/swift-${swift_version}-gfm.tar.gz +get_component swift-docc https://github.com/apple/swift-docc/archive/swift-${swift_version}.tar.gz +get_component swift-docc-render-artifact https://github.com/apple/swift-docc-render-artifact/archive/swift-${swift_version}.tar.gz +get_component swift-docc-symbolkit https://github.com/apple/swift-docc-symbolkit/archive/swift-${swift_version}.tar.gz +get_component swift-collections https://github.com/apple/swift-collections/archive/${swift_collections_version}.tar.gz +get_component swift-numerics https://github.com/apple/swift-numerics/archive/${swift_numerics_version}.tar.gz +get_component swift-system https://github.com/apple/swift-system/archive/${swift_system_version}.tar.gz +get_component swift-nio https://github.com/apple/swift-nio/archive/${swift_nio_version}.tar.gz +get_component swift-nio-ssl https://github.com/apple/swift-nio-ssl/archive/${swift_nio_ssl_version}.tar.gz +get_component swift-format https://github.com/apple/swift-format/archive/swift-${swift_version}.tar.gz +get_component swift-lmdb https://github.com/apple/swift-lmdb/archive/swift-${swift_version}.tar.gz +get_component swift-markdown https://github.com/apple/swift-markdown/archive/swift-${swift_version}.tar.gz + +# Refresh patches, if any +if [ -s swiftlang-${debversion}/debian/patches/series ]; then + cd swiftlang-${debversion} + + export QUILT_PATCHES=debian/patches + export QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index" + + while quilt push; do quilt refresh; done + quilt pop -a + + cd - +fi + +cp -f swiftlang-${debversion}/debian/control.in swiftlang-${debversion}/debian/control + +dpkg-source --create-empty-orig -b swiftlang-${debversion} diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/patches/build-preset-install-dir b/platforms/Linux/DEB/Ubuntu/focal/debian/patches/build-preset-install-dir new file mode 100644 index 00000000..6a7208ea --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/patches/build-preset-install-dir @@ -0,0 +1,18 @@ +Description: Make target installation directory a command line option + Use a variable for the install prefix, so we can specify it at build + time on the command line. +Author: Julien Blache + +Index: swiftlang-5.6.0/swift/utils/build-presets.ini +=================================================================== +--- swiftlang-5.6.0.orig/swift/utils/build-presets.ini ++++ swiftlang-5.6.0/swift/utils/build-presets.ini +@@ -831,7 +831,7 @@ install-swiftpm + install-swift-driver + install-xctest + install-libicu +-install-prefix=/usr ++install-prefix=%(install_prefix)s + install-libcxx + install-sourcekit-lsp + install-swiftdocc diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/patches/cmake_parallel_bootstrap b/platforms/Linux/DEB/Ubuntu/focal/debian/patches/cmake_parallel_bootstrap new file mode 100644 index 00000000..6e3241f2 --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/patches/cmake_parallel_bootstrap @@ -0,0 +1,21 @@ +Description: Enable parallel boostrap for CMake + CMake's bootstrap can be parallelized, but wasn't. +Author: Julien Blache + +Index: swiftlang-5.6.0/swift/utils/swift_build_support/swift_build_support/cmake.py +=================================================================== +--- swiftlang-5.6.0.orig/swift/utils/swift_build_support/swift_build_support/cmake.py ++++ swiftlang-5.6.0/swift/utils/swift_build_support/swift_build_support/cmake.py +@@ -267,8 +267,10 @@ class CMake(object): + + cwd = os.getcwd() + os.chdir(cmake_build_dir) +- shell.call_without_sleeping([cmake_bootstrap, '--no-qt-gui', '--', +- '-DCMAKE_USE_OPENSSL=OFF'], echo=True) ++ shell.call_without_sleeping([cmake_bootstrap, '--no-qt-gui', ++ '--parallel=%s' % self.args.build_jobs, ++ '--', '-DCMAKE_USE_OPENSSL=OFF'], ++ echo=True) + shell.call_without_sleeping(['make', '-j%s' % self.args.build_jobs], + echo=True) + os.chdir(cwd) diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/patches/fix-integration-tests-package-path b/platforms/Linux/DEB/Ubuntu/focal/debian/patches/fix-integration-tests-package-path new file mode 100644 index 00000000..b1987260 --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/patches/fix-integration-tests-package-path @@ -0,0 +1,110 @@ +Description: Fix integration tests to use correct package path + Remove hardcoded usr paths and pass the correct package path to + the tests. +Author: Julien Blache + +Index: swiftlang-5.6.0/swift-integration-tests/lit.cfg +=================================================================== +--- swiftlang-5.6.0.orig/swift-integration-tests/lit.cfg ++++ swiftlang-5.6.0/swift-integration-tests/lit.cfg +@@ -175,31 +175,31 @@ else: + + swift_path = lit_config.params.get( + "swift", +- os.path.join(package_path, "usr", "bin", "swift")) ++ os.path.join(package_path, "bin", "swift")) + lit_config.note("testing using 'swift': %r" % (swift_path,)) + + swiftc_path = lit_config.params.get( + "swiftc", +- os.path.join(package_path, "usr", "bin", "swiftc")) ++ os.path.join(package_path, "bin", "swiftc")) + lit_config.note("testing using 'swiftc': %r" % (swiftc_path,)) + + lldb_path = lit_config.params.get( + "lldb", +- os.path.join(package_path, "usr", "bin", "lldb")) ++ os.path.join(package_path, "bin", "lldb")) + lit_config.note("testing using 'lldb': {}".format(lldb_path)) + + repl_swift_dummy_path = lit_config.params.get( + "repl_swift", +- os.path.join(package_path, "usr", "bin", "repl_swift")) ++ os.path.join(package_path, "bin", "repl_swift")) + lit_config.note("testing using 'repl_swift': {}".format(repl_swift_dummy_path)) + + sourcekit_lsp_path = lit_config.params.get( + "sourcekit-lsp", +- os.path.join(package_path, "usr", "bin", "sourcekit-lsp")) ++ os.path.join(package_path, "bin", "sourcekit-lsp")) + + docc_path = lit_config.params.get( + "docc", +- os.path.join(package_path, "usr", "bin", "docc")) ++ os.path.join(package_path, "bin", "docc")) + lit_config.note("testing using 'docc': {}".format(docc_path)) + + # Verify they exist. +Index: swiftlang-5.6.0/swift-integration-tests/test-snapshot-binaries/test-rpath-linux.py +=================================================================== +--- swiftlang-5.6.0.orig/swift-integration-tests/test-snapshot-binaries/test-rpath-linux.py ++++ swiftlang-5.6.0/swift-integration-tests/test-snapshot-binaries/test-rpath-linux.py +@@ -4,26 +4,26 @@ + # CHECK: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}$ORIGIN/../lib/swift/linux + # + # Tests that DT_RUNPATH is correct for the Swift stdlib and other libraries on Linux. +-# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/libswiftCore.so | %{FileCheck} --check-prefix CHECK-CORE %s ++# RUN: %{readelf} -d %{package_path}/lib/swift/linux/libswiftCore.so | %{FileCheck} --check-prefix CHECK-CORE %s + # CHECK-CORE-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux + # +-# RUN: %{readelf} -d %{package_path}/usr/lib/libsourcekitdInProc.so | %{FileCheck} --check-prefix CHECK-SK %s ++# RUN: %{readelf} -d %{package_path}/lib/libsourcekitdInProc.so | %{FileCheck} --check-prefix CHECK-SK %s + # CHECK-SK-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux + # +-# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/libswiftRemoteMirror.so | %{FileCheck} --check-prefix CHECK-RM %s ++# RUN: %{readelf} -d %{package_path}/lib/swift/linux/libswiftRemoteMirror.so | %{FileCheck} --check-prefix CHECK-RM %s + # CHECK-RM-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux + # +-# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/libswift_Differentiation.so | %{FileCheck} --check-prefix CHECK-SD %s ++# RUN: %{readelf} -d %{package_path}/lib/swift/linux/libswift_Differentiation.so | %{FileCheck} --check-prefix CHECK-SD %s + # CHECK-SD-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux + # +-# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/lib_InternalSwiftSyntaxParser.so | %{FileCheck} --check-prefix CHECK-SP %s ++# RUN: %{readelf} -d %{package_path}/lib/swift/linux/lib_InternalSwiftSyntaxParser.so | %{FileCheck} --check-prefix CHECK-SP %s + # CHECK-SP-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux + # +-# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/libswiftGlibc.so | %{FileCheck} --check-prefix CHECK-SG %s ++# RUN: %{readelf} -d %{package_path}/lib/swift/linux/libswiftGlibc.so | %{FileCheck} --check-prefix CHECK-SG %s + # CHECK-SG-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux + # +-# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/libswiftSwiftOnoneSupport.so | %{FileCheck} --check-prefix CHECK-SON %s ++# RUN: %{readelf} -d %{package_path}/lib/swift/linux/libswiftSwiftOnoneSupport.so | %{FileCheck} --check-prefix CHECK-SON %s + # CHECK-SON-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux + # +-# RUN: %{readelf} -d %{package_path}/usr/lib/libswiftDemangle.so | %{FileCheck} --check-prefix CHECK-SDE %s ++# RUN: %{readelf} -d %{package_path}/lib/libswiftDemangle.so | %{FileCheck} --check-prefix CHECK-SDE %s + # CHECK-SDE-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux +Index: swiftlang-5.6.0/swift/utils/build-script-impl +=================================================================== +--- swiftlang-5.6.0.orig/swift/utils/build-script-impl ++++ swiftlang-5.6.0/swift/utils/build-script-impl +@@ -3463,8 +3463,10 @@ function build_and_test_installable_pack + + if [[ "${host}" == "macosx-"* ]] || [[ "${host}" == "merged-hosts" ]]; then + PKG_TESTS_SANDBOX="${PKG_TESTS_SANDBOX_PARENT}"/"${TOOLCHAIN_PREFIX}" ++ PKG_TESTS_PKG_DIR="${PKG_TESTS_SANDBOX}" + else # Linux + PKG_TESTS_SANDBOX="${PKG_TESTS_SANDBOX_PARENT}" ++ PKG_TESTS_PKG_DIR="${PKG_TESTS_SANDBOX}/${host_install_prefix}" + fi + + LIT_EXECUTABLE_PATH="${LLVM_SOURCE_DIR}/utils/lit/lit.py" +@@ -3479,7 +3481,7 @@ function build_and_test_installable_pack + TIMEOUT_ARGS=--timeout=1200 # 20 minutes + fi + with_pushd "${PKG_TESTS_SOURCE_DIR}" \ +- call python3 "${LIT_EXECUTABLE_PATH}" . -sv --param package-path="${PKG_TESTS_SANDBOX}" --param test-exec-root="${PKG_TESTS_TEMPS}" --param llvm-bin-dir="${LLVM_BIN_DIR}" ${TIMEOUT_ARGS} ++ call python3 "${LIT_EXECUTABLE_PATH}" . -sv --param package-path="${PKG_TESTS_PKG_DIR}" --param test-exec-root="${PKG_TESTS_TEMPS}" --param llvm-bin-dir="${LLVM_BIN_DIR}" ${TIMEOUT_ARGS} + fi + fi + } diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/patches/fix-toolchain-path b/platforms/Linux/DEB/Ubuntu/focal/debian/patches/fix-toolchain-path new file mode 100644 index 00000000..d162fac7 --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/patches/fix-toolchain-path @@ -0,0 +1,44 @@ +Description: Fix toolchain path for build-script-helper.py + Make sure the correct path is passed to the script, and remove + assumption that /usr is used. +Author: Julien Blache + +Index: swiftlang-5.6.0/swift/benchmark/scripts/build_script_helper.py +=================================================================== +--- swiftlang-5.6.0.orig/swift/benchmark/scripts/build_script_helper.py ++++ swiftlang-5.6.0/swift/benchmark/scripts/build_script_helper.py +@@ -53,7 +53,7 @@ def main(): + if not os.path.isdir(bin_dir): + os.makedirs(bin_dir) + +- swiftbuild_path = os.path.join(args.toolchain, "usr", "bin", "swift-build") ++ swiftbuild_path = os.path.join(args.toolchain, "bin", "swift-build") + perform_build(args, swiftbuild_path, "debug", "Benchmark_Onone", "-Onone") + perform_build(args, swiftbuild_path, "release", "Benchmark_Osize", "-Osize") + perform_build(args, swiftbuild_path, "release", "Benchmark_O", "-O") +Index: swiftlang-5.6.0/swift/utils/swift_build_support/swift_build_support/products/benchmarks.py +=================================================================== +--- swiftlang-5.6.0.orig/swift/utils/swift_build_support/swift_build_support/products/benchmarks.py ++++ swiftlang-5.6.0/swift/utils/swift_build_support/swift_build_support/products/benchmarks.py +@@ -100,13 +100,17 @@ class Benchmarks(product.Product): + + + def _get_toolchain_path(host_target, product, args): +- # TODO check if we should prefer using product.install_toolchain_path + # this logic initially was inside run_build_script_helper + # and was factored out so it can be used in testing as well + +- toolchain_path = swiftpm.SwiftPM.get_install_destdir(args, +- host_target, +- product.build_dir) ++ install_destdir = args.install_destdir ++ if swiftpm.SwiftPM.has_cross_compile_hosts(args): ++ install_destdir = swiftpm.SwiftPM.get_install_destdir(args, ++ host_target, ++ product.build_dir) ++ toolchain_path = targets.toolchain_path(install_destdir, ++ args.install_prefix) ++ + if platform.system() == 'Darwin': + # The prefix is an absolute path, so concatenate without os.path. + toolchain_path += \ diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/patches/python3_hwasan_symbolize b/platforms/Linux/DEB/Ubuntu/focal/debian/patches/python3_hwasan_symbolize new file mode 100644 index 00000000..0442e28c --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/patches/python3_hwasan_symbolize @@ -0,0 +1,14 @@ +Description: Fix hwasan_symbolize to call python3 + On Ubuntu, /usr/bin/python is still python 2.x. +Author: Julien Blache + +Index: swiftlang-5.6.0/llvm-project/compiler-rt/lib/hwasan/scripts/hwasan_symbolize +=================================================================== +--- swiftlang-5.6.0.orig/llvm-project/compiler-rt/lib/hwasan/scripts/hwasan_symbolize ++++ swiftlang-5.6.0/llvm-project/compiler-rt/lib/hwasan/scripts/hwasan_symbolize +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + #===- lib/hwasan/scripts/hwasan_symbolize ----------------------------------===# + # + # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/patches/series b/platforms/Linux/DEB/Ubuntu/focal/debian/patches/series new file mode 100644 index 00000000..33cab02d --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/patches/series @@ -0,0 +1,5 @@ +python3_hwasan_symbolize +cmake_parallel_bootstrap +build-preset-install-dir +fix-toolchain-path +fix-integration-tests-package-path diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/rules b/platforms/Linux/DEB/Ubuntu/focal/debian/rules new file mode 100755 index 00000000..f30714ec --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/rules @@ -0,0 +1,85 @@ +#!/usr/bin/make -f +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +#export DH_VERBOSE = 1 + +BUILD_SCRIPT_ARGS = +ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) + NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) + BUILD_SCRIPT_ARGS += -j $(NUMJOBS) +endif + +# Verbose Swift build +export VERBOSE=1 + +SWIFTLANG_PKG_VER=$(shell dpkg-parsechangelog -S Version | sed -e 's/-[^-]*$$//') +SWIFT_BUILDDIR=$(CURDIR)/build + +%: + dh $@ + +clean:: + dh_testdir + + # Generate debian/control and others + sed -e 's/x.y.z/$(SWIFTLANG_PKG_VER)/g' < debian/control.in > debian/control + + rm -f debian/swiftlang-*.install debian/swiftlang.links + sed -e 's/X.Y.Z/$(SWIFTLANG_PKG_VER)/g' < debian/swiftlang-X.Y.Z.install.in > debian/swiftlang-$(SWIFTLANG_PKG_VER).install + sed -e 's/X.Y.Z/$(SWIFTLANG_PKG_VER)/g' < debian/swiftlang.links.in > debian/swiftlang.links + + rm -rf $(SWIFT_BUILDDIR) + + # Modified during the build + rm -f swift-corelibs-libdispatch/dispatch/module.modulemap + rm -f swift-corelibs-libdispatch/private/module.modulemap + + # Python byte-compiled files + find swift/utils -name '*.pyc' -delete + find llvm-project -name '*.pyc' -delete + find cmark/test -name '*.pyc' -delete + find swiftpm -name '*.pyc' -delete + + dh_clean + +override_dh_auto_clean: + # Disabled; we have a non-standard build system that the tool + # doesn't support, so be on the safe side and avoid any potential + # false-triggering. + +override_dh_update_autotools_config: + # Don't go and update config.guess/config.sub, it causes LLVM to + # pick up the x86_64-pc-linux-gnu triplet instead of the expected + # x86_64-unknown-linux-gnu. This causes Swift modules to break. + +override_dh_autoreconf: + # We'd rather not do that either, see above. + +override_dh_makeshlibs: + # Do not provide shlibs for the all-in-one package; shlibs will be + # provided where pertinent as we move toward the end state of the + # packaging, or a different dependency mechanism will be instituted. + +override_dh_shlibdeps: + dh_shlibdeps -l/opt/swift/$(SWIFTLANG_PKG_VER)/lib/swift/linux/ + +override_dh_dwz: + # Disable DWARF debug info compression; it is failing, so we'll + # need to investigate whether or not it is suitable for us. + +override_dh_auto_build: + swift/utils/build-script $(BUILD_SCRIPT_ARGS) --preset=buildbot_linux,no_assertions,no_test \ + install_prefix=/opt/swift/$(SWIFTLANG_PKG_VER) \ + install_destdir=$(SWIFT_BUILDDIR)/discard \ + installable_package=$(SWIFT_BUILDDIR)/swiftdeb-$(SWIFTLANG_PKG_VER).tar.gz + +override_dh_auto_install: + # The build script preset used above will build, install, package, + # and test the resulting tarball. We could split all this into 2 + # or more presets and run them in sequence as expected here, but + # for now we'll just unpack the (tested) tarball and go from there. + mkdir -p $(CURDIR)/debian/tmp + tar -C $(CURDIR)/debian/tmp -xzf $(SWIFT_BUILDDIR)/swiftdeb-$(SWIFTLANG_PKG_VER).tar.gz + + # Manually compress manpages, since they are in a non-standard location + find $(CURDIR)/debian/tmp/opt/swift/$(SWIFTLANG_PKG_VER)/share/man -type f -exec gzip \{\} \; diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/source-versions.sh b/platforms/Linux/DEB/Ubuntu/focal/debian/source-versions.sh new file mode 100644 index 00000000..ce6e192e --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/source-versions.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +debversion=5.6.0 + +swift_version=5.6-RELEASE +icu_version=65-1 +yams_version=4.0.2 +swift_argument_parser_version=1.0.3 +swift_crypto_version=1.1.5 +ninja_version=1.10.2 +cmake_version=3.19.6 +swift_atomics_version=1.0.2 +swift_collections_version=1.0.1 +swift_numerics_version=1.0.1 +swift_system_version=1.1.1 +swift_nio_version=2.31.2 +swift_nio_ssl_version=2.15.0 diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/source/format b/platforms/Linux/DEB/Ubuntu/focal/debian/source/format new file mode 100644 index 00000000..163aaf8d --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/swiftlang-X.Y.Z.install.in b/platforms/Linux/DEB/Ubuntu/focal/debian/swiftlang-X.Y.Z.install.in new file mode 100644 index 00000000..3c0f5a32 --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/swiftlang-X.Y.Z.install.in @@ -0,0 +1 @@ +opt/swift/X.Y.Z/* diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/swiftlang.links.in b/platforms/Linux/DEB/Ubuntu/focal/debian/swiftlang.links.in new file mode 100644 index 00000000..cb2a6c4a --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/swiftlang.links.in @@ -0,0 +1,4 @@ +opt/swift/X.Y.Z/bin/swift usr/bin/swift +opt/swift/X.Y.Z/bin/swiftc usr/bin/swiftc +opt/swift/X.Y.Z/bin/sourcekit-lsp usr/bin/sourcekit-lsp +opt/swift/X.Y.Z/share/man/man1/swift.1.gz usr/share/man/man1/swift.1.gz