Skip to content

Commit 5e1f0d6

Browse files
committed
centos8 rpm spec
motivation: rpm installer for centos8 changes: initial setup: spec, patches, driver script and docker for centos 8
1 parent b150da7 commit 5e1f0d6

File tree

8 files changed

+297
-0
lines changed

8 files changed

+297
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.out
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM centos:8
2+
LABEL PURPOSE="This image is configured to build Swift for the version of CentOS listed above"
3+
4+
WORKDIR /root
5+
6+
RUN yum -y update
7+
8+
# RPM and yum development tools
9+
RUN yum install -y rpmdevtools yum-utils
10+
11+
# Configure powertools
12+
RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
13+
RUN yum config-manager --set-enabled powertools
14+
15+
# Add the spec
16+
RUN mkdir -p /root/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
17+
ADD swift-lang.spec /root/rpmbuild/SPECS/swift-lang.spec
18+
19+
# Install all the dependencies needed to build Swift from the spec file itself
20+
RUN yum-builddep -y /root/rpmbuild/SPECS/swift-lang.spec
21+
22+
# Get the sources for Swift as defined in the spec file
23+
RUN spectool -g -R /root/rpmbuild/SPECS/swift-lang.spec
24+
25+
# Add the patches
26+
ADD patches/*.patch /root/rpmbuild/SOURCES/
27+
28+
# Add the driver script
29+
ADD build_rpm.sh /root/build_rpm.sh
30+
RUN chmod +x /root/build_rpm.sh
31+
32+
CMD ["/root/build_rpm.sh"]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
# This script assumes it's running in a container as root
4+
# and that /out is mounted to a directory on the local
5+
# filesystem so the build output and artifacts can be
6+
# copied out and used
7+
8+
OUTDIR=/out
9+
if [[ ! -d "$OUTDIR" ]]
10+
then
11+
echo "$OUTDIR does not exist, so no place to copy the artifacts!"
12+
exit 1
13+
fi
14+
15+
# Always make sure we're up to date
16+
yum update -y
17+
18+
# Now we proceed to build Swift. If this is successful, we
19+
# will have two files: a SRPM file which contains the source files
20+
# as well as a regular RPM file that can be installed via `dnf' or `yum'
21+
pushd $HOME/rpmbuild/SPECS
22+
rpmbuild -ba ./swift-lang.spec 2>&1 | tee $HOME/build-output.txt
23+
popd
24+
25+
# Include the build log which can be used to determine what went
26+
# wrong if there are no artifacts
27+
cp $HOME/build-output.txt $OUTDIR
28+
cp $HOME/rpmbuild/SRPMS/* $OUTDIR
29+
cp $HOME/rpmbuild/RPMS/`uname -i`/* $OUTDIR
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
diff -Naur swift-orig/utils/build-presets.ini swift/utils/build-presets.ini
3+
--- swift-orig/utils/build-presets.ini 2021-01-11 09:24:03.000000000 -0600
4+
+++ swift/utils/build-presets.ini 2021-01-14 15:42:31.063141040 -0600
5+
@@ -771,7 +771,6 @@
6+
libicu
7+
libcxx
8+
9+
-build-ninja
10+
install-llvm
11+
install-swift
12+
install-lldb
13+
@@ -787,10 +786,6 @@
14+
build-swift-static-sdk-overlay
15+
build-swift-stdlib-unittest-extra
16+
17+
-# Executes the lit tests for the installable package that is created
18+
-# Assumes the swift-integration-tests repo is checked out
19+
-
20+
-test-installable-package
21+
22+
# Build the benchmarks against the toolchain.
23+
toolchain-benchmarks
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
diff --git a/llvm-project/compiler-rt/lib/hwasan/scripts/hwasan_symbolize b/llvm-project/compiler-rt/lib/hwasan/scripts/hwasan_symbolize
2+
index dd5f859561e1..21d18998cf31 100755
3+
--- a/llvm-project/compiler-rt/lib/hwasan/scripts/hwasan_symbolize
4+
+++ b/llvm-project/compiler-rt/lib/hwasan/scripts/hwasan_symbolize
5+
@@ -1,4 +1,4 @@
6+
-#!/usr/bin/env python
7+
+#!/usr/bin/env python3
8+
#===- lib/hwasan/scripts/hwasan_symbolize ----------------------------------===#
9+
#
10+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
diff --git a/swift/utils/api_checker/swift-api-checker.py b/swift/utils/api_checker/swift-api-checker.py
2+
index 8ed16b4abf7..0b11a4bb83a 100755
3+
--- a/swift/utils/api_checker/swift-api-checker.py
4+
+++ b/swift/utils/api_checker/swift-api-checker.py
5+
@@ -1,4 +1,4 @@
6+
-#!/usr/bin/env python
7+
+#!/usr/bin/env python3
8+
9+
from __future__ import print_function
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Building Swift on CentOS Linux
2+
3+
4+
### building with docker
5+
6+
7+
Build the builder docker image, this will download the sources
8+
9+
```
10+
docker build . -t rpm-builder
11+
```
12+
13+
Run the builder, this will run the build
14+
15+
```
16+
docker run -v `pwd`/.out:/out rpm-builder
17+
```
18+
19+
20+
Open Issues / Introduction
21+
* the swift release version should be an argument
22+
* the versions of source packages are no pinned to the swift release version (eg yams) should come from an external file, likely one per swift release version
23+
* the list of build requirements (BuildRequires) and especially requirements (Requires) should come from an external file, likely one per swift release version (which we can use it to also drive documentation)
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
%global debug_package %{nil}
2+
%global swifttag 5.5-RELEASE
3+
%global swiftbuild swift-source
4+
%global icu_version 65-1
5+
%global yams_version 4.0.2
6+
%global sap_version 0.4.3
7+
%global swift_crypto_version 1.1.5
8+
9+
Name: swift-lang
10+
Version: 5.5
11+
Release: 1%{?dist}
12+
Summary: Apple's Swift programming language
13+
License: ASL 2.0 and Unicode
14+
URL: https://swift.org
15+
16+
Source0: https://github.com/apple/swift/archive/swift-%{swifttag}.tar.gz#/swift.tar.gz
17+
Source1: https://github.com/apple/swift-corelibs-libdispatch/archive/swift-%{swifttag}.tar.gz#/corelibs-libdispatch.tar.gz
18+
Source2: https://github.com/apple/swift-corelibs-foundation/archive/swift-%{swifttag}.tar.gz#/corelibs-foundation.tar.gz
19+
Source3: https://github.com/apple/swift-integration-tests/archive/swift-%{swifttag}.tar.gz#/swift-integration-tests.tar.gz
20+
Source4: https://github.com/apple/swift-corelibs-xctest/archive/swift-%{swifttag}.tar.gz#/corelibs-xctest.tar.gz
21+
Source5: https://github.com/apple/swift-package-manager/archive/swift-%{swifttag}.tar.gz#/package-manager.tar.gz
22+
Source6: https://github.com/apple/swift-llbuild/archive/swift-%{swifttag}.tar.gz#/llbuild.tar.gz
23+
Source7: https://github.com/apple/swift-cmark/archive/swift-%{swifttag}.tar.gz#/cmark.tar.gz
24+
Source8: https://github.com/apple/swift-xcode-playground-support/archive/swift-%{swifttag}.tar.gz#/swift-xcode-playground-support.tar.gz
25+
Source9: https://github.com/apple/sourcekit-lsp/archive/swift-%{swifttag}.tar.gz#/sourcekit-lsp.tar.gz
26+
Source10: https://github.com/apple/indexstore-db/archive/swift-%{swifttag}.tar.gz#/indexstore-db.tar.gz
27+
Source11: https://github.com/apple/llvm-project/archive/swift-%{swifttag}.tar.gz#/llvm-project.tar.gz
28+
Source12: https://github.com/apple/swift-tools-support-core/archive/swift-%{swifttag}.tar.gz#/swift-tools-support-core.tar.gz
29+
Source13: https://github.com/apple/swift-argument-parser/archive/%{sap_version}.tar.gz
30+
Source14: https://github.com/apple/swift-driver/archive/swift-%{swifttag}.tar.gz#/swift-driver.tar.gz
31+
Source15: https://github.com/unicode-org/icu/archive/release-%{icu_version}.tar.gz
32+
Source16: https://github.com/apple/swift-syntax/archive/swift-%{swifttag}.zip#/swift-syntax.tar.gz
33+
Source17: https://github.com/jpsim/Yams/archive/%{yams_version}.zip
34+
Source18: https://github.com/apple/swift-crypto/archive/refs/tags/%{swift_crypto_version}.tar.gz
35+
36+
Patch0: patches/build-presets.patch
37+
Patch1: patches/swift-api-checker.patch
38+
Patch2: patches/hwasan_symbolize.patch
39+
40+
BuildRequires: autoconf
41+
BuildRequires: clang
42+
BuildRequires: cmake
43+
BuildRequires: diffutils
44+
BuildRequires: git
45+
BuildRequires: glibc-static
46+
BuildRequires: libbsd-devel
47+
BuildRequires: libcurl-devel
48+
BuildRequires: libedit-devel
49+
BuildRequires: libicu-devel
50+
BuildRequires: libstdc++-static
51+
BuildRequires: libtool
52+
BuildRequires: libuuid-devel
53+
BuildRequires: libxml2-devel
54+
BuildRequires: make
55+
BuildRequires: ncurses-devel
56+
BuildRequires: ninja-build
57+
BuildRequires: pcre-devel
58+
BuildRequires: python2
59+
BuildRequires: python2-devel
60+
BuildRequires: python2-six
61+
BuildRequires: python3
62+
BuildRequires: python3-six
63+
BuildRequires: python3-pexpect
64+
BuildRequires: platform-python-devel
65+
BuildRequires: sqlite-devel
66+
BuildRequires: swig
67+
BuildRequires: rsync
68+
BuildRequires: tar
69+
BuildRequires: which
70+
71+
Requires: binutils
72+
Requires: gcc
73+
Requires: git
74+
Requires: glibc-static
75+
Requires: libbsd-devel
76+
Requires: libedit
77+
Requires: libedit-devel
78+
Requires: libicu-devel
79+
Requires: libstdc++-static
80+
Requires: pkg-config
81+
Requires: python3
82+
Requires: sqlite
83+
Requires: zlib-devel
84+
85+
ExclusiveArch: x86_64 aarch64
86+
87+
%description
88+
Swift is a general-purpose programming language built using
89+
a modern approach to safety, performance, and software design
90+
patterns.
91+
92+
The goal of the Swift project is to create the best available
93+
language for uses ranging from systems programming, to mobile
94+
and desktop apps, scaling up to cloud services. Most
95+
importantly, Swift is designed to make writing and maintaining
96+
correct programs easier for the developer.
97+
98+
%prep
99+
# FIXME: what does -a 0 -a 1 etc do?
100+
%setup -q -c -n %{swiftbuild} -a 0 -a 1 -a 2 -a 3 -a 4 -a 5 -a 6 -a 7 -a 8 -a 9 -a 10 -a 11 -a 12 -a 13 -a 14 -a 15 -a 16 -a 17 -a 18
101+
# The Swift build script requires directories to be named
102+
# in a specific way so renaming the source directories is
103+
# necessary
104+
mv swift-cmark-swift-%{swifttag} cmark
105+
mv swift-corelibs-foundation-swift-%{swifttag} swift-corelibs-foundation
106+
mv swift-corelibs-libdispatch-swift-%{swifttag} swift-corelibs-libdispatch
107+
mv swift-corelibs-xctest-swift-%{swifttag} swift-corelibs-xctest
108+
mv swift-integration-tests-swift-%{swifttag} swift-integration-tests
109+
mv swift-llbuild-swift-%{swifttag} llbuild
110+
mv swift-package-manager-swift-%{swifttag} swiftpm
111+
mv swift-swift-%{swifttag} swift
112+
mv swift-xcode-playground-support-swift-%{swifttag} swift-xcode-playground-support
113+
mv sourcekit-lsp-swift-%{swifttag} sourcekit-lsp
114+
mv indexstore-db-swift-%{swifttag} indexstore-db
115+
mv llvm-project-swift-%{swifttag} llvm-project
116+
mv swift-syntax-swift-%{swifttag} swift-syntax
117+
mv swift-tools-support-core-swift-%{swifttag} swift-tools-support-core
118+
mv swift-argument-parser-%{sap_version} swift-argument-parser
119+
mv swift-driver-swift-%{swifttag} swift-driver
120+
mv swift-crypto-%{swift_crypto_version} swift-crypto
121+
122+
# ICU
123+
mv icu-release-%{icu_version} icu
124+
125+
# Yams
126+
mv Yams-%{yams_version} yams
127+
128+
# Narrow down presets
129+
%patch0 -p0
130+
131+
# FIXME: fix upstream instead of patch
132+
# Python path hard coded in swift-api-checker
133+
%patch1 -p1
134+
135+
# FIXME: fix upstream instead of patch
136+
# Python path hard coded in hwasan_symbolize
137+
%patch2 -p1
138+
139+
# Fix python to python3
140+
ln -s /usr/bin/python3 /usr/bin/python
141+
142+
%build
143+
export VERBOSE=1
144+
145+
# Run the build
146+
swift/utils/build-script --preset=buildbot_linux,no_test install_destdir=%{_builddir} installable_package=%{_builddir}/swift-%{version}-centos8.tar.gz
147+
148+
%install
149+
mkdir -p %{buildroot}%{_libexecdir}/swift/
150+
cp -r %{_builddir}/usr/* %{buildroot}%{_libexecdir}/swift
151+
mkdir -p %{buildroot}%{_bindir}
152+
ln -fs %{_libexecdir}/swift/bin/swift %{buildroot}%{_bindir}/swift
153+
ln -fs %{_libexecdir}/swift/bin/swiftc %{buildroot}%{_bindir}/swiftc
154+
ln -fs %{_libexecdir}/swift/bin/sourcekit-lsp %{buildroot}%{_bindir}/sourcekit-lsp
155+
mkdir -p %{buildroot}%{_mandir}/man1
156+
cp %{_builddir}/usr/share/man/man1/swift.1 %{buildroot}%{_mandir}/man1/swift.1
157+
158+
%files
159+
%license swift/LICENSE.txt
160+
%{_bindir}/swift
161+
%{_bindir}/swiftc
162+
%{_bindir}/sourcekit-lsp
163+
%{_mandir}/man1/swift.1.gz
164+
%{_libexecdir}/swift/
165+
166+
%post -p /sbin/ldconfig
167+
%postun -p /sbin/ldconfig
168+
169+
170+
%changelog

0 commit comments

Comments
 (0)