File kata-runtime.spec of Package runtime

%global DOMAIN github.com
%global ORG kata-containers
%global PROJECT runtime
%global IMPORTNAME %{DOMAIN}/%{ORG}/%{PROJECT}
%global GO_VERSION 1.12.3

%global DEFAULT_QEMU qemu-vanilla-system-x86_64

%define LIBEXECDIR /usr/libexec

%undefine _missing_build_ids_terminate_build
%define  debug_package %{nil}

Name:      kata-runtime
# Version is expected to be started with a digit following by an alphanumeric string
# e.g. 1.0.0+git.1234567
Version:   1.10.0~rc0
Release:   2
Source0:   %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Summary  : No detailed summary available
Group    : Development/Tools
License  : Apache-2.0

BuildRequires: git

Requires: kata-containers-image = 1.10.0~rc0
Requires: kata-linux-container = 4.19.86.62
Requires: kata-proxy = 1.10.0~rc0
Requires: kata-shim = 1.10.0~rc0
Requires: kata-ksm-throttler = 1.10.0~rc0
Requires: qemu-vanilla = 4.1.1+git.99c5874a9b

# Patches
#Patches


%description
.. contents::
.. sectnum::
``kata-runtime``
===================
Overview
--------

%prep
mkdir local
tar -C local -xzf ../SOURCES/go%{GO_VERSION}.linux-amd64.tar.gz
%autosetup -N -S git
# Patches
#Apply patches



%build
export GOROOT=$HOME/rpmbuild/BUILD/local/go
export PATH=$PATH:$HOME/rpmbuild/BUILD/local/go/bin
export GOPATH=$HOME/rpmbuild/BUILD/go/

mkdir -p $HOME/rpmbuild/BUILD/go/src/%{DOMAIN}/%{ORG}
ln -s $HOME/rpmbuild/BUILD/kata-runtime-%{version} $HOME/rpmbuild/BUILD/go/src/%{IMPORTNAME}
cd $HOME/rpmbuild/BUILD/go/src/%{IMPORTNAME}
make \
    QEMUCMD=%{DEFAULT_QEMU} \
    COMMIT=c3629d3  \
    SKIP_GO_VERSION_CHECK=1

%check
export http_proxy=http://127.0.0.1:9/
export https_proxy=http://127.0.0.1:9/
export no_proxy=localhost

%install

export GOROOT=$HOME/rpmbuild/BUILD/local/go
export PATH=$PATH:$HOME/rpmbuild/BUILD/local/go/bin
export GOPATH=$HOME/rpmbuild/BUILD/go/

cd $HOME/rpmbuild/BUILD/go/src/%{IMPORTNAME}
make \
    DESTDIR=%{buildroot} \
    PREFIX=/usr \
    QEMUCMD=%{DEFAULT_QEMU} \
    COMMIT=c3629d3 \
    SKIP_GO_VERSION_CHECK=1 \
    install
sed -i -e '/^initrd =/d' %{buildroot}/usr/share/defaults/kata-containers/configuration.toml

%files
%defattr(-,root,root,-)
/usr/bin/kata-runtime
/usr/bin/containerd-shim-kata-v2
%{LIBEXECDIR}
%{LIBEXECDIR}/kata-containers
%{LIBEXECDIR}/kata-containers/kata-netmon
/usr/bin/kata-collect-data.sh
/usr/share/defaults/
/usr/share/defaults/kata-containers/
/usr/share/defaults/kata-containers/configuration*.toml
/usr/share/bash-completion
/usr/share/bash-completion/completions
/usr/share/bash-completion/completions/kata-runtime