-
Notifications
You must be signed in to change notification settings - Fork 6
/
openstack-example.spec
191 lines (137 loc) · 5.21 KB
/
openstack-example.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
%{!?upstream_version: %global upstream_version %{version}%{?milestone}}
%global service example
Name: openstack-%{service}
Version: XXX
Release: XXX
Summary: OpenStack Example Service
License: ASL 2.0
URL: http://launchpad.net/%{service}/
Source0: http://tarballs.openstack.org/%{service}/%{service}-master.tar.gz
Source1: %{service}.logrotate
Source2: openstack-example-server.service
Source3: %{service}-dist.conf
BuildArch: noarch
BuildRequires: python2-devel
BuildRequires: python-pbr
BuildRequires: python-setuptools
BuildRequires: git
BuildRequires: systemd
BuildRequires: systemd-units
# Required to compile translation files
BuildRequires: python-babel
Requires: openstack-%{service}-common = %{version}-%{release}
Requires(pre): shadow-utils
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%description
This is the description of an example service for OpenStack.
%package -n python-%{service}
Summary: Example Python libraries
Requires: python-oslo-db >= 2.0
%description -n python-%{service}
This is the description of an example service for OpenStack.
This package contains the Example Python library.
%package -n python-%{service}-tests-unit
Summary: Example unit tests
Requires: python-%{service} = %{version}-%{release}
%description -n python-%{service}-tests-unit
This is the description of an example service for OpenStack.
This package contains the Example unit test files.
# python-%{service}-tests package is for backwards compatibility
# it can be ignored for new services
%package -n python-%{service}-tests
Summary: Example tests meta-package
Requires: python-%{service}-tests-unit = %{version}-%{release}
Requires: python-%{service}-tests-tempest
%description -n python-%{service}-tests
This is the description of an example service for OpenStack.
This package is a meta-package for all service tests packages including
unit and tempest tests.
%package common
Summary: Example common files
Requires: python-%{service} = %{version}-%{release}
%description common
This is the description of an example service for OpenStack.
This package contains Example common files.
%package doc
Summary: Example documentation
BuildRequires: python-sphinx
BuildRequires: python-oslo-sphinx
%description doc
This is the description of an example service for OpenStack.
This package contains the documentation.
%prep
%autosetup -n %{service}-%{upstream_version} -S git
# Let's handle dependencies ourseleves
rm -f *requirements.txt
%build
%py2_build
# generate html docs
%{__python2} setup.py build_sphinx
# remove the sphinx-build leftovers
rm -rf html/.{doctrees,buildinfo}
# Generate i18n files
%{__python2} setup.py compile_catalog -d build/lib/%{service}/locale
%install
%py2_install
# Setup directories
install -d -m 755 %{buildroot}%{_datadir}/%{service}
install -d -m 755 %{buildroot}%{_sharedstatedir}/%{service}
install -d -m 755 %{buildroot}%{_localstatedir}/log/%{service}
# Move config files to proper location
install -d -m 755 %{buildroot}%{_sysconfdir}/%{service}
mv %{buildroot}/usr/etc/%{service}/* %{buildroot}%{_sysconfdir}/%{service}
mv %{buildroot}%{_sysconfdir}/%{service}/api-paste.ini %{buildroot}%{_datadir}/%{service}/api-paste.ini
# Install dist conf
install -p -D -m 640 %{SOURCE3} %{buildroot}%{_datadir}/%{service}/%{service}-dist.conf
# Install logrotate
install -p -D -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/openstack-%{service}
# Install systemd units
install -p -D -m 644 %{SOURCE2} %{buildroot}%{_unitdir}/openstack-example-server.service
# Install i18n .mo files (.po and .pot are not required)
install -d -m 755 %{buildroot}%{_datadir}
rm -f %{buildroot}%{python2_sitelib}/%{service}/locale/*/LC_*/%{service}*po
rm -f %{buildroot}%{python2_sitelib}/%{service}/locale/*pot
mv %{buildroot}%{python2_sitelib}/%{service}/locale %{buildroot}%{_datadir}/locale
# Find language files
%find_lang %{service} --all-name
%pre common
getent group %{service} >/dev/null || groupadd -r %{service}
getent passwd %{service} >/dev/null || \
useradd -r -g %{service} -d %{_sharedstatedir}/%{service} -s /sbin/nologin \
-c "OpenStack Example Daemons" %{service}
exit 0
%post
%systemd_post openstack-example-server.service
%preun
%systemd_preun openstack-example-server.service
%postun
%systemd_postun_with_restart openstack-example-server.service
%files
%license LICENSE
%{_bindir}/openstack-example-server
%{_unitdir}/openstack-example-server.service
%attr(-, root, %{service}) %{_datadir}/%{service}/api-paste.ini
%files -n python-%{service}-tests-unit
%license LICENSE
%{python2_sitelib}/%{service}/tests-unit
%files -n python-%{service}
%license LICENSE
%{python2_sitelib}/%{service}
%{python2_sitelib}/%{service}-*.egg-info
%exclude %{python2_sitelib}/%{service}/tests
%files common -f %{service}.lang
%license LICENSE
%doc README.rst
%dir %{_sysconfdir}/%{service}
%config(noreplace) %attr(0640, root, %{service}) %{_sysconfdir}/%{service}/%{service}.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/openstack-%{service}
%dir %{_datadir}/%{service}
%attr(-, root, %{service}) %{_datadir}/%{service}/%{service}-dist.conf
%dir %{_sharedstatedir}/%{service}
%dir %attr(0750, %{service}, root) %{_localstatedir}/log/%{service}
%files doc
%license LICENSE
%doc html README.rst
%changelog