containerd/containerd.spec

169 lines
5.6 KiB
RPMSpec
Raw Normal View History

#
# spec file for package containerd
#
# Copyright (c) 2017 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/
#
# nodebuginfo
#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
%define _fillupdir /var/adm/fillup-templates
%endif
%define go_tool go
%define GO_BUILD_FLAGS -buildmode=pie
# MANUAL: Update the git_version and git_revision
%define git_version 06b9cb35161009dcb7123345749fef02f7cea8e0
%define git_short 06b9cb351610
# How to get the git_revision
# git clone https://github.com/containerd/containerd.git containerd-upstream
# cd containerd
# git checkout $git_version
# git_revision=r$(git rev-list HEAD | wc -l)
%define git_revision r706
# These are the git commits required. We verify them against the source to make
# sure we didn't miss anything important when doing upgrades. This MUST match
# required_dockerrunc in docker.spec!
%define required_dockerrunc 3f2f8b84a77f73d38244dd690525642a72156c64
Name: containerd
Version: 0.2.9+git%{git_revision}_%{git_short}
Release: 0
Summary: Standalone OCI Container Daemon
License: Apache-2.0
Group: System/Management
Url: https://containerd.tools
Source: %{name}-git.%{git_short}.tar.xz
Source1: %{name}.service
Source2: %{name}.socket
Source3: sysconfig.%{name}
# OPENSUSE-FIX-UPSTREAM: Backport of https://github.com/containerd/containerd/pull/1686. bsc#1065109 boo#1053532
Patch100: bsc1065109-0001-makefile-add-support-for-build_flags.patch
BuildRequires: fdupes
BuildRequires: golang(API) = 1.8
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# We provide a git revision so that Docker can require it properly.
Provides: %{name}-git = %{git_version}
# Currently runC is the only supported runtime for containerd. We match the
# same version as the one pinned by Docker.
Requires: docker-runc-git = %{required_dockerrunc}
Requires(post): %fillup_prereq
%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}
BuildRequires: golang(API) = 1.8
%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
BuildRequires: golang(API) = 1.8
BuildArch: noarch
%description test
Test package for containerd. It contains the source code and the tests.
%prep
%setup -q -n %{name}-git.%{git_short}
# bsc#1065109 boo#1053532
%patch100 -p1
%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
export PROJECT=$HOME/go/src/github.com/containerd/containerd
mkdir -p $PROJECT
rm -rf $PROJECT/*
cp -ar * $PROJECT
make -C $PROJECT GIT_COMMIT=%{git_version}
cp $PROJECT/bin/ctr ctr-%{version}
cp $PROJECT/bin/containerd containerd-%{version}
cp $PROJECT/bin/containerd-shim containerd-shim-%{version}
%check
export GOPATH=$HOME/go/src/github.com/containerd/containerd/vendor:$GOPATH
cd $HOME/go/src/github.com/containerd/containerd
%go_tool test %GO_BUILD_FLAGS -v $(%go_tool list ./... | \
grep github.com/containerd/containerd | \
grep -v github.com/containerd/containerd/vendor | \
grep -v /integration-test)
%install
install -D -m755 containerd-%{version} %{buildroot}/%{_sbindir}/containerd
install -D -m755 containerd-shim-%{version} %{buildroot}/%{_sbindir}/containerd-shim
install -D -m755 ctr-%{version} %{buildroot}/%{_sbindir}/%{name}-ctr
# 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}%{_fillupdir}/sysconfig.%{name}
install -d -m755 %{buildroot}/usr/src/containerd/
cp -ar $HOME/go/src/github.com/containerd/containerd/* %{buildroot}/usr/src/containerd/
# remove files we don't want to ship - exclude is the wrong usage here
rm -rf %{buildroot}/usr/src/containerd/bin
%fdupes %{buildroot}
%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}/containerd
%{_sbindir}/containerd-shim
%{_unitdir}/%{name}.service
%{_unitdir}/%{name}.socket
%{_fillupdir}/sysconfig.%{name}
%{_sbindir}/rccontainerd
%files ctr
%{_sbindir}/%{name}-ctr
%files test
%defattr(-,root,root)
/usr/src/containerd/
%changelog