6e340dc934c94433d04bf0ec60525c6b7851a2e2
[ta/caas-etcd.git] / caas-etcd.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 etcd
16 %define RPM_NAME caas-%{COMPONENT}
17 %define RPM_MAJOR_VERSION 3.3.13
18 %define RPM_MINOR_VERSION 2
19 %define IMAGE_TAG %{RPM_MAJOR_VERSION}-%{RPM_MINOR_VERSION}
20 %define docker_build_dir %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-build
21 %define docker_save_dir %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-save
22
23 Name:           %{RPM_NAME}
24 Version:        %{RPM_MAJOR_VERSION}
25 Release:        %{RPM_MINOR_VERSION}%{?dist}
26 Summary:        Containers as a Service %{COMPONENT} component
27 License:        %{_platform_license} and MIT license and BSD and Apache License and Lesser General Public License
28 URL:            https://github.com/etcd-io/etcd
29 BuildArch:      x86_64
30 Vendor:         %{_platform_vendor} and etcd-io/etcd unmodified
31 Source0:        %{name}-%{version}.tar.gz
32
33 Requires: docker-ce >= 18.09.2, rsync
34 BuildRequires: docker-ce-cli >= 18.09.2, xz
35
36 %description
37 This rpm contains the %{COMPONENT} container for CaaS subsystem.
38 This container contains the %{COMPONENT} service.
39
40 %prep
41 %autosetup
42
43 %build
44 docker build \
45   --network=host \
46   --no-cache \
47   --force-rm \
48   --build-arg HTTP_PROXY="${http_proxy}" \
49   --build-arg HTTPS_PROXY="${https_proxy}" \
50   --build-arg NO_PROXY="${no_proxy}" \
51   --build-arg http_proxy="${http_proxy}" \
52   --build-arg https_proxy="${https_proxy}" \
53   --build-arg no_proxy="${no_proxy}" \
54   --build-arg ETCD_VERSION="%{version}" \
55   --tag %{COMPONENT}:%{IMAGE_TAG} \
56   %{docker_build_dir}/%{COMPONENT}/
57 mkdir -p %{docker_save_dir}/
58 docker save %{COMPONENT}:%{IMAGE_TAG} | xz -z -T2 > %{docker_save_dir}/%{COMPONENT}:%{IMAGE_TAG}.tar
59 docker rmi %{COMPONENT}:%{IMAGE_TAG}
60
61 %install
62 mkdir -p %{buildroot}/%{_caas_container_tar_path}
63 rsync -av %{docker_save_dir}/%{COMPONENT}:%{IMAGE_TAG}.tar %{buildroot}/%{_caas_container_tar_path}/
64
65 mkdir -p %{buildroot}/%{_roles_path}
66 rsync -av ansible/roles/* %{buildroot}/%{_roles_path}/
67
68 install -D ansible/playbooks/etcd.yaml %{buildroot}/%{_playbooks_path}/etcd.yaml
69
70 %files
71 %{_caas_container_tar_path}/%{COMPONENT}:%{IMAGE_TAG}.tar
72 %{_roles_path}/etcd
73 %{_playbooks_path}/etcd.yaml
74
75 %preun
76
77 %post
78 mkdir -p %{_postconfig_path}
79 ln -s %{_playbooks_path}/etcd.yaml %{_postconfig_path}/
80
81 %postun
82 if [ $1 -eq 0 ]; then
83   rm -f %{_postconfig_path}/etcd.yaml
84 fi
85
86 %clean
87 rm -rf ${buildroot}