Seed code for yarf
[ta/yarf.git] / yarf.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
16 Name:           yarf
17 Version:        %{_version}
18 Release:        1%{?dist}
19 Summary:        Yet Another Restfulframework
20 License:        %{_platform_licence}
21 Source0:        %{name}-%{version}.tar.gz
22 Vendor:         %{_platform_vendor}
23
24 Requires: python-flask, python2-flask-restful, python2-configparser, python2-requests, mod_wsgi, python2-six 
25 BuildRequires: python
26 BuildRequires: python-setuptools
27
28 %description
29 Yet Another Restfulframework.
30
31 %prep
32 #./autogen.sh
33 %autosetup
34
35 %build
36
37 %install
38 rm -rf $RPM_BUILD_ROOT
39 mkdir -p %{buildroot}%{_platform_etc_path}/yarf
40 mkdir -p %{buildroot}%{_platform_etc_path}/required-secrets
41 mkdir -p %{buildroot}%{_unitdir}/
42 mkdir -p %{buildroot}/var/log/restapi
43 cp required-secrets/*.yaml %{buildroot}/%{_platform_etc_path}/required-secrets
44 #mkdir -p {buildroot}/etc/httpd/conf.d/
45 #mkdir -p {buildroot}/var/www/yarf/
46
47 cd src && python setup.py install --root %{buildroot} --no-compile --install-purelib %{_python_site_packages_path} --install-scripts %{_platform_bin_path} && cd -
48
49 rsync -rv systemd/* %{buildroot}%{_unitdir}/
50
51 %files
52 %defattr(0755,root,root,0755)
53 %{_python_site_packages_path}/yarf*
54 %attr(0755,restapi, restapi) %{_platform_etc_path}/yarf/
55 %{_platform_etc_path}/required-secrets/restful.yaml
56 #/etc/ansible/roles/restful
57 #/opt/openstack-ansible/playbooks/yarf.yml
58 %attr(0755,root, root) %{_platform_bin_path}/restapi
59 # %attr(0644,root, root) %{_unitdir}/restapi.service
60 %attr(0644,root, root) %{_unitdir}/* 
61 %dir %attr(0770, restapi,restapi) /var/log/restapi
62
63 %pre
64 /usr/bin/getent passwd restapi > /dev/null||/usr/sbin/useradd -r -s /sbin/nologin -M restapi
65
66 %post
67 if [ $1 -eq 2 ]; then
68     if [ -f %{_platform_etc_path}/restful/config.ini ]; then
69         sudo /usr/bin/systemctl restart restapi
70     fi
71 fi
72
73 %postun
74
75 #Uninstall
76 if [ $1 -eq 0 ];then
77     /usr/sbin/userdel restapi
78 fi