Go version update to 1.12.9
[ta/caas-helm.git] / SPECS / caas-helm.spec
1 # Copyright 2019 Nokia
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 %define COMPONENT helm
16 %define RPM_NAME caas-%{COMPONENT}
17 %define RPM_MAJOR_VERSION 2.14.3
18 %define RPM_MINOR_VERSION 2
19 %define IMAGE_TAG %{RPM_MAJOR_VERSION}-%{RPM_MINOR_VERSION}
20 %define go_version 1.12.9
21 %define binary_build_dir %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/binary-save
22 %define docker_build_dir %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-build
23 %define docker_save_dir %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-save
24 %define built_binaries_dir /binary-save
25
26 Name:           %{RPM_NAME}
27 Version:        %{RPM_MAJOR_VERSION}
28 Release:        %{RPM_MINOR_VERSION}%{?dist}
29 Summary:        Containers as a Service %{COMPONENT} component
30 License:        %{_platform_licence} and MIT license and BSD and Apache License and Lesser General Public License
31 BuildArch:      x86_64
32 Vendor:         %{_platform_vendor} and helm/helm unmodified
33 Source0:        %{name}-%{version}.tar.gz
34
35 Requires: docker-ce >= 18.09.2, rsync
36 BuildRequires: docker-ce-cli >= 18.09.2, rsync, xz
37
38 %description
39 This rpm contains the %{COMPONENT} container for CaaS subsystem.
40 This container contains the %{COMPONENT} service.
41
42 %prep
43 %autosetup
44
45 %build
46 # Build Helm binaries
47 docker build \
48   --network=host \
49   --no-cache \
50   --force-rm \
51   --build-arg HTTP_PROXY="${http_proxy}" \
52   --build-arg HTTPS_PROXY="${https_proxy}" \
53   --build-arg NO_PROXY="${no_proxy}" \
54   --build-arg http_proxy="${http_proxy}" \
55   --build-arg https_proxy="${https_proxy}" \
56   --build-arg no_proxy="${no_proxy}" \
57   --build-arg HELM_VERSION="%{version}" \
58   --build-arg go_version="%{go_version}" \
59   --build-arg binaries="%{built_binaries_dir}" \
60   --tag helm-builder:%{IMAGE_TAG} \
61   %{docker_build_dir}/helm-builder
62
63 mkdir -p %{binary_build_dir}
64 builder_container=$(docker run -id --rm --network=none --entrypoint=/bin/sh helm-builder:%{IMAGE_TAG})
65 docker cp ${builder_container}:%{built_binaries_dir}/helm   %{binary_build_dir}/
66 docker cp ${builder_container}:%{built_binaries_dir}/tiller %{binary_build_dir}/
67 docker rm -f ${builder_container}
68 docker rmi helm-builder:%{IMAGE_TAG}
69
70 # Build tiller container image
71 rsync -av %{binary_build_dir}/* %{docker_build_dir}/tiller/
72 docker build \
73   --network=host \
74   --no-cache \
75   --force-rm \
76   --build-arg HTTP_PROXY="${http_proxy}" \
77   --build-arg HTTPS_PROXY="${https_proxy}" \
78   --build-arg NO_PROXY="${no_proxy}" \
79   --build-arg http_proxy="${http_proxy}" \
80   --build-arg https_proxy="${https_proxy}" \
81   --build-arg no_proxy="${no_proxy}" \
82   --tag tiller:%{IMAGE_TAG} \
83   %{docker_build_dir}/tiller
84 mkdir -p %{docker_save_dir}/
85 docker save tiller:%{IMAGE_TAG} | xz -z -T2 > "%{docker_save_dir}/tiller:%{IMAGE_TAG}.tar"
86 docker rmi tiller:%{IMAGE_TAG}
87
88 %install
89 mkdir -p %{buildroot}/%{_caas_container_tar_path}
90 rsync -av %{docker_save_dir}/* %{buildroot}/%{_caas_container_tar_path}/
91
92 mkdir -p %{buildroot}/%{_roles_path}
93 rsync -av ansible/roles/helm %{buildroot}/%{_roles_path}/
94
95 install -D ansible/playbooks/helm.yaml %{buildroot}/%{_playbooks_path}/helm.yaml
96
97 install -D -m 0755 %{binary_build_dir}/helm %{buildroot}/usr/bin/helm
98
99 %files
100 %{_caas_container_tar_path}/tiller:%{IMAGE_TAG}.tar
101 %{_roles_path}/helm
102 %{_playbooks_path}/helm.yaml
103 /usr/bin/helm
104
105 %preun
106
107 %post
108 mkdir -p %{_postconfig_path}
109 ln -s %{_playbooks_path}/helm.yaml %{_postconfig_path}/
110
111 %postun
112 if [ $1 -eq 0 ]; then
113   rm -f %{_postconfig_path}/helm.yaml
114 fi
115
116 %clean
117 rm -rf ${buildroot}