Skip to content

Commit 31db6d3

Browse files
committed
exterrnalize metadata and make it version based
motivation: share and scale across multiple platforms changes: * introduce location for share metadata * create metadata file for rpm 5.5.0 * update centos 8 spec and script to use the shared metadata
1 parent 804d523 commit 31db6d3

File tree

5 files changed

+56
-51
lines changed

5 files changed

+56
-51
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
.out
1+
.output
22
.DS_Store

platforms/Linux/centos/8/.output/build-output.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

platforms/Linux/centos/8/build_rpm.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,31 @@
88

99
#!/usr/bin/env bash
1010

11-
set +ex
11+
set -ex
1212

1313
OUTDIR=/output
1414
if [[ ! -d "$OUTDIR" ]]; then
1515
echo "$OUTDIR does not exist, so no place to copy the artifacts!"
1616
exit 1
1717
fi
1818

19+
SWIFT_VERSION=$1
20+
if [[ ! -n "$SWIFT_VERSION" ]]; then
21+
echo "unknown swift version, please pass as argument to the script"
22+
exit 1
23+
fi
24+
1925
# always make sure we're up to date
2026
yum update -y
2127

2228
# prepare direcoties
2329
mkdir -p $HOME/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
2430

2531
# Add the spec
26-
cp swift-lang.spec $HOME/rpmbuild/SPECS/swift-lang.spec
27-
# Add the patches
32+
cp swift-lang.spec $HOME/rpmbuild/SPECS/
33+
# Add the metadata for this swift version
34+
cp /metadata/rpm/$SWIFT_VERSION/metadata.inc $HOME/rpmbuild/SPECS/
35+
# Add any patches
2836
cp patches/*.patch $HOME/rpmbuild/SOURCES/
2937

3038
pushd $HOME/rpmbuild/SPECS

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ services:
2121
depends_on: [docker-setup]
2222
volumes:
2323
- .:/code:z
24+
- ../../../../metadata:/metadata:ro
2425
- ./.output:/output:z
2526
working_dir: /code
2627
cap_drop:
2728
- CAP_NET_RAW
2829
- CAP_NET_BIND_SERVICE
30+
environment:
31+
- SWIFT_VERSION # override this with environment variable
2932

3033
build:
3134
<<: *common
32-
command: /bin/bash -cl "./build_rpm.sh"
35+
command: /bin/bash -cl "./build_rpm.sh ${SWIFT_VERSION}"
3336

3437
shell:
3538
<<: *common

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

0 commit comments

Comments
 (0)