eae678
%if 0%{?fedora}
eae678
%global with_devel 1
eae678
%global with_bundled 1
eae678
%global with_debug 0
eae678
%global with_check 0
eae678
%global with_unit_test 1
eae678
%else 
eae678
%global with_devel 0
eae678
%global with_bundled 1
eae678
%global with_debug 0
eae678
%global with_check 0
eae678
%global with_unit_test 0
eae678
%endif
eae678
eae678
%if 0%{?with_debug}
eae678
%global _dwz_low_mem_die_limit 0
eae678
%else
eae678
%global debug_package   %{nil}
eae678
%endif
eae678
eae678
%if ! 0%{?gobuild:1}
eae678
%define gobuild(o:) go build -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x %{?**};
eae678
%endif
eae678
eae678
%global provider        github
eae678
%global provider_tld    com
eae678
%global project         containernetworking
eae678
%global repo            plugins
eae678
# https://github.com/containernetworking/plugins
eae678
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
eae678
%global import_path     %{provider_prefix}
eae678
%global commit          dd8ff8a5cf537dcfc705e14a1465f82817869bf9
eae678
%global shortcommit     %(c=%{commit}; echo ${c:0:7})
eae678
eae678
Name:           containernetworking-plugins
eae678
Version:        0.7.0
eae678
Release:        101%{?dist}
eae678
Summary:        Some CNI network plugins, maintained by the containernetworking team.
eae678
License:        ASL 2.0
eae678
URL:            https://%{provider_prefix}
eae678
Source0:        https://%{provider_prefix}/archive/%{commit}/%{repo}-%{shortcommit}.tar.gz
eae678
ExcludeArch:    ppc64
eae678
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
eae678
BuildRequires:  %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
eae678
eae678
%if ! 0%{?with_bundled}
eae678
BuildRequires: go-md2man
eae678
BuildRequires: go-bindata
eae678
BuildRequires: golang(github.com/vishvananda/netlink)
eae678
BuildRequires: golang(github.com/coreos/go-systemd/activation)
eae678
BuildRequires: golang(github.com/d2g/dhcp4)
eae678
BuildRequires: golang(github.com/d2g/dhcp4client)
eae678
BuildRequires: golang(github.com/vishvananda/netlink)
eae678
BuildRequires: golang(golang.org/x/sys/unix)
eae678
BuildRequires: golang(github.com/coreos/go-iptables/iptables)
eae678
%endif
eae678
eae678
Provides: containernetworking-plugins = %{version}-%{release}
eae678
eae678
%description
eae678
The CNI (Container Network Interface) project consists of a specification
eae678
and libraries for writing plugins to configure network interfaces in Linux
eae678
containers, along with a number of supported plugins. CNI concerns itself
eae678
only with network connectivity of containers and removing allocated resources
eae678
when the container is deleted.
eae678
eae678
%if 0%{?with_devel}
eae678
%package devel
eae678
Summary:       %{summary}
eae678
BuildArch:     noarch
eae678
eae678
%if 0%{?with_check} && ! 0%{?with_bundled}
eae678
BuildRequires: golang(github.com/coreos/go-iptables/iptables)
eae678
BuildRequires: golang(github.com/vishvananda/netlink)
eae678
BuildRequires: golang(golang.org/x/sys/unix)
eae678
%endif
eae678
eae678
Requires:      golang(github.com/coreos/go-iptables/iptables)
eae678
Requires:      golang(github.com/vishvananda/netlink)
eae678
Requires:      golang(golang.org/x/sys/unix)
eae678
eae678
Provides:      golang(%{import_path}/libcni) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/pkg/invoke) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/pkg/invoke/fakes) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/pkg/ip) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/pkg/ipam) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/pkg/ns) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/pkg/skel) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/pkg/testutils) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/pkg/types) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/pkg/types/020) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/pkg/types/current) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/pkg/utils) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/pkg/utils/hwaddr) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/pkg/utils/sysctl) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/pkg/version) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/pkg/version/legacy_examples) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/pkg/version/testhelpers) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/plugins/ipam/host-local/backend) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/plugins/ipam/host-local/backend/allocator) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/plugins/ipam/host-local/backend/disk) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/plugins/ipam/host-local/backend/testing) = %{version}-%{release}
eae678
Provides:      golang(%{import_path}/plugins/test/noop/debug) = %{version}-%{release}
eae678
eae678
%description devel
eae678
This package contains library source intended for
eae678
building other packages which use import path with
eae678
%{import_path} prefix.
eae678
%endif
eae678
eae678
%if 0%{?with_unit_test} && 0%{?with_devel}
eae678
%package unit-test-devel
eae678
Summary:         Unit tests for %{name} package
eae678
%if 0%{?with_check}
eae678
%endif
eae678
eae678
Requires:        %{name}-devel = %{version}-%{release}
eae678
eae678
%if 0%{?with_check} && ! 0%{?with_bundled}
eae678
BuildRequires: golang(github.com/d2g/dhcp4)
eae678
BuildRequires: golang(github.com/onsi/ginkgo)
eae678
BuildRequires: golang(github.com/onsi/ginkgo/config)
eae678
BuildRequires: golang(github.com/onsi/ginkgo/extensions/table)
eae678
BuildRequires: golang(github.com/onsi/gomega)
eae678
BuildRequires: golang(github.com/onsi/gomega/gbytes)
eae678
BuildRequires: golang(github.com/onsi/gomega/gexec)
eae678
BuildRequires: golang(github.com/vishvananda/netlink/nl)
eae678
%endif
eae678
eae678
Requires:      golang(github.com/d2g/dhcp4)
eae678
Requires:      golang(github.com/onsi/ginkgo)
eae678
Requires:      golang(github.com/onsi/ginkgo/config)
eae678
Requires:      golang(github.com/onsi/ginkgo/extensions/table)
eae678
Requires:      golang(github.com/onsi/gomega)
eae678
Requires:      golang(github.com/onsi/gomega/gbytes)
eae678
Requires:      golang(github.com/onsi/gomega/gexec)
eae678
Requires:      golang(github.com/vishvananda/netlink/nl)
eae678
eae678
%description unit-test-devel
eae678
This package contains unit tests for project
eae678
providing packages with %{import_path} prefix.
eae678
%endif
eae678
eae678
%prep
eae678
%setup -q -n %{repo}-%{commit}
eae678
eae678
%build
eae678
./build.sh
eae678
eae678
%install
eae678
install -d -p %{buildroot}%{_libexecdir}/cni/
eae678
install -p -m 0755 bin/* %{buildroot}/%{_libexecdir}/cni
eae678
eae678
# source codes for building projects
eae678
%if 0%{?with_devel}
eae678
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
eae678
echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list
eae678
# find all *.go but no *_test.go files and generate devel.file-list
eae678
for file in $(find . \( -iname "*.go" -or -iname "*.s" \) \! -iname "*_test.go" | grep -v "vendor") ; do
eae678
    dirprefix=$(dirname $file)
eae678
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix
eae678
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
eae678
    echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list
eae678
eae678
    while [ "$dirprefix" != "." ]; do
eae678
        echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list
eae678
        dirprefix=$(dirname $dirprefix)
eae678
    done
eae678
done
eae678
%endif
eae678
eae678
# testing files for this project
eae678
%if 0%{?with_unit_test} && 0%{?with_devel}
eae678
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/
eae678
# find all *_test.go files and generate unit-test-devel.file-list
eae678
for file in $(find . -iname "*_test.go" | grep -v "vendor") ; do
eae678
    dirprefix=$(dirname $file)
eae678
    install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix
eae678
    cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
eae678
    echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test-devel.file-list
eae678
eae678
    while [ "$dirprefix" != "." ]; do
eae678
        echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list
eae678
        dirprefix=$(dirname $dirprefix)
eae678
    done
eae678
done
eae678
%endif
eae678
eae678
%if 0%{?with_devel}
eae678
sort -u -o devel.file-list devel.file-list
eae678
%endif
eae678
eae678
%check
eae678
%if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel}
eae678
%if ! 0%{?with_bundled}
eae678
export GOPATH=%{buildroot}/%{gopath}:%{gopath}
eae678
%else
eae678
# Since we aren't packaging up the vendor directory we need to link
eae678
# back to it somehow. Hack it up so that we can add the vendor
eae678
# directory from BUILD dir as a gopath to be searched when executing
eae678
# tests from the BUILDROOT dir.
eae678
ln -s ./ ./vendor/src # ./vendor/src -> ./vendor
eae678
eae678
export GOPATH=%{buildroot}/%{gopath}:$(pwd)/vendor:%{gopath}
eae678
%endif
eae678
eae678
%if ! 0%{?gotest:1}
eae678
%global gotest go test
eae678
%endif
eae678
eae678
%gotest %{import_path}/libcni
eae678
%gotest %{import_path}/pkg/invoke
eae678
%gotest %{import_path}/pkg/ip
eae678
%gotest %{import_path}/pkg/ipam
eae678
%gotest %{import_path}/pkg/ns
eae678
%gotest %{import_path}/pkg/skel
eae678
%gotest %{import_path}/pkg/types
eae678
%gotest %{import_path}/pkg/types/020
eae678
%gotest %{import_path}/pkg/types/current
eae678
%gotest %{import_path}/pkg/utils
eae678
%gotest %{import_path}/pkg/utils/hwaddr
eae678
%gotest %{import_path}/pkg/version
eae678
%gotest %{import_path}/pkg/version/legacy_examples
eae678
%gotest %{import_path}/pkg/version/testhelpers
eae678
%gotest %{import_path}/plugins/ipam/dhcp
eae678
%gotest %{import_path}/plugins/ipam/host-local
eae678
%gotest %{import_path}/plugins/ipam/host-local/backend/allocator
eae678
%gotest %{import_path}/plugins/main/bridge
eae678
%gotest %{import_path}/plugins/main/ipvlan
eae678
%gotest %{import_path}/plugins/main/loopback
eae678
%gotest %{import_path}/plugins/main/macvlan
eae678
%gotest %{import_path}/plugins/main/ptp
eae678
%gotest %{import_path}/plugins/meta/flannel
eae678
%gotest %{import_path}/plugins/test/noop
eae678
%endif
eae678
eae678
#define license tag if not already defined
eae678
%{!?_licensedir:%global license %doc}
eae678
eae678
%files
eae678
%license LICENSE
eae678
%doc *.md
eae678
%dir %{_libexecdir}/cni
eae678
%{_libexecdir}/cni/*
eae678
eae678
%if 0%{?with_devel}
eae678
%files devel -f devel.file-list
eae678
%license LICENSE
eae678
%doc *.md
eae678
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
eae678
%endif
eae678
eae678
%if 0%{?with_unit_test} && 0%{?with_devel}
eae678
%files unit-test-devel -f unit-test-devel.file-list
eae678
%license LICENSE
eae678
%doc *.md
eae678
%endif
eae678
eae678
%changelog
eae678
* Thu May 10 2018 Frantisek Kluknavsky <fkluknav@redhat.com> - 0.7.0-101
eae678
- rebase
eae678
- patches already upstream, removed
eae678
eae678
* Thu Apr 26 2018 Frantisek Kluknavsky <fkluknav@redhat.com> - 0.6.0-6
eae678
- Imported from Fedora
eae678
- Renamed CNI -> plugins
eae678
eae678
* Mon Apr  2 2018 Peter Robinson <pbrobinson@fedoraproject.org> 0.6.0-4
eae678
- Own the libexec cni directory
eae678
eae678
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.0-3
eae678
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
eae678
eae678
* Tue Jan 23 2018 Dan Williams <dcbw@redhat.com> - 0.6.0-2
eae678
- skip settling IPv4 addresses
eae678
eae678
* Mon Jan 08 2018 Frantisek Kluknavsky <fkluknav@redhat.com> - 0.6.0-1
eae678
- rebased to 7480240de9749f9a0a5c8614b17f1f03e0c06ab9
eae678
eae678
* Fri Oct 13 2017 Lokesh Mandvekar <lsm5@fedoraproject.org> - 0.5.2-7
eae678
- do not install to /opt (against Fedora Guidelines)
eae678
eae678
* Thu Aug 24 2017 Jan Chaloupka <jchaloup@redhat.com> - 0.5.2-6
eae678
- Enable devel subpackage
eae678
eae678
* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.5.2-5
eae678
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
eae678
eae678
* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.5.2-4
eae678
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
eae678
eae678
* Thu Jul 13 2017 Lokesh Mandvekar <lsm5@fedoraproject.org> - 0.5.2-3
eae678
- excludearch: ppc64 as it's not in goarches anymore
eae678
- re-enable s390x
eae678
eae678
* Fri Jun 30 2017 Lokesh Mandvekar <lsm5@fedoraproject.org> - 0.5.2-2
eae678
- upstream moved to github.com/containernetworking/plugins
eae678
- built commit dcf7368
eae678
- provides: containernetworking-plugins
eae678
- use vendored deps because they're a lot less of a PITA
eae678
- excludearch: s390x for now (rhbz#1466865)
eae678
eae678
* Mon Jun 12 2017 Timothy St. Clair <tstclair@heptio.com> - 0.5.2-1
eae678
- Update to 0.5.2 
eae678
- Softlink to default /opt/cni/bin directories
eae678
eae678
* Sun May 07 2017 Timothy St. Clair <tstclair@heptio.com> - 0.5.1-1
eae678
- Initial package
eae678