Skip to content

add support for oracle linux 8 #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions platforms/Linux/RPM/Oraclelinux/8/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.output
28 changes: 28 additions & 0 deletions platforms/Linux/RPM/Oraclelinux/8/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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 oraclelinux:8
LABEL PURPOSE="This image is configured to build Swift for the version of Oracle Linux listed above"

RUN yum -y update

# RPM and yum development tools
RUN yum install -y rpmdevtools yum-utils createrepo

# Configure epel and codeready
RUN yum install -y oracle-epel-release-el8
RUN yum config-manager --set-enabled ol8_codeready_builder

# Optimization: Install Swift build requirements listed in the spec file
ADD swiftlang.spec /tmp/swiftlang.spec
# rewrite a minimal spec with the build requirements
RUN echo -e "Name: optimization\nVersion: optimization\nRelease: optimization\nSummary: optimization\nLicense: optimization\n" > /tmp/optimization.spec
RUN cat /tmp/swiftlang.spec | grep BuildRequires >> /tmp/optimization.spec
RUN echo -e "\n%description" >> /tmp/optimization.spec
# install the build requirements
RUN cd /tmp && yum-builddep -y optimization.spec
31 changes: 31 additions & 0 deletions platforms/Linux/RPM/Oraclelinux/8/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Building Swift on Oracle Enterprise Linux


### 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_rpm.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


### Open Issues / TODO
* 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)
1 change: 1 addition & 0 deletions platforms/Linux/RPM/Oraclelinux/8/build_rpm.sh
1 change: 1 addition & 0 deletions platforms/Linux/RPM/Oraclelinux/8/createrepo_rpm.sh
1 change: 1 addition & 0 deletions platforms/Linux/RPM/Oraclelinux/8/description.inc
50 changes: 50 additions & 0 deletions platforms/Linux/RPM/Oraclelinux/8/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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

# this setup is designed to build the RPM with docker
# usage:
# docker-compose -f platforms/Linux/oraclelinux/8/docker-compose.yaml build
# to shell into the container for debugging purposes:
# docker-compose -f platforms/Linux/oraclelinux/8/docker-compose.yaml run build

version: "2"

services:

docker-setup:
image: oraclelinux-8-rpm-builder
build:
context: .
dockerfile: Dockerfile

common: &common
image: oraclelinux-8-rpm-builder
depends_on: [docker-setup]
# https://bugs.swift.org/browse/SR-15343
security_opt:
- seccomp:unconfined
volumes:
- ../../Oraclelinux/8:/code/Oraclelinux/8:z
- ../../Shared:/code/Shared:z
- ./.output:/output:z
working_dir: /code/Oraclelinux/8
cap_drop:
- CAP_NET_RAW
- CAP_NET_BIND_SERVICE

build:
<<: *common
command: /bin/bash -cl "./build_rpm.sh"

createrepo:
<<: *common
command: /bin/bash -cl "./createrepo_rpm.sh"

shell:
<<: *common
entrypoint: /bin/bash -l
1 change: 1 addition & 0 deletions platforms/Linux/RPM/Oraclelinux/8/global.inc
1 change: 1 addition & 0 deletions platforms/Linux/RPM/Oraclelinux/8/metadata.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
diff --git a/llvm-project/compiler-rt/lib/hwasan/scripts/hwasan_symbolize b/llvm-project/compiler-rt/lib/hwasan/scripts/hwasan_symbolize
index dd5f859561e1..21d18998cf31 100755
--- a/llvm-project/compiler-rt/lib/hwasan/scripts/hwasan_symbolize
+++ b/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.
165 changes: 165 additions & 0 deletions platforms/Linux/RPM/Oraclelinux/8/swiftlang.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
%include global.inc
%include metadata.inc

Source0: https://github.com/apple/swift/archive/swift-%{swift_version}.tar.gz#/swift.tar.gz
Source1: https://github.com/apple/swift-corelibs-libdispatch/archive/swift-%{swift_version}.tar.gz#/corelibs-libdispatch.tar.gz
Source2: https://github.com/apple/swift-corelibs-foundation/archive/swift-%{swift_version}.tar.gz#/corelibs-foundation.tar.gz
Source3: https://github.com/apple/swift-integration-tests/archive/swift-%{swift_version}.tar.gz#/swift-integration-tests.tar.gz
Source4: https://github.com/apple/swift-corelibs-xctest/archive/swift-%{swift_version}.tar.gz#/corelibs-xctest.tar.gz
Source5: https://github.com/apple/swift-package-manager/archive/swift-%{swift_version}.tar.gz#/package-manager.tar.gz
Source6: https://github.com/apple/swift-llbuild/archive/swift-%{swift_version}.tar.gz#/llbuild.tar.gz
Source7: https://github.com/apple/swift-cmark/archive/swift-%{swift_version}.tar.gz#/cmark.tar.gz
Source8: https://github.com/apple/swift-xcode-playground-support/archive/swift-%{swift_version}.tar.gz#/swift-xcode-playground-support.tar.gz
Source9: https://github.com/apple/sourcekit-lsp/archive/swift-%{swift_version}.tar.gz#/sourcekit-lsp.tar.gz
Source10: https://github.com/apple/indexstore-db/archive/swift-%{swift_version}.tar.gz#/indexstore-db.tar.gz
Source11: https://github.com/apple/llvm-project/archive/swift-%{swift_version}.tar.gz#/llvm-project.tar.gz
Source12: https://github.com/apple/swift-tools-support-core/archive/swift-%{swift_version}.tar.gz#/swift-tools-support-core.tar.gz
Source13: https://github.com/apple/swift-argument-parser/archive/%{swift_argument_parser_version}.tar.gz#/swift-argument-parser.tar.gz
Source14: https://github.com/apple/swift-driver/archive/swift-%{swift_version}.tar.gz#/swift-driver.tar.gz
Source15: https://github.com/unicode-org/icu/archive/release-%{icu_version}.tar.gz#/icu.tar.gz
Source16: https://github.com/apple/swift-syntax/archive/swift-%{swift_version}.zip#/swift-syntax.tar.gz
Source17: https://github.com/jpsim/Yams/archive/%{yams_version}.tar.gz#/yams.tar.gz
Source18: https://github.com/apple/swift-crypto/archive/refs/tags/%{swift_crypto_version}.tar.gz#/swift-crypto.tar.gz
Source19: https://github.com/ninja-build/ninja/archive/refs/tags/v%{ninja_version}.tar.gz#/ninja.tar.gz
Source20: https://github.com/KitWare/CMake/archive/refs/tags/v%{cmake_version}.tar.gz#/cmake.tar.gz
Source21: https://github.com/apple/swift-atomics/archive/%{swift_atomics_version}.tar.gz#/swift-atomics.tar.gz
Source22: https://github.com/apple/swift-cmark/archive/swift-%{swift_version}-gfm.tar.gz#/swift-cmark-gfm.tar.gz
Source23: https://github.com/apple/swift-docc/archive/swift-%{swift_version}.tar.gz#/swift-docc.tar.gz
Source24: https://github.com/apple/swift-docc-render-artifact/archive/swift-%{swift_version}.tar.gz#/swift-docc-render-artifact.tar.gz
Source25: https://github.com/apple/swift-docc-symbolkit/archive/swift-%{swift_version}.tar.gz#/swift-docc-symbolkit.tar.gz
Source26: https://github.com/apple/swift-collections/archive/%{swift_collections_version}.tar.gz#/swift-collections.tar.gz
Source27: https://github.com/apple/swift-numerics/archive/%{swift_numerics_version}.tar.gz#/swift-numerics.tar.gz
Source28: https://github.com/apple/swift-system/archive/%{swift_system_version}.tar.gz#/swift-system.tar.gz
Source29: https://github.com/apple/swift-nio/archive/%{swift_nio_version}.tar.gz#/swift-nio.tar.gz
Source30: https://github.com/apple/swift-nio-ssl/archive/%{swift_nio_ssl_version}.tar.gz#/swift-nio-ssl.tar.gz
Source31: https://github.com/apple/swift-format/archive/swift-%{swift_version}.tar.gz#/swift-format.tar.gz
Source32: https://github.com/apple/swift-lmdb/archive/swift-%{swift_version}.tar.gz#/swift-lmdb.tar.gz
Source33: https://github.com/apple/swift-markdown/archive/swift-%{swift_version}.tar.gz#/swift-markdown.tar.gz

Patch0: patches/hwasan_symbolize.patch

BuildRequires: autoconf
BuildRequires: clang
BuildRequires: diffutils
BuildRequires: git
BuildRequires: glibc-static
BuildRequires: libbsd-devel
BuildRequires: libcurl-devel
BuildRequires: libedit-devel
BuildRequires: libicu-devel
BuildRequires: libstdc++-static
BuildRequires: libtool
BuildRequires: libuuid-devel
BuildRequires: libxml2-devel
BuildRequires: make
BuildRequires: ncurses-devel
BuildRequires: pcre-devel
BuildRequires: platform-python-devel
BuildRequires: python2
BuildRequires: python2-devel
BuildRequires: python2-six
BuildRequires: python3
BuildRequires: python3-pexpect
BuildRequires: python3-six
BuildRequires: rsync
BuildRequires: sqlite-devel
BuildRequires: swig
BuildRequires: tar
BuildRequires: which

Requires: binutils
Requires: gcc
Requires: git
Requires: glibc-static
Requires: libbsd-devel
Requires: libcurl-devel
Requires: libedit
Requires: libedit-devel
Requires: libicu-devel
Requires: libstdc++-static
Requires: libxml2-devel
Requires: pkg-config
Requires: python3
Requires: sqlite
Requires: zlib-devel

ExclusiveArch: x86_64 aarch64

%description
%include description.inc

%prep
%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 -a 20 -a 21 -a 22 -a 23 -a 24 -a 25 -a 26 -a 27 -a 28 -a 29 -a 30 -a 31 -a 32 -a 33

# The Swift build script requires directories to be named
# in a specific way so renaming the source directories is
# necessary
mv CMake-%{cmake_version} cmake
mv icu-release-%{icu_version} icu
mv indexstore-db-swift-%{swift_version} indexstore-db
mv llvm-project-swift-%{swift_version} llvm-project
mv ninja-%{ninja_version} ninja
mv sourcekit-lsp-swift-%{swift_version} sourcekit-lsp
mv swift-argument-parser-%{swift_argument_parser_version} swift-argument-parser
mv swift-atomics-%{swift_atomics_version} swift-atomics
mv swift-cmark-swift-%{swift_version} cmark
mv swift-cmark-swift-%{swift_version}-gfm swift-cmark-gfm
mv swift-collections-%{swift_collections_version} swift-collections
mv swift-corelibs-foundation-swift-%{swift_version} swift-corelibs-foundation
mv swift-corelibs-libdispatch-swift-%{swift_version} swift-corelibs-libdispatch
mv swift-corelibs-xctest-swift-%{swift_version} swift-corelibs-xctest
mv swift-crypto-%{swift_crypto_version} swift-crypto
mv swift-docc-render-artifact-swift-%{swift_version} swift-docc-render-artifact
mv swift-docc-swift-%{swift_version} swift-docc
mv swift-docc-symbolkit-swift-%{swift_version} swift-docc-symbolkit
mv swift-driver-swift-%{swift_version} swift-driver
mv swift-format-swift-%{swift_version} swift-format
mv swift-integration-tests-swift-%{swift_version} swift-integration-tests
mv swift-llbuild-swift-%{swift_version} llbuild
mv swift-lmdb-swift-%{swift_version} swift-lmdb
mv swift-markdown-swift-%{swift_version} swift-markdown
mv swift-nio-%{swift_nio_version} swift-nio
mv swift-nio-ssl-%{swift_nio_ssl_version} swift-nio-ssl
mv swift-numerics-%{swift_numerics_version} swift-numerics
mv swift-package-manager-swift-%{swift_version} swiftpm
mv swift-swift-%{swift_version} swift
mv swift-syntax-swift-%{swift_version} swift-syntax
mv swift-system-%{swift_system_version} swift-system
mv swift-tools-support-core-swift-%{swift_version} swift-tools-support-core
mv swift-xcode-playground-support-swift-%{swift_version} swift-xcode-playground-support
mv Yams-%{yams_version} yams

# Adjust python version hwasan_symbolize
%patch0 -p1

# Fix python to python3
ln -s /usr/bin/python3 /usr/bin/python

%build
export VERBOSE=1

# Run the build
swift/utils/build-script --preset=buildbot_linux,no_assertions,no_test install_destdir=%{_builddir} installable_package=%{_builddir}/swift-%{version}-oel8.tar.gz

%install
mkdir -p %{buildroot}%{_libexecdir}/swift/%{package_version}
cp -r %{_builddir}/usr/* %{buildroot}%{_libexecdir}/swift/%{package_version}
mkdir -p %{buildroot}%{_bindir}
ln -fs %{_libexecdir}/swift/%{package_version}/bin/swift %{buildroot}%{_bindir}/swift
ln -fs %{_libexecdir}/swift/%{package_version}/bin/swiftc %{buildroot}%{_bindir}/swiftc
ln -fs %{_libexecdir}/swift/%{package_version}/bin/sourcekit-lsp %{buildroot}%{_bindir}/sourcekit-lsp
mkdir -p %{buildroot}%{_mandir}/man1
cp %{_builddir}/usr/share/man/man1/swift.1 %{buildroot}%{_mandir}/man1/swift.1

%files
%license swift/LICENSE.txt
%{_bindir}/swift
%{_bindir}/swiftc
%{_bindir}/sourcekit-lsp
%{_mandir}/man1/swift.1.gz
%{_libexecdir}/swift/

%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%changelog