Skip to content

Commit ff823a6

Browse files
authored
Merge pull request #33 from tomerd/metadata
externalize RPM metadata and make it version based
2 parents cf967d5 + 7b84410 commit ff823a6

File tree

6 files changed

+75
-52
lines changed

6 files changed

+75
-52
lines changed

platforms/Linux/centos/8/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ RUN yum -y update
1414
# RPM and yum development tools
1515
RUN yum install -y rpmdevtools yum-utils
1616

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

2121
# Optimization: Install all the dependencies needed to build Swift from the spec file itself
2222
ADD swift-lang.spec /tmp/swift-lang.spec
23-
RUN yum-builddep -y /tmp/swift-lang.spec
23+
RUN touch /tmp/metadata.inc # fake metadata is okay for this optimization
24+
RUN cd /tmp && yum-builddep -y swift-lang.spec

platforms/Linux/centos/8/readme.md renamed to platforms/Linux/centos/8/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,4 @@ note this still uses the docker cache, so will rebuild only if the version of th
2828

2929

3030
### Open Issues / TODO
31-
* the swift release version should be an argument?
32-
* the versions of source packages (eg yams) should come from an external file, likely one per swift release version
3331
* 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)

platforms/Linux/centos/8/build_rpm.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#!/usr/bin/env bash
1010

11-
set +ex
11+
set -ex
1212

1313
OUTDIR=/output
1414
if [[ ! -d "$OUTDIR" ]]; then
@@ -23,8 +23,10 @@ yum update -y
2323
mkdir -p $HOME/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
2424

2525
# Add the spec
26-
cp swift-lang.spec $HOME/rpmbuild/SPECS/swift-lang.spec
27-
# Add the patches
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
2830
cp patches/*.patch $HOME/rpmbuild/SOURCES/
2931

3032
pushd $HOME/rpmbuild/SPECS

platforms/Linux/centos/8/docker-compose.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
# See http://swift.org/LICENSE.txt for license information
77
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9+
# this setup is designed to build the RPM with docker
10+
# usage:
11+
# docker-compose -f platforms/Linux/centos/8/docker-compose.yaml build
12+
# to shell into the container for debugging purposes:
13+
# docker-compose -f platforms/Linux/centos/8/docker-compose.yaml run build
14+
915
version: "2"
1016

1117
services:
@@ -24,6 +30,7 @@ services:
2430
- seccomp:unconfined
2531
volumes:
2632
- .:/code:z
33+
- ../../shared/RPM:/shared:ro
2734
- ./.output:/output:z
2835
working_dir: /code
2936
cap_drop:

platforms/Linux/centos/8/swift-lang.spec

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,31 @@
1+
%include metadata.inc
2+
13
%global debug_package %{nil}
2-
%global swifttag 5.5-RELEASE
3-
%global swiftbuild swift-source
4-
%global icu_version 65-1
5-
%global yams_version 4.0.2
6-
%global swift_argument_parser_version 0.4.3
7-
%global swift_crypto_version 1.1.5
8-
%global ninja_version 1.10.2
9-
10-
Name: swift-lang
11-
Version: 5.5
4+
5+
Name: %{package_name}
6+
Version: %{package_version}
127
Release: 1%{?dist}
13-
Summary: Apple's Swift programming language
14-
License: Apache 2.0
15-
URL: https://swift.org
16-
17-
Source0: https://github.com/apple/swift/archive/swift-%{swifttag}.tar.gz#/swift.tar.gz
18-
Source1: https://github.com/apple/swift-corelibs-libdispatch/archive/swift-%{swifttag}.tar.gz#/corelibs-libdispatch.tar.gz
19-
Source2: https://github.com/apple/swift-corelibs-foundation/archive/swift-%{swifttag}.tar.gz#/corelibs-foundation.tar.gz
20-
Source3: https://github.com/apple/swift-integration-tests/archive/swift-%{swifttag}.tar.gz#/swift-integration-tests.tar.gz
21-
Source4: https://github.com/apple/swift-corelibs-xctest/archive/swift-%{swifttag}.tar.gz#/corelibs-xctest.tar.gz
22-
Source5: https://github.com/apple/swift-package-manager/archive/swift-%{swifttag}.tar.gz#/package-manager.tar.gz
23-
Source6: https://github.com/apple/swift-llbuild/archive/swift-%{swifttag}.tar.gz#/llbuild.tar.gz
24-
Source7: https://github.com/apple/swift-cmark/archive/swift-%{swifttag}.tar.gz#/cmark.tar.gz
25-
Source8: https://github.com/apple/swift-xcode-playground-support/archive/swift-%{swifttag}.tar.gz#/swift-xcode-playground-support.tar.gz
26-
Source9: https://github.com/apple/sourcekit-lsp/archive/swift-%{swifttag}.tar.gz#/sourcekit-lsp.tar.gz
27-
Source10: https://github.com/apple/indexstore-db/archive/swift-%{swifttag}.tar.gz#/indexstore-db.tar.gz
28-
Source11: https://github.com/apple/llvm-project/archive/swift-%{swifttag}.tar.gz#/llvm-project.tar.gz
29-
Source12: https://github.com/apple/swift-tools-support-core/archive/swift-%{swifttag}.tar.gz#/swift-tools-support-core.tar.gz
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
3025
Source13: https://github.com/apple/swift-argument-parser/archive/%{swift_argument_parser_version}.tar.gz#/swift-argument-parser.tar.gz
31-
Source14: https://github.com/apple/swift-driver/archive/swift-%{swifttag}.tar.gz#/swift-driver.tar.gz
26+
Source14: https://github.com/apple/swift-driver/archive/swift-%{swift_version}.tar.gz#/swift-driver.tar.gz
3227
Source15: https://github.com/unicode-org/icu/archive/release-%{icu_version}.tar.gz#/icu.tar.gz
33-
Source16: https://github.com/apple/swift-syntax/archive/swift-%{swifttag}.zip#/swift-syntax.tar.gz
28+
Source16: https://github.com/apple/swift-syntax/archive/swift-%{swift_version}.zip#/swift-syntax.tar.gz
3429
Source17: https://github.com/jpsim/Yams/archive/%{yams_version}.zip#/yams.tar.gz
3530
Source18: https://github.com/apple/swift-crypto/archive/refs/tags/%{swift_crypto_version}.tar.gz#/swift-crypto.tar.gz
3631
Source19: https://github.com/ninja-build/ninja/archive/refs/tags/v%{ninja_version}.tar.gz#/ninja.tar.gz
@@ -96,26 +91,26 @@ importantly, Swift is designed to make writing and maintaining
9691
correct programs easier for the developer.
9792

9893
%prep
99-
%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 -a 19
94+
%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
10095
# The Swift build script requires directories to be named
10196
# in a specific way so renaming the source directories is
10297
# necessary
103-
mv swift-cmark-swift-%{swifttag} cmark
104-
mv swift-corelibs-foundation-swift-%{swifttag} swift-corelibs-foundation
105-
mv swift-corelibs-libdispatch-swift-%{swifttag} swift-corelibs-libdispatch
106-
mv swift-corelibs-xctest-swift-%{swifttag} swift-corelibs-xctest
107-
mv swift-integration-tests-swift-%{swifttag} swift-integration-tests
108-
mv swift-llbuild-swift-%{swifttag} llbuild
109-
mv swift-package-manager-swift-%{swifttag} swiftpm
110-
mv swift-swift-%{swifttag} swift
111-
mv swift-xcode-playground-support-swift-%{swifttag} swift-xcode-playground-support
112-
mv sourcekit-lsp-swift-%{swifttag} sourcekit-lsp
113-
mv indexstore-db-swift-%{swifttag} indexstore-db
114-
mv llvm-project-swift-%{swifttag} llvm-project
115-
mv swift-syntax-swift-%{swifttag} swift-syntax
116-
mv swift-tools-support-core-swift-%{swifttag} swift-tools-support-core
98+
mv swift-cmark-swift-%{swift_version} cmark
99+
mv swift-corelibs-foundation-swift-%{swift_version} swift-corelibs-foundation
100+
mv swift-corelibs-libdispatch-swift-%{swift_version} swift-corelibs-libdispatch
101+
mv swift-corelibs-xctest-swift-%{swift_version} swift-corelibs-xctest
102+
mv swift-integration-tests-swift-%{swift_version} swift-integration-tests
103+
mv swift-llbuild-swift-%{swift_version} llbuild
104+
mv swift-package-manager-swift-%{swift_version} swiftpm
105+
mv swift-swift-%{swift_version} swift
106+
mv swift-xcode-playground-support-swift-%{swift_version} swift-xcode-playground-support
107+
mv sourcekit-lsp-swift-%{swift_version} sourcekit-lsp
108+
mv indexstore-db-swift-%{swift_version} indexstore-db
109+
mv llvm-project-swift-%{swift_version} llvm-project
110+
mv swift-syntax-swift-%{swift_version} swift-syntax
111+
mv swift-tools-support-core-swift-%{swift_version} swift-tools-support-core
117112
mv swift-argument-parser-%{swift_argument_parser_version} swift-argument-parser
118-
mv swift-driver-swift-%{swifttag} swift-driver
113+
mv swift-driver-swift-%{swift_version} swift-driver
119114
mv swift-crypto-%{swift_crypto_version} swift-crypto
120115
mv ninja-%{ninja_version} ninja
121116

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# package metadata
2+
3+
%global package_name swiftlang
4+
%global package_version 5.5.0
5+
%global package_summary The Swift programming language
6+
%global package_license Apache 2.0
7+
%global package_url https://swift.org
8+
9+
# versions
10+
11+
%global swift_version 5.5-RELEASE
12+
%global icu_version 65-1
13+
%global yams_version 4.0.2
14+
%global swift_argument_parser_version 0.4.3
15+
%global swift_crypto_version 1.1.5
16+
%global ninja_version 1.10.2
17+
18+
# locations
19+
20+
%global swift_source_location swift-source

0 commit comments

Comments
 (0)