#? https://src.fedoraproject.org/rpms/golang-google-grpc/blob/rawhide/f/golang-google-grpc.spec

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

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

# https://github.com/grpc/grpc-go
%global goipath         google.golang.org/grpc
%global forgeurl        https://github.com/grpc/grpc-go
Version:                1.81.1

%gometa -L

%global common_description %{expand:
The Go language implementation of gRPC. HTTP/2 based RPC.}

%global golicenses      LICENSE NOTICE.txt
%global godocs          examples AUTHORS CODE-OF-CONDUCT.md CONTRIBUTING.md\\\
                        GOVERNANCE.md MAINTAINERS.md README.md SECURITY.md\\\
                        Documentation

Name:           golang-google-grpc.terra
Release:        1%{?dist}
Summary:        The Go language implementation of gRPC. HTTP/2 based RPC

License:        Apache-2.0
URL:            %{gourl}
Source:         %{gosource}
Conflicts:      golang-google-grpc

%description %{common_description}

%{lua:
  local s = rpm.expand("%gopkg"):gsub("golang%-google%-grpc", "golang-google-grpc.terra")
  print(s)
}

%prep
%goprep -A
%autopatch -p1

# Remove dependency on stackdriver due to dependency issues
# golang-contrib-opencensus-exporter-stackdriver-devel
rm -rf gcp/observability interop/observability/

%dnl %if %{without bootstrap}
%dnl %generate_buildrequires
%dnl %go_generate_buildrequires
%dnl %endif

%if %{without bootstrap}
%build
%define gomodulesmode GO111MODULE=on
for cmd in cmd/* ; do
  pushd $cmd
  %gobuild -o %{gobuilddir}/bin/$(basename $cmd) .
  popd
done
%endif

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

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

for test in "InvalidMetadata" \
            "SvrWriteStatusEarlyWrite" \
            "AuthorizationEngineEvaluate" \
            "HealthWatchServiceStatusSetBeforeStartingServer" \
            "PolicyEngineEvaluate" \
            "IdentityEncoding" \
            "Fallback" \
            "HealthCheckOff" \
            "ControlChannelCredsFailure" \
; do
awk -i inplace '/^func.*'"$test"'\(/ { print; print "\tt.Skip(\"disabled failing test\")"; next}1' $(grep -rl $test)
done
%gocheck -d google.golang.org/grpc/security/advancedtls
%endif
%endif

%if %{without bootstrap}
%files
%license LICENSE NOTICE.txt
%doc examples AUTHORS CODE-OF-CONDUCT.md CONTRIBUTING.md GOVERNANCE.md
%doc MAINTAINERS.md README.md SECURITY.md Documentation
%{_bindir}/protoc-gen-go-grpc
%endif

%{lua:
  local s = rpm.expand("%gopkgfiles"):gsub("golang%-google%-grpc", "golang-google-grpc.terra", 1)
  print(s)
}

%changelog
%autochangelog
