# Generated by go2rpm 1.17.1
%bcond check 0
%bcond bootstrap 0

%if %{with bootstrap}
%global debug_package %{nil}
%endif

%if %{with bootstrap}
%global __requires_exclude %{?__requires_exclude:%{__requires_exclude}|}^golang\\(.*\\)$
%endif

%global providers 1password archlinuxpkgs bitwarden bluetooth bookmarks calc clipboard desktopapplications dnfpackages files menus niriactions nirisessions playerctl providerlist runner snippets symbols todo unicode websearch windows wireplumber

# https://github.com/abenz1267/elephant
%global goipath         github.com/abenz1267/elephant
Version:                2.21.0

%gometa -f

%global common_description %{expand:
Elephant - cuz it's phat - is a powerful data provider service and backend for building custom application launchers and desktop utilities. It provides various data sources and actions through a plugin-based architecture, communicating via Unix sockets and Protocol Buffers.
}

%global golicenses      LICENSE
%global godocs          README.md

Name:           elephant
Release:        1%{?dist}
Summary:        Data provider service and backend for building custom application launchers & desktop utilities

License:        GPL-3.0-only
URL:            %{gourl}
Source:         %{gourl}/archive/refs/tags/v%version.tar.gz

Provides:       golang-github-abenz1267-elephant = %evr
Packager:       madonuko <mado@fyralabs.com>
# desktopapplications
BuildRequires:  wayland-devel

%description %{common_description}

%gopkg

%{lua:
for prov in string.gmatch(macros.providers, "%S+") do
  print("%package "..prov.."\n")
  print("Summary: "..prov.." provider for elephant\n")
  print("\n%description "..prov.."\n"..prov.." provider for elephant.\n\n")
  print("%files "..prov.."\n")
  print("/etc/xdg/elephant/providers/"..prov..".so\n\n")
end
}

%prep
%autosetup -n %name-%version
%goprep -Ae
%autopatch -p1

%if %{without bootstrap}
%build
%define gomodulesmode GO111MODULE=on
pushd cmd
(%{gobuild -o %{gobuilddir}/bin/elephant elephant/elephant.go}) &
popd
for prov in internal/providers/*/; do
  pushd $prov
  (%{gobuild -buildmode=plugin}) &
  popd
done
wait
%endif

%install
%gopkginstall
%if %{without bootstrap}
install -m 0755 -vd                     %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
install -Dm755 internal/providers/*/*.so -t %buildroot/etc/xdg/elephant/providers/
%endif

%if %{without bootstrap}
%if %{with check}
%check
%gocheck
%endif
%endif

%if %{without bootstrap}
%files
%license LICENSE
%doc README.md
%{_bindir}/elephant
%ghost /etc/xdg/elephant/providers/*.so
%endif

%gopkgfiles

%changelog
%autochangelog
