Skip to content

Commit 9fe03fb

Browse files
authored
Merge pull request #90 from jblache/jblache/swift-deb-packaging
Debian packaging for Ubuntu 20.04
2 parents 18dadb1 + 2fe2292 commit 9fe03fb

16 files changed

+541
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
swift for Debian
2+
---------------
3+
4+
The source package for Swift is composed of several different source components
5+
from different projects.
6+
7+
The shell fragment debian/source-versions.sh contains the version information
8+
for all source components, and the Debian package upstream version (debversion).
9+
10+
Fill in debian/source-versions.sh with the correct versions for all components,
11+
then run debian/getsource.sh to fetch the archives to the current directory.
12+
Source archives will be downloaded, renamed, and repacked if needed using
13+
mk-origtargz from devscripts, and any Debian patches will be refreshed; ensure
14+
devscripts and quilt are installed beforehand.
15+
16+
-- Swift Maintainers <[email protected]> Tue, 01 Mar 2022 15:04:23 -0800
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
swiftlang (5.6.0-1) focal; urgency=medium
2+
3+
* Debian packaging introduction for Swift 5.6.
4+
5+
-- Julien Blache <[email protected]> Tue, 15 Mar 2022 16:36:34 -0700
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Source: swiftlang
2+
Section: devel
3+
Priority: optional
4+
Maintainer: Swift Maintainers <[email protected]>
5+
Build-Depends: debhelper-compat (= 12), devscripts,
6+
clang, cmake, git, icu-devtools, ninja-build, pkg-config,
7+
libcurl4-openssl-dev, libedit-dev, libicu-dev, libncurses5-dev,
8+
libpython3-dev, libsqlite3-dev, libxml2-dev,
9+
python, python-six, python2-dev, python3-six, python3-distutils, python3-psutil,
10+
rsync, swig, systemtap-sdt-dev, tzdata, unzip, uuid-dev
11+
Standards-Version: 4.4.1
12+
Homepage: https://www.swift.org
13+
14+
Package: swiftlang
15+
Architecture: all
16+
Depends: swiftlang-x.y.z, ${misc:Depends}
17+
Description: Swift programming language
18+
Swift is a general-purpose programming language built using
19+
a modern approach to safety, performance, and software design
20+
patterns.
21+
.
22+
The goal of the Swift project is to create the best available
23+
language for uses ranging from systems programming, to mobile
24+
and desktop apps, scaling up to cloud services. Most
25+
importantly, Swift is designed to make writing and maintaining
26+
correct programs easier for the developer.
27+
.
28+
This package contains the convenience symlinks for the latest
29+
version of Swift.
30+
31+
Package: swiftlang-x.y.z
32+
Architecture: amd64 arm64
33+
Depends: ${shlibs:Depends}, ${misc:Depends},
34+
libc6-dev, libcurl4-openssl-dev, libgcc-9-dev, libstdc++-9-dev, libxml2-dev,
35+
libz3-dev, uuid-dev, zlib1g-dev,
36+
binutils, git, pkg-config, tzdata,
37+
python3
38+
Description: Swift programming language, release x.y.z
39+
Swift is a general-purpose programming language built using
40+
a modern approach to safety, performance, and software design
41+
patterns.
42+
.
43+
The goal of the Swift project is to create the best available
44+
language for uses ranging from systems programming, to mobile
45+
and desktop apps, scaling up to cloud services. Most
46+
importantly, Swift is designed to make writing and maintaining
47+
correct programs easier for the developer.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# TODO This copyright file needs to be filled out
2+
3+
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
4+
Upstream-Name: swift
5+
Upstream-Contact: <preferred name and address to reach the upstream project>
6+
Source: <url://example.com>
7+
8+
Files: *
9+
Copyright: <years> <put author's name and email here>
10+
<years> <likewise for another author>
11+
License: TBD
12+
13+
Files: debian/*
14+
Copyright: <years> <put author's name and email here>
15+
License: TBD
16+
17+
License: TBD
18+
This copyright file is a template and an active TODO item.
19+
20+
# Please also look if there are files or directories which have a
21+
# different copyright/license attached and list them here.
22+
# Please avoid picking licenses with terms that are more restrictive than the
23+
# packaged work, as it may make Debian's contributions unacceptable upstream.
24+
#
25+
# If you need, there are some extra license texts available in two places:
26+
# /usr/share/debhelper/dh_make/licenses/
27+
# /usr/share/common-licenses/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#!/bin/sh
2+
3+
# This helper script will fetch the Swift sources, save the
4+
# tarballs following the appropriate naming convention, and
5+
# build a Debian source package.
6+
7+
# You will need the devscripts and quilt packages installed
8+
# to run this script and build the packages following these
9+
# instructions.
10+
11+
# Create swiftlang-X.Y.Z, unpack the debian tarball within,
12+
# proceed to adding the appropriate entry to the Debian
13+
# changelog, edit debian/source-version.sh, then run this
14+
# script from the directory containing swiftlang-X.Y.Z.
15+
# $ mkdir swiftlang-X.Y.Z
16+
# $ cd swiftlang-X.Y.Z
17+
# $ tar xvaf ../swiftlang_A.B.C-D.debian.tar.xz
18+
# $ dch -v X.Y.Z-1
19+
# $ cd ..
20+
# $ swiftlang-X.Y.Z/debian/getsource.sh
21+
#
22+
# This will download all the necessary sources, unpack them
23+
# as required, refresh any Debian patches, then create the
24+
# Debian source package.
25+
26+
# If all is well, proceed with building the packages.
27+
# $ cd swiftlang-X.Y.Z
28+
# $ DEB_BUILD_OPTIONS=parallel=64 debuild
29+
30+
set -eu
31+
32+
. $(dirname $0)/source-versions.sh
33+
34+
get_component ()
35+
{
36+
component=$1
37+
url="$2"
38+
39+
dest=swiftlang_${debversion}.orig-${component}
40+
41+
echo "Downloading ${component} from ${url}"
42+
43+
case "${url}" in
44+
*.zip)
45+
tmpdest=${component}.zip
46+
dest=${dest}.tar.gz
47+
48+
curl -L -o ${tmpdest} "${url}"
49+
mk-origtargz --package swiftlang -v ${debversion} -c ${component} --rename --compression gzip ${tmpdest}
50+
;;
51+
52+
*.tar.gz)
53+
dest=${dest}.tar.gz
54+
curl -L -o ${dest} "${url}"
55+
;;
56+
57+
*.tar.xz)
58+
dest=${dest}.tar.xz
59+
curl -L -o ${dest} "${url}"
60+
;;
61+
62+
*.tar.bz2)
63+
dest=${dest}.tar.bz2
64+
curl -L -o ${dest} "${url}"
65+
;;
66+
67+
*)
68+
echo "Source archive not in a suitable format for Debian sources: ${url}" >&2
69+
exit 1
70+
esac
71+
72+
mkdir swiftlang-${debversion}/${component}
73+
tar -C swiftlang-${debversion}/${component} --strip-components=1 -axf ${dest}
74+
}
75+
76+
get_component swift https://github.com/apple/swift/archive/swift-${swift_version}.tar.gz
77+
get_component swift-corelibs-libdispatch https://github.com/apple/swift-corelibs-libdispatch/archive/swift-${swift_version}.tar.gz
78+
get_component swift-corelibs-foundation https://github.com/apple/swift-corelibs-foundation/archive/swift-${swift_version}.tar.gz
79+
get_component swift-integration-tests https://github.com/apple/swift-integration-tests/archive/swift-${swift_version}.tar.gz
80+
get_component swift-corelibs-xctest https://github.com/apple/swift-corelibs-xctest/archive/swift-${swift_version}.tar.gz
81+
get_component swiftpm https://github.com/apple/swift-package-manager/archive/swift-${swift_version}.tar.gz
82+
get_component llbuild https://github.com/apple/swift-llbuild/archive/swift-${swift_version}.tar.gz
83+
get_component cmark https://github.com/apple/swift-cmark/archive/swift-${swift_version}.tar.gz
84+
get_component swift-xcode-playground-support https://github.com/apple/swift-xcode-playground-support/archive/swift-${swift_version}.tar.gz
85+
get_component sourcekit-lsp https://github.com/apple/sourcekit-lsp/archive/swift-${swift_version}.tar.gz
86+
get_component indexstore-db https://github.com/apple/indexstore-db/archive/swift-${swift_version}.tar.gz
87+
get_component llvm-project https://github.com/apple/llvm-project/archive/swift-${swift_version}.tar.gz
88+
get_component swift-tools-support-core https://github.com/apple/swift-tools-support-core/archive/swift-${swift_version}.tar.gz
89+
get_component swift-argument-parser https://github.com/apple/swift-argument-parser/archive/${swift_argument_parser_version}.tar.gz
90+
get_component swift-driver https://github.com/apple/swift-driver/archive/swift-${swift_version}.tar.gz
91+
get_component icu https://github.com/unicode-org/icu/archive/release-${icu_version}.tar.gz
92+
get_component swift-crypto https://github.com/apple/swift-crypto/archive/refs/tags/${swift_crypto_version}.tar.gz
93+
get_component ninja https://github.com/ninja-build/ninja/archive/refs/tags/v${ninja_version}.tar.gz
94+
get_component cmake https://github.com/KitWare/CMake/archive/refs/tags/v${cmake_version}.tar.gz
95+
get_component swift-syntax https://github.com/apple/swift-syntax/archive/swift-${swift_version}.tar.gz
96+
get_component yams https://github.com/jpsim/Yams/archive/${yams_version}.tar.gz
97+
get_component swift-atomics https://github.com/apple/swift-atomics/archive/${swift_atomics_version}.tar.gz
98+
get_component swift-cmark-gfm https://github.com/apple/swift-cmark/archive/swift-${swift_version}-gfm.tar.gz
99+
get_component swift-docc https://github.com/apple/swift-docc/archive/swift-${swift_version}.tar.gz
100+
get_component swift-docc-render-artifact https://github.com/apple/swift-docc-render-artifact/archive/swift-${swift_version}.tar.gz
101+
get_component swift-docc-symbolkit https://github.com/apple/swift-docc-symbolkit/archive/swift-${swift_version}.tar.gz
102+
get_component swift-collections https://github.com/apple/swift-collections/archive/${swift_collections_version}.tar.gz
103+
get_component swift-numerics https://github.com/apple/swift-numerics/archive/${swift_numerics_version}.tar.gz
104+
get_component swift-system https://github.com/apple/swift-system/archive/${swift_system_version}.tar.gz
105+
get_component swift-nio https://github.com/apple/swift-nio/archive/${swift_nio_version}.tar.gz
106+
get_component swift-nio-ssl https://github.com/apple/swift-nio-ssl/archive/${swift_nio_ssl_version}.tar.gz
107+
get_component swift-format https://github.com/apple/swift-format/archive/swift-${swift_version}.tar.gz
108+
get_component swift-lmdb https://github.com/apple/swift-lmdb/archive/swift-${swift_version}.tar.gz
109+
get_component swift-markdown https://github.com/apple/swift-markdown/archive/swift-${swift_version}.tar.gz
110+
111+
# Refresh patches, if any
112+
if [ -s swiftlang-${debversion}/debian/patches/series ]; then
113+
cd swiftlang-${debversion}
114+
115+
export QUILT_PATCHES=debian/patches
116+
export QUILT_REFRESH_ARGS="-p ab --no-timestamps --no-index"
117+
118+
while quilt push; do quilt refresh; done
119+
quilt pop -a
120+
121+
cd -
122+
fi
123+
124+
cp -f swiftlang-${debversion}/debian/control.in swiftlang-${debversion}/debian/control
125+
126+
dpkg-source --create-empty-orig -b swiftlang-${debversion}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Description: Make target installation directory a command line option
2+
Use a variable for the install prefix, so we can specify it at build
3+
time on the command line.
4+
Author: Julien Blache <[email protected]>
5+
6+
Index: swiftlang-5.6.0/swift/utils/build-presets.ini
7+
===================================================================
8+
--- swiftlang-5.6.0.orig/swift/utils/build-presets.ini
9+
+++ swiftlang-5.6.0/swift/utils/build-presets.ini
10+
@@ -831,7 +831,7 @@ install-swiftpm
11+
install-swift-driver
12+
install-xctest
13+
install-libicu
14+
-install-prefix=/usr
15+
+install-prefix=%(install_prefix)s
16+
install-libcxx
17+
install-sourcekit-lsp
18+
install-swiftdocc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Description: Enable parallel boostrap for CMake
2+
CMake's bootstrap can be parallelized, but wasn't.
3+
Author: Julien Blache <[email protected]>
4+
5+
Index: swiftlang-5.6.0/swift/utils/swift_build_support/swift_build_support/cmake.py
6+
===================================================================
7+
--- swiftlang-5.6.0.orig/swift/utils/swift_build_support/swift_build_support/cmake.py
8+
+++ swiftlang-5.6.0/swift/utils/swift_build_support/swift_build_support/cmake.py
9+
@@ -267,8 +267,10 @@ class CMake(object):
10+
11+
cwd = os.getcwd()
12+
os.chdir(cmake_build_dir)
13+
- shell.call_without_sleeping([cmake_bootstrap, '--no-qt-gui', '--',
14+
- '-DCMAKE_USE_OPENSSL=OFF'], echo=True)
15+
+ shell.call_without_sleeping([cmake_bootstrap, '--no-qt-gui',
16+
+ '--parallel=%s' % self.args.build_jobs,
17+
+ '--', '-DCMAKE_USE_OPENSSL=OFF'],
18+
+ echo=True)
19+
shell.call_without_sleeping(['make', '-j%s' % self.args.build_jobs],
20+
echo=True)
21+
os.chdir(cwd)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
Description: Fix integration tests to use correct package path
2+
Remove hardcoded usr paths and pass the correct package path to
3+
the tests.
4+
Author: Julien Blache <[email protected]>
5+
6+
Index: swiftlang-5.6.0/swift-integration-tests/lit.cfg
7+
===================================================================
8+
--- swiftlang-5.6.0.orig/swift-integration-tests/lit.cfg
9+
+++ swiftlang-5.6.0/swift-integration-tests/lit.cfg
10+
@@ -175,31 +175,31 @@ else:
11+
12+
swift_path = lit_config.params.get(
13+
"swift",
14+
- os.path.join(package_path, "usr", "bin", "swift"))
15+
+ os.path.join(package_path, "bin", "swift"))
16+
lit_config.note("testing using 'swift': %r" % (swift_path,))
17+
18+
swiftc_path = lit_config.params.get(
19+
"swiftc",
20+
- os.path.join(package_path, "usr", "bin", "swiftc"))
21+
+ os.path.join(package_path, "bin", "swiftc"))
22+
lit_config.note("testing using 'swiftc': %r" % (swiftc_path,))
23+
24+
lldb_path = lit_config.params.get(
25+
"lldb",
26+
- os.path.join(package_path, "usr", "bin", "lldb"))
27+
+ os.path.join(package_path, "bin", "lldb"))
28+
lit_config.note("testing using 'lldb': {}".format(lldb_path))
29+
30+
repl_swift_dummy_path = lit_config.params.get(
31+
"repl_swift",
32+
- os.path.join(package_path, "usr", "bin", "repl_swift"))
33+
+ os.path.join(package_path, "bin", "repl_swift"))
34+
lit_config.note("testing using 'repl_swift': {}".format(repl_swift_dummy_path))
35+
36+
sourcekit_lsp_path = lit_config.params.get(
37+
"sourcekit-lsp",
38+
- os.path.join(package_path, "usr", "bin", "sourcekit-lsp"))
39+
+ os.path.join(package_path, "bin", "sourcekit-lsp"))
40+
41+
docc_path = lit_config.params.get(
42+
"docc",
43+
- os.path.join(package_path, "usr", "bin", "docc"))
44+
+ os.path.join(package_path, "bin", "docc"))
45+
lit_config.note("testing using 'docc': {}".format(docc_path))
46+
47+
# Verify they exist.
48+
Index: swiftlang-5.6.0/swift-integration-tests/test-snapshot-binaries/test-rpath-linux.py
49+
===================================================================
50+
--- swiftlang-5.6.0.orig/swift-integration-tests/test-snapshot-binaries/test-rpath-linux.py
51+
+++ swiftlang-5.6.0/swift-integration-tests/test-snapshot-binaries/test-rpath-linux.py
52+
@@ -4,26 +4,26 @@
53+
# CHECK: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}$ORIGIN/../lib/swift/linux
54+
#
55+
# Tests that DT_RUNPATH is correct for the Swift stdlib and other libraries on Linux.
56+
-# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/libswiftCore.so | %{FileCheck} --check-prefix CHECK-CORE %s
57+
+# RUN: %{readelf} -d %{package_path}/lib/swift/linux/libswiftCore.so | %{FileCheck} --check-prefix CHECK-CORE %s
58+
# CHECK-CORE-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux
59+
#
60+
-# RUN: %{readelf} -d %{package_path}/usr/lib/libsourcekitdInProc.so | %{FileCheck} --check-prefix CHECK-SK %s
61+
+# RUN: %{readelf} -d %{package_path}/lib/libsourcekitdInProc.so | %{FileCheck} --check-prefix CHECK-SK %s
62+
# CHECK-SK-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux
63+
#
64+
-# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/libswiftRemoteMirror.so | %{FileCheck} --check-prefix CHECK-RM %s
65+
+# RUN: %{readelf} -d %{package_path}/lib/swift/linux/libswiftRemoteMirror.so | %{FileCheck} --check-prefix CHECK-RM %s
66+
# CHECK-RM-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux
67+
#
68+
-# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/libswift_Differentiation.so | %{FileCheck} --check-prefix CHECK-SD %s
69+
+# RUN: %{readelf} -d %{package_path}/lib/swift/linux/libswift_Differentiation.so | %{FileCheck} --check-prefix CHECK-SD %s
70+
# CHECK-SD-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux
71+
#
72+
-# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/lib_InternalSwiftSyntaxParser.so | %{FileCheck} --check-prefix CHECK-SP %s
73+
+# RUN: %{readelf} -d %{package_path}/lib/swift/linux/lib_InternalSwiftSyntaxParser.so | %{FileCheck} --check-prefix CHECK-SP %s
74+
# CHECK-SP-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux
75+
#
76+
-# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/libswiftGlibc.so | %{FileCheck} --check-prefix CHECK-SG %s
77+
+# RUN: %{readelf} -d %{package_path}/lib/swift/linux/libswiftGlibc.so | %{FileCheck} --check-prefix CHECK-SG %s
78+
# CHECK-SG-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux
79+
#
80+
-# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/libswiftSwiftOnoneSupport.so | %{FileCheck} --check-prefix CHECK-SON %s
81+
+# RUN: %{readelf} -d %{package_path}/lib/swift/linux/libswiftSwiftOnoneSupport.so | %{FileCheck} --check-prefix CHECK-SON %s
82+
# CHECK-SON-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux
83+
#
84+
-# RUN: %{readelf} -d %{package_path}/usr/lib/libswiftDemangle.so | %{FileCheck} --check-prefix CHECK-SDE %s
85+
+# RUN: %{readelf} -d %{package_path}/lib/libswiftDemangle.so | %{FileCheck} --check-prefix CHECK-SDE %s
86+
# CHECK-SDE-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux
87+
Index: swiftlang-5.6.0/swift/utils/build-script-impl
88+
===================================================================
89+
--- swiftlang-5.6.0.orig/swift/utils/build-script-impl
90+
+++ swiftlang-5.6.0/swift/utils/build-script-impl
91+
@@ -3463,8 +3463,10 @@ function build_and_test_installable_pack
92+
93+
if [[ "${host}" == "macosx-"* ]] || [[ "${host}" == "merged-hosts" ]]; then
94+
PKG_TESTS_SANDBOX="${PKG_TESTS_SANDBOX_PARENT}"/"${TOOLCHAIN_PREFIX}"
95+
+ PKG_TESTS_PKG_DIR="${PKG_TESTS_SANDBOX}"
96+
else # Linux
97+
PKG_TESTS_SANDBOX="${PKG_TESTS_SANDBOX_PARENT}"
98+
+ PKG_TESTS_PKG_DIR="${PKG_TESTS_SANDBOX}/${host_install_prefix}"
99+
fi
100+
101+
LIT_EXECUTABLE_PATH="${LLVM_SOURCE_DIR}/utils/lit/lit.py"
102+
@@ -3479,7 +3481,7 @@ function build_and_test_installable_pack
103+
TIMEOUT_ARGS=--timeout=1200 # 20 minutes
104+
fi
105+
with_pushd "${PKG_TESTS_SOURCE_DIR}" \
106+
- 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}
107+
+ 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}
108+
fi
109+
fi
110+
}

0 commit comments

Comments
 (0)