Skip to content

update fedora setup to follow conventions of other RPM builders #82

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 1 commit into from
Mar 23, 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
42 changes: 18 additions & 24 deletions platforms/Linux/RPM/Fedora/34/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2021-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 fedora:34
LABEL PURPOSE="This image is configured to build Swift for the version of Fedora listed above"

WORKDIR /root

RUN yum -y update

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

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


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

# Get the sources for Swift as defined in the spec file
RUN spectool -g -R /root/rpmbuild/SPECS/swiftlang.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"]
RUN yum install -y rpmdevtools yum-utils createrepo

# 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/Fedora/34/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Building Swift on Fedora 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)
29 changes: 0 additions & 29 deletions platforms/Linux/RPM/Fedora/34/build_rpm.sh

This file was deleted.

1 change: 1 addition & 0 deletions platforms/Linux/RPM/Fedora/34/build_rpm.sh
1 change: 1 addition & 0 deletions platforms/Linux/RPM/Fedora/34/createrepo_rpm.sh
1 change: 1 addition & 0 deletions platforms/Linux/RPM/Fedora/34/description.inc
47 changes: 47 additions & 0 deletions platforms/Linux/RPM/Fedora/34/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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/fedora/34/docker-compose.yaml build
# to shell into the container for debugging purposes:
# docker-compose -f platforms/Linux/fedora/34/docker-compose.yaml run build

version: "2"

services:

docker-setup:
image: fedora-34-rpm-builder
build:
context: .
dockerfile: Dockerfile

common: &common
image: fedora-34-rpm-builder
depends_on: [docker-setup]
volumes:
- ../../Fedora/34:/code/Fedora/34:z
- ../../Shared:/code/Shared:z
- ./.output:/output:z
working_dir: /code/Fedora/34
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/Fedora/34/global.inc
1 change: 1 addition & 0 deletions platforms/Linux/RPM/Fedora/34/metadata.inc
44 changes: 6 additions & 38 deletions platforms/Linux/RPM/Fedora/34/swiftlang.spec
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
%global debug_package %{nil}
%global linux_version fedora
%global swift_version 5.6-RELEASE
%global package_version 5.6.0
%global swift_source_location swift-source
%global icu_version 65-1
%global yams_version 4.0.2
%global swift_argument_parser_version 1.0.3
%global swift_crypto_version 1.1.5
%global ninja_version 1.10.2
%global cmake_version 3.19.6
%global swift_atomics_version 1.0.2
%global swift_collections_version 1.0.1
%global swift_numerics_version 1.0.1
%global swift_system_version 1.1.1
%global swift_nio_version 2.31.2
%global swift_nio_ssl_version 2.15.0

Name: swiftlang
Version: %{package_version}
Release: 1%{?dist}
Summary: The Swift programming language
License: Apache 2.0
URL: https://www.swift.org
%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
Expand Down Expand Up @@ -91,21 +69,12 @@ Requires: ncurses-devel

ExclusiveArch: x86_64 aarch64

Provides: swiftlang = %{version}-%{release}

%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.
%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
Expand All @@ -114,7 +83,6 @@ 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 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
Expand Down Expand Up @@ -165,8 +133,8 @@ ln -s /usr/bin/python3 $PWD/binforpython/python
export PATH=$PWD/binforpython:$PATH
%endif

# Here we go!
swift/utils/build-script --preset=buildbot_linux,no_assertions,no_test install_destdir=%{_builddir} installable_package=%{_builddir}/swift-%{version}-%{linux_version}.tar.gz
# Run the build
swift/utils/build-script --preset=buildbot_linux,no_assertions,no_test install_destdir=%{_builddir} installable_package=%{_builddir}/swift-%{version}-fedora-34.tar.gz

%install
mkdir -p %{buildroot}%{_libexecdir}/swift/%{package_version}
Expand Down
42 changes: 18 additions & 24 deletions platforms/Linux/RPM/Fedora/35/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2021-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 fedora:35
LABEL PURPOSE="This image is configured to build Swift for the version of Fedora listed above"

WORKDIR /root

RUN yum -y update

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

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


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

# Get the sources for Swift as defined in the spec file
RUN spectool -g -R /root/rpmbuild/SPECS/swiftlang.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"]
RUN yum install -y rpmdevtools yum-utils createrepo

# 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/Fedora/35/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Building Swift on Fedora 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)
29 changes: 0 additions & 29 deletions platforms/Linux/RPM/Fedora/35/build_rpm.sh

This file was deleted.

1 change: 1 addition & 0 deletions platforms/Linux/RPM/Fedora/35/build_rpm.sh
1 change: 1 addition & 0 deletions platforms/Linux/RPM/Fedora/35/createrepo_rpm.sh
1 change: 1 addition & 0 deletions platforms/Linux/RPM/Fedora/35/description.inc
Loading