containerd/containerd.spec

180 lines
5.7 KiB
RPMSpec
Raw Normal View History

#
# spec file for package containerd
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#
# Check if go_arches is defined in the project configuration
# Otherwise, define it here
# In order to define it in the project configuration, see
#
# https://en.opensuse.org/openSUSE:Build%20Service%20prjconf#Macros
#
# The Macros tag is the one that defines the go_arches variable to be used
# in the spec file.
# The "define" one is to help the specfile parser of the buildservice
# to see what packages are being built. You also want to define it here
# for keeping things consistent.
%{!?go_arches: %global go_arches %ix86 x86_64 aarch64 ppc64le}
%ifarch %go_arches
%define go_tool go
%define GO_BUILD_FLAGS %{nil}
%else
%define go_tool go-6
%define GO_BUILD_FLAGS "-gccgoflags=-Wl,--add-needed -Wl,--no-as-needed -static-libgo -ldl"
%endif
%define git_version 0366d7e
%define version_unconverted %{git_version}
Name: containerd
Version: 0.2.4+git%{git_version}
Release: 0
Summary: Standalone OCI Container Daemon
License: Apache-2.0
Group: System/Management
Url: https://containerd.tools
Source: %{name}-git.%{git_version}.tar.xz
Source1: %{name}.service
Source2: %{name}.socket
Source3: sysconfig.%{name}
%ifarch %go_arches
BuildRequires: go >= 1.5
%else
BuildRequires: gcc6-go >= 6.1
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# Currently runC is the only supported runtime for containerd. NOTE:
# This version pinning is done to follow (as well as we can) upstream's
# Dockerfile. However, for some reason the Dockerfile for containerd
# diverges from the one for Docker. As such, this cannot be a hard
# requirement (that would break Docker).
Requires: runc = 0.1.1+git02f8fa7
%define client ctr
%define daemon %{name}
%define shim %{name}-shim
%description
Containerd is a daemon with an API and a command line client, to manage
containers on one machine. It uses runC to run containers according to the OCI
specification. Containerd has advanced features such as seccomp and user
namespace support as well as checkpoint and restore for cloning and live
migration of containers.
%package ctr
Summary: Client for %{name}
Group: System/Management
Requires: %{name} = %{version}
%ifarch %go_arches
BuildRequires: go >= 1.5
%else
BuildRequires: gcc6-go >= 6.1
%endif
%description ctr
Standalone client for containerd, which allows management of containerd containers
separately from Docker.
%package test
Summary: Test package for containerd
Group: System/Management
%ifarch %go_arches
Requires: go >= 1.5
%else
Requires: gcc5-go >= 5.0
%endif
BuildArch: noarch
%description test
Test package for containerd. It contains the source code and the tests.
%prep
%setup -q -n %{name}-git.%{git_version}
%build
# Do not use symlinks. If you want to run the unit tests for this package at
# some point during the build and you need to directly use go list directly it
# will get confused by symlinks.
export GOPATH=${HOME}/go:${HOME}/go/src/github.com/docker/containerd/vendor
mkdir -pv $HOME/go/src/github.com/docker/containerd
rm -rf $HOME/go/src/github.com/docker/containerd/*
cp -avr * $HOME/go/src/github.com/docker/containerd
# Build daemon.
%go_tool build %GO_BUILD_FLAGS -x -o %{daemon}-%{version} github.com/docker/%{name}/%{daemon}
# Build shim.
%go_tool build %GO_BUILD_FLAGS -x -o %{shim}-%{version} github.com/docker/%{name}/%{shim}
# Build client.
%go_tool build %GO_BUILD_FLAGS -x -o %{client}-%{version} github.com/docker/%{name}/%{client}
%ifarch %go_arches
%check
export GOPATH=$HOME/go/src/github.com/docker/containerd/vendor:$GOPATH
cd $HOME/go/src/github.com/docker/containerd
go test -v $(go list ./... | grep github.com/docker/containerd | grep -v /integration-test)
%endif
%install
%{__install} -D -m755 %{daemon}-%{version} %{buildroot}/%{_sbindir}/%{daemon}
%{__install} -D -m755 %{shim}-%{version} %{buildroot}/%{_sbindir}/%{shim}
%{__install} -D -m755 %{client}-%{version} %{buildroot}/%{_sbindir}/%{name}-%{client}
# Add service and sysconfig.
%{__install} -D -m644 %SOURCE1 %{buildroot}/%{_unitdir}/%{name}.service
%{__install} -D -m644 %SOURCE2 %{buildroot}/%{_unitdir}/%{name}.socket
ln -sf %{_sbindir}/service %{buildroot}/%{_sbindir}/rccontainerd
%{__install} -D -m644 %SOURCE3 %{buildroot}/var/adm/fillup-templates/sysconfig.%{name}
install -d -m755 %{buildroot}/usr/src/containerd/
cp -avr $HOME/go/src/github.com/docker/containerd/* %{buildroot}/usr/src/containerd/
%pre
%service_add_pre %{name}.service %{name}.socket
%post
%service_add_post %{name}.service %{name}.socket
%{fillup_only -n containerd}
%preun
%service_del_preun %{name}.service %{name}.socket
%postun
%service_del_postun %{name}.service %{name}.socket
%files
%defattr(-,root,root)
%doc LICENSE.code LICENSE.docs README.md
%{_sbindir}/%{daemon}
%{_sbindir}/%{shim}
%{_unitdir}/%{name}.service
%{_unitdir}/%{name}.socket
/var/adm/fillup-templates/sysconfig.%{name}
%{_sbindir}/rccontainerd
%files ctr
%{_sbindir}/%{name}-%{client}
%files test
%defattr(-,root,root)
/usr/src/containerd/
%exclude /usr/src/containerd/bin
%changelog