diff --git a/platforms/Linux/RPM/Fedora/34/Dockerfile b/platforms/Linux/RPM/Fedora/34/Dockerfile index eb26e763..71563849 100644 --- a/platforms/Linux/RPM/Fedora/34/Dockerfile +++ b/platforms/Linux/RPM/Fedora/34/Dockerfile @@ -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 diff --git a/platforms/Linux/RPM/Fedora/34/README.md b/platforms/Linux/RPM/Fedora/34/README.md new file mode 100644 index 00000000..fd6eb24f --- /dev/null +++ b/platforms/Linux/RPM/Fedora/34/README.md @@ -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) diff --git a/platforms/Linux/RPM/Fedora/34/build_rpm.sh b/platforms/Linux/RPM/Fedora/34/build_rpm.sh deleted file mode 100755 index 43590e2e..00000000 --- a/platforms/Linux/RPM/Fedora/34/build_rpm.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/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 -y update - -# 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 ./swiftlang.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 diff --git a/platforms/Linux/RPM/Fedora/34/build_rpm.sh b/platforms/Linux/RPM/Fedora/34/build_rpm.sh new file mode 120000 index 00000000..e83f0881 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/34/build_rpm.sh @@ -0,0 +1 @@ +../../Shared/scripts/build_rpm.sh \ No newline at end of file diff --git a/platforms/Linux/RPM/Fedora/34/createrepo_rpm.sh b/platforms/Linux/RPM/Fedora/34/createrepo_rpm.sh new file mode 120000 index 00000000..11c58fd2 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/34/createrepo_rpm.sh @@ -0,0 +1 @@ +../../Shared/scripts/createrepo_rpm.sh \ No newline at end of file diff --git a/platforms/Linux/RPM/Fedora/34/description.inc b/platforms/Linux/RPM/Fedora/34/description.inc new file mode 120000 index 00000000..a880ccf4 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/34/description.inc @@ -0,0 +1 @@ +../../Shared/metadata/description.inc \ No newline at end of file diff --git a/platforms/Linux/RPM/Fedora/34/docker-compose.yaml b/platforms/Linux/RPM/Fedora/34/docker-compose.yaml new file mode 100644 index 00000000..189ce022 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/34/docker-compose.yaml @@ -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 diff --git a/platforms/Linux/RPM/Fedora/34/global.inc b/platforms/Linux/RPM/Fedora/34/global.inc new file mode 120000 index 00000000..bee5c7e7 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/34/global.inc @@ -0,0 +1 @@ +../../Shared/metadata/global.inc \ No newline at end of file diff --git a/platforms/Linux/RPM/Fedora/34/metadata.inc b/platforms/Linux/RPM/Fedora/34/metadata.inc new file mode 120000 index 00000000..e0ad3078 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/34/metadata.inc @@ -0,0 +1 @@ +../../Shared/metadata/metadata.inc \ No newline at end of file diff --git a/platforms/Linux/RPM/Fedora/34/swiftlang.spec b/platforms/Linux/RPM/Fedora/34/swiftlang.spec index 0aa11090..cdd7e012 100644 --- a/platforms/Linux/RPM/Fedora/34/swiftlang.spec +++ b/platforms/Linux/RPM/Fedora/34/swiftlang.spec @@ -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 @@ -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 @@ -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 @@ -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} diff --git a/platforms/Linux/RPM/Fedora/35/Dockerfile b/platforms/Linux/RPM/Fedora/35/Dockerfile index 865adbaa..0c166f0d 100644 --- a/platforms/Linux/RPM/Fedora/35/Dockerfile +++ b/platforms/Linux/RPM/Fedora/35/Dockerfile @@ -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 diff --git a/platforms/Linux/RPM/Fedora/35/README.md b/platforms/Linux/RPM/Fedora/35/README.md new file mode 100644 index 00000000..fd6eb24f --- /dev/null +++ b/platforms/Linux/RPM/Fedora/35/README.md @@ -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) diff --git a/platforms/Linux/RPM/Fedora/35/build_rpm.sh b/platforms/Linux/RPM/Fedora/35/build_rpm.sh deleted file mode 100755 index 43590e2e..00000000 --- a/platforms/Linux/RPM/Fedora/35/build_rpm.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/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 -y update - -# 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 ./swiftlang.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 diff --git a/platforms/Linux/RPM/Fedora/35/build_rpm.sh b/platforms/Linux/RPM/Fedora/35/build_rpm.sh new file mode 120000 index 00000000..e83f0881 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/35/build_rpm.sh @@ -0,0 +1 @@ +../../Shared/scripts/build_rpm.sh \ No newline at end of file diff --git a/platforms/Linux/RPM/Fedora/35/createrepo_rpm.sh b/platforms/Linux/RPM/Fedora/35/createrepo_rpm.sh new file mode 120000 index 00000000..11c58fd2 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/35/createrepo_rpm.sh @@ -0,0 +1 @@ +../../Shared/scripts/createrepo_rpm.sh \ No newline at end of file diff --git a/platforms/Linux/RPM/Fedora/35/description.inc b/platforms/Linux/RPM/Fedora/35/description.inc new file mode 120000 index 00000000..a880ccf4 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/35/description.inc @@ -0,0 +1 @@ +../../Shared/metadata/description.inc \ No newline at end of file diff --git a/platforms/Linux/RPM/Fedora/35/docker-compose.yaml b/platforms/Linux/RPM/Fedora/35/docker-compose.yaml new file mode 100644 index 00000000..a681b1f5 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/35/docker-compose.yaml @@ -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/35/docker-compose.yaml build +# to shell into the container for debugging purposes: +# docker-compose -f platforms/Linux/fedora/35/docker-compose.yaml run build + +version: "2" + +services: + + docker-setup: + image: fedora-35-rpm-builder + build: + context: . + dockerfile: Dockerfile + + common: &common + image: fedora-35-rpm-builder + depends_on: [docker-setup] + volumes: + - ../../Fedora/35:/code/Fedora/35:z + - ../../Shared:/code/Shared:z + - ./.output:/output:z + working_dir: /code/Fedora/35 + 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 diff --git a/platforms/Linux/RPM/Fedora/35/global.inc b/platforms/Linux/RPM/Fedora/35/global.inc new file mode 120000 index 00000000..bee5c7e7 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/35/global.inc @@ -0,0 +1 @@ +../../Shared/metadata/global.inc \ No newline at end of file diff --git a/platforms/Linux/RPM/Fedora/35/metadata.inc b/platforms/Linux/RPM/Fedora/35/metadata.inc new file mode 120000 index 00000000..e0ad3078 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/35/metadata.inc @@ -0,0 +1 @@ +../../Shared/metadata/metadata.inc \ No newline at end of file diff --git a/platforms/Linux/RPM/Fedora/35/swiftlang.spec b/platforms/Linux/RPM/Fedora/35/swiftlang.spec index 4c797c3d..b47c787e 100644 --- a/platforms/Linux/RPM/Fedora/35/swiftlang.spec +++ b/platforms/Linux/RPM/Fedora/35/swiftlang.spec @@ -1,28 +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 sap_version 0.4.3 -%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 @@ -92,22 +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 @@ -116,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 @@ -167,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-35.tar.gz %install mkdir -p %{buildroot}%{_libexecdir}/swift/%{package_version} diff --git a/platforms/Linux/RPM/Fedora/rawhide/Dockerfile b/platforms/Linux/RPM/Fedora/rawhide/Dockerfile index 09e1d0e4..e8fbd8f7 100644 --- a/platforms/Linux/RPM/Fedora/rawhide/Dockerfile +++ b/platforms/Linux/RPM/Fedora/rawhide/Dockerfile @@ -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:rawhide 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 diff --git a/platforms/Linux/RPM/Fedora/rawhide/README.md b/platforms/Linux/RPM/Fedora/rawhide/README.md new file mode 100644 index 00000000..fd6eb24f --- /dev/null +++ b/platforms/Linux/RPM/Fedora/rawhide/README.md @@ -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) diff --git a/platforms/Linux/RPM/Fedora/rawhide/build_rpm.sh b/platforms/Linux/RPM/Fedora/rawhide/build_rpm.sh deleted file mode 100755 index 43590e2e..00000000 --- a/platforms/Linux/RPM/Fedora/rawhide/build_rpm.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/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 -y update - -# 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 ./swiftlang.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 diff --git a/platforms/Linux/RPM/Fedora/rawhide/build_rpm.sh b/platforms/Linux/RPM/Fedora/rawhide/build_rpm.sh new file mode 120000 index 00000000..e83f0881 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/rawhide/build_rpm.sh @@ -0,0 +1 @@ +../../Shared/scripts/build_rpm.sh \ No newline at end of file diff --git a/platforms/Linux/RPM/Fedora/rawhide/createrepo_rpm.sh b/platforms/Linux/RPM/Fedora/rawhide/createrepo_rpm.sh new file mode 120000 index 00000000..11c58fd2 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/rawhide/createrepo_rpm.sh @@ -0,0 +1 @@ +../../Shared/scripts/createrepo_rpm.sh \ No newline at end of file diff --git a/platforms/Linux/RPM/Fedora/rawhide/description.inc b/platforms/Linux/RPM/Fedora/rawhide/description.inc new file mode 120000 index 00000000..a880ccf4 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/rawhide/description.inc @@ -0,0 +1 @@ +../../Shared/metadata/description.inc \ No newline at end of file diff --git a/platforms/Linux/RPM/Fedora/rawhide/docker-compose.yaml b/platforms/Linux/RPM/Fedora/rawhide/docker-compose.yaml new file mode 100644 index 00000000..ab7ad8f3 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/rawhide/docker-compose.yaml @@ -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/rawhide/docker-compose.yaml build +# to shell into the container for debugging purposes: +# docker-compose -f platforms/Linux/fedora/rawhide/docker-compose.yaml run build + +version: "2" + +services: + + docker-setup: + image: fedora-rawhide-rpm-builder + build: + context: . + dockerfile: Dockerfile + + common: &common + image: fedora-rawhide-rpm-builder + depends_on: [docker-setup] + volumes: + - ../../Fedora/rawhide:/code/Fedora/rawhide:z + - ../../Shared:/code/Shared:z + - ./.output:/output:z + working_dir: /code/Fedora/rawhide + 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 diff --git a/platforms/Linux/RPM/Fedora/rawhide/global.inc b/platforms/Linux/RPM/Fedora/rawhide/global.inc new file mode 120000 index 00000000..bee5c7e7 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/rawhide/global.inc @@ -0,0 +1 @@ +../../Shared/metadata/global.inc \ No newline at end of file diff --git a/platforms/Linux/RPM/Fedora/rawhide/metadata.inc b/platforms/Linux/RPM/Fedora/rawhide/metadata.inc new file mode 120000 index 00000000..e0ad3078 --- /dev/null +++ b/platforms/Linux/RPM/Fedora/rawhide/metadata.inc @@ -0,0 +1 @@ +../../Shared/metadata/metadata.inc \ No newline at end of file diff --git a/platforms/Linux/RPM/Fedora/rawhide/swiftlang.spec b/platforms/Linux/RPM/Fedora/rawhide/swiftlang.spec index 1fd07c01..14daed91 100644 --- a/platforms/Linux/RPM/Fedora/rawhide/swiftlang.spec +++ b/platforms/Linux/RPM/Fedora/rawhide/swiftlang.spec @@ -1,28 +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 sap_version 0.4.3 -%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 @@ -60,7 +37,7 @@ Source32: https://github.com/apple/swift-lmdb/archive/swift-%{swift_versio Source33: https://github.com/apple/swift-markdown/archive/swift-%{swift_version}.tar.gz#/swift-markdown.tar.gz Patch0: nocyclades.patch -Patch1: unusedvariable.patch +Patch1: unusedvariable.patch BuildRequires: clang BuildRequires: libbsd-devel @@ -92,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 @@ -115,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 @@ -166,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-rawhide.tar.gz %install mkdir -p %{buildroot}%{_libexecdir}/swift/%{package_version}