# Disable tests
%bcond_with  check

%global goipath       github.com/opencontainers/umoci
%global golicenses    COPYING
%global godocs        README.md
%global date          20201029
%global commit        b09d036cbfde5ec6be71a904e4b3143d1a1b042f
Version:              0.4.6

%global gomodulesmode GO111MODULE=on
%gometa -i

Name:           %{goname}
Release:        1%{?dist}
Summary:        Open Container Image manipulation tool
License:        Apache-2.0
URL:            %{gourl}
Source0:        %{gosource}

BuildRequires:  /usr/bin/git
BuildRequires:  /usr/bin/go-md2man
BuildRequires:  dep


%description
umoci (pronounced /uːmoˈʨi/ or approximately "oo-mo-tchee") is a reference
implementation of the OCI image specification and provides users with the
ability to create, manipulate, and otherwise interact with container images.
It is designed to be as small and unopinonated as possible, so as to act as
a foundation for larger systems to be built on top of it.


%prep
%goprep


%build
%gobuildroot
go mod download

export LDFLAGS="${LDFLAGS} -X %{goipath}.gitCommit=%{commit}  -X %{goipath}.version=%{version}%{distprefix} "

for cmd in umoci; do
    echo building ${cmd}
    %gobuild -o %{gobuilddir}/bin/$cmd %{goipath}/cmd/$cmd
done

# compile manuals
%make_build docs


%install
# install manuals
%make_install docs DESTDIR=%{buildroot}

# install binaries
install -p -m 0755 -d %{buildroot}%{_bindir}
install -p -m 0755 _build/bin/* %{buildroot}%{_bindir}/

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


%files
%license %{golicenses}
%doc %{godocs}
%{_bindir}/umoci
%{_mandir}/man1/*.1*


%changelog
* Tue Nov 03 2020 Damian Wrobel <dwrobel@ertelnet.rybnik.pl> - 0.4.6-3
- Initial RPM release