File cloud-init.spec of Package cloud-init.4242

# spec file for package cloud-init
# 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

%global configver 0.7

Name:           cloud-init
Version:        0.7.8
Release:        0
Summary:        Cloud node initialization tool
License:        GPL-3.0 and AGPL-3.0
Group:          System/Management
Source0:        %{name}-%{version}.tar.gz
Source1:        cloud.cfg.suse
Source2:        rsyslog-cloud-init.cfg
Patch0:         suseSysVInit.diff
# FIXME addopenSUSEBase.patch proposed for upstream merge
Patch1:         addopenSUSEBase.patch
# FIXME suseIntegratedHandler.patch proposed for upstream merge
Patch2:         suseIntegratedHandler.patch
Patch3:         setupSUSEsysVInit.diff
# FIXME openSUSEhostsTemplate.diff proposed for upstream merge
Patch5:         openSUSEhostsTemplate.diff
# FIXME dynamicInitCmd.patch proposed for upstream merge
Patch6:         dynamicInitCmd.diff
Patch9:         cloud-init-no-dmidecode-on-ppc64.patch
Patch10:        cloud-init-no-user-lock-if-already-locked.patch
Patch11:        dataSourceOpenNebula.patch
Patch12:        fix-default-systemd-unit-dir.patch
Patch14:        cloud-init-finalbeforelogin.patch
# python2 disables SIGPIPE, causing broken pipe errors in shell scripts (bsc#903449)
Patch20:        cloud-init-python2-sigpipe.patch
Patch21:        cloud-init-net-eni.patch
Patch22:        cloud-init-service.patch
Patch23:        cloud-init-fix-unicode-handling-binarydecode.patch
# From upstream patch
Patch24:        cloud-init-handle-no-carrier.patch
Patch25:        cloud-init-digital-ocean-datasource.patch
Patch26:        cloud-init-digital-ocean-datasource-enable-by-default.patch
Patch27:        cloud-init-sysconfig-netpathfix.patch
Patch28:        zypp_add_repos.diff
Patch29:        datasourceLocalDisk.patch
Patch30:        cloud-init-handle-not-implemented-query.patch
BuildRequires:  fdupes
BuildRequires:  filesystem
BuildRequires:  python-devel
BuildRequires:  python-setuptools
# pkg-config is needed to find correct systemd unit dir
BuildRequires:  pkg-config
# needed for /lib/udev
BuildRequires:  udev
%if 0%{?suse_version} > 1320
# Test requirements
BuildRequires:  python-Cheetah
BuildRequires:  python-Jinja2
BuildRequires:  python-PrettyTable
BuildRequires:  python-PyYAML
BuildRequires:  python-argparse
BuildRequires:  python-configobj
BuildRequires:  python-contextlib2
BuildRequires:  python-httpretty
BuildRequires:  python-jsonpatch
BuildRequires:  python-mock
BuildRequires:  python-oauthlib
BuildRequires:  python-requests
BuildRequires:  python-testtools
Requires:       bash
Requires:       cloud-init-config = %configver
Requires:       e2fsprogs
Requires:       file
Requires:       growpart
Requires:       net-tools
Requires:       openssh
Requires:       python-Jinja2
Requires:       python-PrettyTable
Requires:       python-PyYAML
Requires:       python-argparse
Requires:       python-boto >= 2.7
Requires:       python-cheetah
Requires:       python-configobj
Requires:       python-jsonpatch
Requires:       python-oauthlib
Requires:       python-pyserial
Requires:       python-requests
Requires:       python-setuptools
Requires:       python-six
Requires:       python-xml
Requires:       sudo
Requires:       util-linux
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%define         docdir %{_defaultdocdir}/%{name}
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%ifarch %ix86 x86_64
Requires:       pmtools
%ifarch %ix86 x86_64
Requires:       dmidecode
%if 0%{?suse_version} && 0%{?suse_version} <= 1210
%define initsys sysvinit_suse
Patch40:        cloud-init-python26.patch
%define initsys systemd
BuildRequires:  systemd
Requires:       systemd
%if 0%{?suse_version} && 0%{?suse_version} == 1220
%define systemd_prefix /lib
%define systemd_prefix /usr/lib
%if 0%{?suse_version} && 0%{?suse_version} >= 1315
Requires:       wicked-service
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
Requires:       sysconfig
Requires:       sysconfig-network

Cloud-init is an init script that initializes a cloud node (VM)
according to the fetched configuration data from the admin node.

%package config-suse
Summary:        Configuration file for Cloud node initialization tool
Group:          System/Management
Provides:       cloud-init-config = %configver
Conflicts:      otherproviders(cloud-init-config)

%description config-suse
This package contains the product specific configuration file
for cloud-init.

%package doc
Summary:        Cloud node initialization tool - Documentation
Group:          System/Management
Recommends:     cloud-init = %{version}

%description doc
Cloud-init is an init script that initializes a cloud node (VM)
according to the fetched configuration data from the admin node.

Documentation and examples for cloud-init tools

%package test
Summary:        Cloud node initialization tool  - Testsuite
Group:          System/Management
Requires:       cloud-init = %{version}

%description test
Cloud-init is an init script that initializes a cloud node (VM)
according to the fetched configuration data from the admin node.

Unit tests for the cloud-init tools

%setup -q
%patch0 -p1
%patch1 -p1
%patch10 -p1
%patch25 -p1
%patch26 -p1
%patch28 -p0
%patch29 -p0
%if 0%{?suse_version} && 0%{?suse_version} <= 1210
%patch40 -p1

%if 0%{?suse_version} <= 1130
# disable ecdsa for SLE 11 (not available)
echo "ssh_genkeytypes: ['rsa', 'dsa']" >> %{SOURCE1}

python build

%if 0%{?suse_version} > 1320
# these tests are currently failing due to suse patches
rm -v tests/unittests/test_distros/
rm -v tests/unittests/
rm -v tests/unittests/test_datasource/
rm -v tests/unittests/test_datasource/
python -m

python install --root=%{buildroot} --prefix=%{_prefix} --install-lib=%{python_sitelib} --init-system=%{initsys}
find %{buildroot} \( -name .gitignore -o -name .placeholder \) -delete
# from debian install script
for x in "%{buildroot}%{_bindir}/"*.py; do
   [ -f "${x}" ] && mv "${x}" "${}"
mkdir -p %{buildroot}%{_localstatedir}/lib/cloud
# move documentation
mkdir -p %{buildroot}%{_defaultdocdir}
mv %{buildroot}%{_datadir}/doc/%{name} %{buildroot}%{docdir}
cp -a %{SOURCE1} %{buildroot}/%{_sysconfdir}/cloud/cloud.cfg
# copy the LICENSE
cp LICENSE %{buildroot}%{docdir}
# Set the distribution indicator
%if 0%{?suse_version}
%if 0%{?suse_version} < 1130
#SLE 11, openSUSE 11.x is EOL
sed -i s/INSERT_SUSE_DISTRO/sles/ %{buildroot}/%{_sysconfdir}/cloud/cloud.cfg
%if 0%{?suse_version} > 1140
%if 0%{?suse_version} == 1315
# SLE 12
sed -i s/INSERT_SUSE_DISTRO/sles/ %{buildroot}/%{_sysconfdir}/cloud/cloud.cfg
sed -i s/INSERT_SUSE_DISTRO/opensuse/ %{buildroot}/%{_sysconfdir}/cloud/cloud.cfg
%if 0%{?suse_version} && 0%{?suse_version} > 1110
mkdir -p %{buildroot}/%{_sysconfdir}/rsyslog.d
mkdir -p %{buildroot}/usr/lib/udev/rules.d/
cp -a %{SOURCE2} %{buildroot}/%{_sysconfdir}/rsyslog.d/21-cloudinit.conf
mv %{buildroot}/lib/udev/rules.d/66-azure-ephemeral.rules %{buildroot}/usr/lib/udev/rules.d/

# remove debian/ubuntu specific profile.d file (bnc#779553)
rm -f %{buildroot}%{_sysconfdir}/profile.d/

# Remove non-SUSE templates
rm %{buildroot}/%{_sysconfdir}/cloud/templates/*.debian.*
rm %{buildroot}/%{_sysconfdir}/cloud/templates/*.redhat.*
rm %{buildroot}/%{_sysconfdir}/cloud/templates/*.ubuntu.*

# move sysvinit scripts into the "right" place
%if 0%{?suse_version} && 0%{?suse_version} <= 1210
mkdir -p %{buildroot}/%{_initddir}
mkdir -p %{buildroot}/%{_sbindir}
pushd "%{buildroot}%{_initddir}"
for iniF in *; do
    ln -s "%{_initddir}/${iniF}" "%{buildroot}/%{_sbindir}/rc${iniF}"

# remove duplicate files
%if 0%{?suse_version}
%fdupes %{buildroot}%{python_sitelib}


# do not mark as doc or we get conflicts with the doc package
%dir %{_sysconfdir}/cloud
%config(noreplace) %{_sysconfdir}/cloud/cloud.cfg.d
%config(noreplace) %{_sysconfdir}/cloud/templates
%if 0%{?suse_version} && 0%{?suse_version} <= 1210
%attr(0755, root, root) %{_initddir}/cloud-config
%attr(0755, root, root) %{_initddir}/cloud-init
%attr(0755, root, root) %{_initddir}/cloud-init-local
%attr(0755, root, root) %{_initddir}/cloud-final
%if 0%{?suse_version} && 0%{?suse_version} > 1110
%dir %{_sysconfdir}/rsyslog.d
# This if condition really distinquished between OBS and IBS.
# For SLE 12 builds in OBS owning the directories is not required, while
# SLE 12 builds in IBS require owning the directories
%dir %attr(0755, root, root) %{_localstatedir}/lib/cloud
%dir %{docdir}
%dir /etc/NetworkManager
%dir /etc/NetworkManager/dispatcher.d
%dir /etc/dhcp
%dir /etc/dhcp/dhclient-exit-hooks.d

%files config-suse
%config(noreplace) %{_sysconfdir}/cloud/cloud.cfg

%files doc
%dir %{docdir}/examples

%files test

openSUSE Build Service is sponsored by