Skip to content

Commit f76a4b6

Browse files
authored
Merge pull request swiftlang#35 from apple/revert-32-fix/docker-setup
Revert "improve docker setup"
2 parents 14238eb + 77db631 commit f76a4b6

File tree

6 files changed

+39
-93
lines changed

6 files changed

+39
-93
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
.output
1+
.out
22
.DS_Store

platforms/Linux/centos/8/.dockerignore

-1
This file was deleted.

platforms/Linux/centos/8/Dockerfile

+20-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
# This source file is part of the Swift.org open source project
2-
#
3-
# Copyright (c) 2021 Apple Inc. and the Swift project authors
4-
# Licensed under Apache License v2.0 with Runtime Library Exception
5-
#
6-
# See http://swift.org/LICENSE.txt for license information
7-
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8-
91
FROM centos:8
102
LABEL PURPOSE="This image is configured to build Swift for the version of CentOS listed above"
113

4+
WORKDIR /root
5+
126
RUN yum -y update
137

148
# RPM and yum development tools
@@ -18,6 +12,21 @@ RUN yum install -y rpmdevtools yum-utils
1812
RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
1913
RUN yum config-manager --set-enabled powertools
2014

21-
# Optimization: Install all the dependencies needed to build Swift from the spec file itself
22-
ADD swift-lang.spec /tmp/swift-lang.spec
23-
RUN yum-builddep -y /tmp/swift-lang.spec
15+
# Add the spec
16+
RUN mkdir -p /root/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
17+
ADD swift-lang.spec /root/rpmbuild/SPECS/swift-lang.spec
18+
19+
# Install all the dependencies needed to build Swift from the spec file itself
20+
RUN yum-builddep -y /root/rpmbuild/SPECS/swift-lang.spec
21+
22+
# Get the sources for Swift as defined in the spec file
23+
RUN spectool -g -R /root/rpmbuild/SPECS/swift-lang.spec
24+
25+
# Add the patches
26+
ADD patches/*.patch /root/rpmbuild/SOURCES/
27+
28+
# Add the driver script
29+
ADD build_rpm.sh /root/build_rpm.sh
30+
RUN chmod +x /root/build_rpm.sh
31+
32+
CMD ["/root/build_rpm.sh"]

platforms/Linux/centos/8/build_rpm.sh

100755100644
+10-26
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,25 @@
1-
# This source file is part of the Swift.org open source project
2-
#
3-
# Copyright (c) 2021 Apple Inc. and the Swift project authors
4-
# Licensed under Apache License v2.0 with Runtime Library Exception
5-
#
6-
# See http://swift.org/LICENSE.txt for license information
7-
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
8-
91
#!/usr/bin/env bash
102

11-
set +ex
3+
# This script assumes it's running in a container as root
4+
# and that /out is mounted to a directory on the local
5+
# filesystem so the build output and artifacts can be
6+
# copied out and used
127

13-
OUTDIR=/output
14-
if [[ ! -d "$OUTDIR" ]]; then
8+
OUTDIR=/out
9+
if [[ ! -d "$OUTDIR" ]]
10+
then
1511
echo "$OUTDIR does not exist, so no place to copy the artifacts!"
1612
exit 1
1713
fi
1814

19-
# always make sure we're up to date
15+
# Always make sure we're up to date
2016
yum update -y
2117

22-
# prepare direcoties
23-
mkdir -p $HOME/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
24-
25-
# Add the spec
26-
cp swift-lang.spec $HOME/rpmbuild/SPECS/swift-lang.spec
27-
# Add the patches
28-
cp patches/*.patch $HOME/rpmbuild/SOURCES/
29-
30-
pushd $HOME/rpmbuild/SPECS
31-
# install all the dependencies needed to build Swift from the spec file itself
32-
yum-builddep -y ./swift-lang.spec
33-
# get the sources for Swift as defined in the spec file
34-
spectool -g -R ./swift-lang.spec
3518
# Now we proceed to build Swift. If this is successful, we
3619
# will have two files: a SRPM file which contains the source files
3720
# as well as a regular RPM file that can be installed via `dnf' or `yum'
38-
rpmbuild -ba ./swift-lang.spec 2>&1 | tee /root/build-output.txt
21+
pushd $HOME/rpmbuild/SPECS
22+
rpmbuild -ba ./swift-lang.spec 2>&1 | tee $HOME/build-output.txt
3923
popd
4024

4125
# Include the build log which can be used to determine what went

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

-36
This file was deleted.

platforms/Linux/centos/8/readme.md

+8-18
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,23 @@
11
# Building Swift on CentOS Linux
22

33

4-
### building with docker-compose
4+
### building with docker
55

6-
* to run the build end-to-end
76

8-
```
9-
docker-compose run build
10-
```
11-
12-
* to enter the docker env in shell mode
7+
Build the builder docker image, this will download the sources
138

149
```
15-
docker-compose run shell
10+
docker build . -t rpm-builder
1611
```
1712

18-
then you can run `./build_rpm.sh` to run the build manually inside the docker
19-
20-
21-
* to rebuild the base image
13+
Run the builder, this will run the build
2214

2315
```
24-
docker-compose build --pull
16+
docker run -v `pwd`/.out:/out rpm-builder
2517
```
2618

27-
note this still uses the docker cache, so will rebuild only if the version of the underlying base image changed upstream
28-
2919

30-
### 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
20+
Open Issues / Introduction
21+
* the swift release version should be an argument
22+
* 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
3323
* 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)

0 commit comments

Comments
 (0)