2014-09-24 16:31:47 +04:00
|
|
|
#!/usr/bin/env python
|
2013-06-25 03:14:42 +04:00
|
|
|
#
|
|
|
|
# Windows Azure Linux Agent setup.py
|
|
|
|
#
|
|
|
|
# Copyright 2013 Microsoft Corporation
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
|
2015-06-09 12:04:18 +03:00
|
|
|
import os
|
2015-06-18 08:50:46 +03:00
|
|
|
from azurelinuxagent.metadata import GuestAgentName, GuestAgentVersion, \
|
2015-06-29 12:26:32 +03:00
|
|
|
GuestAgentDescription, \
|
2015-06-18 08:50:46 +03:00
|
|
|
DistroName, DistroVersion, DistroFullName
|
2015-06-16 10:00:24 +03:00
|
|
|
|
2015-06-28 14:49:45 +03:00
|
|
|
from azurelinuxagent.utils.osutil import OSUtil
|
2015-06-16 10:00:24 +03:00
|
|
|
import setuptools
|
2015-06-04 09:19:12 +03:00
|
|
|
from setuptools import find_packages
|
2015-06-29 12:26:32 +03:00
|
|
|
from setuptools.command.install import install as _install
|
2014-09-24 16:31:47 +04:00
|
|
|
|
2015-06-09 12:04:18 +03:00
|
|
|
root_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
os.chdir(root_dir)
|
|
|
|
|
2015-06-29 14:02:22 +03:00
|
|
|
def get_data_files(name, version, fullname):
|
2015-06-16 10:00:24 +03:00
|
|
|
"""
|
|
|
|
Determine data_files according to distro name, version and init system type
|
|
|
|
"""
|
2015-06-04 09:19:12 +03:00
|
|
|
data_files=[]
|
2015-06-16 10:00:24 +03:00
|
|
|
|
|
|
|
#Script file
|
|
|
|
script_dest = '/usr/sbin'
|
2015-06-18 08:50:46 +03:00
|
|
|
script_src = ['bin/waagent', 'bin/azurela']
|
2015-06-16 10:00:24 +03:00
|
|
|
if name == 'coreos':
|
|
|
|
script_dest = '/usr/share/oem/bin'
|
|
|
|
data_files.append((script_dest, script_src))
|
|
|
|
|
|
|
|
#Config file
|
|
|
|
conf_dest = '/etc'
|
|
|
|
conf_src = ['config/waagent.conf']
|
|
|
|
if name == 'suse':
|
|
|
|
conf_src = ['config/suse/waagent.conf']
|
2015-06-18 08:50:46 +03:00
|
|
|
if name == 'ubuntu':
|
|
|
|
conf_src = ['config/ubuntu/waagent.conf']
|
2015-06-28 14:49:45 +03:00
|
|
|
if name == 'coreos':
|
|
|
|
conf_dest = '/usr/share/oem/'
|
2015-06-16 10:00:24 +03:00
|
|
|
data_files.append((conf_dest, conf_src))
|
|
|
|
|
|
|
|
#logrotate config file
|
|
|
|
logrotate_dest = '/etc/logrotate.d'
|
|
|
|
logrotate_src = ['config/waagent.logrotate']
|
|
|
|
data_files.append((logrotate_dest, logrotate_src))
|
|
|
|
|
2015-06-29 14:02:22 +03:00
|
|
|
#init script file, default is sysV
|
2015-06-28 14:49:45 +03:00
|
|
|
init_dest = '/etc/rc.d/init.d'
|
2015-06-26 05:45:48 +03:00
|
|
|
init_src = ['init/waagent']
|
2015-06-16 10:00:24 +03:00
|
|
|
|
|
|
|
if name == 'redhat' or name == 'centos':
|
2015-06-28 14:49:45 +03:00
|
|
|
if version >= "7.0":
|
|
|
|
init_dest = '/etc/systemd/system'
|
2015-06-18 08:50:46 +03:00
|
|
|
init_src = ['init/waagent.service']
|
2015-06-16 10:00:24 +03:00
|
|
|
elif name == 'coreos':
|
|
|
|
init_dest = '/usr/share/oem'
|
|
|
|
init_src = ['init/coreos/cloud-config.yml']
|
2015-06-18 08:50:46 +03:00
|
|
|
elif name == 'ubuntu':
|
|
|
|
init_dest = '/etc/init'
|
|
|
|
init_src = ['init/ubuntu/walinuxagent.conf']
|
2015-06-29 14:02:22 +03:00
|
|
|
elif name == 'suse':
|
|
|
|
if fullname == 'SUSE Linux Enterprise Server' and version >= '12' or \
|
|
|
|
fullname == 'openSUSE' and version >= '13.2':
|
|
|
|
init_dest = '/etc/systemd/system'
|
|
|
|
init_src = ['init/waagent.service']
|
|
|
|
else:
|
|
|
|
init_dest = '/etc/init.d'
|
|
|
|
init_src = ['init/waagent']
|
2015-06-16 10:00:24 +03:00
|
|
|
|
|
|
|
data_files.append((init_dest, init_src))
|
|
|
|
|
2015-06-04 09:19:12 +03:00
|
|
|
return data_files
|
2014-11-19 09:49:22 +03:00
|
|
|
|
2015-06-29 12:26:32 +03:00
|
|
|
class install(_install):
|
|
|
|
user_options = _install.user_options + [
|
2015-06-16 10:00:24 +03:00
|
|
|
# This will magically show up in member variable 'init_system'
|
2015-06-29 14:02:22 +03:00
|
|
|
('init-system=', None, 'Deprecated, use --lnx-distro* instead'),
|
2015-06-16 10:00:24 +03:00
|
|
|
('lnx-distro=', None, 'target Linux distribution'),
|
|
|
|
('lnx-distro-version=', None, 'target Linux distribution version'),
|
2015-06-29 14:02:22 +03:00
|
|
|
('lnx-distro-fullname=', None, 'target Linux distribution full name'),
|
2015-06-28 14:49:45 +03:00
|
|
|
('register-service=', None, 'register as startup service'),
|
2015-06-16 10:00:24 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
def initialize_options(self):
|
2015-06-29 12:26:32 +03:00
|
|
|
_install.initialize_options(self)
|
2015-06-18 08:50:46 +03:00
|
|
|
self.lnx_distro = DistroName
|
|
|
|
self.lnx_distro_version = DistroVersion
|
2015-06-29 14:02:22 +03:00
|
|
|
self.lnx_distro_fullname = DistroFullName
|
2015-06-28 14:49:45 +03:00
|
|
|
self.register_service = False
|
2015-06-29 12:26:32 +03:00
|
|
|
|
2015-06-16 10:00:24 +03:00
|
|
|
def finalize_options(self):
|
2015-06-29 12:26:32 +03:00
|
|
|
_install.finalize_options(self)
|
2015-06-16 10:00:24 +03:00
|
|
|
data_files = get_data_files(self.lnx_distro, self.lnx_distro_version,
|
2015-06-29 14:02:22 +03:00
|
|
|
self.lnx_distro_fullname)
|
2015-06-16 10:00:24 +03:00
|
|
|
self.distribution.data_files = data_files
|
|
|
|
self.distribution.reinitialize_command('install_data', True)
|
|
|
|
|
2015-06-28 14:49:45 +03:00
|
|
|
def run(self):
|
2015-06-29 12:26:32 +03:00
|
|
|
_install.run(self)
|
2015-06-28 14:49:45 +03:00
|
|
|
if self.register_service:
|
|
|
|
print "Register agent service"
|
|
|
|
OSUtil.RegisterAgentService()
|
2015-06-16 10:00:24 +03:00
|
|
|
|
|
|
|
setuptools.setup(name=GuestAgentName,
|
|
|
|
version=GuestAgentVersion,
|
2015-06-29 12:26:32 +03:00
|
|
|
long_description=GuestAgentDescription,
|
2015-06-16 10:00:24 +03:00
|
|
|
author= 'Yue Zhang, Stephen Zarkos, Eric Gable',
|
|
|
|
author_email = 'walinuxagent@microsoft.com',
|
|
|
|
platforms = 'Linux',
|
|
|
|
url='https://github.com/Azure/WALinuxAgent',
|
|
|
|
license = 'Apache License Version 2.0',
|
|
|
|
packages=find_packages(exclude=["tests"]),
|
|
|
|
cmdclass = {
|
2015-06-29 14:02:22 +03:00
|
|
|
'install': install
|
2015-06-16 10:00:24 +03:00
|
|
|
})
|