%global debug_package %{nil}

%define tempdir github.com/openSUSE/umoci

Name:           umoci
Version:        0.4.5
Release:        4
Summary:        Open Container Image manipulation tool
License:        Apache-2.0
URL:            https://github.com/opencontainers/umoci
Source0:        https://github.com/opencontainers/umoci/archive/v0.4.5.tar.gz
BuildRequires:  fdupes go >= 1.6 go-md2man
Patch0:         CVE-2021-29136.patch

%description
Umoci modifies Open Container images. Umoci intends to be a complete manipulation tool for OCI images.
In particular, it should be seen as a more end-user-focused version of the oci-image-tools provided by
the OCI.

%package_help

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

%build

export GOPATH=$HOME/go
mkdir -pv $HOME/go/src/%{tempdir}
rm -rf $HOME/go/src/%{tempdir}/*
cp -ar * $HOME/go/src/%{tempdir}
make umoci
make local-doc

%install
install -D -m 0755 %{name} %{buildroot}/%{_bindir}/%{name}
%fdupes %{buildroot}

for man_file in doc/man/*.1; do
	install -D -m 0644 $man_file %{buildroot}/%{_mandir}/man1/$(basename $man_file)
done

%files
%defattr(-,root,root)
%license COPYING
%{_bindir}/%{name}

%files help
%doc README.md doc/* CHANGELOG.md
%{_mandir}/man1/umoci*

%changelog
* Fri Apr 16 2021 wangyue <wangyue92@huawei.com> - 0.4.5-4
- Fix CVE-2021-29136

* Wed Sep 9 2020 Ge Wang <wangge20@huawei.com> - 0.4.5-3
- Modify Source0 Url

* Wed Mar 18 2020 openEuler Buildteam <buildteam@openeuler.org> - 0.4.5-2
- Package init
