-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathjsonstats.spec
180 lines (147 loc) · 5.29 KB
/
jsonstats.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
# Depends on redhat-rpm-config
%define distribution %(/usr/lib/rpm/redhat/dist.sh --disttype)
%define distribution_version %(/usr/lib/rpm/redhat/dist.sh --distnum)
%if "el" == "%{distribution}"
%{!?rhel: %define rhel %{distribution_version}}
%endif
%if 0%{?rhel} <= 5
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
%endif
# Fedora >= 18, RHEL >= 7, and CentOS >= 7 have migrated to systemd
# and now provide the proper RPM macros
%if 0%{?fedora} >= 18 || 0%{?rhel} >= 7 || 0%{?centos} >= 7
%global with_systemd_macros 1
%global with_tmpfiles_macro 1
%endif
Name: jsonstats
%define _name jsonstatsd
Release: 1%{?dist}
Summary: Client for exposing system information over a REST interface
Version: 1.0.4
Group: Development/Libraries
License: MIT
Source0: %{name}-%{version}.tar.gz
Url: https://github.com/RHInception/jsonstats
BuildArch: noarch
# Common *Requires
Requires: PyYAML
BuildRequires: python2-devel
BuildRequires: redhat-rpm-config
######################################################################
# Fedora >= 18, RHEL >= 7, and CentOS >= 7
%if 0%{?with_systemd_macros}
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
BuildRequires: systemd
%endif
# RHEL 5/6
%if ! 0%{?with_systemd_macros}
Requires(post): chkconfig
Requires(preun): chkconfig
Requires(preun): initscripts
Requires(postun): initscripts
%endif
######################################################################
# And this ends our *Requires madness. Let's set up the proper
# pre/post script handlers for creating the jsonstatsd user and
# registering the service with the system init
######################################################################
%pre
getent passwd %{_name} >/dev/null 2>&1 || %{_sbindir}/useradd -M -r --shell %{_sbindir}/nologin %{_name}
%post
%if 0%{?with_systemd_macros}
%systemd_post %{_name}.service
%else
/sbin/chkconfig --add %{_name}
%endif
%preun
%if 0%{?with_systemd_macros}
%systemd_preun %{_name}.service
%{_sbindir}/userdel -r %{_name} > /dev/null 2>&1
%else
if [ $1 -eq 0 ] ; then
/sbin/service %{_name} stop >/dev/null 2>&1
/sbin/chkconfig --del %{_name}
%{_sbindir}/userdel %{_name} > /dev/null 2>&1
fi
%endif
%postun
%if 0%{?with_systemd_macros}
%systemd_postun_with_restart %{_name}.service
%else
if [ "$1" -ge "1" ] ; then
/sbin/service %{name} condrestart >/dev/null 2>&1 || :
fi
%endif
######################################################################
# END
######################################################################
%description
A simple REST client which exposes provides arbitrary system
information ('facts'). The fact providing system is plugin
based. Exposing additional facts is as simple as returning a JSON
serializable python datastructure.
%prep
%setup -q
%build
%{__python} setup.py build
%install
%{__python} setup.py install -O1 --root=$RPM_BUILD_ROOT
%{__mkdir_p} $RPM_BUILD_ROOT%{_localstatedir}/log/%{_name}
mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man1/
cp -v docs/man/man1/*.1 $RPM_BUILD_ROOT/%{_mandir}/man1/
%clean
rm -rf $RPM_BUILD_ROOT
######################################################################
# files for 'jsonstats' package
%files
%defattr(-,root,root)
%{python_sitelib}/*
%{_bindir}/%{_name}
%if 0%{?with_systemd_macros}
%{_unitdir}/%{_name}.service
%else
%{_initddir}/%{_name}
%endif
%config(noreplace)/etc/sysconfig/%{_name}
%attr(0755,jsonstatsd,jsonstatsd) %dir %{_localstatedir}/log/%{_name}
%doc %{_mandir}/man1/jsonstatsd*
%doc README.md LICENSE
######################################################################
%changelog
* Tue Feb 17 2015 Tim Bielawa <[email protected]> - 1.0.4-1
- Disable Facter plugin if yaml import fails
* Mon Aug 4 2014 Chris Murphy <[email protected]> - 1.0.3-4
- Update spec to work with new RHEL 7 and systemd RPM Macros
- Depreciated Fedora 17 and below
* Tue Jul 15 2014 Tim Bielawa <[email protected]> - 1.0.3-3
- Bump for fixes
* Sun Jul 6 2014 Tim Bielawa <[email protected]> - 1.0.3-2
- RPM version includes release string now
* Thu May 8 2014 Tim Bielawa <[email protected]> - 1.0.3-1
- Don't set 'epilog' in option parser on old python boxes
* Thu May 1 2014 Chris Murphy <[email protected]> - 1.0.2-2
- Bumped release because of earlier build conflict
* Thu Apr 3 2014 Tim Bielawa <[email protected]> - 1.0.2-1
- New Plugins: Timestamp
- Better debian compat
- Configurable 'extra plugin' paths
- White/black listing plugins
- Fix init script bug
* Fri Dec 13 2013 Tim Bielawa <[email protected]> - 1.0.1-1
- Bug fixes and useability improvements
- CLI options parsed before plugin loading
- JSON output is sorted
- Facter plugin uses puppet only if available
- Packaging correctly adds/removes jsonstatsd user
- More unit tests
* Wed Nov 27 2013 Tim Bielawa <[email protected]> - 1.0.0-2
- Make log files named consistently
* Wed Nov 20 2013 Tim Bielawa <[email protected]> - 1.0.0-1
- Ready for 1.0.0
* Sun Nov 17 2013 Tim Bielawa <[email protected]> - 0.6.0-1
- Now daemonizes and has proper init scripts
* Mon Nov 4 2013 Tim Bielawa <[email protected]> - 0.5.0-2
- First functional release and RPM distribution.