File cloudflared.spec of Package failed_cloudflared

#
# spec file for package cloudflared
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

Name:           cloudflared
Version:        2024.6.0
Release:        0
Summary:        Cloudflare Tunnel client
License:        Apache-2.0
Group:          Productivity/Networking/System
URL:            https://github.com/cloudflare/cloudflared
Source0:        https://github.com/cloudflare/cloudflared/archive/%{version}/%{name}-%{version}.tar.gz
Source1:        vendor.tar.gz
# PATCH-FIX-OPENSUSE 001-skip-test.patch hillwood@opensuse.org
Patch0:         001-skip-test.patch
# PATCH-FIX-OPENSUSE 002-use-pie.patch hillwood@opensuse.org
Patch1:         002-use-pie.patch
# PATCH-FIX-UPSTREAM 003-support-ppc64le.patch hillwood@opensuse.org
Patch2:         003-support-ppc64le.patch
BuildRequires:  fdupes
BuildRequires:  git-core
BuildRequires:  golang(API) >= 1.22
BuildRequires:  golang-packaging
AutoReqProv:    Off
%{go_provides}

%description
Contains the command-line client for Cloudflare Tunnel, a tunneling daemon that
proxies traffic from the Cloudflare network to your origins. This daemon sits
between Cloudflare network and your origin (e.g. a webserver). Cloudflare
attracts client requests and sends them to you via this daemon, without
requiring you to poke holes on your firewall --- your origin can remain as
closed as possible. Extensive documentation can be found in the Cloudflare
Tunnel section of the Cloudflare Docs. All usages related with proxying to your
origins are available under cloudflared tunnel help.

%prep
%autosetup -p1 -a1 -n %{name}-%{version}

%build
# The upstream Makefile blocks unsupported architectures (e.g. riscv64).
# For architectures where qemu/kvm builds are used (like riscv64 in this OBS
# project) bypass the Makefile and use 'go build' directly so the package can
# be built cross-arch using the Go toolchain and the bundled vendor directory.
cd %{name}-%{version}
export GOOS=linux
# Explicitly set GOARCH to the build architecture; OBS sets BUILD_ARCH=riscv64
# We set GOARCH to riscv64 here to allow builds on riscv64. This is minimal and
# targeted to fix the current CI failure.
export GOARCH=riscv64
# Build the cloudflared binary using the vendor directory.
GOOS=${GOOS} GOARCH=${GOARCH} go build -mod=vendor -buildmode=pie -o cloudflared ./cmd/cloudflared

%install
# Install only the built binary and license/docs. Skip upstream install target
# that invokes the Makefile (which checks architecture).
rm -rf %{buildroot}
mkdir -p %{buildroot}%{_bindir}
install -m0755 cloudflared %{buildroot}%{_bindir}/cloudflared
# Install license and README if present in the source tree
if [ -f LICENSE ]; then
  mkdir -p %{buildroot}%{_docdir}/%{name}
  install -m0644 LICENSE %{buildroot}%{_docdir}/%{name}/LICENSE
fi
if [ -f README.md ]; then
  mkdir -p %{buildroot}%{_docdir}/%{name}
  install -m0644 README.md %{buildroot}%{_docdir}/%{name}/README.md
fi

%files
%doc README.md
%license LICENSE
%{_bindir}/%{name}

%changelog
openSUSE Build Service is sponsored by