## START: Set by rpmautospec
## (rpmautospec version 0.6.0)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 2;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

# Generated by go2rpm 1.9.0
%bcond check 1
%bcond bundled 1
%bcond golang_library %{without bundled}

# https://github.com/ansible/receptor
%global goipath         github.com/ansible/receptor
Version:                1.4.4

%gometa -f

%global goname receptor

%global common_description %{expand:
Receptor is an overlay network intended to ease the distribution of work across
a large and dispersed collection of workers. Receptor nodes establish
peer-to-peer connections with each other via existing networks. Once connected,
the Receptor mesh provides datagram (UDP-like) and stream (TCP-like)
capabilities to applications, as well as robust unit-of-work handling with
resiliency against transient network failures.

See the readthedocs page for Receptor at:

https://receptor.readthedocs.io/en/latest}

%global golicenses      LICENSE.md %{?with_bundled:vendor/modules.txt} license.go
%global godocs          docs tools README.md

Name:           %{goname}
Release:        %autorelease
Summary:        Multi-service relayer with remote execution and orchestration capabilities

# License for github.com/ansible/receptor: Apache-2.0
# License for github.com/creack/pty: MIT
# License for github.com/davecgh/go-spew: ISC
# License for github.com/emicklei/go-restful/v3: MIT
# License for github.com/fortytw2/leaktest: BSD-3-Clause
# License for github.com/fsnotify/fsnotify: BSD-3-Clause
# License for github.com/ghjm/cmdline: Apache-2.0
# License for github.com/go-logr/logr: Apache-2.0
# License for github.com/go-openapi/jsonpointer: Apache-2.0
# License for github.com/go-openapi/jsonreference: Apache-2.0
# License for github.com/go-openapi/swag: Apache-2.0
# License for github.com/go-task/slim-sprig: MIT
# License for github.com/gogo/protobuf: BSD-3-Clause
# License for github.com/golang-jwt/jwt/v4: MIT
# License for github.com/golang/mock: Apache-2.0
# License for github.com/golang/protobuf: BSD-3-Clause
# License for github.com/google/gnostic: Apache-2.0
# License for github.com/google/go-cmp: BSD-3-Clause
# License for github.com/google/gofuzz: Apache-2.0
# License for github.com/google/pprof: Apache-2.0
# License for github.com/google/shlex: Apache-2.0
# License for github.com/google/uuid: BSD-3-Clause
# License for github.com/gorilla/websocket: BSD-2-Clause
# License for github.com/imdario/mergo: BSD-3-Clause
# License for github.com/josharian/intern: MIT
# License for github.com/json-iterator/go: MIT
# License for github.com/jupp0r/go-priority-queue: MIT
# License for github.com/mailru/easyjson: MIT
# License for github.com/minio/highwayhash: Apache-2.0
# License for github.com/moby/spdystream: Apache-2.0
# License for github.com/modern-go/concurrent: Apache-2.0
# License for github.com/modern-go/reflect2: Apache-2.0
# License for github.com/munnerz/goautoneg: BSD-3-Clause
# License for github.com/onsi/ginkgo/v2: MIT
# License for github.com/pbnjay/memory: BSD-3-Clause
# License for github.com/pmezard/go-difflib: BSD-3-Clause
# License for github.com/prep/socketpair: BSD-3-Clause
# License for github.com/quic-go/qtls-go1-19: BSD-3-Clause
# License for github.com/quic-go/qtls-go1-20: BSD-3-Clause
# License for github.com/quic-go/quic-go: MIT
# License for github.com/rogpeppe/go-internal: BSD-3-Clause
# License for github.com/songgao/water: BSD-3-Clause
# License for github.com/spf13/pflag: BSD-3-Clause
# License for github.com/stretchr/testify: MIT
# License for github.com/vishvananda/netlink: Apache-2.0
# License for github.com/vishvananda/netns: Apache-2.0
# License for golang.org/x/crypto: BSD-3-Clause
# License for golang.org/x/exp: BSD-3-Clause
# License for golang.org/x/mod: BSD-3-Clause
# License for golang.org/x/net: BSD-3-Clause
# License for golang.org/x/oauth2: BSD-3-Clause
# License for golang.org/x/sys: BSD-3-Clause
# License for golang.org/x/term: BSD-3-Clause
# License for golang.org/x/text: BSD-3-Clause
# License for golang.org/x/time: BSD-3-Clause
# License for golang.org/x/tools: BSD-3-Clause
# License for google.golang.org/appengine: Apache-2.0
# License for google.golang.org/protobuf: BSD-3-Clause
# License for gopkg.in/inf.v0: BSD-3-Clause
# License for gopkg.in/yaml.v2: Apache-2.0 AND MIT
# License for gopkg.in/yaml.v3: MIT AND Apache-2.0
# License for k8s.io/api: Apache-2.0
# License for k8s.io/apimachinery: Apache-2.0
# License for k8s.io/client-go: Apache-2.0
# License for k8s.io/klog/v2: Apache-2.0
# License for k8s.io/kube-openapi: Apache-2.0
# License for k8s.io/utils: Apache-2.0
# License for sigs.k8s.io/json: Apache-2.0 AND BSD-3-Clause
# License for sigs.k8s.io/structured-merge-diff/v4: Apache-2.0
# License for sigs.k8s.io/yaml: MIT AND BSD-3-Clause
License:        Apache-2.0 AND ISC AND MIT AND BSD-3-Clause AND BSD-2-Clause
URL:            %{gourl}
Source0:        %{gosource}
Source1:	vendor-%{version}.tar.gz
Source3: 	receptor.service
Source4: 	receptor@.service
Source5: 	receptor.conf
Source6: 	receptor.conf.example
Source7: 	receptor.pp
Source8:	receptor.sysusers
Source9:	receptor.logrotate
Source10:	receptor_tmp.conf
# https://github.com/ansible/receptor/pull/816

BuildRequires:  python3-devel
# For Python tests
BuildRequires:  psmisc
BuildRequires:  openssh
BuildRequires:	openssl
BuildRequires:  systemd-rpm-macros

%{?sysusers_requires_compat}

Requires:	receptorctl%{?_isa} = %{version}-%{release}
Requires:	python3-receptor-python-worker%{?_isa} = %{version}-%{release}
Requires:	logrotate

Requires(post): libselinux-utils, policycoreutils
Requires(postun): libselinux-utils, policycoreutils

%description %{common_description}


%package -n receptorctl
Summary:        Front-end CLI and importable Python library that interacts with Receptor
Requires:	receptor
Requires:	python3-receptor-python-worker

%description -n receptorctl
Receptorctl is a front-end CLI and importable Python library that interacts
with Receptor over its control socket interface.


%package -n python3-receptor-python-worker
Summary:        Python plugin called by Receptor

%description -n python3-receptor-python-worker
The receptor-python-worker command is called by Receptor to supervise the
operation of a Python worker plugin.


%if %{with golang_library}
%gopkg
%endif


%prep
%autosetup -p1 %{forgesetupargs} %{?with_bundled:-a1}
%goprep -e %{?with_bundled:-k}

# Set versions
echo "%{version}" > receptor-python-worker/.VERSION
echo "%{version}" > receptorctl/.VERSION


%generate_buildrequires
%if %{without bundled}
%go_generate_buildrequires
%endif
cd receptorctl
%pyproject_buildrequires %{?with_check:-t}
cd ../receptor-python-worker
%pyproject_buildrequires


%build
%if %{with bundled}
%global gomodulesmode GO111MODULE=on
export GOFLAGS=-mod=vendor
%endif
export LDFLAGS="-X 'github.com/ansible/receptor/internal/version.Version=%{VERSION}' "
%gobuild -o %{gobuilddir}/bin/receptor %{goipath}/cmd/receptor-cl
pushd receptorctl
%pyproject_wheel
popd
pushd receptor-python-worker
%pyproject_wheel
popd


%install
%if %{with golang_library}
%gopkginstall
%endif
mkdir -p %{buildroot}%{_tmpfilesdir}
install -m 0644 %{SOURCE10}		%{buildroot}%{_tmpfilesdir}/receptor.conf
install -m 0755 -vd			%{buildroot}/var/run/receptor
install -m 0755 -vd                     %{buildroot}/var/log/receptor
install -m 0700 -vd                     %{buildroot}/var/lib/receptor
install -m 0755 -vd                     %{buildroot}%{_sysconfdir}/logrotate.d
install -m 0644 -vp %{SOURCE9}          %{buildroot}%{_sysconfdir}/logrotate.d/receptor
install -m 0755 -vd                     %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
install -m 0755 -vd                     %{buildroot}%{_unitdir}
install -m 0644 -vp %{SOURCE3}          %{buildroot}%{_unitdir}/receptor.service
install -m 0644 -vp %{SOURCE4}          %{buildroot}%{_unitdir}/receptor@.service
install -m 0755 -vd                     %{buildroot}%{_sysconfdir}/receptor
install -m 0644 -vp %{SOURCE5}          %{buildroot}%{_sysconfdir}/receptor/receptor.conf
install -m 0644 -vp %{SOURCE6}          %{buildroot}%{_sysconfdir}/receptor/receptor.conf.example
install -m 0755 -vd                     %{buildroot}%{_datadir}/selinux/packages
install -m 0644 -vp %{SOURCE7}          %{buildroot}%{_datadir}/selinux/packages/receptor.pp
rm -rf tools/examples/simple-network/.gitignore
rm -rf tools/examples/simple-network/socks/.gitignore
%pyproject_install


%pre
%sysusers_create_compat %{SOURCE8}


%post
semodule -n -i %{_datadir}/selinux/packages/receptor.pp
if /usr/sbin/selinuxenabled ; then
    /usr/sbin/load_policy
fi;
exit 0;
%systemd_post receptor.service


%preun
%systemd_preun receptor.service


%postun
if [ $1 -eq 0 ]; then
    semodule -n -r receptor
    if /usr/sbin/selinuxenabled ; then
       /usr/sbin/load_policy
    fi;
fi;
exit 0
%systemd_postun_with_restart receptor.service


%if %{with check}
%check
# Disable flaky tests
for test in "TestCreatePing" "TestCancel" "TestRelease"; do
    awk -i inplace '/^func.*'"$test"'\(/ { print; print "\tt.Skip(\"disabled failing test\")"; next}1' $(grep -rl $test)
done
export PATH="%{gobuilddir}/bin:$PATH"
# Disable various test relying on Kube and network
%gocheck -t tests/functional/mesh
pushd receptorctl
%tox -- -- --ignore=tests/test_mesh.py
popd
%endif


%files
%license LICENSE.md %{?with_bundled:vendor/modules.txt}
%doc docs tools README.md
%attr(0755,receptor,receptor) %{_bindir}/receptor
%{_datadir}/selinux/packages/receptor.pp
%dir %{_sysconfdir}/receptor
%config(noreplace) %attr(0644,receptor,receptor) %{_sysconfdir}/receptor/receptor.conf
%config(noreplace) %attr(0644,receptor,receptor) %{_sysconfdir}/receptor/receptor.conf.example
%{_unitdir}/receptor.service
%{_unitdir}/receptor@.service
%dir %attr(0700,receptor,receptor) /var/lib/receptor
%dir %attr(0755,receptor,receptor) /var/log/receptor
%dir %attr(0755,receptor,receptor) /var/run/receptor
%{_sysconfdir}/logrotate.d/receptor
%{_tmpfilesdir}/receptor.conf


%files -n receptorctl
%doc receptorctl/README.md
%{_bindir}/receptorctl
%{python3_sitelib}/receptorctl/
%{python3_sitelib}/receptorctl-%{version}.dist-info/


%files -n python3-receptor-python-worker
%doc receptor-python-worker/README.md
%{_bindir}/receptor-python-worker
%{python3_sitelib}/receptor_python_worker/
%{python3_sitelib}/receptor_python_worker-%{version}.dist-info/

%if %{with golang_library}
%gopkgfiles
%endif


%changelog
## START: Generated by rpmautospec
* Tue Feb 20 2024 Andrew Heath <anheath@anheath-thinkpadt14sgen2i.rmtusnc.csb> - 1.4.4-2
- Update tests to fix broken tests

* Tue Feb 13 2024 Andrew Heath <anheath@anheath-thinkpadt14sgen2i.rmtusnc.csb> - 1.4.4-1
- Update to 1.4.4

* Sun Feb 11 2024 Maxwell G <maxwell@gtmx.me> - 1.4.3-4
- Rebuild for golang 1.22.0

* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.4.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Tue Nov 28 2023 Andrew Heath <anheath@redhat.com> - 1.4.3-1
- Update to 1.4.3 and removed unneeded script

* Tue Oct 31 2023 Andrew Heath <anheath@redhat.com> - 1.4.2-1
- Update to 1.4.2

* Tue Oct 17 2023 Andrew Heath <anheath@redhat.com> - 1.4.1-4
- Updated spec file and removed vendor tar ball

* Mon Oct 09 2023 Andrew Heath <anheath@redhat.com> - 1.4.1-3
- fixed typo

* Mon Oct 09 2023 Andrew Heath <anheath@redhat.com> - 1.4.1-2
- Revert "Removeing to reimport"

* Mon Oct 09 2023 Andrew Heath <anheath@redhat.com> - 1.4.1-1
- Initial import (fedora#2232203).
## END: Generated by rpmautospec