40
41
description = (_install_scripts.description
41
42
+ " and add path to /etc/profile.d")
44
user_options = _install_scripts.user_options + [
45
("skip-profile", None, "Skip installing a profile script"),
48
boolean_options = _install_scripts.boolean_options + ['skip-profile']
43
50
profile_file = "/etc/profile.d/mysql-utilities.sh"
52
def initialize_options(self):
53
_install_scripts.initialize_options(self)
54
self.skip_profile = None
56
def finalize_options(self):
57
_install_scripts.finalize_options(self)
58
self.set_undefined_options('install',
59
('skip_profile', 'skip_profile'))
62
from distutils import log, dir_util
63
_install_scripts.run(self)
46
64
# We should probably use distutils.dist.execute here to allow
47
65
# --dry-run to work properly.
48
from distutils import log, dir_util
49
if os.path.exists(os.path.dirname(self.profile_file)):
50
outfile = self.profile_file
51
if os.path.isdir(outfile) and not os.path.islink(outfile):
52
dir_util.remove_tree(outfile)
53
elif os.path.exists(outfile):
54
log.info("Removing %s", outfile)
56
script = PROFILE_SCRIPT % (self.install_dir,)
57
log.info("Writing %s", outfile)
58
open(outfile, "w+").write(script)
59
_install_scripts.run(self)
61
log.info("Not adding %s", self.profile_file)
66
if not self.skip_profile:
67
if os.path.exists(os.path.dirname(self.profile_file)):
68
outfile = self.profile_file
69
if os.path.isdir(outfile) and not os.path.islink(outfile):
70
dir_util.remove_tree(outfile)
71
elif os.path.exists(outfile):
72
log.info("Removing %s", outfile)
74
script = PROFILE_SCRIPT % (self.install_dir,)
75
log.info("Writing %s", outfile)
76
open(outfile, "w+").write(script)
78
log.info("Not adding %s%s", self.profile_file,
79
" (skipped)" if self.skip_profile else "")
63
81
def get_outputs(self):
64
82
outputs = _install_scripts.get_outputs(self)
65
outputs.append(self.profile_file)
83
if not self.skip_profile:
84
outputs.append(self.profile_file)
68
87
class install_man(distutils.core.Command):
115
134
# See if we have Sphinx installed, otherwise, just ignore building
136
class install(_install):
137
user_options = _install.user_options + [
138
("skip-profile", None, "Skip installing a profile script"),
141
boolean_options = _install.boolean_options + ['skip-profile']
143
def initialize_options(self):
144
_install.initialize_options(self)
145
self.skip_profile = False
147
def finalize_options(self):
148
_install.finalize_options(self)
150
COMMANDS['cmdclass'].update({
118
155
import sphinx.setup_command
119
from distutils.command.install import install as _install
121
class install(_install):
122
sub_commands = _install.sub_commands + [
123
('install_man', lambda self: True),
157
# Add install_man command if we have Sphinx
158
install.sub_commands = _install.sub_commands + [
159
('install_man', lambda self: True),
126
162
COMMANDS['cmdclass'].update({
128
163
'install_man': install_man,
129
164
'build_sphinx': sphinx.setup_command.BuildDoc,
130
165
'build_man': sphinx.setup_command.BuildDoc,