forked from RedHatInsights/insights-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsights-client.spec
166 lines (136 loc) · 4.73 KB
/
insights-client.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
%define _binaries_in_noarch_packages_terminate_build 0
# This conditional build macro adds a "--with ros" commandline option to
# rpmbuild. The default behavior is to build without it.
%bcond_with ros
Name: insights-client
Summary: Uploads Insights information to Red Hat on a periodic basis
Version: {{{ git_dir_version lead=3.2 }}}
Release: 0%{?dist}
Source: {{{ git_dir_pack }}}
License: GPL-2.0-or-later
URL: https://console.redhat.com/insights
Group: Applications/System
Vendor: Red Hat, Inc.
BuildArch: noarch
Requires: tar
Requires: gpg
Requires: pciutils
%{?__python3:Requires: %{__python3}}
%{?systemd_requires}
Requires: python3-requests >= 2.6
Requires: python3-PyYAML
Requires: python3-six
Requires: python3dist(setuptools)
Requires: coreutils
Requires: subscription-manager
BuildRequires: wget
BuildRequires: binutils
BuildRequires: python3-devel
BuildRequires: systemd
BuildRequires: pam
BuildRequires: meson
BuildRequires: python3-pytest
BuildRequires: systemd-rpm-macros
%description
Sends insightful information to Red Hat for automated analysis
%if %{with ros}
%package ros
Requires: pcp-zeroconf
Requires: insights-client
Summary: The subpackage for Insights resource optimization service
%description ros
The ros subpackage add ros_collect configuration parameter to insights-client.conf file,
the parameter is set to True by default. The system starts sending PCP archives to
Resource Optimization service upon modifying ros_collect parameter to True.
%endif
%prep
{{{ git_dir_setup_macro }}}
%build
%{meson} \
-Dpython=%{__python3} \
%if (0%{?rhel} && 0%{?rhel} < 10)
-Dredhat_access_insights=true \
%endif
%{nil}
%{meson_build}
%install
%{meson_install}
# Create different insights directories in /var
mkdir -p %{buildroot}%{_localstatedir}/log/insights-client/
mkdir -p %{buildroot}%{_localstatedir}/lib/insights/
mkdir -p %{buildroot}%{_localstatedir}/cache/insights/
mkdir -p %{buildroot}%{_localstatedir}/cache/insights-client/
%post
%systemd_post %{name}.timer
%systemd_post %{name}-boot.service
if [ -d %{_sysconfdir}/motd.d ]; then
if [ ! -e %{_sysconfdir}/motd.d/insights-client -a ! -L %{_sysconfdir}/motd.d/insights-client ]; then
if [ -e %{_localstatedir}/lib/insights/newest.egg ]; then
ln -sn /dev/null %{_sysconfdir}/motd.d/insights-client
else
ln -sn %{_sysconfdir}/insights-client/insights-client.motd %{_sysconfdir}/motd.d/insights-client
fi
fi
fi
%if %{with ros}
%post ros
rm -f /var/lib/pcp/config/pmlogger/config.ros
sed -i "/PCP_LOG_DIR\/pmlogger\/ros/d" /etc/pcp/pmlogger/control.d/local
if ! grep -q "^ros_collect" %{_sysconfdir}/insights-client/insights-client.conf; then
cat <<EOF >> %{_sysconfdir}/insights-client/insights-client.conf
### Begin insights-client-ros ###
ros_collect=True
### End insights-client-ros ###
EOF
fi
%endif
%preun
%systemd_preun %{name}.timer
%systemd_preun %{name}.service
%systemd_preun %{name}-boot.service
%postun
%systemd_postun %{name}.timer
%systemd_postun %{name}.service
%systemd_postun %{name}-boot.service
# Clean up files created by insights-client that are unowned by the RPM
if [ $1 -eq 0 ]; then
rm -f %{_sysconfdir}/cron.daily/insights-client
rm -f %{_sysconfdir}/ansible/facts.d/insights.fact
rm -f %{_sysconfdir}/ansible/facts.d/insights_machine_id.fact
rm -f %{_sysconfdir}/motd.d/insights-client
rm -rf %{_localstatedir}/lib/insights
rm -rf %{_localstatedir}/log/insights-client
rm -f %{_sysconfdir}/insights-client/.*.etag
fi
%if %{with ros}
%postun ros
sed -i '/### Begin insights-client-ros ###/,/### End insights-client-ros ###/d;/ros_collect=True/d' %{_sysconfdir}/insights-client/insights-client.conf
%endif
%files
%config(noreplace) %{_sysconfdir}/insights-client/*.conf
%{_sysconfdir}/insights-client/insights-client.motd
%{_sysconfdir}/insights-client/.fallback.json*
%{_sysconfdir}/insights-client/.exp.sed
%{_sysconfdir}/insights-client/rpm.egg*
%{_bindir}/*
%{_unitdir}/*
%attr(444,root,root) %{_sysconfdir}/insights-client/*.pem
%attr(444,root,root) %{_sysconfdir}/insights-client/redhattools.pub.gpg
%{python3_sitelib}/insights_client/
%{_defaultdocdir}/%{name}
%{_presetdir}/*.preset
%attr(700,root,root) %dir %{_localstatedir}/log/insights-client/
%attr(700,root,root) %dir %{_localstatedir}/cache/insights-client/
%attr(750,root,root) %dir %{_localstatedir}/cache/insights/
%attr(750,root,root) %dir %{_localstatedir}/lib/insights/
%{_sysconfdir}/logrotate.d/insights-client
%{_tmpfilesdir}/insights-client.conf
%doc
%defattr(-, root, root)
%{_mandir}/man8/*.8.gz
%{_mandir}/man5/*.5.gz
%if %{with ros}
%files ros
%endif
%changelog
{{{ git_dir_changelog }}}