Skip to content

Commit 3bf648f

Browse files
authored
improve sharing across RPMs (#86)
motivation: dedup more across RPM spec and scripts changes: * organize shared content in the a "Shared" directory * create several more ".inc" files that extract duplicate information across RPM spec, including the description and header * add symlinks to shared metadata and script so that the spec can also run easily outide docker * update docker compose scripts to use new directory structure * update Dockerfile optimization to be more resiliant by rewrting an bare-bone optimnization spec
1 parent b544dac commit 3bf648f

29 files changed

+130
-231
lines changed

platforms/Linux/RPM/Amazonlinux/2/Dockerfile

+7-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ RUN yum install -y rpmdevtools yum-utils createrepo
1717
# Configure epel
1818
RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
1919

20-
# Optimization: Install all the dependencies needed to build Swift from the spec file itself
20+
# Optimization: Install Swift build requirements listed in the spec file
2121
ADD swiftlang.spec /tmp/swiftlang.spec
22-
RUN touch /tmp/metadata.inc # fake metadata is okay for this optimization
23-
RUN cd /tmp && yum-builddep -y swiftlang.spec
22+
# rewrite a minimal spec with the build requirements
23+
RUN echo -e "Name: optimization\nVersion: optimization\nRelease: optimization\nSummary: optimization\nLicense: optimization\n" > /tmp/optimization.spec
24+
RUN cat /tmp/swiftlang.spec | grep BuildRequires >> /tmp/optimization.spec
25+
RUN echo -e "\n%description" >> /tmp/optimization.spec
26+
# install the build requirements
27+
RUN cd /tmp && yum-builddep -y optimization.spec
2428

2529
# fix python six
2630
RUN mkdir -p /usr/local/lib/python3.7/site-packages/

platforms/Linux/RPM/Amazonlinux/2/build_rpm.sh

-47
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Shared/scripts/build_rpm.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Shared/scripts/createrepo_rpm.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Shared/metadata/description.inc

platforms/Linux/RPM/Amazonlinux/2/docker-compose.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ services:
2626
image: amazonlinux-2-rpm-builder
2727
depends_on: [docker-setup]
2828
volumes:
29-
- .:/code:z
30-
- ../../../RPM:/shared:ro
29+
- ../../Amazonlinux/2:/code/Amazonlinux/2:z
30+
- ../../Shared:/code/Shared:z
3131
- ./.output:/output:z
32-
working_dir: /code
32+
working_dir: /code/Amazonlinux/2
3333
cap_drop:
3434
- CAP_NET_RAW
3535
- CAP_NET_BIND_SERVICE
@@ -40,7 +40,7 @@ services:
4040

4141
createrepo:
4242
<<: *common
43-
command: /bin/bash -cl "../shared/createrepo_rpm.sh"
43+
command: /bin/bash -cl "./createrepo_rpm.sh"
4444

4545
shell:
4646
<<: *common
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Shared/metadata/global.inc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Shared/metadata/metadata.inc

platforms/Linux/RPM/Amazonlinux/2/swiftlang.spec

+2-19
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1+
%include global.inc
12
%include metadata.inc
23

3-
%global debug_package %{nil}
4-
5-
Name: %{package_name}
6-
Version: %{package_version}
7-
Release: 1%{?dist}
8-
Summary: %{package_summary}
9-
License: %{package_license}
10-
URL: %{package_url}
11-
124
Source0: https://github.com/apple/swift/archive/swift-%{swift_version}.tar.gz#/swift.tar.gz
135
Source1: https://github.com/apple/swift-corelibs-libdispatch/archive/swift-%{swift_version}.tar.gz#/corelibs-libdispatch.tar.gz
146
Source2: https://github.com/apple/swift-corelibs-foundation/archive/swift-%{swift_version}.tar.gz#/corelibs-foundation.tar.gz
@@ -44,7 +36,6 @@ Source31: https://github.com/apple/swift-format/archive/swift-%{swift_vers
4436
Source32: https://github.com/apple/swift-lmdb/archive/swift-%{swift_version}.tar.gz#/swift-lmdb.tar.gz
4537
Source33: https://github.com/apple/swift-markdown/archive/swift-%{swift_version}.tar.gz#/swift-markdown.tar.gz
4638

47-
4839
Patch0: patches/hwasan_symbolize.patch
4940

5041
BuildRequires: clang
@@ -94,15 +85,7 @@ Requires: tzdata
9485
ExclusiveArch: x86_64 aarch64
9586

9687
%description
97-
Swift is a general-purpose programming language built using
98-
a modern approach to safety, performance, and software design
99-
patterns.
100-
101-
The goal of the Swift project is to create the best available
102-
language for uses ranging from systems programming, to mobile
103-
and desktop apps, scaling up to cloud services. Most
104-
importantly, Swift is designed to make writing and maintaining
105-
correct programs easier for the developer.
88+
%include description.inc
10689

10790
%prep
10891
%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 -a 20 -a 21 -a 22 -a 23 -a 24 -a 25 -a 26 -a 27 -a 28 -a 29 -a 30 -a 31 -a 32 -a 33

platforms/Linux/RPM/Centos/7/Dockerfile

+7-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ RUN yum install -y rpmdevtools yum-utils createrepo
1717
# Configure epel
1818
RUN yum install -y epel-release centos-release-scl
1919

20-
# Optimization: Install all the dependencies needed to build Swift from the spec file itself
20+
# Optimization: Install Swift build requirements listed in the spec file
2121
ADD swiftlang.spec /tmp/swiftlang.spec
22-
RUN touch /tmp/metadata.inc # fake metadata is okay for this optimization
23-
RUN cd /tmp && yum-builddep -y swiftlang.spec
22+
# rewrite a minimal spec with the build requirements
23+
RUN echo -e "Name: optimization\nVersion: optimization\nRelease: optimization\nSummary: optimization\nLicense: optimization\n" > /tmp/optimization.spec
24+
RUN cat /tmp/swiftlang.spec | grep BuildRequires >> /tmp/optimization.spec
25+
RUN echo -e "\n%description" >> /tmp/optimization.spec
26+
# install the build requirements
27+
RUN cd /tmp && yum-builddep -y optimization.spec
2428

2529
# Workaround to support clang-3.5 or a later version
2630
RUN echo -e ". /opt/rh/sclo-git25/enable\n. /opt/rh/llvm-toolset-7/enable\n. /opt/rh/devtoolset-8/enable\n" >> $HOME/.bashrc

platforms/Linux/RPM/Centos/7/build_rpm.sh

-47
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Shared/scripts/build_rpm.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Shared/scripts/createrepo_rpm.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Shared/metadata/description.inc

platforms/Linux/RPM/Centos/7/docker-compose.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ services:
2929
security_opt:
3030
- seccomp:unconfined
3131
volumes:
32-
- .:/code:z
33-
- ../../../RPM:/shared:ro
32+
- ../../Centos/7:/code/Centos/7:z
33+
- ../../Shared:/code/Shared:z
3434
- ./.output:/output:z
35-
working_dir: /code
35+
working_dir: /code/Centos/7
3636
cap_drop:
3737
- CAP_NET_RAW
3838
- CAP_NET_BIND_SERVICE
@@ -43,7 +43,7 @@ services:
4343

4444
createrepo:
4545
<<: *common
46-
command: /bin/bash -cl "../shared/createrepo_rpm.sh"
46+
command: /bin/bash -cl "./createrepo_rpm.sh"
4747

4848
shell:
4949
<<: *common
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Shared/metadata/global.inc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Shared/metadata/metadata.inc

platforms/Linux/RPM/Centos/7/swiftlang.spec

+2-18
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1+
%include global.inc
12
%include metadata.inc
23

3-
%global debug_package %{nil}
4-
5-
Name: %{package_name}
6-
Version: %{package_version}
7-
Release: 1%{?dist}
8-
Summary: %{package_summary}
9-
License: %{package_license}
10-
URL: %{package_url}
11-
124
Source0: https://github.com/apple/swift/archive/swift-%{swift_version}.tar.gz#/swift.tar.gz
135
Source1: https://github.com/apple/swift-corelibs-libdispatch/archive/swift-%{swift_version}.tar.gz#/corelibs-libdispatch.tar.gz
146
Source2: https://github.com/apple/swift-corelibs-foundation/archive/swift-%{swift_version}.tar.gz#/corelibs-foundation.tar.gz
@@ -95,15 +87,7 @@ Requires: zlib-devel
9587
ExclusiveArch: x86_64 aarch64
9688

9789
%description
98-
Swift is a general-purpose programming language built using
99-
a modern approach to safety, performance, and software design
100-
patterns.
101-
102-
The goal of the Swift project is to create the best available
103-
language for uses ranging from systems programming, to mobile
104-
and desktop apps, scaling up to cloud services. Most
105-
importantly, Swift is designed to make writing and maintaining
106-
correct programs easier for the developer.
90+
%include description.inc
10791

10892
%prep
10993
%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 -a 20 -a 21 -a 22 -a 23 -a 24 -a 25 -a 26 -a 27 -a 28 -a 29 -a 30 -a 31 -a 32 -a 33

platforms/Linux/RPM/Centos/8/Dockerfile

+7-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ RUN yum install -y rpmdevtools yum-utils createrepo
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

21-
# Optimization: Install all the dependencies needed to build Swift from the spec file itself
21+
# Optimization: Install Swift build requirements listed in the spec file
2222
ADD swiftlang.spec /tmp/swiftlang.spec
23-
RUN touch /tmp/metadata.inc # fake metadata is okay for this optimization
24-
RUN cd /tmp && yum-builddep -y swiftlang.spec
23+
# rewrite a minimal spec with the build requirements
24+
RUN echo -e "Name: optimization\nVersion: optimization\nRelease: optimization\nSummary: optimization\nLicense: optimization\n" > /tmp/optimization.spec
25+
RUN cat /tmp/swiftlang.spec | grep BuildRequires >> /tmp/optimization.spec
26+
RUN echo -e "\n%description" >> /tmp/optimization.spec
27+
# install the build requirements
28+
RUN cd /tmp && yum-builddep -y optimization.spec

platforms/Linux/RPM/Centos/8/build_rpm.sh

-47
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Shared/scripts/build_rpm.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Shared/scripts/createrepo_rpm.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Shared/metadata/description.inc

platforms/Linux/RPM/Centos/8/docker-compose.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ services:
2929
security_opt:
3030
- seccomp:unconfined
3131
volumes:
32-
- .:/code:z
33-
- ../../../RPM:/shared:ro
32+
- ../../Centos/8:/code/Centos/8:z
33+
- ../../Shared:/code/Shared:z
3434
- ./.output:/output:z
35-
working_dir: /code
35+
working_dir: /code/Centos/8
3636
cap_drop:
3737
- CAP_NET_RAW
3838
- CAP_NET_BIND_SERVICE
@@ -43,7 +43,7 @@ services:
4343

4444
createrepo:
4545
<<: *common
46-
command: /bin/bash -cl "../shared/createrepo_rpm.sh"
46+
command: /bin/bash -cl "./createrepo_rpm.sh"
4747

4848
shell:
4949
<<: *common
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Shared/metadata/global.inc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../Shared/metadata/metadata.inc

0 commit comments

Comments
 (0)