Skip to content

Commit

Permalink
Merge pull request #90 from jblache/jblache/swift-deb-packaging
Browse files Browse the repository at this point in the history
Debian packaging for Ubuntu 20.04
  • Loading branch information
shahmishal authored May 9, 2022
2 parents 18dadb1 + 2fe2292 commit 9fe03fb
Show file tree
Hide file tree
Showing 16 changed files with 541 additions and 0 deletions.
16 changes: 16 additions & 0 deletions platforms/Linux/DEB/Ubuntu/focal/debian/README.source
Original file line number Diff line number Diff line change
@@ -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 <[email protected]> Tue, 01 Mar 2022 15:04:23 -0800
5 changes: 5 additions & 0 deletions platforms/Linux/DEB/Ubuntu/focal/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
swiftlang (5.6.0-1) focal; urgency=medium

* Debian packaging introduction for Swift 5.6.

-- Julien Blache <[email protected]> Tue, 15 Mar 2022 16:36:34 -0700
47 changes: 47 additions & 0 deletions platforms/Linux/DEB/Ubuntu/focal/debian/control.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Source: swiftlang
Section: devel
Priority: optional
Maintainer: Swift Maintainers <[email protected]>
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.
27 changes: 27 additions & 0 deletions platforms/Linux/DEB/Ubuntu/focal/debian/copyright
Original file line number Diff line number Diff line change
@@ -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: <preferred name and address to reach the upstream project>
Source: <url://example.com>

Files: *
Copyright: <years> <put author's name and email here>
<years> <likewise for another author>
License: TBD

Files: debian/*
Copyright: <years> <put author's name and email here>
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/
126 changes: 126 additions & 0 deletions platforms/Linux/DEB/Ubuntu/focal/debian/getsource.sh
Original file line number Diff line number Diff line change
@@ -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}
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Description: Enable parallel boostrap for CMake
CMake's bootstrap can be parallelized, but wasn't.
Author: Julien Blache <[email protected]>

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)
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>

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
}
Loading

0 comments on commit 9fe03fb

Please sign in to comment.