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

%global debug_package %{nil}
%global __requires_exclude %{?__requires_exclude:%{__requires_exclude}|}^golang\\(.*\\)$

# https://github.com/moby/buildkit
%global goipath         github.com/moby/buildkit
%global tag             v0.20.0
Version:                0.20.0

%gometa -L -f

%global common_description %{expand:
Concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit.}

%global golicenses      LICENSE
%global godocs          AUTHORS PROJECT.md README.md

Name:           buildkit
Release:        %autorelease
Summary:        Concurrent, cache-efficient, and Dockerfile-agnostic builder toolkit

License:        Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND CC-BY-4.0 AND CC-BY-SA-4.0 AND GPL-2.0-only AND ISC AND MIT AND MPL-2.0
URL:            %{gourl}
Source0:        %{gosource}
Source1:        go-vendor-tools.toml
Source2:        buildkit.service
Source3:        buildkit.socket
Source4:        buildkitd.toml
Source5:        buildkit.sysusers

BuildRequires:  go-vendor-tools
BuildRequires:  systemd-rpm-macros
%{?sysusers_requires_compat}

Recommends:     containernetworking-plugins
Recommends:     containerd

%description %{common_description}

%gopkg

%prep
%goprep -A -k
%autopatch -p1 -q

%generate_buildrequires
%go_vendor_license_buildrequires -c %{S:1}

%build
GO_LDFLAGS="-X %{goipath}/version.Version=%{version} -X %{goipath}/version.Package=%{goipath}"
for cmd in cmd/* ; do
  %gobuild -o %{gobuilddir}/bin/$(basename $cmd) %{goipath}/$cmd
done

%install
%go_vendor_license_install -c %{S:1}
install -m 0755 -vd                     %{buildroot}%{_bindir}
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
install -Dpm 0644 %{S:2} -t %{buildroot}%{_unitdir}
install -Dpm 0644 %{S:3} -t %{buildroot}%{_unitdir}
install -Dpm 0644 %{S:4} %{buildroot}%{_sysconfdir}/buildkit/buildkitd.toml
install -p -D -m 0644 %{S:5} %{buildroot}%{_sysusersdir}/buildkit.conf

%pre
%sysusers_create_compat %{S:5}

%if %{with check}
%check
%go_vendor_license_check -c %{S:1}
%endif

%files -f %{go_vendor_license_filelist}
%doc AUTHORS README.md
%{_bindir}/buildkitd
%{_bindir}/buildctl
%dir %{_sysconfdir}/buildkit
%config(noreplace) %{_sysconfdir}/buildkit/buildkitd.toml
%{_unitdir}/buildkit.service
%{_unitdir}/buildkit.socket
%{_sysusersdir}/buildkit.conf

%changelog
%autochangelog