From 6924ad60fde120b83d9ccd9cd743087538dffe9a Mon Sep 17 00:00:00 2001 From: Julien Blache Date: Fri, 18 Mar 2022 16:01:48 -0700 Subject: [PATCH 1/2] Debian packaging for Ubuntu 20.04 --- .../DEB/Ubuntu/focal/debian/README.source | 17 +++ .../Linux/DEB/Ubuntu/focal/debian/changelog | 17 +++ .../Linux/DEB/Ubuntu/focal/debian/control | 46 +++++++ .../Linux/DEB/Ubuntu/focal/debian/control.in | 46 +++++++ .../Linux/DEB/Ubuntu/focal/debian/copyright | 38 ++++++ .../DEB/Ubuntu/focal/debian/getsource.sh | 124 ++++++++++++++++++ .../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 | 84 ++++++++++++ .../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 + 17 files changed, 607 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 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..93956a26 --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/README.source @@ -0,0 +1,17 @@ +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. + + -- Julien Blache 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..298fb366 --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/changelog @@ -0,0 +1,17 @@ +swiftlang (5.6.0-1) focal; urgency=medium + + * New upstream release. + + -- Julien Blache Tue, 15 Mar 2022 16:36:34 -0700 + +swiftlang (5.5.3-2) focal; urgency=medium + + * Add a default swiftlang package with symlinks in the PATH. + + -- Julien Blache Fri, 11 Mar 2022 15:04:24 -0800 + +swiftlang (5.5.3-1) focal; urgency=medium + + * Initial release. + + -- Julien Blache Tue, 01 Mar 2022 15:04:23 -0800 diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/control b/platforms/Linux/DEB/Ubuntu/focal/debian/control new file mode 100644 index 00000000..777f5b25 --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/control @@ -0,0 +1,46 @@ +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, libgcc-9-dev, libstdc++-9-dev, libz3-dev, uuid-dev, zlib1g-dev, + libxml2-dev, libcurl4-openssl-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/control.in b/platforms/Linux/DEB/Ubuntu/focal/debian/control.in new file mode 100644 index 00000000..777f5b25 --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/control.in @@ -0,0 +1,46 @@ +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, libgcc-9-dev, libstdc++-9-dev, libz3-dev, uuid-dev, zlib1g-dev, + libxml2-dev, libcurl4-openssl-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..cb331d9c --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/copyright @@ -0,0 +1,38 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: swift +Upstream-Contact: +Source: + +Files: * +Copyright: + +License: Apache-2.0 + +Files: debian/* +Copyright: Author Name +License: Apache-2.0 + +License: Apache-2.0 + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + . + https://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + . + On Debian systems, the complete text of the Apache version 2.0 license + can be found in "/usr/share/common-licenses/Apache-2.0". + +# 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..81207300 --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/getsource.sh @@ -0,0 +1,124 @@ +#!/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 + +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..9b54a0ee --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/patches/build-preset-install-dir @@ -0,0 +1,18 @@ +Description: Change the target installation directory + Presets will be modified to use the command line, after + the dust settles. +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=/opt/swift/5.6.0 + 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..de4f66cf --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/debian/rules @@ -0,0 +1,84 @@ +#!/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_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 From 4499edf215da7c22d81b9bbe9454341f2ab352fc Mon Sep 17 00:00:00 2001 From: tom doron Date: Thu, 24 Mar 2022 22:47:23 -0700 Subject: [PATCH 2/2] refactor debian packager motivation: add docker support + prepare for sharing changes: * add docker and docker compose setup to build in docker * move shared scripts and metadata into the "shared" directory * rename getsource.sh to build_source_package.sh and udpate it to handle the new directory structure * create build_deb.sh driver script to do the package building end-to-end * update readme with details --- platforms/Linux/DEB/Shared/build_deb.sh | 39 +++++++++++ .../build_source_package.sh} | 38 ++++++---- .../{Ubuntu/focal/debian => Shared}/copyright | 0 .../source-versions.sh => Shared/versions.sh} | 2 +- platforms/Linux/DEB/Ubuntu/README.md | 70 +++++++++++++++++++ platforms/Linux/DEB/Ubuntu/focal/Dockerfile | 21 ++++++ platforms/Linux/DEB/Ubuntu/focal/README.md | 1 - platforms/Linux/DEB/Ubuntu/focal/build_deb.sh | 1 + .../DEB/Ubuntu/focal/build_source_package.sh | 1 + .../DEB/Ubuntu/focal/debian/README.source | 17 ----- .../Linux/DEB/Ubuntu/focal/debian/control | 46 ------------ .../DEB/Ubuntu/focal/docker-compose.yaml | 47 +++++++++++++ platforms/Linux/DEB/Ubuntu/focal/versions.sh | 1 + 13 files changed, 206 insertions(+), 78 deletions(-) create mode 100755 platforms/Linux/DEB/Shared/build_deb.sh rename platforms/Linux/DEB/{Ubuntu/focal/debian/getsource.sh => Shared/build_source_package.sh} (87%) rename platforms/Linux/DEB/{Ubuntu/focal/debian => Shared}/copyright (100%) rename platforms/Linux/DEB/{Ubuntu/focal/debian/source-versions.sh => Shared/versions.sh} (96%) create mode 100644 platforms/Linux/DEB/Ubuntu/focal/Dockerfile delete mode 100644 platforms/Linux/DEB/Ubuntu/focal/README.md create mode 120000 platforms/Linux/DEB/Ubuntu/focal/build_deb.sh create mode 120000 platforms/Linux/DEB/Ubuntu/focal/build_source_package.sh delete mode 100644 platforms/Linux/DEB/Ubuntu/focal/debian/README.source delete mode 100644 platforms/Linux/DEB/Ubuntu/focal/debian/control create mode 100644 platforms/Linux/DEB/Ubuntu/focal/docker-compose.yaml create mode 120000 platforms/Linux/DEB/Ubuntu/focal/versions.sh diff --git a/platforms/Linux/DEB/Shared/build_deb.sh b/platforms/Linux/DEB/Shared/build_deb.sh new file mode 100755 index 00000000..ace7d849 --- /dev/null +++ b/platforms/Linux/DEB/Shared/build_deb.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +set -eux + +here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# load version definitions +. ${here}/versions.sh + +# working in /tmp since docker file sharing makes this very slow to do dirctly on the share +staging_dir=/tmp/swift-deb-builder +package_dir=${staging_dir}/swiftlang-${debversion} + +# clean +#rm -rf ${staging_dir} && mkdir -p ${staging_dir} +rm -rf ${package_dir} && mkdir -p ${package_dir} + +# copy control files to pakcage build directory +cp -r ${here}/debian ${package_dir}/ +cp -r ${package_dir}/debian/control.in ${package_dir}/debian/control + +# build the source package +${here}/build_source_package.sh ${staging_dir} + +# install the build dependencies +cd ${staging_dir} +mk-build-deps --install ${package_dir}/debian/control.in --tool 'apt-get -y -o Debug::pkgProblemResolver=yes --no-install-recommends' + +# build the installable package +# TODO: add signing key information +cd ${package_dir} +DEB_BUILD_OPTIONS=parallel=64 debuild + +# copy the final packages to /output +cd ${staging_dir} +cp *.deb /output/ +cp *.ddeb /output/ +cp *.dsc /output/ +cp *.tar.* /output/ diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/getsource.sh b/platforms/Linux/DEB/Shared/build_source_package.sh similarity index 87% rename from platforms/Linux/DEB/Ubuntu/focal/debian/getsource.sh rename to platforms/Linux/DEB/Shared/build_source_package.sh index 81207300..22d0f1c9 100755 --- a/platforms/Linux/DEB/Ubuntu/focal/debian/getsource.sh +++ b/platforms/Linux/DEB/Shared/build_source_package.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # This helper script will fetch the Swift sources, save the # tarballs following the appropriate naming convention, and @@ -10,7 +10,7 @@ # 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 +# changelog, edit /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 @@ -27,17 +27,22 @@ # $ cd swiftlang-X.Y.Z # $ DEB_BUILD_OPTIONS=parallel=64 debuild -set -eu +set -eux -. $(dirname $0)/source-versions.sh +here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# load version definitions +. ${here}/versions.sh + +staging_dir=$1 +package_dir=$staging_dir/swiftlang-${debversion} get_component () { component=$1 url="$2" - dest=swiftlang_${debversion}.orig-${component} - + dest=${staging_dir}/swiftlang_${debversion}.orig-${component} echo "Downloading ${component} from ${url}" case "${url}" in @@ -51,7 +56,10 @@ get_component () *.tar.gz) dest=${dest}.tar.gz - curl -L -o ${dest} "${url}" + # temp + if [ ! -f ${dest} ]; then + curl -L -o ${dest} "${url}" + fi ;; *.tar.xz) @@ -69,10 +77,12 @@ get_component () exit 1 esac - mkdir swiftlang-${debversion}/${component} - tar -C swiftlang-${debversion}/${component} --strip-components=1 -axf ${dest} + echo "Extracting ${component}" + mkdir ${package_dir}/${component} + tar -C ${package_dir}/${component} --strip-components=1 -axf ${dest} } +# download 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 @@ -109,10 +119,10 @@ get_component swift-lmdb https://github.com/apple/swift-lmdb/archive/swift-${swi 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} +if [ -s ${package_dir}/debian/patches/series ]; then + cd ${package_dir} - export QUILT_PATCHES=debian/patches + export QUILT_PATCHES=debian/patches export QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index" while quilt push; do quilt refresh; done @@ -121,4 +131,6 @@ if [ -s swiftlang-${debversion}/debian/patches/series ]; then cd - fi -dpkg-source --create-empty-orig -b swiftlang-${debversion} +# create a source package +cd $staging_dir +dpkg-source --create-empty-orig -b ${package_dir} diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/copyright b/platforms/Linux/DEB/Shared/copyright similarity index 100% rename from platforms/Linux/DEB/Ubuntu/focal/debian/copyright rename to platforms/Linux/DEB/Shared/copyright diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/source-versions.sh b/platforms/Linux/DEB/Shared/versions.sh similarity index 96% rename from platforms/Linux/DEB/Ubuntu/focal/debian/source-versions.sh rename to platforms/Linux/DEB/Shared/versions.sh index ce6e192e..89992a89 100644 --- a/platforms/Linux/DEB/Ubuntu/focal/debian/source-versions.sh +++ b/platforms/Linux/DEB/Shared/versions.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash debversion=5.6.0 diff --git a/platforms/Linux/DEB/Ubuntu/README.md b/platforms/Linux/DEB/Ubuntu/README.md index 4fa66847..4d016f4e 100644 --- a/platforms/Linux/DEB/Ubuntu/README.md +++ b/platforms/Linux/DEB/Ubuntu/README.md @@ -1 +1,71 @@ ## Ubuntu + +Ubuntu uses the [Deb package format]() to install software packages. +The Swift Deb package can be built either by creating a Linux container image or manually on a computer running Ubuntu. + +There are separate directories for each version of Ubuntu. +The instructions below are applicable to all versions. + +## Importand file and directories + +**build_deb.sh** +Driver file to build the deb package + +**build_source.sh** +Driver file to build the deb source package (which is a step in `build_deb`) + +**patches/*.patch** +Any post-release patches that have not yet been merged upstream that are temporarily necessary to build Swift. + +**control.in** +Debian package metadata, including the `BuildDepends` and `Depends` definitions. + +**changelog** +Debian package changelog + +**rules** +Debian package recipe + +**Dockerfile** +Defines the base docker image to run the install scripts in. + +**docker-compose** +Defines docker compose tasks to drive the pacakge build in Docker. + +## Importand file and directories + +**Shared/version.sh** +Shell fragment versions.sh containing version information for all source components, and the Debian package upstream version (debversion). + +**Shared/copyright** +Copyright information + +### Building with docker-compose + +* to run the build end-to-end + +``` +docker-compose run build +``` + +* to enter the docker env in shell mode + +``` +docker-compose run shell +``` + +then you can run `./build_deb.sh` to run the build manually inside the docker + + +* to rebuild the base image + +``` +docker-compose build --pull +``` + +note this still uses the docker cache, so will rebuild only if the version of the underlying base image changed upstream + +### Building locally on an Ubuntu machine + +1. Install required development tools (see Dockerfile) +2. Run `./build_deb.sh` diff --git a/platforms/Linux/DEB/Ubuntu/focal/Dockerfile b/platforms/Linux/DEB/Ubuntu/focal/Dockerfile new file mode 100644 index 00000000..395a329c --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/Dockerfile @@ -0,0 +1,21 @@ +# This source file is part of the Swift.org open source project +# +# Copyright (c) 2022 Apple Inc. and the Swift project authors +# Licensed under Apache License v2.0 with Runtime Library Exception +# +# See http://swift.org/LICENSE.txt for license information +# See http://swift.org/CONTRIBUTORS.txt for Swift project authors + +FROM ubuntu:focal +LABEL PURPOSE="This image is configured to build Swift for the version of Ubuntu listed above" + +ARG DEBIAN_FRONTEND=noninteractive + +RUN apt-get update + +# Required deb packaging tools +RUN apt-get install -y curl devscripts equivs quilt tar + +# Optimization: Install Swift build requirements listed in the control file +ADD control.in /tmp/control.in +RUN mk-build-deps --install /tmp/control.in --tool 'apt-get -y -o Debug::pkgProblemResolver=yes --no-install-recommends' diff --git a/platforms/Linux/DEB/Ubuntu/focal/README.md b/platforms/Linux/DEB/Ubuntu/focal/README.md deleted file mode 100644 index bc18dec0..00000000 --- a/platforms/Linux/DEB/Ubuntu/focal/README.md +++ /dev/null @@ -1 +0,0 @@ -## focal diff --git a/platforms/Linux/DEB/Ubuntu/focal/build_deb.sh b/platforms/Linux/DEB/Ubuntu/focal/build_deb.sh new file mode 120000 index 00000000..376962a2 --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/build_deb.sh @@ -0,0 +1 @@ +../../Shared/build_deb.sh \ No newline at end of file diff --git a/platforms/Linux/DEB/Ubuntu/focal/build_source_package.sh b/platforms/Linux/DEB/Ubuntu/focal/build_source_package.sh new file mode 120000 index 00000000..2c947fb1 --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/build_source_package.sh @@ -0,0 +1 @@ +../../Shared/build_source_package.sh \ No newline at end of file diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/README.source b/platforms/Linux/DEB/Ubuntu/focal/debian/README.source deleted file mode 100644 index 93956a26..00000000 --- a/platforms/Linux/DEB/Ubuntu/focal/debian/README.source +++ /dev/null @@ -1,17 +0,0 @@ -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. - - -- Julien Blache Tue, 01 Mar 2022 15:04:23 -0800 - diff --git a/platforms/Linux/DEB/Ubuntu/focal/debian/control b/platforms/Linux/DEB/Ubuntu/focal/debian/control deleted file mode 100644 index 777f5b25..00000000 --- a/platforms/Linux/DEB/Ubuntu/focal/debian/control +++ /dev/null @@ -1,46 +0,0 @@ -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, libgcc-9-dev, libstdc++-9-dev, libz3-dev, uuid-dev, zlib1g-dev, - libxml2-dev, libcurl4-openssl-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/docker-compose.yaml b/platforms/Linux/DEB/Ubuntu/focal/docker-compose.yaml new file mode 100644 index 00000000..b7df03a7 --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/docker-compose.yaml @@ -0,0 +1,47 @@ +# This source file is part of the Swift.org open source project +# +# Copyright (c) 2021 Apple Inc. and the Swift project authors +# Licensed under Apache License v2.0 with Runtime Library Exception +# +# See http://swift.org/LICENSE.txt for license information +# See http://swift.org/CONTRIBUTORS.txt for Swift project authors + +# this setup is designed to build the RPM with docker +# usage: +# docker-compose -f platforms/Linux/DEB/ubuntu/focal/docker-compose.yaml build +# to shell into the container for debugging purposes: +# docker-compose -f platforms/Linux/DEB/ubuntu/focal/docker-compose.yaml run build + +version: "2" + +services: + + docker-setup: + image: ubuntu-focal-deb-builder + build: + context: . + dockerfile: Dockerfile + + common: &common + image: ubuntu-focal-deb-builder + depends_on: [docker-setup] + volumes: + - ../../Ubuntu/focal:/code/Ubuntu/focal:z + - ../../Shared:/code/Shared:z + - ./.output:/output:z + working_dir: /code/Ubuntu/focal + cap_drop: + - CAP_NET_RAW + - CAP_NET_BIND_SERVICE + + build: + <<: *common + command: /bin/bash -cl "./build_deb.sh" + + #createrepo: + # <<: *common + # command: /bin/bash -cl "./createrepo_rpm.sh" + + shell: + <<: *common + entrypoint: /bin/bash -l diff --git a/platforms/Linux/DEB/Ubuntu/focal/versions.sh b/platforms/Linux/DEB/Ubuntu/focal/versions.sh new file mode 120000 index 00000000..1edc8848 --- /dev/null +++ b/platforms/Linux/DEB/Ubuntu/focal/versions.sh @@ -0,0 +1 @@ +../../Shared/versions.sh \ No newline at end of file