Skip to content

centos8 rpm spec #27

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
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.out
32 changes: 32 additions & 0 deletions platforms/Linux/centos/8/dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM centos:8
LABEL PURPOSE="This image is configured to build Swift for the version of CentOS listed above"

WORKDIR /root

RUN yum -y update

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

# Configure powertools
RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
RUN yum config-manager --set-enabled powertools

# Add the spec
RUN mkdir -p /root/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
ADD swift-lang.spec /root/rpmbuild/SPECS/swift-lang.spec

# Install all the dependencies needed to build Swift from the spec file itself
RUN yum-builddep -y /root/rpmbuild/SPECS/swift-lang.spec

# Get the sources for Swift as defined in the spec file
RUN spectool -g -R /root/rpmbuild/SPECS/swift-lang.spec

# Add the patches
ADD patches/*.patch /root/rpmbuild/SOURCES/

# Add the driver script
ADD build_rpm.sh /root/build_rpm.sh
RUN chmod +x /root/build_rpm.sh

CMD ["/root/build_rpm.sh"]
29 changes: 29 additions & 0 deletions platforms/Linux/centos/8/dev/build_rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

# This script assumes it's running in a container as root
# and that /out is mounted to a directory on the local
# filesystem so the build output and artifacts can be
# copied out and used

OUTDIR=/out
if [[ ! -d "$OUTDIR" ]]
then
echo "$OUTDIR does not exist, so no place to copy the artifacts!"
exit 1
fi

# Always make sure we're up to date
yum update -y

# Now we proceed to build Swift. If this is successful, we
# will have two files: a SRPM file which contains the source files
# as well as a regular RPM file that can be installed via `dnf' or `yum'
pushd $HOME/rpmbuild/SPECS
rpmbuild -ba ./swift-lang.spec 2>&1 | tee $HOME/build-output.txt
popd

# Include the build log which can be used to determine what went
# wrong if there are no artifacts
cp $HOME/build-output.txt $OUTDIR
cp $HOME/rpmbuild/SRPMS/* $OUTDIR
cp $HOME/rpmbuild/RPMS/`uname -i`/* $OUTDIR
23 changes: 23 additions & 0 deletions platforms/Linux/centos/8/dev/patches/build-presets.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this patch for CentOS 8?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally I would like to get to zero patches. this one specifically does two things in build-presets:

  1. uses the system ninja instead building it from source. we can also change the spec to download ninja and build it from source if preferable
  2. disables "test-installable-package", which I took from the fedora spec. not sure why it was needed there. @tachoknight?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomerd I'm trying to get Fedora down to no patches as well. I have this PR which I called buildbot_linux_fedora,no_test, but maybe it would be better to make it more generic to RPM-based distros? The test-installable-package was the source of a lot of errors with Python, I'm trying a build with it enabled to see if it's still an issue.

Copy link
Contributor

@tachoknight tachoknight Oct 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally I would like to get to zero patches. this one specifically does two things in build-presets:

  1. uses the system ninja instead building it from source. we can also change the spec to download ninja and build it from source if preferable

I had to do this for CMake under CentOS 8 for awhile; I have an example if you'd like to see how to do it in a spec file here.

  1. disables "test-installable-package", which I took from the fedora spec. not sure why it was needed there. @tachoknight?

I tested the latest Swift-5.5 snapshot with test-installable-package enabled and it worked, so this is no longer necessary to be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uses the system ninja instead building it from source. we can also change the spec to download ninja and build it from source if preferable

@shahmishal is there a reason not to use the system ninja when it is available?

Copy link
Contributor Author

@tomerd tomerd Oct 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disables "test-installable-package", which I took from the fedora spec. not sure why it was needed there. @tachoknight?
I tested the latest Swift-5.5 snapshot with test-installable-package enabled and it worked, so this is no longer necessary to be removed.

@tachoknight should we update/remove the patch then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uses the system ninja instead building it from source. we can also change the spec to download ninja and build it from source if preferable
@shahmishal is there a reason not to use the system ninja when it is available?

I dont see a problem in using the system ninja if it's available.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disables "test-installable-package", which I took from the fedora spec. not sure why it was needed there. @tachoknight?
I tested the latest Swift-5.5 snapshot with test-installable-package enabled and it worked, so this is no longer necessary to be removed.
@tachoknight should we update/remove the patch then?

I think we should remove the patch, and add support spec file to clone ninja.

diff -Naur swift-orig/utils/build-presets.ini swift/utils/build-presets.ini
--- swift-orig/utils/build-presets.ini 2021-01-11 09:24:03.000000000 -0600
+++ swift/utils/build-presets.ini 2021-01-14 15:42:31.063141040 -0600
@@ -771,7 +771,6 @@
libicu
libcxx

-build-ninja
install-llvm
install-swift
install-lldb
@@ -787,10 +786,6 @@
build-swift-static-sdk-overlay
build-swift-stdlib-unittest-extra

-# Executes the lit tests for the installable package that is created
-# Assumes the swift-integration-tests repo is checked out
-
-test-installable-package

# Build the benchmarks against the toolchain.
toolchain-benchmarks
10 changes: 10 additions & 0 deletions platforms/Linux/centos/8/dev/patches/hwasan_symbolize.patch
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.
9 changes: 9 additions & 0 deletions platforms/Linux/centos/8/dev/patches/swift-api-checker.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
diff --git a/swift/utils/api_checker/swift-api-checker.py b/swift/utils/api_checker/swift-api-checker.py
index 8ed16b4abf7..0b11a4bb83a 100755
--- a/swift/utils/api_checker/swift-api-checker.py
+++ b/swift/utils/api_checker/swift-api-checker.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3

from __future__ import print_function
23 changes: 23 additions & 0 deletions platforms/Linux/centos/8/dev/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Building Swift on CentOS Linux


### building with docker


Build the builder docker image, this will download the sources

```
docker build . -t rpm-builder
```

Run the builder, this will run the build

```
docker run -v `pwd`/.out:/out rpm-builder
```


Open Issues / Introduction
* the swift release version should be an argument
* 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
* 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)
170 changes: 170 additions & 0 deletions platforms/Linux/centos/8/dev/swift-lang.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
%global debug_package %{nil}
%global swifttag 5.5-RELEASE
%global swiftbuild swift-source
%global icu_version 65-1
%global yams_version 4.0.2
%global sap_version 0.4.3
%global swift_crypto_version 1.1.5

Name: swift-lang
Version: 5.5
Release: 1%{?dist}
Summary: Apple's Swift programming language
License: ASL 2.0 and Unicode
URL: https://swift.org

Source0: https://github.com/apple/swift/archive/swift-%{swifttag}.tar.gz#/swift.tar.gz
Source1: https://github.com/apple/swift-corelibs-libdispatch/archive/swift-%{swifttag}.tar.gz#/corelibs-libdispatch.tar.gz
Source2: https://github.com/apple/swift-corelibs-foundation/archive/swift-%{swifttag}.tar.gz#/corelibs-foundation.tar.gz
Source3: https://github.com/apple/swift-integration-tests/archive/swift-%{swifttag}.tar.gz#/swift-integration-tests.tar.gz
Source4: https://github.com/apple/swift-corelibs-xctest/archive/swift-%{swifttag}.tar.gz#/corelibs-xctest.tar.gz
Source5: https://github.com/apple/swift-package-manager/archive/swift-%{swifttag}.tar.gz#/package-manager.tar.gz
Source6: https://github.com/apple/swift-llbuild/archive/swift-%{swifttag}.tar.gz#/llbuild.tar.gz
Source7: https://github.com/apple/swift-cmark/archive/swift-%{swifttag}.tar.gz#/cmark.tar.gz
Source8: https://github.com/apple/swift-xcode-playground-support/archive/swift-%{swifttag}.tar.gz#/swift-xcode-playground-support.tar.gz
Source9: https://github.com/apple/sourcekit-lsp/archive/swift-%{swifttag}.tar.gz#/sourcekit-lsp.tar.gz
Source10: https://github.com/apple/indexstore-db/archive/swift-%{swifttag}.tar.gz#/indexstore-db.tar.gz
Source11: https://github.com/apple/llvm-project/archive/swift-%{swifttag}.tar.gz#/llvm-project.tar.gz
Source12: https://github.com/apple/swift-tools-support-core/archive/swift-%{swifttag}.tar.gz#/swift-tools-support-core.tar.gz
Source13: https://github.com/apple/swift-argument-parser/archive/%{sap_version}.tar.gz
Source14: https://github.com/apple/swift-driver/archive/swift-%{swifttag}.tar.gz#/swift-driver.tar.gz
Source15: https://github.com/unicode-org/icu/archive/release-%{icu_version}.tar.gz
Source16: https://github.com/apple/swift-syntax/archive/swift-%{swifttag}.zip#/swift-syntax.tar.gz
Source17: https://github.com/jpsim/Yams/archive/%{yams_version}.zip
Source18: https://github.com/apple/swift-crypto/archive/refs/tags/%{swift_crypto_version}.tar.gz

Patch0: patches/build-presets.patch
Patch1: patches/swift-api-checker.patch
Patch2: patches/hwasan_symbolize.patch

BuildRequires: autoconf
BuildRequires: clang
BuildRequires: cmake
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: ninja-build
BuildRequires: pcre-devel
BuildRequires: python2
BuildRequires: python2-devel
BuildRequires: python2-six
BuildRequires: python3
BuildRequires: python3-six
BuildRequires: python3-pexpect
BuildRequires: platform-python-devel
BuildRequires: sqlite-devel
BuildRequires: swig
BuildRequires: rsync
BuildRequires: tar
BuildRequires: which

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

ExclusiveArch: x86_64 aarch64

%description
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.

%prep
# FIXME: what does -a 0 -a 1 etc do?
%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
# The Swift build script requires directories to be named
# in a specific way so renaming the source directories is
# necessary
mv swift-cmark-swift-%{swifttag} cmark
mv swift-corelibs-foundation-swift-%{swifttag} swift-corelibs-foundation
mv swift-corelibs-libdispatch-swift-%{swifttag} swift-corelibs-libdispatch
mv swift-corelibs-xctest-swift-%{swifttag} swift-corelibs-xctest
mv swift-integration-tests-swift-%{swifttag} swift-integration-tests
mv swift-llbuild-swift-%{swifttag} llbuild
mv swift-package-manager-swift-%{swifttag} swiftpm
mv swift-swift-%{swifttag} swift
mv swift-xcode-playground-support-swift-%{swifttag} swift-xcode-playground-support
mv sourcekit-lsp-swift-%{swifttag} sourcekit-lsp
mv indexstore-db-swift-%{swifttag} indexstore-db
mv llvm-project-swift-%{swifttag} llvm-project
mv swift-syntax-swift-%{swifttag} swift-syntax
mv swift-tools-support-core-swift-%{swifttag} swift-tools-support-core
mv swift-argument-parser-%{sap_version} swift-argument-parser
mv swift-driver-swift-%{swifttag} swift-driver
mv swift-crypto-%{swift_crypto_version} swift-crypto

# ICU
mv icu-release-%{icu_version} icu

# Yams
mv Yams-%{yams_version} yams

# Narrow down presets
%patch0 -p0

# FIXME: fix upstream instead of patch
# Python path hard coded in swift-api-checker
%patch1 -p1

# FIXME: fix upstream instead of patch
# Python path hard coded in hwasan_symbolize
%patch2 -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_test install_destdir=%{_builddir} installable_package=%{_builddir}/swift-%{version}-centos8.tar.gz

%install
mkdir -p %{buildroot}%{_libexecdir}/swift/
cp -r %{_builddir}/usr/* %{buildroot}%{_libexecdir}/swift
mkdir -p %{buildroot}%{_bindir}
ln -fs %{_libexecdir}/swift/bin/swift %{buildroot}%{_bindir}/swift
ln -fs %{_libexecdir}/swift/bin/swiftc %{buildroot}%{_bindir}/swiftc
ln -fs %{_libexecdir}/swift/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