File libcontainers-common.spec of Package libcontainers-common.12794

# spec file for package libcontainers-common
# Copyright (c) 2018 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

# libpodver - version from containers/libpod
%define libpodver 1.5.1

# storagever - version from containers/storage
%define storagever 1.13.2

# imagever - version from containers/image
%define imagever 3.0.2

Name:           libcontainers-common
Version:        20190923
Release:        0
Summary:        Configuration files common to
License:        Apache-2.0 and GPL-3.0+
Group:          System/Management
Source0:        image-%{imagever}.tar.xz
Source1:        storage-%{storagever}.tar.xz
Source2:        LICENSE
Source3:        policy.json
Source4:        storage.conf
Source5:        mounts.conf
Source6:        registries.conf
Source7:        libpod-%{libpodver}.tar.xz
Source8:        default.yaml
BuildRequires:  go-go-md2man
Provides:       libcontainers-image
Provides:       libcontainers-storage
Obsoletes:      libcontainers-image
Obsoletes:      libcontainers-storage
Requires(post): util-linux
Requires(post): grep
BuildArch:      noarch

Configuration files and manpages shared by tools that are based on the libraries, such as Buildah, CRI-O, Podman and Skopeo.

%setup -q -T -D -b 0 -n image-%{imagever}
%setup -q -T -D -b 1 -n storage-%{storagever}
%setup -q -T -D -b 7 -n libpod-%{libpodver}
# copy the LICENSE file in the build root
cd ..
cp %{SOURCE2} .

cd ..
# compile containers/image manpages
cd image-%{imagever}
for md in docs/*.md
	go-md2man -in $md -out $md
rename '' '.5' docs/*
rename '.md' '.1' docs/*
cd ..
# compile containers/storage manpages
cd storage-%{storagever}
for md in docs/*.md
	go-md2man -in $md -out $md
rename '' '.5' docs/*
rename '.md' '.1' docs/*
cd ..
# compile subset of containers/libpod manpages
cd libpod-%{libpodver}
go-md2man -in pkg/hooks/docs/ -out pkg/hooks/docs/oci-hooks.5
cd ..

%if 0%{?is_opensuse}
# no default mounts
cat >>%{SOURCE5} <<EOL

cd ..
install -d -m 0755 %{buildroot}/%{_sysconfdir}/containers
install -d -m 0755 %{buildroot}/%{_sysconfdir}/containers/oci/hooks.d
install -d -m 0755 %{buildroot}/%{_datadir}/containers/oci/hooks.d
install -d -m 0755 %{buildroot}/%{_sysconfdir}/containers/registries.d

install -D -m 0644 %{SOURCE3} %{buildroot}/%{_sysconfdir}/containers/policy.json
install -D -m 0644 %{SOURCE4} %{buildroot}/%{_sysconfdir}/containers/storage.conf
install -D -m 0644 %{SOURCE5} %{buildroot}/%{_datadir}/containers/mounts.conf
install -D -m 0644 %{SOURCE5} %{buildroot}/%{_sysconfdir}/containers/mounts.conf
install -D -m 0644 %{SOURCE6} %{buildroot}/%{_sysconfdir}/containers/registries.conf
install -D -m 0644 %{SOURCE8} %{buildroot}/%{_sysconfdir}/containers/registries.d/default.yaml
install -D -m 0644 libpod-%{libpodver}/seccomp.json %{buildroot}/%{_datadir}/containers/seccomp.json
install -D -m 0644 libpod-%{libpodver}/seccomp.json %{buildroot}/%{_sysconfdir}/containers/seccomp.json

install -d %{buildroot}/%{_mandir}/man1
install -d %{buildroot}/%{_mandir}/man5
install -D -m 0644 image-%{imagever}/docs/*.1 %{buildroot}/%{_mandir}/man1/
install -D -m 0644 image-%{imagever}/docs/*.5 %{buildroot}/%{_mandir}/man5/
install -D -m 0644 storage-%{storagever}/docs/*.1 %{buildroot}/%{_mandir}/man1/
install -D -m 0644 storage-%{storagever}/docs/*.5 %{buildroot}/%{_mandir}/man5/
install -D -m 0644 libpod-%{libpodver}/pkg/hooks/docs/oci-hooks.5 %{buildroot}/%{_mandir}/man5/

# If installing, check if /var/lib/containers (or /var/lib in its defect) is btrfs and set driver
# to "btrfs" if true
if [ $1 -eq 1 ] ; then
  fstype=$((findmnt -o FSTYPE -l --target /var/lib/containers || findmnt -o FSTYPE -l --target /var/lib) | grep -v FSTYPE)
  if [ "$fstype" = "btrfs" ]; then
    sed -i 's/driver = ""/driver = "btrfs"/g' %{_sysconfdir}/containers/storage.conf

%dir %{_sysconfdir}/containers
%dir %{_sysconfdir}/containers/oci
%dir %{_sysconfdir}/containers/oci/hooks.d
%dir %{_sysconfdir}/containers/registries.d
%dir %{_datadir}/containers
%dir %{_datadir}/containers/oci
%dir %{_datadir}/containers/oci/hooks.d

%config(noreplace) %{_sysconfdir}/containers/policy.json
%config(noreplace) %{_sysconfdir}/containers/storage.conf
%config(noreplace) %{_sysconfdir}/containers/mounts.conf
%config(noreplace) %{_sysconfdir}/containers/registries.conf
%config(noreplace) %{_sysconfdir}/containers/seccomp.json
%config(noreplace) %{_sysconfdir}/containers/registries.d/default.yaml

%license LICENSE

openSUSE Build Service is sponsored by