2012-07-01 01:54:25 +00:00
|
|
|
#!/usr/bin/env python
|
2014-01-13 07:35:18 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2011-02-27 22:17:45 +00:00
|
|
|
'''
|
|
|
|
The setup script for salt
|
|
|
|
'''
|
2011-11-14 15:49:06 +00:00
|
|
|
|
2014-11-07 16:50:11 +00:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2014-10-05 19:05:26 +00:00
|
|
|
# pylint: disable=C0111,E1101,E1103,F0401,W0611,W0201,W0232,R0201,R0902,R0903
|
2013-11-14 18:49:26 +00:00
|
|
|
|
2012-05-07 03:25:14 +00:00
|
|
|
# For Python 2.5. A no-op on 2.6 and above.
|
2014-10-05 19:05:26 +00:00
|
|
|
from __future__ import print_function, with_statement
|
2012-05-07 03:25:14 +00:00
|
|
|
|
2011-12-10 20:12:16 +00:00
|
|
|
import os
|
|
|
|
import sys
|
2013-11-12 05:10:41 +00:00
|
|
|
import glob
|
2015-01-09 16:41:50 +00:00
|
|
|
import time
|
2014-11-07 16:50:11 +00:00
|
|
|
try:
|
|
|
|
from urllib2 import urlopen
|
|
|
|
except ImportError:
|
|
|
|
from urllib.request import urlopen
|
2013-02-06 04:23:56 +00:00
|
|
|
from datetime import datetime
|
2013-11-14 18:49:26 +00:00
|
|
|
# pylint: disable=E0611
|
2014-10-05 19:05:26 +00:00
|
|
|
import distutils.dist
|
2013-11-14 18:18:51 +00:00
|
|
|
from distutils import log
|
2011-07-22 17:47:34 +00:00
|
|
|
from distutils.cmd import Command
|
2014-06-17 23:34:04 +00:00
|
|
|
from distutils.errors import DistutilsArgError
|
2013-02-06 04:23:56 +00:00
|
|
|
from distutils.command.build import build
|
2012-10-12 14:51:28 +00:00
|
|
|
from distutils.command.clean import clean
|
2013-11-14 18:06:12 +00:00
|
|
|
from distutils.command.sdist import sdist
|
2014-03-17 16:56:31 +00:00
|
|
|
from distutils.command.install_lib import install_lib
|
2013-11-14 18:49:26 +00:00
|
|
|
# pylint: enable=E0611
|
2011-12-22 22:56:33 +00:00
|
|
|
|
2014-02-25 22:52:02 +00:00
|
|
|
try:
|
|
|
|
import zmq
|
|
|
|
HAS_ZMQ = True
|
|
|
|
except ImportError:
|
|
|
|
HAS_ZMQ = False
|
|
|
|
|
2012-12-30 17:55:23 +00:00
|
|
|
# Change to salt source's directory prior to running any command
|
2013-05-22 01:00:44 +00:00
|
|
|
try:
|
2013-08-23 22:17:13 +00:00
|
|
|
SETUP_DIRNAME = os.path.dirname(__file__)
|
2013-05-22 01:00:44 +00:00
|
|
|
except NameError:
|
|
|
|
# We're most likely being frozen and __file__ triggered this NameError
|
|
|
|
# Let's work around that
|
2013-08-23 22:17:13 +00:00
|
|
|
SETUP_DIRNAME = os.path.dirname(sys.argv[0])
|
2013-05-22 01:00:44 +00:00
|
|
|
|
2013-08-23 22:17:13 +00:00
|
|
|
if SETUP_DIRNAME != '':
|
|
|
|
os.chdir(SETUP_DIRNAME)
|
2012-12-30 17:55:23 +00:00
|
|
|
|
2013-11-14 23:01:30 +00:00
|
|
|
SETUP_DIRNAME = os.path.abspath(SETUP_DIRNAME)
|
|
|
|
|
2013-11-14 18:18:51 +00:00
|
|
|
BOOTSTRAP_SCRIPT_DISTRIBUTED_VERSION = os.environ.get(
|
|
|
|
# The user can provide a different bootstrap-script version.
|
|
|
|
# ATTENTION: A tag for that version MUST exist
|
|
|
|
'BOOTSTRAP_SCRIPT_VERSION',
|
|
|
|
# If no bootstrap-script version was provided from the environment, let's
|
|
|
|
# provide the one we define.
|
2014-06-21 13:46:08 +00:00
|
|
|
'v2014.06.21'
|
2013-11-14 18:18:51 +00:00
|
|
|
)
|
|
|
|
|
2013-08-23 22:58:26 +00:00
|
|
|
# Store a reference to the executing platform
|
|
|
|
IS_WINDOWS_PLATFORM = sys.platform.startswith('win')
|
|
|
|
|
2012-07-01 02:00:22 +00:00
|
|
|
# Use setuptools only if the user opts-in by setting the USE_SETUPTOOLS env var
|
2013-05-21 23:36:31 +00:00
|
|
|
# Or if setuptools was previously imported (which is the case when using
|
|
|
|
# 'distribute')
|
2012-07-01 02:00:22 +00:00
|
|
|
# This ensures consistent behavior but allows for advanced usage with
|
|
|
|
# virtualenv, buildout, and others.
|
2013-08-23 22:17:13 +00:00
|
|
|
WITH_SETUPTOOLS = False
|
2013-03-20 21:05:20 +00:00
|
|
|
if 'USE_SETUPTOOLS' in os.environ or 'setuptools' in sys.modules:
|
2012-06-30 20:01:57 +00:00
|
|
|
try:
|
|
|
|
from setuptools import setup
|
2013-02-13 10:53:33 +00:00
|
|
|
from setuptools.command.install import install
|
2013-11-14 18:06:12 +00:00
|
|
|
from setuptools.command.sdist import sdist
|
2014-10-01 20:39:37 +00:00
|
|
|
from setuptools.command.egg_info import egg_info
|
2013-08-23 22:17:13 +00:00
|
|
|
WITH_SETUPTOOLS = True
|
|
|
|
except ImportError:
|
|
|
|
WITH_SETUPTOOLS = False
|
2012-06-30 20:01:57 +00:00
|
|
|
|
2013-08-23 22:17:13 +00:00
|
|
|
if WITH_SETUPTOOLS is False:
|
2013-01-14 13:41:42 +00:00
|
|
|
import warnings
|
2013-11-14 18:49:26 +00:00
|
|
|
# pylint: disable=E0611
|
2013-02-13 10:53:33 +00:00
|
|
|
from distutils.command.install import install
|
2012-06-05 10:00:20 +00:00
|
|
|
from distutils.core import setup
|
2013-11-14 18:49:26 +00:00
|
|
|
# pylint: enable=E0611
|
2013-01-14 13:41:42 +00:00
|
|
|
warnings.filterwarnings(
|
|
|
|
'ignore',
|
2014-06-20 11:10:34 +00:00
|
|
|
'Unknown distribution option: \'(extras_require|tests_require|install_requires|zip_safe)\'',
|
2013-01-14 13:41:42 +00:00
|
|
|
UserWarning,
|
|
|
|
'distutils.dist'
|
|
|
|
)
|
2012-06-05 10:00:20 +00:00
|
|
|
|
2013-01-01 22:49:26 +00:00
|
|
|
try:
|
|
|
|
# Add the esky bdist target if the module is available
|
|
|
|
# may require additional modules depending on platform
|
|
|
|
from esky import bdist_esky
|
|
|
|
# bbfreeze chosen for its tight integration with distutils
|
|
|
|
import bbfreeze
|
|
|
|
HAS_ESKY = True
|
|
|
|
except ImportError:
|
|
|
|
HAS_ESKY = False
|
|
|
|
|
2014-06-17 14:19:03 +00:00
|
|
|
SALT_VERSION = os.path.join(os.path.abspath(SETUP_DIRNAME), 'salt', 'version.py')
|
2014-08-01 18:10:49 +00:00
|
|
|
SALT_VERSION_HARDCODED = os.path.join(os.path.abspath(SETUP_DIRNAME), 'salt', '_version.py')
|
2015-01-12 19:58:09 +00:00
|
|
|
SALT_REQS = os.path.join(os.path.abspath(SETUP_DIRNAME), 'requirements', 'base.txt')
|
|
|
|
SALT_ZEROMQ_REQS = os.path.join(os.path.abspath(SETUP_DIRNAME), 'requirements', 'zeromq.txt')
|
|
|
|
SALT_RAET_REQS = os.path.join(os.path.abspath(SETUP_DIRNAME), 'requirements', 'raet.txt')
|
2013-08-23 22:58:26 +00:00
|
|
|
|
2014-10-01 19:47:03 +00:00
|
|
|
# Salt SSH Packaging Detection
|
|
|
|
PACKAGED_FOR_SALT_SSH_FILE = os.path.join(os.path.abspath(SETUP_DIRNAME), '.salt-ssh-package')
|
|
|
|
PACKAGED_FOR_SALT_SSH = os.path.isfile(PACKAGED_FOR_SALT_SSH_FILE)
|
|
|
|
|
2014-10-05 19:05:26 +00:00
|
|
|
|
2013-11-14 18:49:26 +00:00
|
|
|
# pylint: disable=W0122
|
2013-08-23 22:17:13 +00:00
|
|
|
exec(compile(open(SALT_VERSION).read(), SALT_VERSION, 'exec'))
|
2013-11-14 18:49:26 +00:00
|
|
|
# pylint: enable=W0122
|
2011-09-25 06:30:36 +00:00
|
|
|
|
2012-06-30 20:35:31 +00:00
|
|
|
|
2014-06-17 14:19:03 +00:00
|
|
|
# ----- Helper Functions -------------------------------------------------------------------------------------------->
|
|
|
|
def _parse_requirements_file(requirements_file):
|
|
|
|
parsed_requirements = []
|
|
|
|
with open(requirements_file) as rfh:
|
|
|
|
for line in rfh.readlines():
|
|
|
|
line = line.strip()
|
|
|
|
if not line or line.startswith(('#', '-r')):
|
|
|
|
continue
|
|
|
|
if IS_WINDOWS_PLATFORM and 'libcloud' in line:
|
|
|
|
continue
|
|
|
|
parsed_requirements.append(line)
|
|
|
|
return parsed_requirements
|
|
|
|
# <---- Helper Functions ---------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
# ----- Custom Distutils/Setuptools Commands ------------------------------------------------------------------------>
|
2014-08-01 18:10:49 +00:00
|
|
|
class WriteSaltVersion(Command):
|
|
|
|
|
|
|
|
description = 'Write salt\'s hardcoded version file'
|
2015-03-09 06:03:38 +00:00
|
|
|
user_options = []
|
2014-08-01 18:10:49 +00:00
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
if not os.path.exists(SALT_VERSION_HARDCODED):
|
|
|
|
# Write the version file
|
|
|
|
if getattr(self.distribution, 'salt_version_hardcoded_path', None) is None:
|
2014-10-05 19:05:26 +00:00
|
|
|
print('This command is not meant to be called on it\'s own')
|
2014-08-01 18:10:49 +00:00
|
|
|
exit(1)
|
|
|
|
|
|
|
|
# pylint: disable=E0602
|
|
|
|
open(self.distribution.salt_version_hardcoded_path, 'w').write(
|
|
|
|
INSTALL_VERSION_TEMPLATE.format(
|
|
|
|
date=datetime.utcnow(),
|
|
|
|
full_version_info=__saltstack_version__.full_info
|
|
|
|
)
|
|
|
|
)
|
|
|
|
# pylint: enable=E0602
|
|
|
|
|
|
|
|
|
2014-10-01 19:47:03 +00:00
|
|
|
class WriteSaltSshPackaingFile(Command):
|
|
|
|
|
|
|
|
description = 'Write salt\'s ssh packaging file'
|
2015-03-09 06:03:38 +00:00
|
|
|
user_options = []
|
2014-10-01 19:47:03 +00:00
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
if not os.path.exists(PACKAGED_FOR_SALT_SSH_FILE):
|
|
|
|
# Write the salt-ssh packaging file
|
|
|
|
if getattr(self.distribution, 'salt_ssh_packaging_file', None) is None:
|
2014-10-05 19:05:26 +00:00
|
|
|
print('This command is not meant to be called on it\'s own')
|
2014-10-01 19:47:03 +00:00
|
|
|
exit(1)
|
|
|
|
|
|
|
|
# pylint: disable=E0602
|
|
|
|
open(self.distribution.salt_ssh_packaging_file, 'w').write('Packaged for Salt-SSH\n')
|
|
|
|
# pylint: enable=E0602
|
|
|
|
|
|
|
|
|
2014-08-01 18:10:49 +00:00
|
|
|
class Sdist(sdist):
|
2014-10-01 19:47:03 +00:00
|
|
|
|
2014-08-01 18:10:49 +00:00
|
|
|
def make_release_tree(self, base_dir, files):
|
2014-10-05 19:05:26 +00:00
|
|
|
if self.distribution.ssh_packaging:
|
2014-10-01 19:47:03 +00:00
|
|
|
self.distribution.salt_ssh_packaging_file = PACKAGED_FOR_SALT_SSH_FILE
|
2015-03-09 06:03:38 +00:00
|
|
|
self.run_command('write_salt_ssh_packaging_file')
|
2014-10-01 20:39:37 +00:00
|
|
|
self.filelist.files.append(os.path.basename(PACKAGED_FOR_SALT_SSH_FILE))
|
|
|
|
|
2014-08-01 18:10:49 +00:00
|
|
|
sdist.make_release_tree(self, base_dir, files)
|
|
|
|
|
|
|
|
# Let's generate salt/_version.py to include in the sdist tarball
|
|
|
|
self.distribution.running_salt_sdist = True
|
|
|
|
self.distribution.salt_version_hardcoded_path = os.path.join(
|
|
|
|
base_dir, 'salt', '_version.py'
|
|
|
|
)
|
2015-03-09 06:03:38 +00:00
|
|
|
self.run_command('write_salt_version')
|
2014-08-01 18:10:49 +00:00
|
|
|
|
2014-10-01 19:47:03 +00:00
|
|
|
def make_distribution(self):
|
|
|
|
sdist.make_distribution(self)
|
2014-10-05 19:05:26 +00:00
|
|
|
if self.distribution.ssh_packaging:
|
2014-10-01 19:47:03 +00:00
|
|
|
os.unlink(PACKAGED_FOR_SALT_SSH_FILE)
|
|
|
|
|
2014-08-01 18:10:49 +00:00
|
|
|
|
|
|
|
class CloudSdist(Sdist):
|
2014-10-01 19:47:03 +00:00
|
|
|
user_options = Sdist.user_options + [
|
2014-01-03 01:24:17 +00:00
|
|
|
('download-bootstrap-script', None,
|
|
|
|
'Download the latest stable bootstrap-salt.sh script. This '
|
|
|
|
'can also be triggered by having `DOWNLOAD_BOOTSTRAP_SCRIPT=1` as an '
|
|
|
|
'environment variable.')
|
|
|
|
|
2013-11-14 18:06:12 +00:00
|
|
|
]
|
2014-10-01 19:47:03 +00:00
|
|
|
boolean_options = Sdist.boolean_options + [
|
2014-01-03 01:24:17 +00:00
|
|
|
'download-bootstrap-script'
|
2013-11-14 18:06:12 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
def initialize_options(self):
|
2014-08-01 18:10:49 +00:00
|
|
|
Sdist.initialize_options(self)
|
|
|
|
self.skip_bootstrap_download = True
|
2014-01-03 01:24:17 +00:00
|
|
|
self.download_bootstrap_script = False
|
2013-11-14 18:06:12 +00:00
|
|
|
|
|
|
|
def finalize_options(self):
|
2014-08-01 18:10:49 +00:00
|
|
|
Sdist.finalize_options(self)
|
|
|
|
if 'SKIP_BOOTSTRAP_DOWNLOAD' in os.environ:
|
|
|
|
log('Please stop using \'SKIP_BOOTSTRAP_DOWNLOAD\' and use '
|
|
|
|
'\'DOWNLOAD_BOOTSTRAP_SCRIPT\' instead')
|
|
|
|
|
2014-01-03 01:24:17 +00:00
|
|
|
if 'DOWNLOAD_BOOTSTRAP_SCRIPT' in os.environ:
|
|
|
|
download_bootstrap_script = os.environ.get(
|
|
|
|
'DOWNLOAD_BOOTSTRAP_SCRIPT', '0'
|
2013-11-14 18:06:12 +00:00
|
|
|
)
|
2014-01-03 01:24:17 +00:00
|
|
|
self.download_bootstrap_script = download_bootstrap_script == '1'
|
2013-11-14 18:06:12 +00:00
|
|
|
|
|
|
|
def run(self):
|
2014-01-03 01:24:17 +00:00
|
|
|
if self.download_bootstrap_script is True:
|
2013-11-14 18:06:12 +00:00
|
|
|
# Let's update the bootstrap-script to the version defined to be
|
|
|
|
# distributed. See BOOTSTRAP_SCRIPT_DISTRIBUTED_VERSION above.
|
|
|
|
url = (
|
|
|
|
'https://github.com/saltstack/salt-bootstrap/raw/{0}'
|
|
|
|
'/bootstrap-salt.sh'.format(
|
|
|
|
BOOTSTRAP_SCRIPT_DISTRIBUTED_VERSION
|
|
|
|
)
|
|
|
|
)
|
|
|
|
deploy_path = os.path.join(
|
2013-11-14 18:18:51 +00:00
|
|
|
SETUP_DIRNAME,
|
|
|
|
'salt',
|
|
|
|
'cloud',
|
2013-11-14 18:06:12 +00:00
|
|
|
'deploy',
|
|
|
|
'bootstrap-salt.sh'
|
|
|
|
)
|
2014-06-17 14:19:03 +00:00
|
|
|
log.info(
|
|
|
|
'Updating bootstrap-salt.sh.'
|
|
|
|
'\n\tSource: {0}'
|
|
|
|
'\n\tDestination: {1}'.format(
|
|
|
|
url,
|
|
|
|
deploy_path
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
|
|
|
import requests
|
|
|
|
req = requests.get(url)
|
|
|
|
if req.status_code == 200:
|
|
|
|
script_contents = req.text.encode(req.encoding)
|
|
|
|
else:
|
|
|
|
log.error(
|
|
|
|
'Failed to update the bootstrap-salt.sh script. HTTP '
|
|
|
|
'Error code: {0}'.format(
|
|
|
|
req.status_code
|
2013-11-14 18:06:12 +00:00
|
|
|
)
|
|
|
|
)
|
2014-06-17 14:19:03 +00:00
|
|
|
except ImportError:
|
2014-11-07 16:50:11 +00:00
|
|
|
req = urlopen(url)
|
2014-06-17 14:19:03 +00:00
|
|
|
|
|
|
|
if req.getcode() == 200:
|
|
|
|
script_contents = req.read()
|
|
|
|
else:
|
2013-11-14 18:06:12 +00:00
|
|
|
log.error(
|
2014-06-17 14:19:03 +00:00
|
|
|
'Failed to update the bootstrap-salt.sh script. HTTP '
|
|
|
|
'Error code: {0}'.format(
|
|
|
|
req.getcode()
|
|
|
|
)
|
2013-11-14 18:06:12 +00:00
|
|
|
)
|
2014-06-17 14:19:03 +00:00
|
|
|
try:
|
|
|
|
with open(deploy_path, 'w') as fp_:
|
|
|
|
fp_.write(script_contents)
|
|
|
|
except (OSError, IOError) as err:
|
2013-11-14 18:06:12 +00:00
|
|
|
log.error(
|
2014-06-17 14:19:03 +00:00
|
|
|
'Failed to write the updated script: {0}'.format(err)
|
2013-11-14 18:06:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Let's the rest of the build command
|
2014-08-01 18:10:49 +00:00
|
|
|
Sdist.run(self)
|
2013-11-14 18:06:12 +00:00
|
|
|
|
2013-11-14 08:22:17 +00:00
|
|
|
def write_manifest(self):
|
2014-10-05 19:05:26 +00:00
|
|
|
# We only need to ship the scripts which are supposed to be installed
|
|
|
|
dist_scripts = self.distribution.scripts
|
|
|
|
for script in self.filelist.files[:]:
|
|
|
|
if not script.startswith('scripts/'):
|
|
|
|
continue
|
|
|
|
if script not in dist_scripts:
|
|
|
|
self.filelist.files.remove(script)
|
2014-08-01 18:10:49 +00:00
|
|
|
return Sdist.write_manifest(self)
|
2013-11-14 08:22:17 +00:00
|
|
|
|
2013-11-14 18:06:12 +00:00
|
|
|
|
2011-12-22 01:36:26 +00:00
|
|
|
class TestCommand(Command):
|
|
|
|
description = 'Run tests'
|
2012-09-29 18:41:21 +00:00
|
|
|
user_options = [
|
|
|
|
('runtests-opts=', 'R', 'Command line options to pass to runtests.py')
|
|
|
|
]
|
2012-06-30 20:35:31 +00:00
|
|
|
|
|
|
|
def initialize_options(self):
|
2012-09-29 18:41:21 +00:00
|
|
|
self.runtests_opts = None
|
2012-06-30 20:35:31 +00:00
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
2011-12-22 01:36:26 +00:00
|
|
|
def run(self):
|
|
|
|
from subprocess import Popen
|
|
|
|
self.run_command('build')
|
|
|
|
build_cmd = self.get_finalized_command('build_ext')
|
|
|
|
runner = os.path.abspath('tests/runtests.py')
|
2013-01-18 01:05:45 +00:00
|
|
|
test_cmd = sys.executable + ' {0}'.format(runner)
|
2012-09-29 18:41:21 +00:00
|
|
|
if self.runtests_opts:
|
|
|
|
test_cmd += ' {0}'.format(self.runtests_opts)
|
|
|
|
|
2013-05-21 23:36:31 +00:00
|
|
|
print('running test')
|
2011-12-22 01:36:26 +00:00
|
|
|
test_process = Popen(
|
|
|
|
test_cmd, shell=True,
|
|
|
|
stdout=sys.stdout, stderr=sys.stderr,
|
|
|
|
cwd=build_cmd.build_lib
|
|
|
|
)
|
|
|
|
test_process.communicate()
|
2012-05-05 11:53:39 +00:00
|
|
|
sys.exit(test_process.returncode)
|
2011-12-22 01:36:26 +00:00
|
|
|
|
2012-10-12 14:51:28 +00:00
|
|
|
|
|
|
|
class Clean(clean):
|
|
|
|
def run(self):
|
|
|
|
clean.run(self)
|
|
|
|
# Let's clean compiled *.py[c,o]
|
2013-09-26 16:44:14 +00:00
|
|
|
for subdir in ('salt', 'tests', 'doc'):
|
2012-10-12 14:51:28 +00:00
|
|
|
root = os.path.join(os.path.dirname(__file__), subdir)
|
2014-10-05 19:05:26 +00:00
|
|
|
for dirname, _, _ in os.walk(root):
|
2014-08-01 18:10:49 +00:00
|
|
|
for to_remove_filename in glob.glob('{0}/*.py[oc]'.format(dirname)):
|
2013-11-12 05:10:41 +00:00
|
|
|
os.remove(to_remove_filename)
|
2012-10-12 14:51:28 +00:00
|
|
|
|
|
|
|
|
2013-08-23 22:17:13 +00:00
|
|
|
INSTALL_VERSION_TEMPLATE = '''\
|
2013-02-06 04:23:56 +00:00
|
|
|
# This file was auto-generated by salt's setup on \
|
2013-03-14 03:36:50 +00:00
|
|
|
{date:%A, %d %B %Y @ %H:%m:%S UTC}.
|
2013-02-06 04:23:56 +00:00
|
|
|
|
2014-05-06 04:43:22 +00:00
|
|
|
from salt.version import SaltStackVersion
|
|
|
|
|
|
|
|
__saltstack_version__ = SaltStackVersion{full_version_info!r}
|
2013-05-21 23:36:31 +00:00
|
|
|
'''
|
2013-02-06 04:23:56 +00:00
|
|
|
|
|
|
|
|
2013-09-19 10:42:09 +00:00
|
|
|
INSTALL_SYSPATHS_TEMPLATE = '''\
|
2013-08-23 22:58:26 +00:00
|
|
|
# This file was auto-generated by salt's setup on \
|
|
|
|
{date:%A, %d %B %Y @ %H:%m:%S UTC}.
|
|
|
|
|
|
|
|
ROOT_DIR = {root_dir!r}
|
|
|
|
CONFIG_DIR = {config_dir!r}
|
|
|
|
CACHE_DIR = {cache_dir!r}
|
|
|
|
SOCK_DIR = {sock_dir!r}
|
No more hard-coded salt paths.
All system paths that salt expects and needs are all configurable at install time. This allows for packagers to setup salt's **default** internal paths at build time. For example, under windows, the configuration directory is expected at `c:\salt\conf\`, on FreeBSD at `/usr/local/etc/salt`, etc.
The configurable paths are:
* Salt root directory, `salt_root` in the master and minion configuration files, `--salt-root-dir` option to `python setup.py install`. Default: `/`
* Salt configuration directory, `--salt-config-dir` option to `python setup.py install`. Default: `/etc/salt`
* Salt cache directory, `--salt-cache-dir` option to `python setup.py install`. Default: `/var/cache/salt`
* Salt sock directory, `--salt-sock-dir` option to `python setup.py install`. Default: `/var/run/salt`
* Salt services root directory, `--salt-srv-root-dir` option to `python setup.py install`. Default: `/srv`
* Salt base file roots directory, `--salt-base-file-roots-dir` option to `python setup.py install`. Default: `/srv/salt`
* Salt base pillar roots directory, `--salt-base-pillar-roots-dir` option to `python setup.py install`. Default: `/srv/pillar`
* Salt base master roots directory, `--salt-base-master-roots-dir` option to `python setup.py install`. Default: `/srv/salt-master`
* Salt logs directory, `--salt-logs-dir` option to `python setup.py install`. Default: `/var/log/salt`
* Salt pidfile directory, `--salt-pidfile-dir` option to `python setup.py install`. Default: `/var/run`
2013-08-25 22:55:57 +00:00
|
|
|
SRV_ROOT_DIR= {srv_root_dir!r}
|
2013-08-23 22:58:26 +00:00
|
|
|
BASE_FILE_ROOTS_DIR = {base_file_roots_dir!r}
|
|
|
|
BASE_PILLAR_ROOTS_DIR = {base_pillar_roots_dir!r}
|
|
|
|
BASE_MASTER_ROOTS_DIR = {base_master_roots_dir!r}
|
|
|
|
LOGS_DIR = {logs_dir!r}
|
|
|
|
PIDFILE_DIR = {pidfile_dir!r}
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
2013-02-06 04:23:56 +00:00
|
|
|
class Build(build):
|
|
|
|
def run(self):
|
|
|
|
# Run build.run function
|
|
|
|
build.run(self)
|
|
|
|
if getattr(self.distribution, 'running_salt_install', False):
|
2013-08-23 22:58:26 +00:00
|
|
|
# If our install attribute is present and set to True, we'll go
|
|
|
|
# ahead and write our install time python modules.
|
|
|
|
|
2014-08-01 18:10:49 +00:00
|
|
|
# Write the hardcoded salt version module salt/_version.py
|
2015-03-09 06:03:38 +00:00
|
|
|
self.run_command('write_salt_version')
|
2013-02-06 04:23:56 +00:00
|
|
|
|
2013-08-23 22:58:26 +00:00
|
|
|
# Write the system paths file
|
|
|
|
system_paths_file_path = os.path.join(
|
|
|
|
self.build_lib, 'salt', '_syspaths.py'
|
|
|
|
)
|
|
|
|
open(system_paths_file_path, 'w').write(
|
2013-09-19 10:42:09 +00:00
|
|
|
INSTALL_SYSPATHS_TEMPLATE.format(
|
2013-08-23 22:58:26 +00:00
|
|
|
date=datetime.utcnow(),
|
2013-08-27 08:46:26 +00:00
|
|
|
root_dir=self.distribution.salt_root_dir,
|
|
|
|
config_dir=self.distribution.salt_config_dir,
|
|
|
|
cache_dir=self.distribution.salt_cache_dir,
|
|
|
|
sock_dir=self.distribution.salt_sock_dir,
|
|
|
|
srv_root_dir=self.distribution.salt_srv_root_dir,
|
|
|
|
base_file_roots_dir=self.distribution.salt_base_file_roots_dir,
|
|
|
|
base_pillar_roots_dir=self.distribution.salt_base_pillar_roots_dir,
|
|
|
|
base_master_roots_dir=self.distribution.salt_base_master_roots_dir,
|
|
|
|
logs_dir=self.distribution.salt_logs_dir,
|
|
|
|
pidfile_dir=self.distribution.salt_pidfile_dir,
|
2013-08-23 22:58:26 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2013-02-06 04:23:56 +00:00
|
|
|
|
|
|
|
class Install(install):
|
2013-08-23 22:58:26 +00:00
|
|
|
user_options = install.user_options + [
|
2015-06-30 21:59:00 +00:00
|
|
|
('salt-transport=', None, 'The transport to prepare salt for. Choices are \'zeromq\' '
|
|
|
|
'\'raet\' or \'both\'. Defaults to \'zeromq\'', 'zeromq'),
|
2013-08-23 22:58:26 +00:00
|
|
|
('salt-root-dir=', None,
|
|
|
|
'Salt\'s pre-configured root directory'),
|
|
|
|
('salt-config-dir=', None,
|
|
|
|
'Salt\'s pre-configured configuration directory'),
|
|
|
|
('salt-cache-dir=', None,
|
|
|
|
'Salt\'s pre-configured cache directory'),
|
|
|
|
('salt-sock-dir=', None,
|
|
|
|
'Salt\'s pre-configured socket directory'),
|
No more hard-coded salt paths.
All system paths that salt expects and needs are all configurable at install time. This allows for packagers to setup salt's **default** internal paths at build time. For example, under windows, the configuration directory is expected at `c:\salt\conf\`, on FreeBSD at `/usr/local/etc/salt`, etc.
The configurable paths are:
* Salt root directory, `salt_root` in the master and minion configuration files, `--salt-root-dir` option to `python setup.py install`. Default: `/`
* Salt configuration directory, `--salt-config-dir` option to `python setup.py install`. Default: `/etc/salt`
* Salt cache directory, `--salt-cache-dir` option to `python setup.py install`. Default: `/var/cache/salt`
* Salt sock directory, `--salt-sock-dir` option to `python setup.py install`. Default: `/var/run/salt`
* Salt services root directory, `--salt-srv-root-dir` option to `python setup.py install`. Default: `/srv`
* Salt base file roots directory, `--salt-base-file-roots-dir` option to `python setup.py install`. Default: `/srv/salt`
* Salt base pillar roots directory, `--salt-base-pillar-roots-dir` option to `python setup.py install`. Default: `/srv/pillar`
* Salt base master roots directory, `--salt-base-master-roots-dir` option to `python setup.py install`. Default: `/srv/salt-master`
* Salt logs directory, `--salt-logs-dir` option to `python setup.py install`. Default: `/var/log/salt`
* Salt pidfile directory, `--salt-pidfile-dir` option to `python setup.py install`. Default: `/var/run`
2013-08-25 22:55:57 +00:00
|
|
|
('salt-srv-root-dir=', None,
|
|
|
|
'Salt\'s pre-configured service directory'),
|
2013-08-23 22:58:26 +00:00
|
|
|
('salt-base-file-roots-dir=', None,
|
|
|
|
'Salt\'s pre-configured file roots directory'),
|
|
|
|
('salt-base-pillar-roots-dir=', None,
|
|
|
|
'Salt\'s pre-configured pillar roots directory'),
|
|
|
|
('salt-base-master-roots-dir=', None,
|
|
|
|
'Salt\'s pre-configured master roots directory'),
|
|
|
|
('salt-logs-dir=', None,
|
|
|
|
'Salt\'s pre-configured logs directory'),
|
|
|
|
('salt-pidfile-dir=', None,
|
|
|
|
'Salt\'s pre-configured pidfiles directory'),
|
|
|
|
]
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
install.initialize_options(self)
|
2015-01-09 16:53:36 +00:00
|
|
|
# pylint: disable=undefined-variable
|
2015-01-09 17:03:45 +00:00
|
|
|
if __saltstack_version__.info >= SaltStackVersion.from_name('Boron'):
|
2015-01-09 16:53:36 +00:00
|
|
|
# XXX: Remove the Salt Specific Options In Salt Boron. They are now global options
|
|
|
|
raise DistutilsArgError(
|
|
|
|
'Developers, please remove the salt paths configuration '
|
|
|
|
'setting from the setup\'s install command'
|
|
|
|
)
|
|
|
|
# pylint: enable=undefined-variable
|
2015-01-09 16:41:50 +00:00
|
|
|
self.salt_root_dir = None
|
|
|
|
self.salt_config_dir = None
|
|
|
|
self.salt_cache_dir = None
|
|
|
|
self.salt_sock_dir = None
|
|
|
|
self.salt_srv_root_dir = None
|
|
|
|
self.salt_base_file_roots_dir = None
|
|
|
|
self.salt_base_pillar_roots_dir = None
|
|
|
|
self.salt_base_master_roots_dir = None
|
|
|
|
self.salt_logs_dir = None
|
|
|
|
self.salt_pidfile_dir = None
|
2015-06-30 21:59:00 +00:00
|
|
|
self.salt_transport = None
|
2013-08-23 22:58:26 +00:00
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
install.finalize_options(self)
|
2014-10-01 19:47:03 +00:00
|
|
|
|
2015-01-09 16:41:50 +00:00
|
|
|
logged_warnings = False
|
2013-08-23 22:58:26 +00:00
|
|
|
for optname in ('root_dir', 'config_dir', 'cache_dir', 'sock_dir',
|
2013-08-27 08:46:26 +00:00
|
|
|
'srv_root_dir', 'base_file_roots_dir',
|
|
|
|
'base_pillar_roots_dir', 'base_master_roots_dir',
|
|
|
|
'logs_dir', 'pidfile_dir'):
|
|
|
|
optvalue = getattr(self, 'salt_{0}'.format(optname))
|
2015-01-09 16:41:50 +00:00
|
|
|
if optvalue is not None:
|
|
|
|
dist_opt_value = getattr(self.distribution, 'salt_{0}'.format(optname))
|
|
|
|
logged_warnings = True
|
|
|
|
log.warn(
|
|
|
|
'The \'--salt-{0}\' setting is now a global option just pass it '
|
|
|
|
'right after \'setup.py\'. This install setting will still work '
|
|
|
|
'until Salt Boron but please migrate to the global setting as '
|
|
|
|
'soon as possible.'.format(
|
2013-08-23 22:58:26 +00:00
|
|
|
optname.replace('_', '-')
|
|
|
|
)
|
2015-01-09 16:41:50 +00:00
|
|
|
|
2013-08-23 22:58:26 +00:00
|
|
|
)
|
2015-01-09 16:41:50 +00:00
|
|
|
if dist_opt_value is not None:
|
|
|
|
raise DistutilsArgError(
|
|
|
|
'The \'--salt-{0}\' setting was passed as a global option '
|
|
|
|
'and as an option to the install command. Please only pass '
|
|
|
|
'one of them, preferrably the global option since the other '
|
|
|
|
'is now deprecated and will be removed in Salt Boron.'.format(
|
|
|
|
optname.replace('_', '-')
|
|
|
|
)
|
|
|
|
)
|
|
|
|
setattr(self.distribution, 'salt_{0}'.format(optname), optvalue)
|
|
|
|
|
|
|
|
if logged_warnings is True:
|
|
|
|
time.sleep(3)
|
2013-08-23 22:58:26 +00:00
|
|
|
|
2013-02-06 04:23:56 +00:00
|
|
|
def run(self):
|
|
|
|
# Let's set the running_salt_install attribute so we can add
|
|
|
|
# _version.py in the build command
|
|
|
|
self.distribution.running_salt_install = True
|
2014-08-01 18:10:49 +00:00
|
|
|
self.distribution.salt_version_hardcoded_path = os.path.join(
|
|
|
|
self.build_lib, 'salt', '_version.py'
|
|
|
|
)
|
2013-02-06 04:23:56 +00:00
|
|
|
# Run install.run
|
|
|
|
install.run(self)
|
|
|
|
|
|
|
|
|
2014-03-17 16:56:31 +00:00
|
|
|
class InstallLib(install_lib):
|
|
|
|
def run(self):
|
2014-04-08 05:29:29 +00:00
|
|
|
executables = [
|
|
|
|
'salt/templates/git/ssh-id-wrapper',
|
|
|
|
'salt/templates/lxc/salt_tarball',
|
|
|
|
]
|
2014-03-17 16:56:31 +00:00
|
|
|
install_lib.run(self)
|
|
|
|
|
|
|
|
# input and outputs match 1-1
|
|
|
|
inp = self.get_inputs()
|
|
|
|
out = self.get_outputs()
|
2014-04-08 05:29:29 +00:00
|
|
|
chmod = []
|
2014-03-17 16:56:31 +00:00
|
|
|
|
2014-04-08 07:30:47 +00:00
|
|
|
for idx, inputfile in enumerate(inp):
|
2014-04-08 05:29:29 +00:00
|
|
|
for executeable in executables:
|
2014-04-08 07:30:47 +00:00
|
|
|
if inputfile.endswith(executeable):
|
|
|
|
chmod.append(idx)
|
2014-04-08 05:29:29 +00:00
|
|
|
for idx in chmod:
|
|
|
|
filename = out[idx]
|
2014-11-07 16:50:11 +00:00
|
|
|
os.chmod(filename, 0o755)
|
2014-06-17 14:19:03 +00:00
|
|
|
# <---- Custom Distutils/Setuptools Commands -------------------------------------------------------------------------
|
|
|
|
|
2014-11-04 17:42:03 +00:00
|
|
|
|
|
|
|
# ----- Custom Distribution Class ----------------------------------------------------------------------------------->
|
|
|
|
# We use this to override the package name in case --ssh-packaging is passed to
|
|
|
|
# setup.py or the special .salt-ssh-package is found
|
|
|
|
class SaltDistribution(distutils.dist.Distribution):
|
|
|
|
'''
|
|
|
|
Just so it's completely clear
|
|
|
|
|
|
|
|
Under windows, the following scripts should be installed:
|
|
|
|
|
|
|
|
* salt-call
|
|
|
|
* salt-cp
|
|
|
|
* salt-minion
|
|
|
|
* salt-unity
|
|
|
|
|
|
|
|
When packaged for salt-ssh, the following scripts should be installed:
|
|
|
|
* salt-call
|
|
|
|
* salt-run
|
|
|
|
* salt-ssh
|
|
|
|
* salt-cloud
|
|
|
|
|
|
|
|
Under windows, the following scripts should be omitted from the salt-ssh package:
|
|
|
|
* salt-cloud
|
|
|
|
* salt-run
|
|
|
|
|
|
|
|
Under *nix, all scripts should be installed
|
|
|
|
'''
|
|
|
|
global_options = distutils.dist.Distribution.global_options + [
|
|
|
|
('ssh-packaging', None, 'Run in SSH packaging mode'),
|
|
|
|
('salt-transport=', None, 'The transport to prepare salt for. Choices are \'zeromq\' '
|
2015-01-09 16:41:50 +00:00
|
|
|
'\'raet\' or \'both\'. Defaults to \'zeromq\'', 'zeromq')] + [
|
|
|
|
# Salt's Paths Configuration Settings
|
|
|
|
('salt-root-dir=', None,
|
|
|
|
'Salt\'s pre-configured root directory'),
|
|
|
|
('salt-config-dir=', None,
|
|
|
|
'Salt\'s pre-configured configuration directory'),
|
|
|
|
('salt-cache-dir=', None,
|
|
|
|
'Salt\'s pre-configured cache directory'),
|
|
|
|
('salt-sock-dir=', None,
|
|
|
|
'Salt\'s pre-configured socket directory'),
|
|
|
|
('salt-srv-root-dir=', None,
|
|
|
|
'Salt\'s pre-configured service directory'),
|
|
|
|
('salt-base-file-roots-dir=', None,
|
|
|
|
'Salt\'s pre-configured file roots directory'),
|
|
|
|
('salt-base-pillar-roots-dir=', None,
|
|
|
|
'Salt\'s pre-configured pillar roots directory'),
|
|
|
|
('salt-base-master-roots-dir=', None,
|
|
|
|
'Salt\'s pre-configured master roots directory'),
|
|
|
|
('salt-logs-dir=', None,
|
|
|
|
'Salt\'s pre-configured logs directory'),
|
|
|
|
('salt-pidfile-dir=', None,
|
|
|
|
'Salt\'s pre-configured pidfiles directory'),
|
2014-11-04 17:42:03 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
def __init__(self, attrs=None):
|
|
|
|
distutils.dist.Distribution.__init__(self, attrs)
|
|
|
|
|
|
|
|
self.ssh_packaging = PACKAGED_FOR_SALT_SSH
|
|
|
|
self.salt_transport = None
|
|
|
|
|
2015-01-09 16:41:50 +00:00
|
|
|
# Salt Paths Configuration Settings
|
|
|
|
self.salt_root_dir = None
|
|
|
|
self.salt_config_dir = None
|
|
|
|
self.salt_cache_dir = None
|
|
|
|
self.salt_sock_dir = None
|
|
|
|
self.salt_srv_root_dir = None
|
|
|
|
self.salt_base_file_roots_dir = None
|
|
|
|
self.salt_base_pillar_roots_dir = None
|
|
|
|
self.salt_base_master_roots_dir = None
|
|
|
|
self.salt_logs_dir = None
|
|
|
|
self.salt_pidfile_dir = None
|
|
|
|
|
|
|
|
|
2014-11-04 17:42:03 +00:00
|
|
|
self.name = 'salt-ssh' if PACKAGED_FOR_SALT_SSH else 'salt'
|
2015-03-11 19:21:26 +00:00
|
|
|
self.salt_version = __version__ # pylint: disable=undefined-variable
|
2014-11-04 17:42:03 +00:00
|
|
|
self.description = 'Portable, distributed, remote execution and configuration management system'
|
|
|
|
self.author = 'Thomas S Hatch'
|
|
|
|
self.author_email = 'thatch45@gmail.com'
|
|
|
|
self.url = 'http://saltstack.org'
|
|
|
|
self.cmdclass.update({'test': TestCommand,
|
|
|
|
'clean': Clean,
|
|
|
|
'build': Build,
|
|
|
|
'sdist': Sdist,
|
|
|
|
'install': Install,
|
2015-03-09 06:03:38 +00:00
|
|
|
'write_salt_version': WriteSaltVersion,
|
|
|
|
'write_salt_ssh_packaging_file': WriteSaltSshPackaingFile})
|
2014-11-04 17:42:03 +00:00
|
|
|
if not IS_WINDOWS_PLATFORM:
|
|
|
|
self.cmdclass.update({'sdist': CloudSdist,
|
|
|
|
'install_lib': InstallLib})
|
|
|
|
|
|
|
|
self.license = 'Apache Software License 2.0'
|
|
|
|
self.packages = self.discover_packages()
|
|
|
|
self.zip_safe = False
|
|
|
|
|
|
|
|
if HAS_ESKY:
|
|
|
|
self.setup_esky()
|
|
|
|
|
|
|
|
self.update_metadata()
|
|
|
|
|
|
|
|
def update_metadata(self):
|
|
|
|
for attrname in dir(self):
|
2014-11-08 00:44:40 +00:00
|
|
|
if attrname.startswith('__'):
|
|
|
|
continue
|
2014-11-04 17:42:03 +00:00
|
|
|
attrvalue = getattr(self, attrname, None)
|
|
|
|
if attrvalue == 0:
|
|
|
|
continue
|
2015-03-11 19:21:26 +00:00
|
|
|
if attrname == 'salt_version':
|
|
|
|
attrname = 'version'
|
2014-11-04 17:42:03 +00:00
|
|
|
if hasattr(self.metadata, 'set_{0}'.format(attrname)):
|
|
|
|
getattr(self.metadata, 'set_{0}'.format(attrname))(attrvalue)
|
|
|
|
elif hasattr(self.metadata, attrname):
|
2014-11-07 23:48:30 +00:00
|
|
|
try:
|
|
|
|
setattr(self.metadata, attrname, attrvalue)
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
2014-11-04 17:42:03 +00:00
|
|
|
|
|
|
|
def discover_packages(self):
|
|
|
|
modules = []
|
|
|
|
for root, _, files in os.walk(os.path.join(SETUP_DIRNAME, 'salt')):
|
|
|
|
if '__init__.py' not in files:
|
|
|
|
continue
|
|
|
|
modules.append(os.path.relpath(root, SETUP_DIRNAME).replace(os.sep, '.'))
|
|
|
|
return modules
|
|
|
|
|
2015-01-27 07:12:35 +00:00
|
|
|
# ----- Static Data -------------------------------------------------------------------------------------------->
|
2014-11-04 17:42:03 +00:00
|
|
|
@property
|
|
|
|
def _property_classifiers(self):
|
|
|
|
return ['Programming Language :: Python',
|
|
|
|
'Programming Language :: Cython',
|
|
|
|
'Programming Language :: Python :: 2.6',
|
|
|
|
'Programming Language :: Python :: 2.7',
|
|
|
|
'Development Status :: 5 - Production/Stable',
|
|
|
|
'Environment :: Console',
|
|
|
|
'Intended Audience :: Developers',
|
|
|
|
'Intended Audience :: Information Technology',
|
|
|
|
'Intended Audience :: System Administrators',
|
|
|
|
'License :: OSI Approved :: Apache Software License',
|
|
|
|
'Operating System :: POSIX :: Linux',
|
|
|
|
'Topic :: System :: Clustering',
|
|
|
|
'Topic :: System :: Distributed Computing']
|
|
|
|
|
|
|
|
@property
|
|
|
|
def _property_dependency_links(self):
|
|
|
|
return ['https://github.com/saltstack/salt-testing/tarball/develop#egg=SaltTesting']
|
|
|
|
|
|
|
|
@property
|
|
|
|
def _property_tests_require(self):
|
|
|
|
return ['SaltTesting']
|
|
|
|
# <---- Static Data ----------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# ----- Dynamic Data -------------------------------------------------------------------------------------------->
|
|
|
|
@property
|
|
|
|
def _property_package_data(self):
|
|
|
|
package_data = {'salt.templates': ['rh_ip/*.jinja',
|
|
|
|
'debian_ip/*.jinja',
|
|
|
|
'virt/*.jinja',
|
|
|
|
'git/*',
|
|
|
|
'lxc/*',
|
|
|
|
]}
|
|
|
|
if not IS_WINDOWS_PLATFORM:
|
|
|
|
package_data['salt.cloud'] = ['deploy/*.sh']
|
|
|
|
|
|
|
|
if not self.ssh_packaging and not PACKAGED_FOR_SALT_SSH:
|
|
|
|
package_data['salt.daemons.flo'] = ['*.flo']
|
|
|
|
return package_data
|
|
|
|
|
|
|
|
@property
|
|
|
|
def _property_data_files(self):
|
|
|
|
# Data files common to all scenarios
|
|
|
|
data_files = [
|
|
|
|
('share/man/man1', ['doc/man/salt-call.1']),
|
|
|
|
('share/man/man7', ['doc/man/salt.7'])
|
|
|
|
]
|
|
|
|
if self.ssh_packaging or PACKAGED_FOR_SALT_SSH:
|
|
|
|
data_files[0][1].append('doc/man/salt-ssh.1')
|
|
|
|
if IS_WINDOWS_PLATFORM:
|
|
|
|
return data_files
|
|
|
|
data_files[0][1].extend(['doc/man/salt-run.1',
|
|
|
|
'doc/man/salt-cloud.1'])
|
|
|
|
return data_files
|
|
|
|
|
|
|
|
if IS_WINDOWS_PLATFORM:
|
|
|
|
data_files[0][1].extend(['doc/man/salt-cp.1',
|
|
|
|
'doc/man/salt-minion.1',
|
|
|
|
'doc/man/salt-unity.1'])
|
|
|
|
return data_files
|
|
|
|
|
|
|
|
# *nix, so, we need all man pages
|
|
|
|
data_files[0][1].extend(['doc/man/salt-api.1',
|
|
|
|
'doc/man/salt-cloud.1',
|
|
|
|
'doc/man/salt-cp.1',
|
|
|
|
'doc/man/salt-key.1',
|
|
|
|
'doc/man/salt-master.1',
|
2012-06-05 10:00:20 +00:00
|
|
|
'doc/man/salt-minion.1',
|
2014-10-05 19:05:26 +00:00
|
|
|
'doc/man/salt-run.1',
|
2015-07-09 01:25:09 +00:00
|
|
|
'doc/man/spm.1',
|
2014-10-05 19:05:26 +00:00
|
|
|
'doc/man/salt-ssh.1',
|
|
|
|
'doc/man/salt-syndic.1',
|
|
|
|
'doc/man/salt-unity.1'])
|
|
|
|
return data_files
|
2012-06-05 10:00:20 +00:00
|
|
|
|
2014-10-05 19:05:26 +00:00
|
|
|
@property
|
|
|
|
def _property_install_requires(self):
|
|
|
|
install_requires = _parse_requirements_file(SALT_REQS)
|
|
|
|
|
|
|
|
if IS_WINDOWS_PLATFORM:
|
|
|
|
install_requires.append('WMI')
|
|
|
|
|
|
|
|
if self.salt_transport == 'zeromq':
|
|
|
|
install_requires += _parse_requirements_file(SALT_ZEROMQ_REQS)
|
|
|
|
elif self.salt_transport == 'raet':
|
|
|
|
install_requires += _parse_requirements_file(SALT_RAET_REQS)
|
|
|
|
return install_requires
|
|
|
|
|
|
|
|
@property
|
|
|
|
def _property_extras_require(self):
|
|
|
|
if self.ssh_packaging:
|
|
|
|
return {}
|
2015-06-17 16:00:17 +00:00
|
|
|
return {'RAET': _parse_requirements_file(SALT_RAET_REQS)}
|
2014-10-05 19:05:26 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def _property_scripts(self):
|
|
|
|
# Scripts common to all scenarios
|
|
|
|
scripts = ['scripts/salt-call']
|
|
|
|
if self.ssh_packaging or PACKAGED_FOR_SALT_SSH:
|
|
|
|
scripts.append('scripts/salt-ssh')
|
|
|
|
if IS_WINDOWS_PLATFORM:
|
|
|
|
return scripts
|
2015-06-29 14:51:12 +00:00
|
|
|
scripts.extend(['scripts/salt-cloud', 'scripts/salt-run', 'scripts/spm'])
|
2014-10-05 19:05:26 +00:00
|
|
|
return scripts
|
|
|
|
|
|
|
|
if IS_WINDOWS_PLATFORM:
|
|
|
|
scripts.extend(['scripts/salt-cp',
|
|
|
|
'scripts/salt-minion',
|
|
|
|
'scripts/salt-unity'])
|
|
|
|
return scripts
|
|
|
|
|
|
|
|
# *nix, so, we need all scripts
|
|
|
|
scripts.extend(['scripts/salt',
|
|
|
|
'scripts/salt-api',
|
|
|
|
'scripts/salt-cloud',
|
|
|
|
'scripts/salt-cp',
|
|
|
|
'scripts/salt-key',
|
|
|
|
'scripts/salt-master',
|
|
|
|
'scripts/salt-minion',
|
|
|
|
'scripts/salt-run',
|
|
|
|
'scripts/salt-ssh',
|
|
|
|
'scripts/salt-syndic',
|
2015-06-29 14:49:48 +00:00
|
|
|
'scripts/salt-unity',
|
|
|
|
'scripts/spm'])
|
2014-10-05 19:05:26 +00:00
|
|
|
return scripts
|
|
|
|
|
2014-11-11 16:19:18 +00:00
|
|
|
@property
|
|
|
|
def _property_entry_points(self):
|
|
|
|
# console scripts common to all scenarios
|
|
|
|
scripts = ['salt-call = salt.scripts:salt_call']
|
|
|
|
if self.ssh_packaging or PACKAGED_FOR_SALT_SSH:
|
|
|
|
scripts.append('salt-ssh = salt.scripts:salt_ssh')
|
|
|
|
if IS_WINDOWS_PLATFORM:
|
|
|
|
return {'console_scripts': scripts}
|
|
|
|
scripts.extend(['salt-cloud = salt.scripts:salt_cloud',
|
|
|
|
'salt-run = salt.scripts:salt_run'])
|
|
|
|
return {'console_scripts': scripts}
|
|
|
|
|
|
|
|
if IS_WINDOWS_PLATFORM:
|
2014-11-19 23:10:36 +00:00
|
|
|
scripts.extend(['salt-cp = salt.scripts:salt_cp',
|
2014-11-11 16:19:18 +00:00
|
|
|
'salt-minion = salt.scripts:salt_minion',
|
2015-06-29 14:51:12 +00:00
|
|
|
'salt-unity = salt.scripts:salt_unity',
|
|
|
|
'spm = salt.scripts:salt_spm'])
|
2014-11-11 16:19:18 +00:00
|
|
|
return {'console_scripts': scripts}
|
|
|
|
|
|
|
|
# *nix, so, we need all scripts
|
|
|
|
scripts.extend(['salt = salt.scripts:salt_main',
|
|
|
|
'salt-api = salt.scripts:salt_api',
|
|
|
|
'salt-cloud = salt.scripts:salt_cloud',
|
|
|
|
'salt-cp = salt.scripts:salt_cp',
|
|
|
|
'salt-key = salt.scripts:salt_key',
|
|
|
|
'salt-master = salt.scripts:salt_master',
|
|
|
|
'salt-minion = salt.scripts:salt_minion',
|
|
|
|
'salt-run = salt.scripts:salt_run',
|
|
|
|
'salt-ssh = salt.scripts:salt_ssh',
|
|
|
|
'salt-syndic = salt.scripts:salt_syndic',
|
2015-06-29 14:49:48 +00:00
|
|
|
'salt-unity = salt.scripts:salt_unity',
|
|
|
|
'spm = salt.scripts:salt_spm'])
|
2014-11-11 16:19:18 +00:00
|
|
|
return {'console_scripts': scripts}
|
2014-10-05 19:05:26 +00:00
|
|
|
# <---- Dynamic Data ---------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# ----- Esky Setup ---------------------------------------------------------------------------------------------->
|
|
|
|
def setup_esky(self):
|
|
|
|
opt_dict = self.get_option_dict('bdist_esky')
|
|
|
|
opt_dict['freezer_module'] = ('setup script', 'bbfreeze')
|
|
|
|
opt_dict['freezer_options'] = ('setup script', {'includes': self.get_esky_freezer_includes()})
|
|
|
|
|
|
|
|
@property
|
|
|
|
def _property_freezer_options(self):
|
|
|
|
return {'includes': self.get_esky_freezer_includes()}
|
|
|
|
|
|
|
|
def get_esky_freezer_includes(self):
|
|
|
|
# Sometimes the auto module traversal doesn't find everything, so we
|
|
|
|
# explicitly add it. The auto dependency tracking especially does not work for
|
|
|
|
# imports occurring in salt.modules, as they are loaded at salt runtime.
|
|
|
|
# Specifying includes that don't exist doesn't appear to cause a freezing
|
|
|
|
# error.
|
|
|
|
freezer_includes = [
|
|
|
|
'zmq.core.*',
|
|
|
|
'zmq.utils.*',
|
|
|
|
'ast',
|
2014-12-04 09:34:37 +00:00
|
|
|
'csv',
|
2014-10-05 19:05:26 +00:00
|
|
|
'difflib',
|
|
|
|
'distutils',
|
|
|
|
'distutils.version',
|
|
|
|
'numbers',
|
|
|
|
'json',
|
|
|
|
'M2Crypto',
|
|
|
|
'Cookie',
|
|
|
|
'asyncore',
|
|
|
|
'fileinput',
|
|
|
|
'sqlite3',
|
|
|
|
'email',
|
|
|
|
'email.mime.*',
|
|
|
|
'requests',
|
|
|
|
'sqlite3',
|
|
|
|
]
|
|
|
|
if HAS_ZMQ and hasattr(zmq, 'pyzmq_version_info'):
|
|
|
|
if HAS_ZMQ and zmq.pyzmq_version_info() >= (0, 14):
|
|
|
|
# We're freezing, and when freezing ZMQ needs to be installed, so this
|
|
|
|
# works fine
|
|
|
|
if 'zmq.core.*' in freezer_includes:
|
|
|
|
# For PyZMQ >= 0.14, freezing does not need 'zmq.core.*'
|
|
|
|
freezer_includes.remove('zmq.core.*')
|
|
|
|
|
|
|
|
if IS_WINDOWS_PLATFORM:
|
|
|
|
freezer_includes.extend([
|
2015-02-26 06:23:26 +00:00
|
|
|
'imp',
|
2014-10-05 19:05:26 +00:00
|
|
|
'win32api',
|
|
|
|
'win32file',
|
|
|
|
'win32con',
|
|
|
|
'win32com',
|
|
|
|
'win32net',
|
|
|
|
'win32netcon',
|
|
|
|
'win32gui',
|
|
|
|
'win32security',
|
|
|
|
'ntsecuritycon',
|
|
|
|
'pywintypes',
|
|
|
|
'pythoncom',
|
|
|
|
'_winreg',
|
|
|
|
'wmi',
|
|
|
|
'site',
|
|
|
|
'psutil',
|
2014-10-01 21:57:39 +00:00
|
|
|
])
|
2014-10-05 19:05:26 +00:00
|
|
|
elif sys.platform.startswith('linux'):
|
|
|
|
freezer_includes.append('spwd')
|
|
|
|
try:
|
|
|
|
import yum # pylint: disable=unused-variable
|
|
|
|
freezer_includes.append('yum')
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
elif sys.platform.startswith('sunos'):
|
|
|
|
# (The sledgehammer approach)
|
|
|
|
# Just try to include everything
|
|
|
|
# (This may be a better way to generate freezer_includes generally)
|
|
|
|
try:
|
|
|
|
from bbfreeze.modulegraph.modulegraph import ModuleGraph
|
|
|
|
mgraph = ModuleGraph(sys.path[:])
|
|
|
|
for arg in glob.glob('salt/modules/*.py'):
|
|
|
|
mgraph.run_script(arg)
|
|
|
|
for mod in mgraph.flatten():
|
|
|
|
if type(mod).__name__ != 'Script' and mod.filename:
|
|
|
|
freezer_includes.append(str(os.path.basename(mod.identifier)))
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
# Include C extension that convinces esky to package up the libsodium C library
|
|
|
|
# This is needed for ctypes to find it in libnacl which is in turn needed for raet
|
|
|
|
# see pkg/smartos/esky/sodium_grabber{.c,_installer.py}
|
|
|
|
freezer_includes.extend([
|
|
|
|
'sodium_grabber',
|
|
|
|
'ioflo',
|
|
|
|
'raet',
|
|
|
|
'libnacl',
|
2014-10-01 19:47:03 +00:00
|
|
|
])
|
2014-10-05 19:05:26 +00:00
|
|
|
return freezer_includes
|
|
|
|
# <---- Esky Setup -----------------------------------------------------------------------------------------------
|
2014-06-17 22:56:05 +00:00
|
|
|
|
2014-10-05 19:05:26 +00:00
|
|
|
# ----- Overridden Methods -------------------------------------------------------------------------------------->
|
|
|
|
def parse_command_line(self):
|
|
|
|
args = distutils.dist.Distribution.parse_command_line(self)
|
|
|
|
|
|
|
|
# Setup our property functions after class initialization and
|
|
|
|
# after parsing the command line since most are set to None
|
|
|
|
for funcname in dir(self):
|
|
|
|
if not funcname.startswith('_property_'):
|
|
|
|
continue
|
|
|
|
property_name = funcname.split('_property_', 1)[-1]
|
|
|
|
setattr(self, property_name, getattr(self, funcname))
|
2014-10-01 19:47:03 +00:00
|
|
|
|
2014-10-05 19:05:26 +00:00
|
|
|
if not self.ssh_packaging and PACKAGED_FOR_SALT_SSH:
|
|
|
|
self.ssh_packaging = 1
|
2014-10-01 19:47:03 +00:00
|
|
|
|
2014-10-05 19:05:26 +00:00
|
|
|
if self.ssh_packaging:
|
|
|
|
self.metadata.name = 'salt-ssh'
|
|
|
|
self.salt_transport = 'ssh'
|
|
|
|
elif self.salt_transport is None:
|
|
|
|
self.salt_transport = 'zeromq'
|
|
|
|
|
|
|
|
if self.salt_transport not in ('zeromq', 'raet', 'both', 'ssh', 'none'):
|
|
|
|
raise DistutilsArgError(
|
|
|
|
'The value of --salt-transport needs be \'zeromq\', '
|
|
|
|
'\'raet\', \'both\', \'ssh\' or \'none\' not {0!r}'.format(
|
|
|
|
self.salt_transport
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
return args
|
|
|
|
# <---- Overridden Methods ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# <---- Custom Distribution Class ------------------------------------------------------------------------------------
|
2014-10-01 19:47:03 +00:00
|
|
|
|
2013-11-14 07:20:01 +00:00
|
|
|
|
2012-09-23 05:19:39 +00:00
|
|
|
if __name__ == '__main__':
|
2014-10-05 19:05:26 +00:00
|
|
|
setup(distclass=SaltDistribution)
|