Skip to content

Commit cf610aa

Browse files
authored
Merge pull request swiftlang#41 from tomerd/centos7
add centos 7 RPM spec
2 parents 9363e6b + 3f1f64b commit cf610aa

File tree

8 files changed

+327
-0
lines changed

8 files changed

+327
-0
lines changed

Diff for: platforms/Linux/centos/7/.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.output

Diff for: platforms/Linux/centos/7/Dockerfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This source file is part of the Swift.org open source project
2+
#
3+
# Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
# Licensed under Apache License v2.0 with Runtime Library Exception
5+
#
6+
# See http://swift.org/LICENSE.txt for license information
7+
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8+
9+
FROM centos:7
10+
LABEL PURPOSE="This image is configured to build Swift for the version of CentOS listed above"
11+
12+
RUN yum -y update
13+
14+
# RPM and yum development tools
15+
RUN yum install -y rpmdevtools yum-utils
16+
17+
# Configure epel
18+
RUN yum install -y epel-release centos-release-scl
19+
20+
# Optimization: Install all the dependencies needed to build Swift from the spec file itself
21+
ADD swift-lang.spec /tmp/swift-lang.spec
22+
RUN touch /tmp/metadata.inc # fake metadata is okay for this optimization
23+
RUN cd /tmp && yum-builddep -y swift-lang.spec

Diff for: platforms/Linux/centos/7/README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Building Swift on CentOS Linux
2+
3+
4+
### building with docker-compose
5+
6+
* to run the build end-to-end
7+
8+
```
9+
docker-compose run build
10+
```
11+
12+
* to enter the docker env in shell mode
13+
14+
```
15+
docker-compose run shell
16+
```
17+
18+
then you can run `./build_rpm.sh` to run the build manually inside the docker
19+
20+
21+
* to rebuild the base image
22+
23+
```
24+
docker-compose build --pull
25+
```
26+
27+
note this still uses the docker cache, so will rebuild only if the version of the underlying base image changed upstream
28+
29+
30+
### Open Issues / TODO
31+
* 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)

Diff for: platforms/Linux/centos/7/build_rpm.sh

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This source file is part of the Swift.org open source project
2+
#
3+
# Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
# Licensed under Apache License v2.0 with Runtime Library Exception
5+
#
6+
# See http://swift.org/LICENSE.txt for license information
7+
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8+
9+
#!/usr/bin/env bash
10+
11+
set -ex
12+
13+
OUTDIR=/output
14+
if [[ ! -d "$OUTDIR" ]]; then
15+
echo "$OUTDIR does not exist, so no place to copy the artifacts!"
16+
exit 1
17+
fi
18+
19+
# always make sure we're up to date
20+
yum update -y
21+
22+
# prepare direcoties
23+
mkdir -p $HOME/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
24+
25+
# Add the spec
26+
cp swift-lang.spec $HOME/rpmbuild/SPECS/
27+
# Add the metadata for this swift version
28+
cp /shared/metadata.inc $HOME/rpmbuild/SPECS/
29+
# Add any patches
30+
cp patches/*.patch $HOME/rpmbuild/SOURCES/
31+
32+
pushd $HOME/rpmbuild/SPECS
33+
# install all the dependencies needed to build Swift from the spec file itself
34+
yum-builddep -y ./swift-lang.spec
35+
# get the sources for Swift as defined in the spec file
36+
spectool -g -R ./swift-lang.spec
37+
# Now we proceed to build Swift. If this is successful, we
38+
# will have two files: a SRPM file which contains the source files
39+
# as well as a regular RPM file that can be installed via `dnf' or `yum'
40+
rpmbuild -ba ./swift-lang.spec 2>&1 | tee /root/build-output.txt
41+
popd
42+
43+
# Include the build log which can be used to determine what went
44+
# wrong if there are no artifacts
45+
cp $HOME/build-output.txt $OUTDIR
46+
cp $HOME/rpmbuild/SRPMS/* $OUTDIR
47+
cp $HOME/rpmbuild/RPMS/`uname -i`/* $OUTDIR

Diff for: platforms/Linux/centos/7/docker-compose.yaml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This source file is part of the Swift.org open source project
2+
#
3+
# Copyright (c) 2021 Apple Inc. and the Swift project authors
4+
# Licensed under Apache License v2.0 with Runtime Library Exception
5+
#
6+
# See http://swift.org/LICENSE.txt for license information
7+
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8+
9+
# this setup is designed to build the RPM with docker
10+
# usage:
11+
# docker-compose -f platforms/Linux/centos/7/docker-compose.yaml build
12+
# to shell into the container for debugging purposes:
13+
# docker-compose -f platforms/Linux/centos/7/docker-compose.yaml run build
14+
15+
version: "2"
16+
17+
services:
18+
19+
docker-setup:
20+
image: centos7-rpm-builder
21+
build:
22+
context: .
23+
dockerfile: Dockerfile
24+
25+
common: &common
26+
image: centos7-rpm-builder
27+
depends_on: [docker-setup]
28+
# https://bugs.swift.org/browse/SR-15343
29+
security_opt:
30+
- seccomp:unconfined
31+
volumes:
32+
- .:/code:z
33+
- ../../shared/RPM:/shared:ro
34+
- ./.output:/output:z
35+
working_dir: /code
36+
cap_drop:
37+
- CAP_NET_RAW
38+
- CAP_NET_BIND_SERVICE
39+
40+
build:
41+
<<: *common
42+
command: /bin/bash -cl "./build_rpm.sh"
43+
44+
shell:
45+
<<: *common
46+
entrypoint: /bin/bash -l
+10
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.
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

Diff for: platforms/Linux/centos/7/swift-lang.spec

+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
%include metadata.inc
2+
3+
%global debug_package %{nil}
4+
5+
Name: %{package_name}
6+
Version: %{package_version}
7+
Release: 1%{?dist}
8+
Summary: %{package_summary}
9+
License: %{package_license}
10+
URL: %{package_url}
11+
12+
Source0: https://github.com/apple/swift/archive/swift-%{swift_version}.tar.gz#/swift.tar.gz
13+
Source1: https://github.com/apple/swift-corelibs-libdispatch/archive/swift-%{swift_version}.tar.gz#/corelibs-libdispatch.tar.gz
14+
Source2: https://github.com/apple/swift-corelibs-foundation/archive/swift-%{swift_version}.tar.gz#/corelibs-foundation.tar.gz
15+
Source3: https://github.com/apple/swift-integration-tests/archive/swift-%{swift_version}.tar.gz#/swift-integration-tests.tar.gz
16+
Source4: https://github.com/apple/swift-corelibs-xctest/archive/swift-%{swift_version}.tar.gz#/corelibs-xctest.tar.gz
17+
Source5: https://github.com/apple/swift-package-manager/archive/swift-%{swift_version}.tar.gz#/package-manager.tar.gz
18+
Source6: https://github.com/apple/swift-llbuild/archive/swift-%{swift_version}.tar.gz#/llbuild.tar.gz
19+
Source7: https://github.com/apple/swift-cmark/archive/swift-%{swift_version}.tar.gz#/cmark.tar.gz
20+
Source8: https://github.com/apple/swift-xcode-playground-support/archive/swift-%{swift_version}.tar.gz#/swift-xcode-playground-support.tar.gz
21+
Source9: https://github.com/apple/sourcekit-lsp/archive/swift-%{swift_version}.tar.gz#/sourcekit-lsp.tar.gz
22+
Source10: https://github.com/apple/indexstore-db/archive/swift-%{swift_version}.tar.gz#/indexstore-db.tar.gz
23+
Source11: https://github.com/apple/llvm-project/archive/swift-%{swift_version}.tar.gz#/llvm-project.tar.gz
24+
Source12: https://github.com/apple/swift-tools-support-core/archive/swift-%{swift_version}.tar.gz#/swift-tools-support-core.tar.gz
25+
Source13: https://github.com/apple/swift-argument-parser/archive/%{swift_argument_parser_version}.tar.gz#/swift-argument-parser.tar.gz
26+
Source14: https://github.com/apple/swift-driver/archive/swift-%{swift_version}.tar.gz#/swift-driver.tar.gz
27+
Source15: https://github.com/unicode-org/icu/archive/release-%{icu_version}.tar.gz#/icu.tar.gz
28+
Source16: https://github.com/apple/swift-syntax/archive/swift-%{swift_version}.zip#/swift-syntax.tar.gz
29+
Source17: https://github.com/jpsim/Yams/archive/%{yams_version}.zip#/yams.tar.gz
30+
Source18: https://github.com/apple/swift-crypto/archive/refs/tags/%{swift_crypto_version}.tar.gz#/swift-crypto.tar.gz
31+
Source19: https://github.com/ninja-build/ninja/archive/refs/tags/v%{ninja_version}.tar.gz#/ninja.tar.gz
32+
33+
Patch0: patches/swift-api-checker.patch
34+
Patch1: patches/hwasan_symbolize.patch
35+
36+
BuildRequires: autoconf
37+
BuildRequires: cmake
38+
BuildRequires: devtoolset-8
39+
BuildRequires: glibc-static
40+
BuildRequires: libatomic
41+
BuildRequires: libcurl-devel
42+
BuildRequires: libedit-devel
43+
BuildRequires: libstdc++-static
44+
BuildRequires: libtool
45+
BuildRequires: libuuid-devel
46+
BuildRequires: libxml2-devel
47+
BuildRequires: llvm-toolset-7
48+
BuildRequires: make
49+
BuildRequires: ncurses-devel
50+
BuildRequires: ninja-build
51+
BuildRequires: openssl-devel
52+
BuildRequires: pexpect
53+
BuildRequires: python-devel
54+
BuildRequires: python3-devel
55+
BuildRequires: python-pygments
56+
BuildRequires: python-six
57+
BuildRequires: python36-pexpect
58+
BuildRequires: python36-six
59+
BuildRequires: PyYAML
60+
BuildRequires: rsync
61+
BuildRequires: sclo-git25-git
62+
BuildRequires: sqlite-devel
63+
BuildRequires: swig3
64+
BuildRequires: which
65+
BuildRequires: zlib-devel
66+
67+
Requires: binutils
68+
Requires: gcc
69+
Requires: git
70+
Requires: glibc-static
71+
Requires: libbsd-devel
72+
Requires: libedit
73+
Requires: libedit-devel
74+
Requires: libicu-devel
75+
Requires: libstdc++-static
76+
Requires: pkg-config
77+
Requires: python3
78+
Requires: sqlite
79+
Requires: zlib-devel
80+
81+
ExclusiveArch: x86_64 aarch64
82+
83+
%description
84+
Swift is a general-purpose programming language built using
85+
a modern approach to safety, performance, and software design
86+
patterns.
87+
88+
The goal of the Swift project is to create the best available
89+
language for uses ranging from systems programming, to mobile
90+
and desktop apps, scaling up to cloud services. Most
91+
importantly, Swift is designed to make writing and maintaining
92+
correct programs easier for the developer.
93+
94+
%prep
95+
%setup -q -c -n %{swift_source_location} -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 -a 19
96+
# The Swift build script requires directories to be named
97+
# in a specific way so renaming the source directories is
98+
# necessary
99+
mv swift-cmark-swift-%{swift_version} cmark
100+
mv swift-corelibs-foundation-swift-%{swift_version} swift-corelibs-foundation
101+
mv swift-corelibs-libdispatch-swift-%{swift_version} swift-corelibs-libdispatch
102+
mv swift-corelibs-xctest-swift-%{swift_version} swift-corelibs-xctest
103+
mv swift-integration-tests-swift-%{swift_version} swift-integration-tests
104+
mv swift-llbuild-swift-%{swift_version} llbuild
105+
mv swift-package-manager-swift-%{swift_version} swiftpm
106+
mv swift-swift-%{swift_version} swift
107+
mv swift-xcode-playground-support-swift-%{swift_version} swift-xcode-playground-support
108+
mv sourcekit-lsp-swift-%{swift_version} sourcekit-lsp
109+
mv indexstore-db-swift-%{swift_version} indexstore-db
110+
mv llvm-project-swift-%{swift_version} llvm-project
111+
mv swift-syntax-swift-%{swift_version} swift-syntax
112+
mv swift-tools-support-core-swift-%{swift_version} swift-tools-support-core
113+
mv swift-argument-parser-%{swift_argument_parser_version} swift-argument-parser
114+
mv swift-driver-swift-%{swift_version} swift-driver
115+
mv swift-crypto-%{swift_crypto_version} swift-crypto
116+
mv ninja-%{ninja_version} ninja
117+
118+
# ICU
119+
mv icu-release-%{icu_version} icu
120+
121+
# Yams
122+
mv Yams-%{yams_version} yams
123+
124+
# Adjust python version swift-api-checker
125+
%patch0 -p1
126+
127+
# Adjust python version hwasan_symbolize
128+
%patch1 -p1
129+
130+
# Fix python to python3
131+
ln -s /usr/bin/python3 /usr/bin/python
132+
133+
%build
134+
export VERBOSE=1
135+
136+
# Run the build
137+
swift/utils/build-script --preset=buildbot_linux,no_test install_destdir=%{_builddir} installable_package=%{_builddir}/swift-%{version}-centos8.tar.gz
138+
139+
%install
140+
mkdir -p %{buildroot}%{_libexecdir}/swift/
141+
cp -r %{_builddir}/usr/* %{buildroot}%{_libexecdir}/swift
142+
mkdir -p %{buildroot}%{_bindir}
143+
ln -fs %{_libexecdir}/swift/bin/swift %{buildroot}%{_bindir}/swift
144+
ln -fs %{_libexecdir}/swift/bin/swiftc %{buildroot}%{_bindir}/swiftc
145+
ln -fs %{_libexecdir}/swift/bin/sourcekit-lsp %{buildroot}%{_bindir}/sourcekit-lsp
146+
mkdir -p %{buildroot}%{_mandir}/man1
147+
cp %{_builddir}/usr/share/man/man1/swift.1 %{buildroot}%{_mandir}/man1/swift.1
148+
149+
%files
150+
%license swift/LICENSE.txt
151+
%{_bindir}/swift
152+
%{_bindir}/swiftc
153+
%{_bindir}/sourcekit-lsp
154+
%{_mandir}/man1/swift.1.gz
155+
%{_libexecdir}/swift/
156+
157+
%post -p /sbin/ldconfig
158+
%postun -p /sbin/ldconfig
159+
160+
%changelog

0 commit comments

Comments
 (0)