## START: Set by rpmautospec
## (rpmautospec version 0.3.0)
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 3;
    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.8.2
%bcond_without check

# https://github.com/OliveTin/OliveTin
%global goipath         github.com/OliveTin/OliveTin
Version:                2022.11.14
%global tag             %{version}

%gometa -f
%global goname OliveTin

%global common_description %{expand:
OliveTin gives safe and simple access to predefined shell commands from a web
interface.}

%global golicenses      LICENSE
%global godocs          CODE_OF_CONDUCT.md README.md SECURITY.md

Name:           %{goname}
Release:        %autorelease
Summary:        Give safe and simple access to predefined shell commands from a web interface

BuildRequires: systemd-rpm-macros
BuildRequires: googleapis-devel 
BuildRequires: protobuf-compiler
BuildRequires: protobuf-devel
BuildRequires: golang-google-grpc
BuildRequires: golang-google-protobuf
BuildRequires: golang-github-grpc-ecosystem-gateway-2

License:        AGPLv3
URL:            %{gourl}
Source:         %{gosource}

%description %{common_description}

%gopkg

%prep
%goprep
sed -i 's/local\///g' %{name}.service
rm webui/.eslintrc.json
rm webui/.stylelintrc.json

%generate_buildrequires
%go_generate_buildrequires

%build
make protoc
export LDFLAGS="-X main.version=%{version}%{dist} "
%gobuild -o %{gobuilddir}/bin/$(basename $cmd) %{goipath}/cmd/%{name}

%install
%gopkginstall
install -m 0755 -vd                             %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/*         %{buildroot}%{_bindir}/

install -m 0644 -vD config.yaml                 %{buildroot}/%{_sysconfdir}/%{name}/config.yaml
install -m 0644 -vD var/manpage/%{name}.1.gz    %{buildroot}%{_mandir}/man1/%{name}.1.gz
install -m 0644 -vD %{name}.service             %{buildroot}/%{_unitdir}/%{name}.service

install -m 0755 -vd                             %{buildroot}/%{_datadir}/%{name}/webui
for d in $(find webui -type d); do
    install --mode 0755 -vd "$d" %{buildroot}%{_datadir}/%{name}/$d
done
for f in $(find webui -type f); do
    install --mode 0644 -vp "$f" %{buildroot}%{_datadir}/%{name}/$f
done

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

%post
%systemd_post %{name}.service

%preun
%systemd_preun %{name}.service

%postun
%systemd_postun_with_restart %{name}.service

%files
%license LICENSE
%doc CODE_OF_CONDUCT.md README.md SECURITY.md
%{_bindir}/%{name}
%config(noreplace) /%{_sysconfdir}/%{name}/config.yaml
%{_datadir}/%{name}/webui
%{_mandir}/man1/%{name}.1.gz
%{_unitdir}/%{name}.service

%gopkgfiles

%changelog
* Tue Nov 29 2022 jamesread <contact@jread.com> 2022.11.14-3
- Unused patch from an earlier spec

* Mon Nov 28 2022 jamesread <contact@jread.com> 2022.11.14-2
- Various spec updates to be compatible with Fedora standards

* Mon Nov 28 2022 jamesread <contact@jread.com> 2022.11.14-1
- Initial import (fedora#2143804)