8e5c0ed7e22a5c7bbb46142c3caeab6af854978b
[ta/caas-helm.git] / SPECS / caas-chartrepo.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 chartrepo
16 %define RPM_NAME caas-%{COMPONENT}
17 %define RPM_MAJOR_VERSION 1.0.0
18 %define RPM_MINOR_VERSION 4
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_licence} and MIT license and BSD and Apache License and Lesser General Public License
28 BuildArch:      x86_64
29 Vendor:         %{_platform_vendor} and kubernetes/kubernetes unmodified
30 Source0:        %{name}-%{version}.tar.gz
31
32 Requires: docker-ce >= 18.09.2, rsync
33 BuildRequires: docker-ce-cli >= 18.09.2, xz
34
35 %description
36 This rpm contains the %{COMPONENT} container for CaaS subsystem.
37 This container contains the %{COMPONENT} service.
38
39 %prep
40 %autosetup
41
42 %build
43 rsync -av %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/src/*   %{docker_build_dir}/chartrepohandler/
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   --tag %{COMPONENT}:%{IMAGE_TAG} \
55   %{docker_build_dir}/chartrepohandler
56 mkdir -p %{docker_save_dir}
57 docker save %{COMPONENT}:%{IMAGE_TAG} | xz -z -T2 > %{docker_save_dir}/%{COMPONENT}:%{IMAGE_TAG}.tar
58 docker rmi %{COMPONENT}:%{IMAGE_TAG}
59
60 %install
61 mkdir -p %{buildroot}/%{_caas_container_tar_path}
62 rsync -av %{docker_save_dir}/* %{buildroot}/%{_caas_container_tar_path}/
63
64 mkdir -p %{buildroot}/%{_roles_path}
65 rsync -av ansible/roles/chart_repo %{buildroot}/%{_roles_path}/
66
67 install -D ansible/playbooks/chart_repo.yaml %{buildroot}/%{_playbooks_path}/chart_repo.yaml
68
69 %files
70 %{_caas_container_tar_path}/*.tar
71 %{_roles_path}/chart_repo/
72 %{_playbooks_path}/chart_repo.yaml
73
74 %preun
75
76 %post
77 mkdir -p %{_postconfig_path}
78 ln -s %{_playbooks_path}/chart_repo.yaml          %{_postconfig_path}/
79
80 %postun
81 if [ $1 -eq 0 ]; then
82   rm -f %{_playbooks_path}/chart_repo.yaml
83 fi
84
85 %clean
86 rm -rf ${buildroot}