%define name WALinuxAgent
%define version 2.2.40
%define unmangled_version 2.2.40
%define release 1

Summary:   The Microsoft Azure Linux Agent
Name:      %{name}
Version:   %{version}
Release:   %{release}%{?dist}
Source0:   %{name}-%{unmangled_version}.tar.gz
License:   Apache License Version 2.0
Group:     Development/Libraries
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
Prefix:    %{_prefix}
BuildArch: noarch
Vendor:    Microsoft Corporation <walinuxagent@microsoft.com>
Url:       https://github.com/Azure/WALinuxAgent
Requires: util-linux
Requires: net-tools
Requires: openssh
Requires: openssh-server
Requires: openssl
Requires: parted
Requires: python-pyasn1
Requires: iptables
#Requires:       NetworkManager
BuildRequires:   systemd
Requires(pre):  systemd
Requires(post):  systemd
Requires(preun): systemd
Requires(postun): systemd


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


%prep
%setup -n %{name}-%{unmangled_version} -n %{name}-%{unmangled_version}
sed 's/centos/powerel/g' -i setup.py
sed 's/euleros/powerel/g' -i azurelinuxagent/common/osutil/factory.py
sed 's/alpine/powerel/g' -i azurelinuxagent/common/version.py
sed 's/euleros/powerel/g' -i azurelinuxagent/common/version.py
sed 's/euleros/powerel/g' -i bin/waagent2.0


%build
python setup.py build


%install
python setup.py install --single-version-externally-managed -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES


%clean
rm -rf $RPM_BUILD_ROOT


%post
%systemd_post waagent.service


%preun
%systemd_preun waagent.service


%postun
%systemd_postun_with_restart waagent.service


%files -f INSTALLED_FILES
%{python_sitelib}/*
%config(noreplace) %{_sysconfdir}/waagent.conf
%defattr(-,root,root)


%changelog
