diff --git a/.gitignore b/.gitignore index 146c62e8f7201..a52722c3f6efe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -.output +.out .DS_Store diff --git a/platforms/Linux/centos/8/.dockerignore b/platforms/Linux/centos/8/.dockerignore deleted file mode 100644 index 16ff3c79ed155..0000000000000 --- a/platforms/Linux/centos/8/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -.output diff --git a/platforms/Linux/centos/8/Dockerfile b/platforms/Linux/centos/8/Dockerfile index 21d391734365f..bd6f478013a13 100644 --- a/platforms/Linux/centos/8/Dockerfile +++ b/platforms/Linux/centos/8/Dockerfile @@ -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 @@ -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"] diff --git a/platforms/Linux/centos/8/build_rpm.sh b/platforms/Linux/centos/8/build_rpm.sh old mode 100755 new mode 100644 index fb0cad96db73c..77922daf8ae6f --- a/platforms/Linux/centos/8/build_rpm.sh +++ b/platforms/Linux/centos/8/build_rpm.sh @@ -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 diff --git a/platforms/Linux/centos/8/docker-compose.yaml b/platforms/Linux/centos/8/docker-compose.yaml deleted file mode 100644 index dd4b921eb3764..0000000000000 --- a/platforms/Linux/centos/8/docker-compose.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# 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 - -version: "3" - -services: - - docker-setup: - image: centos8-rpm-builder - build: - context: . - dockerfile: Dockerfile - - common: &common - image: centos8-rpm-builder - depends_on: [docker-setup] - volumes: - - .:/code:z - - ./.output:/output:z - working_dir: /code - cap_drop: - - CAP_NET_RAW - - CAP_NET_BIND_SERVICE - - build: - <<: *common - command: /bin/bash -cl "./build_rpm.sh" - - shell: - <<: *common - entrypoint: /bin/bash -l diff --git a/platforms/Linux/centos/8/readme.md b/platforms/Linux/centos/8/readme.md index 65a7008ebc030..529c7b9fdca3e 100644 --- a/platforms/Linux/centos/8/readme.md +++ b/platforms/Linux/centos/8/readme.md @@ -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)