Blame SPECS/insights-client.spec

0df4b3
%define _binaries_in_noarch_packages_terminate_build 0
0df4b3
0df4b3
Name:                   insights-client
0df4b3
Summary:                Uploads Insights information to Red Hat on a periodic basis
b245bf
Version:                3.0.6
b245bf
Release:                2%{?dist}
0df4b3
Source0:                https://github.com/redhatinsights/insights-client/archive/insights-client-%{version}.tar.gz
0df4b3
Epoch:                  0
0df4b3
License:                GPLv2+
b245bf
URL:                    http://cloud.redhat.com/insights
0df4b3
Group:                  Applications/System
0df4b3
Vendor:                 Red Hat, Inc.
0df4b3
0df4b3
Provides: redhat-access-insights = 1.0.13-3
b245bf
Provides: redhat-access-insights = %{version}-%{release}%{?dist}
b245bf
b245bf
Obsoletes: redhat-access-insights
b245bf
Obsoletes: redhat-access-proactive
0df4b3
b245bf
Requires: tar
b245bf
Requires: gpg
b245bf
Requires: pciutils
b245bf
BuildArch: noarch
0df4b3
b245bf
# RHEL 8
b245bf
%if 0%{?rhel} == 8
b245bf
%{?__python3:Requires: %{__python3}}
b245bf
Requires: platform-python-setuptools
b245bf
Requires: python3-requests >= 2.6
b245bf
Requires: python3-PyYAML
b245bf
Requires: python3-pyOpenSSL
b245bf
Requires: python3-magic
b245bf
Requires: python3-six
b245bf
BuildRequires: python3-devel
b245bf
BuildRequires: python3-setuptools
b245bf
b245bf
# RHEL 6-7
b245bf
%else
0df4b3
Requires: python
0df4b3
Requires: python-setuptools
0df4b3
Requires: python-requests >= 2.6
0df4b3
Requires: PyYAML
0df4b3
Requires: pyOpenSSL
0df4b3
Requires: libcgroup
0df4b3
Requires: python-magic
b245bf
Requires: python-six >= 1.9.0
b245bf
BuildRequires: python2-devel
b245bf
BuildRequires: python-setuptools
b245bf
%endif
b245bf
b245bf
# systemd/RHEL 6 deps
b245bf
%if 0%{?rhel} == 6
0df4b3
Requires: python-argparse
0df4b3
%else
0df4b3
%{?systemd_requires}
0df4b3
Requires: systemd
0df4b3
BuildRequires: systemd
0df4b3
%endif
0df4b3
0df4b3
%description
0df4b3
Sends insightful information to Red Hat for automated analysis
0df4b3
0df4b3
%prep
b245bf
%setup -q
0df4b3
0df4b3
%install
0df4b3
rm -rf ${RPM_BUILD_ROOT}
b245bf
%if 0%{?rhel} == 8
b245bf
%{__python3} setup.py install --root=${RPM_BUILD_ROOT} $PREFIX
b245bf
pathfix.py -pni "%{__python3}" %{buildroot}%{python3_sitelib}/insights_client/{__init__.py,major_version.py,run.py}
b245bf
pathfix.py -pni "%{__python3}" %{buildroot}%{_bindir}/insights-client-run
b245bf
pathfix.py -pni "%{__python3}" %{buildroot}%{_bindir}/insights-client
b245bf
pathfix.py -pni "%{__python3}" %{buildroot}%{_bindir}/redhat-access-insights
b245bf
%else
b245bf
%{__python2} setup.py install --root=${RPM_BUILD_ROOT} $PREFIX
b245bf
%endif
0df4b3
0df4b3
%post
0df4b3
0df4b3
%if 0%{?rhel} != 6
0df4b3
%systemd_post %{name}.timer
0df4b3
%endif
0df4b3
0df4b3
# Only perform migration from redhat-access-insights to insights-client
0df4b3
if  [ $1 -eq 1  ]; then
0df4b3
    #Migrate existing machine-id
0df4b3
    if  [ -f "/etc/redhat_access_proactive/machine-id" ]; then
0df4b3
        cp /etc/redhat_access_proactive/machine-id /etc/insights-client/machine-id
0df4b3
    fi
0df4b3
    #Migrate OTHER existing machine-id
0df4b3
    if [ -f "/etc/redhat-access-insights/machine-id" ]; then
0df4b3
        cp /etc/redhat-access-insights/machine-id /etc/insights-client/machine-id
0df4b3
    fi
0df4b3
    #Migrate existing config
0df4b3
    if [ -f "/etc/redhat-access-insights/redhat-access-insights.conf" ]; then
0df4b3
        cp /etc/redhat-access-insights/redhat-access-insights.conf /etc/insights-client/insights-client.conf
0df4b3
        sed -i 's/\[redhat-access-insights\]/\[insights-client\]/' /etc/insights-client/insights-client.conf
0df4b3
    fi
0df4b3
    #Migrate registration record
0df4b3
    if [ -f "/etc/redhat-access-insights/.registered" ]; then
0df4b3
        cp /etc/redhat-access-insights/.registered /etc/insights-client/.registered
0df4b3
    fi
0df4b3
    if [ -f "/etc/redhat-access-insights/.unregistered" ]; then
0df4b3
        cp /etc/redhat-access-insights/.unregistered /etc/insights-client/.unregistered
0df4b3
    fi
0df4b3
    #Migrate last upload record
0df4b3
    if [ -f "/etc/redhat-access-insights/.lastupload" ]; then
0df4b3
        cp /etc/redhat-access-insights/.lastupload /etc/insights-client/.lastupload
0df4b3
    fi
b245bf
    #Migrate remove.conf
b245bf
    if [ -f "/etc/redhat-access-insights/remove.conf" ]; then
b245bf
        cp /etc/redhat-access-insights/remove.conf /etc/insights-client/remove.conf
b245bf
    fi
0df4b3
    if ! [ -d "/etc/redhat-access-insights" ]; then
0df4b3
        mkdir /etc/redhat-access-insights
0df4b3
    fi
0df4b3
    # Symlink new cron job if the old one exists. Remove the old one
0df4b3
    if [ -f "/etc/cron.daily/redhat-access-insights" ]; then
0df4b3
        rm -f /etc/cron.daily/redhat-access-insights
b245bf
        %if 0%{?rhel} == 6
0df4b3
            ln -sf /etc/insights-client/insights-client.cron /etc/cron.daily/insights-client                               
0df4b3
        %else
0df4b3
            %_bindir/systemctl start insights-client.timer
0df4b3
        %endif
0df4b3
    fi 
0df4b3
fi
0df4b3
0df4b3
# if the logging directory isnt created then make it
0df4b3
if ! [ -d "/var/log/insights-client" ]; then
b245bf
mkdir -m 640 /var/log/insights-client
0df4b3
fi
0df4b3
0df4b3
# if the library directory for eggs and such isn't present
b245bf
# make it
0df4b3
if ! [ -d "/var/lib/insights" ]; then
b245bf
mkdir -m 644 /var/lib/insights
0df4b3
fi
0df4b3
0df4b3
# always perform legacy symlinks
0df4b3
%posttrans
0df4b3
mkdir -p /etc/redhat-access-insights
0df4b3
ln -sf /etc/insights-client/insights-client.conf /etc/redhat-access-insights/redhat-access-insights.conf
0df4b3
ln -sf /etc/insights-client/insights-client.cron /etc/redhat-access-insights/redhat-access-insights.cron
0df4b3
ln -sf /etc/insights-client/.registered /etc/redhat-access-insights/.registered
0df4b3
ln -sf /etc/insights-client/.unregistered /etc/redhat-access-insights/.unregistered
0df4b3
ln -sf /etc/insights-client/.lastupload /etc/redhat-access-insights/.lastupload
0df4b3
ln -sf /etc/insights-client/machine-id /etc/redhat-access-insights/machine-id
b245bf
# remove all ACLs on upgrade, forever and always
b245bf
setfacl -Rb /var/lib/insights
b245bf
setfacl -Rb /var/log/insights-client
b245bf
setfacl -Rb /etc/insights-client
0df4b3
0df4b3
%preun
0df4b3
%if 0%{?rhel} != 6
0df4b3
%systemd_preun %{name}.timer
0df4b3
%systemd_preun %{name}.service
0df4b3
%endif
0df4b3
0df4b3
%postun
0df4b3
if [ "$1" -eq 0 ]; then
0df4b3
# One run on removal, not upgrade
0df4b3
%if 0%{?rhel} != 6
0df4b3
%_bindir/systemctl daemon-reload > /dev/null 2>&1
0df4b3
%endif
0df4b3
rm -f /etc/cron.daily/insights-client
0df4b3
rm -f /etc/cron.weekly/insights-client
0df4b3
rm -f /etc/insights-client/.cache*
0df4b3
rm -f /etc/insights-client/.registered
0df4b3
rm -f /etc/insights-client/.unregistered
0df4b3
rm -f /etc/insights-client/.lastupload
0df4b3
rm -f /etc/insights-client/rpm.egg
0df4b3
rm -f /etc/insights-client/rpm.egg.asc
b245bf
rm -f /etc/insights-client/.insights-core*.etag
0df4b3
rm -rf /var/lib/insights
b245bf
# keep these to remove from previous install
0df4b3
rm -f /etc/ansible/facts.d/insights.fact
0df4b3
rm -f /etc/ansible/facts.d/insights_machine_id.fact
0df4b3
# remove symlink to old name on uninstall
0df4b3
rm -f %{_bindir}/redhat-access-insights
0df4b3
# remove symlinks to old configs
0df4b3
rm -rf /etc/redhat-access-insights/
0df4b3
rm -f /etc/cron.daily/redhat-access-insights
0df4b3
rm -f /etc/cron.weekly/redhat-access-insights
0df4b3
fi
0df4b3
0df4b3
%clean
0df4b3
test "x$RPM_BUILD_ROOT" != "x" && rm -rf $RPM_BUILD_ROOT
0df4b3
0df4b3
%files
0df4b3
%defattr(0600, root, root)
0df4b3
%config(noreplace) /etc/insights-client/*.conf
0df4b3
/etc/insights-client/.fallback.json
0df4b3
/etc/insights-client/.fallback.json.asc
0df4b3
/etc/insights-client/.exp.sed
0df4b3
0df4b3
%if 0%{?rhel} != 6
0df4b3
%attr(644,root,root) %{_unitdir}/insights-client.service
0df4b3
%attr(644,root,root) %{_unitdir}/insights-client.timer
0df4b3
%endif
0df4b3
0df4b3
%attr(440,root,root) /etc/insights-client/*.pem
0df4b3
%attr(440,root,root) /etc/insights-client/redhattools.pub.gpg
0df4b3
0df4b3
%attr(755,root,root) %{_bindir}/insights-client
0df4b3
%attr(755,root,root) %{_bindir}/redhat-access-insights
0df4b3
%attr(755,root,root) %{_bindir}/insights-client-run
0df4b3
b245bf
%if 0%{?rhel} == 6
0df4b3
%attr(755,root,root) /etc/insights-client/insights-client.cron
0df4b3
%endif
0df4b3
0df4b3
%attr(644,root,root) /etc/insights-client/rpm.egg
0df4b3
%attr(644,root,root) /etc/insights-client/rpm.egg.asc
0df4b3
b245bf
%if 0%{?rhel} == 8
b245bf
%attr(755,root,root) %dir %{python3_sitelib}/insights_client*.egg-info
b245bf
%attr(644,root,root) %{python3_sitelib}/insights_client*.egg-info/*
b245bf
%attr(644,root,root) %{python3_sitelib}/insights_client/*.py*
b245bf
%attr(644,root,root) %{python3_sitelib}/insights_client/__pycache__
b245bf
%else
b245bf
%attr(755,root,root) %dir %{python2_sitelib}/insights_client*.egg-info
b245bf
%attr(644,root,root) %{python2_sitelib}/insights_client*.egg-info/*
b245bf
%attr(644,root,root) %{python2_sitelib}/insights_client/*.py*
b245bf
%endif
b245bf
b245bf
%attr(640,root,root) /var/log/insights-client
b245bf
%attr(644,root,root) /var/lib/insights
0df4b3
0df4b3
%doc
0df4b3
%defattr(-, root, root)
0df4b3
/usr/share/man/man8/*.8.gz
0df4b3
/usr/share/man/man5/*.5.gz
0df4b3
0df4b3
%changelog
b245bf
* Wed Jul 10 2019 Jeremy Crafts <jcrafts@redhat.com> - 3.0.6-0
b245bf
- Optimize specfile for RHEL 6, 7, 8 compatibility
b245bf
- Update service URL
b245bf
- Remove ACLs and insights user from installation
b245bf
- Resolves: BZ1730796, BZ1730797, BZ1730798, BZ1730799, BZ1730800, BZ1730801
b245bf
b245bf
* Wed Mar 14 2018 Richard Brantley <rbrantle@redhat.com> - 3.0.3-8
b245bf
- Resolves: rhbz#1555041
b245bf
0df4b3
* Fri Feb 16 2018 Kyle Lape <klape@redhat.com> - 3.0.3-6
0df4b3
- Persist systemd timer config between reboots
0df4b3
0df4b3
* Wed Feb 7 2018 Kyle Lape <klape@redhat.com> - 3.0.3-2
0df4b3
- Correct the version strings in Obsoletes and Provides in RPM spec
0df4b3
0df4b3
* Thu Jan 18 2018 Kyle Lape <klape@redhat.com> - 3.0.3-1
0df4b3
- RHEL 7 RPM now uses systemd service and timer instead of cron
0df4b3
- Addition of IO and CPU cgroup constraints
0df4b3
- Fixed memory cgroup constraint
0df4b3
0df4b3
* Wed Oct 18 2017 Richard Brantley <rbrantle@redhat.com> - 3.0.2-2
0df4b3
- Resolves BZ1498650, BZ1500008, BZ1501545, BZ1501552, BZ1501556, BZ1501561, BZ1501565, BZ1501566
0df4b3
- Fixes version migration logic
0df4b3
- Fixes symlink issues to old binary
0df4b3
- Fixes short ID analysis for images and containers
0df4b3
- Fixes Docker library detection
0df4b3
- Fixes image and container detection
0df4b3
- Fixes registration execution flow
0df4b3
- Fixes --version flag to print to stdout and include additional versioning information
0df4b3
- Includes Insights Core 3.0.3-1
0df4b3
0df4b3
* Wed Oct 4 2017 Richard Brantley <rbrantle@redhat.com> - 3.0.1-5
0df4b3
- Resolves BZ1498581
0df4b3
- Fixes sys.path issues
0df4b3
- Includes Insights Core 3.0.2-6
0df4b3
0df4b3
* Wed Sep 27 2017 Richard Brantley <rbrantle@redhat.com> - 3.0.0-4
0df4b3
- Initial build