Skip to content

Commit

Permalink
Merge pull request swiftlang#35 from apple/revert-32-fix/docker-setup
Browse files Browse the repository at this point in the history
Revert "improve docker setup"
  • Loading branch information
shahmishal authored Oct 8, 2021
2 parents 14238eb + 77db631 commit f76a4b6
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.output
.out
.DS_Store
1 change: 0 additions & 1 deletion platforms/Linux/centos/8/.dockerignore

This file was deleted.

31 changes: 20 additions & 11 deletions platforms/Linux/centos/8/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2021 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 centos:8
LABEL PURPOSE="This image is configured to build Swift for the version of CentOS listed above"

WORKDIR /root

RUN yum -y update

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

# Optimization: Install all the dependencies needed to build Swift from the spec file itself
ADD swift-lang.spec /tmp/swift-lang.spec
RUN yum-builddep -y /tmp/swift-lang.spec
# Add the spec
RUN mkdir -p /root/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
ADD swift-lang.spec /root/rpmbuild/SPECS/swift-lang.spec

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

# Get the sources for Swift as defined in the spec file
RUN spectool -g -R /root/rpmbuild/SPECS/swift-lang.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"]
36 changes: 10 additions & 26 deletions platforms/Linux/centos/8/build_rpm.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,41 +1,25 @@
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2021 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

#!/usr/bin/env bash

set +ex
# 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=/output
if [[ ! -d "$OUTDIR" ]]; then
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
# Always make sure we're up to date
yum update -y

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

# Add the spec
cp swift-lang.spec $HOME/rpmbuild/SPECS/swift-lang.spec
# Add the patches
cp patches/*.patch $HOME/rpmbuild/SOURCES/

pushd $HOME/rpmbuild/SPECS
# install all the dependencies needed to build Swift from the spec file itself
yum-builddep -y ./swift-lang.spec
# get the sources for Swift as defined in the spec file
spectool -g -R ./swift-lang.spec
# 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'
rpmbuild -ba ./swift-lang.spec 2>&1 | tee /root/build-output.txt
pushd $HOME/rpmbuild/SPECS
rpmbuild -ba ./swift-lang.spec 2>&1 | tee $HOME/build-output.txt
popd

# Include the build log which can be used to determine what went
Expand Down
36 changes: 0 additions & 36 deletions platforms/Linux/centos/8/docker-compose.yaml

This file was deleted.

26 changes: 8 additions & 18 deletions platforms/Linux/centos/8/readme.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,23 @@
# Building Swift on CentOS Linux


### building with docker-compose
### building with docker

* to run the build end-to-end

```
docker-compose run build
```

* to enter the docker env in shell mode
Build the builder docker image, this will download the sources

```
docker-compose run shell
docker build . -t rpm-builder
```

then you can run `./build_rpm.sh` to run the build manually inside the docker


* to rebuild the base image
Run the builder, this will run the build

```
docker-compose build --pull
docker run -v `pwd`/.out:/out rpm-builder
```

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 swift release version should be an argument?
* the versions of source packages (eg yams) should come from an external file, likely one per swift release version
Open Issues / Introduction
* the swift release version should be an argument
* 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
* 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 comments on commit f76a4b6

Please sign in to comment.