AArch64 support
[ta/caas-registry.git] / SPECS / swift.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 swift
16 %define RPM_NAME caas-%{COMPONENT}
17 %define RPM_MAJOR_VERSION 2.22.0
18 %define RPM_MINOR_VERSION 3
19 %define IMAGE_TAG %{RPM_MAJOR_VERSION}-%{RPM_MINOR_VERSION}
20 %define centos_build 191001
21 Name:           %{RPM_NAME}
22 Version:        %{RPM_MAJOR_VERSION}
23 Release:        %{RPM_MINOR_VERSION}%{?dist}
24 Summary:        Containers as a Service Swift component
25 License:        %{_platform_license} and Apache License and GNU Lesser General Public License v3.0 only and BSD 3-clause New or Revised License and MIT License and Common Development and Distribution License and BSD and GNU General Public License v2.0 only
26 URL:            https://github.com/openstack/swift
27 BuildArch:      %{_arch}
28 Vendor:         %{_platform_vendor} and openstack/swift unmodified
29 Source0:        %{name}-%{version}.tar.gz
30
31 Requires: docker-ce >= 18.09.2, rsync
32 BuildRequires: docker-ce-cli >= 18.09.2, xz, wget
33
34 %description
35 This rpm contains the swift container and ansible for caas subsystem.
36 This container contains the swift service.
37
38 %prep
39 %autosetup
40
41 %build
42 wget --progress=dot:giga http://artifacts.ci.centos.org/sig-cloudinstance/centos-7-%{centos_build}/%{_arch}/centos-7-%{_arch}-docker.tar.xz -O %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-build/%{COMPONENT}/centos-7-docker.tar.xz
43 # Building the container
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 SWIFT="%{version}" \
55   --tag %{COMPONENT}:%{IMAGE_TAG} \
56   %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-build/%{COMPONENT}/
57
58 # Creating a new folder for the container tar file
59 mkdir -p %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-save/
60
61 # Save the container
62 docker save %{COMPONENT}:%{IMAGE_TAG} | xz -z -T2 > %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-save/%{COMPONENT}:%{IMAGE_TAG}.tar
63
64 # Remove container
65 docker rmi -f %{COMPONENT}:%{IMAGE_TAG}
66
67 %install
68 mkdir -p %{buildroot}/%{_caas_container_tar_path}/
69 rsync -av %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-save/%{COMPONENT}:%{IMAGE_TAG}.tar %{buildroot}/%{_caas_container_tar_path}/
70
71 mkdir -p %{buildroot}/%{_playbooks_path}/
72 rsync -av ansible/playbooks/swift.yaml %{buildroot}/%{_playbooks_path}/
73
74 mkdir -p %{buildroot}/%{_roles_path}/
75 rsync -av ansible/roles/swift %{buildroot}/%{_roles_path}/
76
77
78 %files
79 %{_caas_container_tar_path}/%{COMPONENT}:%{IMAGE_TAG}.tar
80 %{_playbooks_path}/*
81 %{_roles_path}/*
82
83 %preun
84
85 %post
86 mkdir -p %{_postconfig_path}/
87 ln -sf %{_playbooks_path}/swift.yaml %{_postconfig_path}/
88
89 %postun
90 if [ $1 -eq 0 ]; then
91     rm -f %{_postconfig_path}/swift.yaml
92 fi
93
94 %clean
95 rm -rf ${buildroot}