File WALinuxAgent.spec of Package WALinuxAgent

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

Name:           WALinuxAgent
Summary:        The Microsoft Azure Linux Agent
License:        Apache-2.0
Group:          System/Daemons
Version:        2.0.17
Release:        0
Source1:        99-azure-timeout.rules
Source2:        README.SUSE
BuildRequires:  python-devel
BuildRequires:  python-setuptools

BuildRequires:  dos2unix

%if 0%{?suse_version}
Requires:       python-xml

%if 0%{?suse_version} > 1140
BuildRequires:  systemd
%if 0%{?suse_version} < 1140
Requires:       insserv
Requires:       sysvinit

BuildRequires:  udev

Requires:       grep
Requires:       iptables
Requires:       logrotate
Requires:       openssh
Requires:       openssl
Requires:       pwdutils
Requires:       python-pyasn1
Requires:       sudo
Requires:       util-linux

Conflicts:      NetworkManager

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%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()")}
BuildArch:      noarch

The Microsoft Azure Linux Agent supports the provisioning and running of Linux
VMs in the Microsoft Azure cloud. This package should be installed on Linux disk
images that are built to run in the Microsoft Azure environment.

%setup -qn %{name}-%{name}-%{version}

find . -type f -exec sed -i 's/\r//' {} +
find . -type f -exec chmod 0644 {} +

iconv -f cp1250 -t utf-8 README.old > README
dos2unix README
rm README.old

cp %{SOURCE2} .

python build

%if 0%{?suse_version} > 1140
python install --prefix=%{_prefix} --lnx-distro='suse' --init-system='systemd' --root=%{buildroot}
%if 0%{?suse_version} < 1230
    mkdir -p %{buildroot}/%{_unitdir}
    mv %{buildroot}/usr/lib/systemd/system/* %{buildroot}/%{_unitdir}
    rm -rf %{buildroot}/usr/lib/systemd
python install --prefix=%{_prefix} --lnx-distro='suse' --init-system='sysV' --root=%{buildroot}
### rc symlink
ln -s ../..%{_initddir}/waagent %{buildroot}%{_sbindir}/rcwaagent
### udev rules
%if 0%{?suse_version} < 1230
mkdir -p %{buildroot}/lib/udev/rules.d
install -D -m 0644 %{SOURCE1} %{buildroot}/lib/udev/rules.d/99-azure-timeout.rules
mv %{buildroot}/%{_sysconfdir}/udev/rules.d/99-azure-product-uuid.rules %{buildroot}/lib/udev/rules.d/
mkdir -p %{buildroot}/usr/lib/udev/rules.d
install -D -m 0644 %{SOURCE1} %{buildroot}/usr/lib/udev/rules.d/99-azure-timeout.rules
mv %{buildroot}/%{_sysconfdir}/udev/rules.d/99-azure-product-uuid.rules %{buildroot}/usr/lib/udev/rules.d/
### log file ghost
mkdir -p  %{buildroot}/%{_localstatedir}/log
touch %{buildroot}/%{_localstatedir}/log/waagent.log

%if 0%{?suse_version} > 1140
    %service_add_pre waagent.service

%if 0%{?suse_version} > 1140
    %service_add_post waagent.service

%if 0%{?suse_version} > 1140
    %service_del_preun waagent.service
    %stop_on_removal waagent

%restart_on_update waagent
%if 0%{?suse_version} > 1140
    %service_del_postun waagent.service

%attr(0755,root,root) %{_sbindir}/waagent
%config(noreplace) %{_sysconfdir}/logrotate.d/waagent
%config(noreplace) %{_sysconfdir}/waagent.conf
%ghost %{_localstatedir}/log/waagent.log
%if 0%{?suse_version} > 1140
%attr(0755,root,root) %{_initddir}/waagent
%if 0%{?suse_version} < 1230
%config /lib/udev/rules.d/99-azure-timeout.rules
%config /lib/udev/rules.d/99-azure-product-uuid.rules
%config /usr/lib/udev/rules.d/99-azure-timeout.rules
%config /usr/lib/udev/rules.d/99-azure-product-uuid.rules

openSUSE Build Service is sponsored by