%global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') %global installdir /usr/share/python %global homedir /usr/lib/opentaxii Name: opentaxii Version: 0.9.1 Release: 1%{?dist}.harbottle Summary: A robust Python implementation of TAXII Services Group: Applications/System License: BSD URL: http://www.opentaxii.org Source0: opentaxii.sysconfig Source1: opentaxii.yml Source2: opentaxii.service %if 0%{?rhel} == 7 BuildRequires: python36-virtualenv %endif %if 0%{?rhel} == 8 BuildRequires: python3-virtualenv %endif BuildRequires: systemd-units AutoReqProv: no Requires: python36 Requires(post): sqlite Requires(post): systemd Requires(preun): systemd %description A robust Python implementation of TAXII Services. %prep %build mkdir -p .%{installdir} virtualenv-3.6 .%{installdir}/%{name} export LANG=en_US.UTF-8 export LANGUAGE=en_US:en export LC_ALL=en_US.UTF-8 .%{installdir}/%{name}/bin/pip3.6 install "opentaxii==%{version}" .%{installdir}/%{name}/bin/pip3.6 install "psycopg2-binary==2.7.6.1" .%{installdir}/%{name}/bin/pip3.6 install "gunicorn==19.9.0" .%{installdir}/%{name}/bin/pip3.6 install "virtualenv-tools3==2.0.2" pushd .%{installdir}/%{name} bin/virtualenv-tools --update-path %{installdir}/%{name} popd find . -iname *.pyc -exec rm {} \; find . -iname *.pyo -exec rm {} \; %install install -d -m 755 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig install -d -m 755 $RPM_BUILD_ROOT%{_sysconfdir}/%{name} install -d -m 755 $RPM_BUILD_ROOT%{_bindir} install -d -m 755 $RPM_BUILD_ROOT%{homedir} install -d -m 755 $RPM_BUILD_ROOT%{_unitdir} install -d -m 755 $RPM_BUILD_ROOT%{installdir} # Python virtualenv mv .%{installdir}/* $RPM_BUILD_ROOT%{installdir}/ # Conf install -m 644 %{SOURCE0} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/%{name} install -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/%{name}.yml # Service install -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_unitdir}/%{name}.service # Binary links for file in $RPM_BUILD_ROOT%{installdir}/opentaxii/bin/opentaxii*; do ln -s %{installdir}/opentaxii/bin/$(basename $file) $RPM_BUILD_ROOT%{_bindir}/$(basename $file) done ln -s %{installdir}/opentaxii/bin/gunicorn $RPM_BUILD_ROOT%{_bindir}/opentaxii-gunicorn %pre getent group %{name} >/dev/null || groupadd -f -r %{name} getent passwd %{name} >/dev/null || useradd -r -g %{name} -d %{homedir} -s /sbin/nologin -c "OpenTAXII user" %{name} exit 0 %post if [ -e %{homedir}/auth.db ] && [ ! -e %{homedir}/authdb_migration_0.1.9_0.1.10 ] then /usr/bin/sqlite3 %{homedir}/auth.db <