973062ba8b100478dee11eaa1ae3555950a570ba
[ta/caas-lcm.git] / rpmbuild.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 lcm
16 %define RPM_NAME caas-%{COMPONENT}
17 %define RPM_MAJOR_VERSION 1.0.0
18 %define RPM_MINOR_VERSION 8
19 %define IMAGE_TAG %{RPM_MAJOR_VERSION}-%{RPM_MINOR_VERSION}
20 %define DEPLOY_PATH %{_caas_lcm_path}/deploy
21 %define SU_PATH %{_caas_lcm_path}/su
22
23 Name:           %{RPM_NAME}
24 Version:        %{RPM_MAJOR_VERSION}
25 Release:        %{RPM_MINOR_VERSION}%{?dist}
26 Summary:        Containers as a Service Life Cycle Managemnet workflows
27 License:        %{_platform_license}
28 BuildArch:      x86_64
29 Vendor:         %{_platform_vendor}
30 Source0:        %{name}-%{version}.tar.gz
31
32 Requires: rsync >= 3.1.0
33
34 %description
35 This RPM contains Life Cycle Managemnet workflows for the CaaS subsystem.
36
37 %prep
38 %autosetup
39
40 %build
41
42 %install
43 mkdir -p %{buildroot}/%{SU_PATH}/
44 rsync -av su/* %{buildroot}/%{SU_PATH}/
45
46 mkdir -p %{buildroot}/%{DEPLOY_PATH}/
47 rsync -av deploy/* %{buildroot}/%{DEPLOY_PATH}/
48
49 mkdir -p %{buildroot}/%{_playbooks_path}/
50 rsync -av ansible/playbooks/pre_config_lcm.yaml %{buildroot}/%{_playbooks_path}/
51
52 mkdir -p %{buildroot}/%{_roles_path}/
53 rsync -av ansible/roles/pre_config_lcm %{buildroot}/%{_roles_path}/
54
55 # ------- set lcm path inside deploy
56 sed -i 's|{{ lcm_path }}|%{_caas_lcm_path}|g' %{buildroot}/%{DEPLOY_PATH}/roles/bm_onboard/tasks/main.yml
57 sed -i 's|{{ lcm_path }}|%{_caas_lcm_path}|g' %{buildroot}/%{DEPLOY_PATH}/roles/list_application_deployments/tasks/main.yml
58 sed -i 's|{{ lcm_path }}|%{_caas_lcm_path}|g' %{buildroot}/%{DEPLOY_PATH}/roles/list_application_packages/tasks/main.yml
59 sed -i 's|{{ lcm_path }}|%{_caas_lcm_path}|g' %{buildroot}/%{DEPLOY_PATH}/roles/list_docker_images/tasks/main.yml
60 sed -i 's|{{ caas_manifest_path }}|%{_caas_manifest_path}|g' %{buildroot}/%{DEPLOY_PATH}/group_vars/controller-1.caas_master/params.yml
61 # ------- set lcm path inside roles
62 sed -i 's|{{ lcm_path }}|%{_caas_lcm_path}|g' %{buildroot}/%{_roles_path}/pre_config_lcm/tasks/main.yml
63 # -------
64
65 %files
66 %{SU_PATH}
67 %{DEPLOY_PATH}
68 %{_playbooks_path}/pre_config_lcm.yaml
69 %{_roles_path}/pre_config_lcm
70
71 %preun
72
73 %post
74 mkdir -p %{_postconfig_path}/
75 ln -sf %{_playbooks_path}/pre_config_lcm.yaml %{_postconfig_path}/
76
77 %postun
78 if [ $1 -eq 0 ]; then
79     rm -f %{_postconfig_path}/pre_config_lcm.yaml
80 fi
81
82 %clean
83 rm -rf ${buildroot}
84