Blame SPECS/insights-client.spec

0df4b3
%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
0df4b3
%define _binaries_in_noarch_packages_terminate_build 0
0df4b3
0df4b3
%global insights_user  insights
0df4b3
%global insights_group %{insights_user}
0df4b3
0df4b3
Name:                   insights-client
0df4b3
Summary:                Uploads Insights information to Red Hat on a periodic basis
0df4b3
Version:                3.0.3
0df4b3
Release:                8%{?dist}
0df4b3
Source0:                https://github.com/redhatinsights/insights-client/archive/insights-client-%{version}.tar.gz
0df4b3
Epoch:                  0
0df4b3
License:                GPLv2+
0df4b3
URL:                    http://access.redhat.com/insights
0df4b3
Group:                  Applications/System
0df4b3
Vendor:                 Red Hat, Inc.
0df4b3
0df4b3
Provides: redhat-access-insights = 1.0.13-3
0df4b3
Provides: redhat-access-insights = %{version}-%{release}
0df4b3
0df4b3
Obsoletes: redhat-access-insights <= 1.0.13-2%{?dist}
0df4b3
Obsoletes: redhat-access-proactive <= 0.3.3-0%{?dist}
0df4b3
0df4b3
Requires: python
0df4b3
Requires: python-setuptools
0df4b3
Requires: python-requests >= 2.6
0df4b3
Requires: PyYAML
0df4b3
Requires: pyOpenSSL
0df4b3
Requires: libcgroup
0df4b3
Requires: tar
0df4b3
Requires: gpg
0df4b3
Requires: pciutils
0df4b3
Requires: python-magic
0df4b3
Requires: python-six
0df4b3
%if 0%{?rhel} && 0%{?rhel} == 6
0df4b3
Requires: python-argparse
0df4b3
%else
0df4b3
%{?systemd_requires}
0df4b3
Requires: systemd
0df4b3
%endif
0df4b3
BuildArch: noarch
0df4b3
0df4b3
# git is need for '%%autosetup -S git' which automatically applies all the
0df4b3
# patches above. Please, be aware that the patches must be generated
0df4b3
# by 'git format-patch'
0df4b3
BuildRequires: git
0df4b3
0df4b3
BuildRequires: findutils
0df4b3
BuildRequires: zip
0df4b3
BuildRequires: unzip
0df4b3
BuildRequires: python2-devel
0df4b3
BuildRequires: python-setuptools
0df4b3
%if 0%{?rhel} != 6
0df4b3
BuildRequires: systemd
0df4b3
%endif
0df4b3
0df4b3
Patch1: 0001-Bump-release.patch
0df4b3
Patch2: 0002-Bump-release-again.patch
0df4b3
Patch3: 0003-Bump-release-to-4.patch
0df4b3
Patch4: 0004-Scheduling-should-enable-disable-systemd-timer.patch
0df4b3
Patch5: 0005-Bump-egg-release-to-3.patch
0df4b3
Patch6: 0006-Bump-release-to-5.patch
0df4b3
Patch7: 0007-Removing-magic.py.patch
0df4b3
Patch8: 0008-Resolving-differences-between-build-metadata.patch
0df4b3
Patch9: 0009-Bump-release-to-6.patch
0df4b3
Patch10: 0010-Updating-egg-signature.patch
0df4b3
Patch11: 0011-Bump-release-to-7.patch
0df4b3
Patch12: 0012-GPG-verify-egg-in-parent-process.patch
0df4b3
Patch13: 0013-Bump-release-to-8.patch
0df4b3
0df4b3
%description
0df4b3
Sends insightful information to Red Hat for automated analysis
0df4b3
0df4b3
%prep
0df4b3
# http://www.rpm.org/wiki/PackagerDocs/Autosetup
0df4b3
# Default '__scm_apply_git' is 'git apply && git commit' but this workflow
0df4b3
# doesn't allow us to create a new file within a patch, so we have to use
0df4b3
# 'git am' (see /usr/lib/rpm/macros for more details)
0df4b3
%define __scm_apply_git(qp:m:) %{__git} am
0df4b3
0df4b3
%autosetup -S git -N
0df4b3
%_bindir/unzip etc/rpm.egg -d egg
0df4b3
git add egg
0df4b3
git commit -q -m "Add unzipped egg"
0df4b3
%autopatch
0df4b3
cd egg
0df4b3
# Hard coding the timestamps makes the rpm reproducible bit-for-bit (needed for
0df4b3
# signing).  --no-dir-entries is also necessary.  This archive is never
0df4b3
# unzipped by insights.
0df4b3
%_bindir/rm -f ../etc/rpm.egg
0df4b3
%_bindir/find . -type f -exec touch -c -t 201801010000.00 {} \;
0df4b3
%_bindir/find . -type f -exec chmod 0444 {} \;
0df4b3
%_bindir/find . -type f -print | %_bindir/sort -df | %_bindir/xargs %_bindir/zip -X --no-dir-entries -r ../etc/rpm.egg
0df4b3
cd ..
0df4b3
%_bindir/git rm -rf egg
0df4b3
%_bindir/git commit -q -m "Remove unzipped egg"
0df4b3
%_bindir/git add etc/rpm.egg
0df4b3
%_bindir/git commit -q -m "Update egg"
0df4b3
0df4b3
%install
0df4b3
rm -rf ${RPM_BUILD_ROOT}
0df4b3
%{__python} setup.py install --root=${RPM_BUILD_ROOT} $PREFIX
0df4b3
0df4b3
%pre
0df4b3
getent group insights > /dev/null || /usr/sbin/groupadd -r %{insights_group}
0df4b3
getent passwd insights > /dev/null || \
0df4b3
    /usr/sbin/useradd -g insights -r --shell /sbin/nologin %{insights_user} \
0df4b3
    -c "Red Hat Insights" -d /var/lib/insights
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
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
0df4b3
        %if 0%{?rhel} && 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
# and set the ACLs
0df4b3
if ! [ -d "/var/log/insights-client" ]; then
0df4b3
mkdir /var/log/insights-client
0df4b3
fi
0df4b3
setfacl -Rd -m g:insights:rwX /var/log/insights-client
0df4b3
setfacl -m g:insights:rwX /var/log/insights-client
0df4b3
0df4b3
# if the library directory for eggs and such isn't present
0df4b3
# make it AND
0df4b3
# set the ACLs
0df4b3
if ! [ -d "/var/lib/insights" ]; then
0df4b3
mkdir /var/lib/insights
0df4b3
fi
0df4b3
setfacl -Rd -m g:insights:rwX /var/lib/insights
0df4b3
setfacl -R -m g:insights:rwX /var/lib/insights
0df4b3
0df4b3
# set some more ACLs
0df4b3
setfacl -Rd -m g:insights:rwX -m m:rw /etc/insights-client
0df4b3
setfacl -R -m g:insights:rwX -m m:rw /etc/insights-client
0df4b3
setfacl -m g:insights:r -m m:r /etc/insights-client/*.pem
0df4b3
setfacl -m g:insights:r -m m:r /etc/insights-client/redhattools.pub.gpg
0df4b3
setfacl -m g:insights:rw -m m:rw /etc/insights-client/insights-client.conf
0df4b3
setfacl -m g:insights:r -m m:r /etc/insights-client/rpm.egg
0df4b3
setfacl -m g:insights:r -m m:r /etc/insights-client/rpm.egg.asc
0df4b3
setfacl -m g:insights:rwx /etc/insights-client
0df4b3
0df4b3
# if ansible is present
0df4b3
# make the fact directory AND
0df4b3
# the fact file AND
0df4b3
# set the ACLs
0df4b3
if [ -d "/etc/ansible" ]; then
0df4b3
if ! [ -d "/etc/ansible/facts.d" ]; then
0df4b3
mkdir /etc/ansible/facts.d
0df4b3
fi
0df4b3
fi
0df4b3
if [ -d "/etc/ansible/facts.d" ]; then
0df4b3
touch /etc/ansible/facts.d/insights.fact
0df4b3
touch /etc/ansible/facts.d/insights_machine_id.fact
0df4b3
setfacl -m g:insights:rw /etc/ansible/facts.d/insights.fact
0df4b3
setfacl -m g:insights:rw /etc/ansible/facts.d/insights_machine_id.fact
0df4b3
fi
0df4b3
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
0df4b3
if [ -f "/etc/insights-client/.lastupload" ]; then
0df4b3
    setfacl -m g:insights:rwx /etc/insights-client/.lastupload
0df4b3
fi
0df4b3
if [ -f "/etc/insights-client/.registered" ]; then
0df4b3
    setfacl -m g:insights:rwx /etc/insights-client/.registered
0df4b3
fi
0df4b3
if [ -f "/etc/insights-client/.unregistered" ]; then
0df4b3
    setfacl -m g:insights:rwx /etc/insights-client/.unregistered
0df4b3
fi
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
0df4b3
rm -rf /var/lib/insights
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
0df4b3
%if 0%{?rhel} && 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
0df4b3
%attr(755,root,root) %dir %{python_sitelib}/insights_client*.egg-info
0df4b3
%attr(644,root,root) %{python_sitelib}/insights_client*.egg-info/*
0df4b3
%attr(644,root,root) %{python_sitelib}/insights_client/*.py*
0df4b3
0df4b3
%doc
0df4b3
%defattr(-, root, root)
0df4b3
/usr/share/man/man8/*.8.gz
0df4b3
/usr/share/man/man5/*.5.gz
0df4b3
0df4b3
%changelog
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