File kubevirt.spec of Package kubevirt.22268

# spec file for package kubevirt
# Copyright (c) 2021 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

# The openSUSE docker prefix is stable and can be used as is. The SLE one needs
# more work to accommodate versions other than 15 SP2, but this will suffice now
# for testing purposes.
%if 0%{?is_opensuse}
%define docker_prefix
%define docker_prefix

Name:           kubevirt
Version:        0.40.0
Release:        0
Summary:        Container native virtualization
License:        Apache-2.0
Group:          System/Packages
Source0:        %{name}-%{version}.tar.gz
Source1:        kubevirt-psp-caasp.yaml
Source2:        kubevirt_containers_meta
Source3:        kubevirt_containers_meta.service
Source100:      %{name}-rpmlintrc
Patch0:         dont-build-virtctl-darwin.patch
Patch1:         dont-use-bazel-in-build-manifests.patch
Patch2:         fix-virsh-domcapabilities-error.patch
Patch3:         fix-double-free-of-VirDomain.patch
BuildRequires:  glibc-devel-static
BuildRequires:  golang-packaging
BuildRequires:  pkgconfig
BuildRequires:  rsync
BuildRequires:  sed
BuildRequires:  golang(API) = 1.13
BuildRequires:  pkgconfig(libvirt)
ExclusiveArch:  x86_64

Kubevirt is a virtual machine management add-on for Kubernetes

%package        virtctl
Summary:        Client for managing kubevirt
Group:          System/Packages

%description    virtctl
The virtctl client is a command-line utility for managing container native virtualization resources

%package        virt-api
Summary:        Kubevirt API server
Group:          System/Packages

%description    virt-api
The virt-api package provides the kubernetes API extension for kubevirt

%package        container-disk
Summary:        Container disk for kubevirt
Group:          System/Packages

%description    container-disk
The containter-disk package provides a container disk functionality for kubevirt

%package        virt-controller
Summary:        Controller for kubevirt
Group:          System/Packages

%description    virt-controller
The virt-controller package provides a controller for kubevirt

%package        virt-handler
Summary:        Handler component for kubevirt
Group:          System/Packages

%description    virt-handler
The virt-handler package provides a handler for kubevirt

%package        virt-launcher
Summary:        Launcher component for kubevirt
Group:          System/Packages

%description    virt-launcher
The virt-launcher package provides a launcher for kubevirt

%package        virt-operator
Summary:        Operator component for kubevirt
Group:          System/Packages

%description    virt-operator
The virt-opertor package provides an operator for kubevirt CRD

%package        manifests
Summary:        YAML manifests used to install kubevirt
Group:          System/Packages

%description    manifests
This contains the built YAML manifests used to install kubevirt into a
kubernetes installation with kubectl apply.

%package        tests
Summary:        Kubevirt functional tests
Group:          System/Packages

%description    tests
The package provides Kubevirt end-to-end tests.

%package -n     obs-service-kubevirt_containers_meta
Summary:        Kubevirt containers meta information (build service)
Group:          System/Packages

%description -n obs-service-kubevirt_containers_meta
The package provides meta information that is used during the build of
the Kubevirt container images.

%autosetup -p1

# Hackery to determine which registry path to use in kubevirt-operator.yaml
# when building the manifests
# The 'kubevirt_registry_path' macro can be used to define an explicit path in
# the project config, e.g.
# Macros:
# %kubevirt_registry_path
# :Macros
# 'kubevirt_registry_path' can also be defined when building locally, e.g.
# osc build --define='kubevirt_registry_path' ...
# If 'kubevirt_registry_path' is not specified, the standard publish location
# for SLE and openSUSE-based containers is used.
case "${distro}" in

%if "%{?kubevirt_registry_path}" == ""

sed -i"" \
    -e "s#_TAGPREFIX_#${tagprefix}#g" \
    -e "s#_LABELPREFIX_#${labelprefix}#g" \
    -e "s#_REGISTRY_#${registry}#g" \
    -e "s#_PKG_VERSION_#%{version}#g" \
    -e "s#_PKG_RELEASE_#%{release}#g" \

mkdir -p go/src/ go/pkg
ln -s ../../../ go/src/
export GOPATH=${PWD}/go
export GOFLAGS="-buildmode=pie"
cd ${GOPATH}/src/
env \
KUBEVIRT_GIT_COMMIT='v%{version}' \
KUBEVIRT_GIT_VERSION='v%{version}' \
build_tests="true" \
./hack/ install \
	cmd/virtctl \
	cmd/virt-api \
	cmd/virt-controller \
	cmd/virt-chroot \
	cmd/virt-handler \
	cmd/virt-launcher \
	cmd/virt-operator \

env DOCKER_PREFIX=$reg_path DOCKER_TAG=%{version}-%{release} ./hack/ --skipj2

mkdir -p %{buildroot}%{_bindir}

install -p -m 0755 _out/cmd/container-disk-v2alpha/container-disk %{buildroot}%{_bindir}/
install -p -m 0755 _out/cmd/virtctl/virtctl %{buildroot}%{_bindir}/
install -p -m 0755 _out/cmd/virt-api/virt-api %{buildroot}%{_bindir}/
install -p -m 0755 _out/cmd/virt-controller/virt-controller %{buildroot}%{_bindir}/
install -p -m 0755 _out/cmd/virt-chroot/virt-chroot %{buildroot}%{_bindir}/
install -p -m 0755 _out/cmd/virt-handler/virt-handler %{buildroot}%{_bindir}/
install -p -m 0755 _out/cmd/virt-launcher/virt-launcher %{buildroot}%{_bindir}/
install -p -m 0755 _out/cmd/virt-operator/virt-operator %{buildroot}%{_bindir}/
install -p -m 0755 _out/tests/tests.test %{buildroot}%{_bindir}/virt-tests

# node-labeller needs to be installed in /bin
mkdir -p %{buildroot}/bin
install -p -m 0755 cmd/virt-launcher/node-labeller/ %{buildroot}/bin/

# virt-launcher SELinux policy needs to land in virt-handler container
install -p -m 0644 cmd/virt-handler/virt_launcher.cil %{buildroot}/

mkdir -p %{buildroot}%{_datadir}/kube-virt
cp -r _out/manifests %{buildroot}%{_datadir}/kube-virt/
# Dont install OLM manifests
rm -rf %{buildroot}%{_datadir}/kube-virt/manifests/release/olm
# Create a proper Pod Security Policy (PSP) for KubeVirt. For now, add one
# that uses the CaaSP privileged PSP. It can be used with CaaSP-based
# Kubernetes clusters.
install -m 644 %{S:1} %{buildroot}/%{_datadir}/kube-virt/manifests/release/
install -m 0644 tests/default-config.json %{buildroot}%{_datadir}/kube-virt

# Install kubevirt_containers_meta build service
mkdir -p %{buildroot}%{_prefix}/lib/obs/service
install -m 0755 %{S:2} %{buildroot}%{_prefix}/lib/obs/service
install -m 0644 %{S:3} %{buildroot}%{_prefix}/lib/obs/service

%files virtctl
%license LICENSE

%files virt-api
%license LICENSE

%files container-disk
%license LICENSE

%files virt-controller
%license LICENSE

%files virt-handler
%license LICENSE

%files virt-launcher
%license LICENSE

%files virt-operator
%license LICENSE

%files manifests
%license LICENSE
%dir %{_datadir}/kube-virt

%files tests
%license LICENSE
%dir %{_datadir}/kube-virt

%files -n obs-service-kubevirt_containers_meta
%license LICENSE
%dir %{_prefix}/lib/obs

openSUSE Build Service is sponsored by