2
# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; version 2 of the License.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
"""This Class extends DistUtils commands for create mac osx distribution
25
from distutils import log
26
from distutils.command.bdist import bdist
27
from distutils.file_util import copy_file
28
from distutils.dir_util import copy_tree, remove_tree
31
class BuildDistOSX(bdist):
32
"""This class contains the command to built an osx distribution package
35
platf_v = '.'.join(platform.mac_ver()[0].split('.', 2)[0:2])
36
description = 'create a mac osx distribution package'
39
"keep the pseudo-installation tree around after "
40
"creating the distribution archive"),
42
"create a dmg image from the resulting package file "
45
"signs the package file (default 'False')"),
47
"identity or name of the certificate to use to sign the package file"
48
"(default 'MySQL-Utilities')"),
50
"directory to put final built distributions in"),
52
"name of the platform in resulting file "
53
"(default '{0}')".format(platf_n)),
54
('platform-version=', 'v',
55
"version of the platform in resulting file "
56
"(default '{0}')".format(platf_v))
59
boolean_options = ['keep-temp', 'create-dmg', 'sign']
61
def initialize_options(self):
62
"""Initialize the options"""
63
self.name = self.distribution.get_name()
64
self.version = self.distribution.get_version()
66
self.create_dmg = False
68
self.started_dir = os.getcwd()
69
self.platform = self.platf_n
70
self.platform_version = self.platf_v
72
self.osx_pkg_name = "{0}-{1}.pkg".format(self.name, self.version)
73
self.dstroot = "dstroot"
75
self.identity = "MySQL-Utilities"
77
def finalize_options(self):
78
"""Finalize the options"""
79
self.set_undefined_options('bdist',
80
('dist_dir', 'dist_dir'))
82
def _prepare_pgk_base(self, template_name, root='', gpl=True):
83
"""Create and populate the src base directory
85
osx_pkg_name[in] the name of the resulting package
86
root[in] the root path for the package contents
87
gpl[in] if false license and readme will correspond to the
88
commercial package instead of GPL files. default=True
91
# copy and create necessary files
92
osx_dist_name = template_name.format(self.name, self.version)
93
osx_pkg_name = "{0}.pkg".format(osx_dist_name)
94
osx_pkg_contents = os.path.join(root, osx_pkg_name, 'Contents')
95
osx_pkg_resrc = os.path.join(osx_pkg_contents, 'Resources')
96
self.mkpath(osx_pkg_resrc)
97
osx_path = os.path.join(root, self.dstroot)
99
cwd = os.path.join(os.getcwd())
101
copy_file_src_dst = [
102
(os.path.join("support", "osx", "PkgInfo"),
103
os.path.join(osx_pkg_contents, "PkgInfo")),
104
(os.path.join("support", "osx", "background.jpg"),
105
os.path.join(osx_pkg_resrc, "background.jpg")),
106
(os.path.join("support", "osx", "Welcome.rtf"),
107
os.path.join(osx_pkg_resrc, "Welcome.rtf"))
110
# No special folder for GPL or commercial. Files inside the directory
111
# will determine what it is.
112
data_path = os.path.join(
113
osx_path, 'usr', 'local',
114
'{0}-{1}'.format(self.name, self.version)
116
self.mkpath(data_path)
119
copy_file_src_dst += [
120
(os.path.join(cwd, "README.txt"),
121
os.path.join(osx_pkg_resrc, "ReadMe.txt")),
122
(os.path.join(cwd, "LICENSE.txt"),
123
os.path.join(osx_pkg_resrc, "License.txt")),
124
(os.path.join(cwd, "README.txt"),
125
os.path.join(data_path, "ReadMe.txt")),
126
(os.path.join(cwd, "LICENSE.txt"),
127
os.path.join(data_path, "License.txt")),
130
com_path = os.path.join('support', 'commercial_docs')
131
copy_file_src_dst += [
132
(os.path.join(cwd, com_path, "README_com.txt"),
133
os.path.join(osx_pkg_resrc, "ReadMe.txt")),
134
(os.path.join(cwd, com_path, "LICENSE_com.txt"),
135
os.path.join(osx_pkg_resrc, "License.txt")),
136
(os.path.join(cwd, com_path, "README_com.txt"),
137
os.path.join(data_path, "ReadMe.txt")),
138
(os.path.join(cwd, com_path, "LICENSE_com.txt"),
139
os.path.join(data_path, "License.txt")),
143
(os.path.join("support", "osx", "Info.plist"),
144
os.path.join(osx_pkg_contents, "Info.plist")),
145
(os.path.join("support", "osx", "Description.plist"),
146
os.path.join(osx_pkg_resrc, "Description.plist"))
149
for pro_file, dest_file in property_files:
150
with open(pro_file) as temp_f:
151
lines = (ln.replace('\n', '') for ln in temp_f)
152
major_version = self.version.split('.')[0]
153
minor_version = self.version.split('.')[1]
154
content = '\n'.join(lines).format(VERSION=self.version,
155
MAJORVERSION=major_version,
156
MINORVERSION=minor_version)
157
with open(dest_file, 'w') as dest_f:
158
dest_f.write('{0}\n'.format(content))
160
for src, dst in copy_file_src_dst:
163
def _create_pkg(self, template_name, dmg=False, sign=False, root='',
165
"""Create the mac osx pkg and a dmg image if it is required
167
dmg[in] if true a dmg file will created for the package folder
168
root[in] the root path for the package contents
171
osx_dist_name = template_name.format(self.name, self.version)
172
osx_pkg_name = "{0}.pkg".format(osx_dist_name)
173
osx_pkg_contents = os.path.join(osx_pkg_name, 'Contents')
176
log.info("current directory: {0}".format(os.getcwd()))
178
log.info("Root directory: {0}".format(os.getcwd()))
180
# create a bom(8) file to tell the installer which files need to be
182
log.info("creating Archive.bom file, that describe files to install")
183
archive_bom_path = os.path.join(osx_pkg_contents, 'Archive.bom')
184
self.spawn(['mkbom', self.dstroot, archive_bom_path])
186
# Create an archive of the files to install
187
log.info("creating Archive.pax with files to be installed")
188
os.chdir(self.dstroot)
190
pax_file = '../{NAME}/Contents/Archive.pax'.format(NAME=osx_pkg_name)
191
self.spawn(['pax', '-w', '-x', 'cpio', '.', '-f', pax_file])
194
log.info("current directory: {0}".format(os.getcwd()))
197
# In Order to be possible the certificates needs to be installed
199
log.info("Signing the package")
200
osx_pkg_name_signed = '{0}_s.pkg'.format(osx_dist_name)
201
self.spawn(['productsign', '--sign', identity,
203
osx_pkg_name_signed])
204
self.spawn(['spctl', '-a', '-v', '--type', 'install',
205
osx_pkg_name_signed])
206
osx_pkg_name = osx_pkg_name_signed
208
# Create a .dmg image
210
log.info("Creating dmg file")
211
self.spawn(['hdiutil', 'create', '-volname', osx_dist_name,
212
'-srcfolder', osx_pkg_name, '-ov', '-format',
213
'UDZO', '{0}.dmg'.format(osx_dist_name)])
215
log.info("Current directory: {0}".format(os.getcwd()))
217
for base, dirs, files in os.walk(os.getcwd()):
218
for filename in files:
219
if filename.endswith('.dmg'):
220
new_name = filename.replace(
221
'{0}'.format(self.version),
222
'{0}{1}{2}'.format(self.version, self.platform,
223
self.platform_version)
225
file_path = os.path.join(base, filename)
226
file_dest = os.path.join(self.started_dir,
227
self.dist_dir, new_name)
228
copy_file(file_path, file_dest)
230
for dir_name in dirs:
232
if dir_name.endswith('.pkg'):
233
new_name = dir_name.replace(
234
'{0}'.format(self.version),
235
'{0}{1}{2}'.format(self.version, self.platform,
236
self.platform_version)
238
dir_dest = os.path.join(self.started_dir,
239
self.dist_dir, new_name)
240
copy_tree(dir_name, dir_dest)
245
"""Run the distutils command"""
246
self.mkpath(self.dist_dir)
248
self.debug = self.verbose
251
root = os.path.join(build_path, 'osx')
252
osx_path = os.path.join(root, self.dstroot)
253
self.mkpath(osx_path)
256
log.info("os.getcwd() {0}".format(os.getcwd()))
257
install_cmd = self.reinitialize_command('install',
258
reinit_subcommands=1)
260
install_cmd.prefix = osx_path
261
log.info("install_cmd.prefix {0}".format(install_cmd.prefix))
263
install_cmd.verbose = 0
264
install_cmd.compile = False
265
purelib_path = os.path.join('Library', 'Python',
266
sys.version[0:3], 'site-packages')
267
log.info("py_version {0}".format(purelib_path))
268
install_cmd.install_purelib = purelib_path
269
install_cmd.root = osx_path
270
#install_cmd.install_dir = build_path
271
log.info("running install cmd")
272
self.run_command('install')
273
log.info("install cmd finish")
275
copy_tree(os.path.join(osx_path, osx_path, 'bin'),
276
os.path.join(osx_path, 'bin'))
278
remove_tree(os.path.join(osx_path, 'build'))
280
man_prefix = '/usr/local/share/man'
281
install_man_cmd = self.reinitialize_command('install_man',
282
reinit_subcommands=1)
284
install_man_cmd.root = osx_path
285
install_man_cmd.prefix = man_prefix
286
log.info("install_cmd.root {0}".format(install_man_cmd.root))
287
log.info("install_cmd.prefix {0}".format(install_man_cmd.prefix))
289
install_man_cmd.verbose = 0
290
log.info("running install_man cmd")
291
self.run_command('install_man')
292
log.info("install_man cmd finish")
295
log.info("current directory: {0}".format(os.getcwd()))
297
template_name = "{0}-{1}"
298
self._prepare_pgk_base(template_name, root=root)
301
log.info("current directory: {0}".format(os.getcwd()))
303
self._create_pkg(template_name, dmg=self.create_dmg, root=root,
304
sign=self.sign, identity=self.identity)
306
os.chdir(self.started_dir)
308
log.info("current directory: {0}".format(os.getcwd()))
309
if not self.keep_temp:
310
remove_tree(build_path, dry_run=self.dry_run)
313
class BuildDistOSXcom(BuildDistOSX):
314
"""This class contains the command to built an osx distribution package
316
description = 'create a mac osx distribution package'
319
"keep the pseudo-installation tree around after "
320
"creating the distribution archive"),
322
"create a dmg image from the resulting package file "
323
"(default 'False')"),
325
"signs the package file (default 'False')"),
327
"identity or name of the certificate to use to sign the package file"
328
"(default 'MySQL-Utilities')"),
330
"directory to put final built distributions in"),
332
"name of the platform in resulting file "
333
"(default '{0}')".format(BuildDistOSX.platf_n)),
334
('platform-version=', 'v',
335
"version of the platform in resulting file "
336
"(default '{0}')".format(BuildDistOSX.platf_v))
339
boolean_options = ['keep-temp', 'create-dmg', 'sign']
341
def initialize_options(self):
342
"""Initialize the options"""
343
self.name = self.distribution.get_name()
344
self.version = self.distribution.get_version()
345
self.keep_temp = None
346
self.create_dmg = False
348
self.started_dir = os.getcwd()
349
self.platform = self.platf_n
350
self.platform_version = self.platf_v
352
self.osx_pkg_name = "{0}-{1}.pkg".format(self.name, self.version)
353
self.dstroot = "dstroot"
355
self.identity = "MySQL-Utilities"
357
def finalize_options(self):
358
"""Finalize the options"""
359
self.set_undefined_options('bdist',
360
('dist_dir', 'dist_dir'))
363
"""Run the distutils command"""
364
log.info("self.name = {0}".format(self.name))
365
self.mkpath(self.dist_dir)
367
self.debug = self.verbose
370
root = os.path.join(build_path, 'osx')
371
osx_path = os.path.join(root, self.dstroot)
372
self.mkpath(osx_path)
375
log.info("current directory: {0}".format(os.getcwd()))
377
log.info("Current directory: {0}".format(os.getcwd()))
378
bdist = self.get_finalized_command('bdist_com')
379
bdist.dist_dir = root
380
bdist.prefix = osx_path
381
log.info("install_cmd.prefix {0}".format(bdist.prefix))
384
bdist.compile = False
385
purelib_path = os.path.join(osx_path, 'Library', 'Python',
386
sys.version[0:3], 'site-packages')
387
log.info("py_version {0}".format(purelib_path))
388
bdist.bdist_dir = purelib_path
389
bdist.man_root = osx_path
390
bdist.man_prefix = os.path.join('usr', 'local', 'share', 'man')
391
bdist.bin_install_dir = os.path.join(osx_path, 'bin')
392
self.run_command('bdist_com')
394
log.info("current directory: {0}".format(os.getcwd()))
395
log.info("bdist_com cmd finish")
397
if self.distribution.data_files:
398
install_cmd = self.get_finalized_command('install_data')
399
log.info("install_cmd.dist_dir {0}".format(root))
400
install_cmd.install_dir = root
401
log.info("install_cmd.root {0}".format(osx_path))
402
install_cmd.root = osx_path
403
log.info("install_cmd.prefix {0}".format(bdist.prefix))
405
self.run_command('install_data')
407
log.info("current directory: {0}".format(os.getcwd()))
408
log.info("install_cmd cmd finish")
410
# Copy necessary files to build osx package.
412
log.info('dir(bdist) {0}'.format(dir(bdist)))
413
log.info('bdist.dist_name {0}'.format(bdist.dist_name))
415
template_name = "{0}-commercial-{1}"
416
self._prepare_pgk_base(template_name, root=root, gpl=False)
419
log.info("current directory: {0}".format(os.getcwd()))
421
self._create_pkg(template_name, dmg=self.create_dmg, root=root,
422
sign=self.sign, identity=self.identity)
424
os.chdir(self.started_dir)
426
log.info("current directory: {0}".format(os.getcwd()))
427
if not self.keep_temp:
428
remove_tree(build_path, dry_run=self.dry_run)
2
# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; version 2 of the License.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
"""This Class extends DistUtils commands for create mac osx distribution
25
from distutils import log
26
from distutils.command.bdist import bdist
27
from distutils.file_util import copy_file
28
from distutils.dir_util import copy_tree, remove_tree
31
class BuildDistOSX(bdist):
32
"""This class contains the command to built an osx distribution package
35
platf_v = '.'.join(platform.mac_ver()[0].split('.', 2)[0:2])
36
description = 'create a mac osx distribution package'
39
"keep the pseudo-installation tree around after "
40
"creating the distribution archive"),
42
"create a dmg image from the resulting package file "
45
"signs the package file (default 'False')"),
47
"identity or name of the certificate to use to sign the package file"
48
"(default 'MySQL-Utilities')"),
50
"directory to put final built distributions in"),
52
"name of the platform in resulting file "
53
"(default '{0}')".format(platf_n)),
54
('platform-version=', 'v',
55
"version of the platform in resulting file "
56
"(default '{0}')".format(platf_v))
59
boolean_options = ['keep-temp', 'create-dmg', 'sign']
61
def initialize_options(self):
62
"""Initialize the options"""
63
self.name = self.distribution.get_name()
64
self.version = self.distribution.get_version()
66
self.create_dmg = False
68
self.started_dir = os.getcwd()
69
self.platform = self.platf_n
70
self.platform_version = self.platf_v
72
self.osx_pkg_name = "{0}-{1}.pkg".format(self.name, self.version)
73
self.dstroot = "dstroot"
75
self.identity = "MySQL-Utilities"
77
def finalize_options(self):
78
"""Finalize the options"""
79
self.set_undefined_options('bdist',
80
('dist_dir', 'dist_dir'))
82
def _prepare_pgk_base(self, template_name, root='', gpl=True):
83
"""Create and populate the src base directory
85
osx_pkg_name[in] the name of the resulting package
86
root[in] the root path for the package contents
87
gpl[in] if false license and readme will correspond to the
88
commercial package instead of GPL files. default=True
91
# copy and create necessary files
92
osx_dist_name = template_name.format(self.name, self.version)
93
osx_pkg_name = "{0}.pkg".format(osx_dist_name)
94
osx_pkg_contents = os.path.join(root, osx_pkg_name, 'Contents')
95
osx_pkg_resrc = os.path.join(osx_pkg_contents, 'Resources')
96
self.mkpath(osx_pkg_resrc)
97
osx_path = os.path.join(root, self.dstroot)
99
cwd = os.path.join(os.getcwd())
101
copy_file_src_dst = [
102
(os.path.join("support", "osx", "PkgInfo"),
103
os.path.join(osx_pkg_contents, "PkgInfo")),
104
(os.path.join("support", "osx", "background.jpg"),
105
os.path.join(osx_pkg_resrc, "background.jpg")),
106
(os.path.join("support", "osx", "Welcome.rtf"),
107
os.path.join(osx_pkg_resrc, "Welcome.rtf"))
110
# No special folder for GPL or commercial. Files inside the directory
111
# will determine what it is.
112
data_path = os.path.join(
113
osx_path, 'usr', 'local',
114
'{0}-{1}'.format(self.name, self.version)
116
self.mkpath(data_path)
119
copy_file_src_dst += [
120
(os.path.join(cwd, "README.txt"),
121
os.path.join(osx_pkg_resrc, "ReadMe.txt")),
122
(os.path.join(cwd, "LICENSE.txt"),
123
os.path.join(osx_pkg_resrc, "License.txt")),
124
(os.path.join(cwd, "README.txt"),
125
os.path.join(data_path, "ReadMe_Utilities.txt")),
126
(os.path.join(cwd, "CHANGES.txt"),
127
os.path.join(data_path, "CHANGES_Utilities.txt")),
128
(os.path.join(cwd, "LICENSE.txt"),
129
os.path.join(data_path, "License.txt")),
130
(os.path.join(cwd, "README_fabric.txt"),
131
os.path.join(data_path, "ReadMe_fabric.txt")),
132
(os.path.join(cwd, "CHANGES_fabric.txt"),
133
os.path.join(data_path, "CHANGES_fabric.txt"))
136
com_path = os.path.join('support', 'commercial_docs')
137
copy_file_src_dst += [
138
(os.path.join(cwd, com_path, "README_com.txt"),
139
os.path.join(osx_pkg_resrc, "ReadMe.txt")),
140
(os.path.join(cwd, com_path, "LICENSE_com.txt"),
141
os.path.join(osx_pkg_resrc, "License.txt")),
142
(os.path.join(cwd, com_path, "README_com.txt"),
143
os.path.join(data_path, "ReadMe.txt")),
144
(os.path.join(cwd, com_path, "LICENSE_com.txt"),
145
os.path.join(data_path, "License.txt")),
149
(os.path.join("support", "osx", "Info.plist"),
150
os.path.join(osx_pkg_contents, "Info.plist")),
151
(os.path.join("support", "osx", "Description.plist"),
152
os.path.join(osx_pkg_resrc, "Description.plist"))
155
for pro_file, dest_file in property_files:
156
with open(pro_file) as temp_f:
157
lines = (ln.replace('\n', '') for ln in temp_f)
158
major_version = self.version.split('.')[0]
159
minor_version = self.version.split('.')[1]
160
content = '\n'.join(lines).format(VERSION=self.version,
161
MAJORVERSION=major_version,
162
MINORVERSION=minor_version)
163
with open(dest_file, 'w') as dest_f:
164
dest_f.write('{0}\n'.format(content))
166
for src, dst in copy_file_src_dst:
167
if os.path.exists(src):
170
log.info("File not found: {0}".format(src))
172
def _create_pkg(self, template_name, dmg=False, sign=False, root='',
174
"""Create the mac osx pkg and a dmg image if it is required
176
dmg[in] if true a dmg file will created for the package folder
177
root[in] the root path for the package contents
180
osx_dist_name = template_name.format(self.name, self.version)
181
osx_pkg_name = "{0}.pkg".format(osx_dist_name)
182
osx_pkg_contents = os.path.join(osx_pkg_name, 'Contents')
185
log.info("current directory: {0}".format(os.getcwd()))
187
log.info("Root directory: {0}".format(os.getcwd()))
189
# create a bom(8) file to tell the installer which files need to be
191
log.info("creating Archive.bom file, that describe files to install")
192
archive_bom_path = os.path.join(osx_pkg_contents, 'Archive.bom')
193
self.spawn(['mkbom', self.dstroot, archive_bom_path])
195
# Create an archive of the files to install
196
log.info("creating Archive.pax with files to be installed")
197
os.chdir(self.dstroot)
199
pax_file = '../{NAME}/Contents/Archive.pax'.format(NAME=osx_pkg_name)
200
self.spawn(['pax', '-w', '-x', 'cpio', '.', '-f', pax_file])
203
log.info("current directory: {0}".format(os.getcwd()))
206
# In Order to be possible the certificates needs to be installed
208
log.info("Signing the package")
209
osx_pkg_name_signed = '{0}_s.pkg'.format(osx_dist_name)
210
self.spawn(['productsign', '--sign', identity,
212
osx_pkg_name_signed])
213
self.spawn(['spctl', '-a', '-v', '--type', 'install',
214
osx_pkg_name_signed])
215
osx_pkg_name = osx_pkg_name_signed
217
# Create a .dmg image
219
log.info("Creating dmg file")
220
self.spawn(['hdiutil', 'create', '-volname', osx_dist_name,
221
'-srcfolder', osx_pkg_name, '-ov', '-format',
222
'UDZO', '{0}.dmg'.format(osx_dist_name)])
224
log.info("Current directory: {0}".format(os.getcwd()))
226
for base, dirs, files in os.walk(os.getcwd()):
227
for filename in files:
228
if filename.endswith('.dmg'):
229
new_name = filename.replace(
230
'{0}'.format(self.version),
231
'{0}{1}{2}'.format(self.version, self.platform,
232
self.platform_version)
234
file_path = os.path.join(base, filename)
235
file_dest = os.path.join(self.started_dir,
236
self.dist_dir, new_name)
237
copy_file(file_path, file_dest)
239
for dir_name in dirs:
241
if dir_name.endswith('.pkg'):
242
new_name = dir_name.replace(
243
'{0}'.format(self.version),
244
'{0}{1}{2}'.format(self.version, self.platform,
245
self.platform_version)
247
dir_dest = os.path.join(self.started_dir,
248
self.dist_dir, new_name)
249
copy_tree(dir_name, dir_dest)
254
"""Run the distutils command"""
255
self.mkpath(self.dist_dir)
257
self.debug = self.verbose
260
root = os.path.join(build_path, 'osx')
261
osx_path = os.path.join(root, self.dstroot)
262
self.mkpath(osx_path)
265
log.info("os.getcwd() {0}".format(os.getcwd()))
266
install_cmd = self.reinitialize_command('install',
267
reinit_subcommands=1)
269
install_cmd.prefix = osx_path
270
log.info("install_cmd.prefix {0}".format(install_cmd.prefix))
272
install_cmd.verbose = 0
273
install_cmd.compile = False
274
purelib_path = os.path.join('Library', 'Python',
275
sys.version[0:3], 'site-packages')
276
log.info("py_version {0}".format(purelib_path))
277
install_cmd.install_purelib = purelib_path
278
install_cmd.root = osx_path
279
#install_cmd.install_dir = build_path
280
log.info("running install cmd")
281
self.run_command('install')
282
log.info("install cmd finish")
284
copy_tree(os.path.join(osx_path, osx_path, 'bin'),
285
os.path.join(osx_path, 'bin'))
287
remove_tree(os.path.join(osx_path, 'build'))
289
man_prefix = '/usr/local/share/man'
290
install_man_cmd = self.reinitialize_command('install_man',
291
reinit_subcommands=1)
293
install_man_cmd.root = osx_path
294
install_man_cmd.prefix = man_prefix
295
log.info("install_cmd.root {0}".format(install_man_cmd.root))
296
log.info("install_cmd.prefix {0}".format(install_man_cmd.prefix))
298
install_man_cmd.verbose = 0
299
log.info("running install_man cmd")
300
self.run_command('install_man')
301
log.info("install_man cmd finish")
304
log.info("current directory: {0}".format(os.getcwd()))
306
template_name = "{0}-{1}"
307
self._prepare_pgk_base(template_name, root=root)
310
log.info("current directory: {0}".format(os.getcwd()))
312
self._create_pkg(template_name, dmg=self.create_dmg, root=root,
313
sign=self.sign, identity=self.identity)
315
os.chdir(self.started_dir)
317
log.info("current directory: {0}".format(os.getcwd()))
318
if not self.keep_temp:
319
remove_tree(build_path, dry_run=self.dry_run)
322
class BuildDistOSXcom(BuildDistOSX):
323
"""This class contains the command to built an osx distribution package
325
description = 'create a mac osx distribution package'
328
"keep the pseudo-installation tree around after "
329
"creating the distribution archive"),
331
"create a dmg image from the resulting package file "
332
"(default 'False')"),
334
"signs the package file (default 'False')"),
336
"identity or name of the certificate to use to sign the package file"
337
"(default 'MySQL-Utilities')"),
339
"directory to put final built distributions in"),
341
"name of the platform in resulting file "
342
"(default '{0}')".format(BuildDistOSX.platf_n)),
343
('platform-version=', 'v',
344
"version of the platform in resulting file "
345
"(default '{0}')".format(BuildDistOSX.platf_v))
348
boolean_options = ['keep-temp', 'create-dmg', 'sign']
350
def initialize_options(self):
351
"""Initialize the options"""
352
self.name = self.distribution.get_name()
353
self.version = self.distribution.get_version()
354
self.keep_temp = None
355
self.create_dmg = False
357
self.started_dir = os.getcwd()
358
self.platform = self.platf_n
359
self.platform_version = self.platf_v
361
self.osx_pkg_name = "{0}-{1}.pkg".format(self.name, self.version)
362
self.dstroot = "dstroot"
364
self.identity = "MySQL-Utilities"
366
def finalize_options(self):
367
"""Finalize the options"""
368
self.set_undefined_options('bdist',
369
('dist_dir', 'dist_dir'))
372
"""Run the distutils command"""
373
log.info("self.name = {0}".format(self.name))
374
self.mkpath(self.dist_dir)
376
self.debug = self.verbose
379
root = os.path.join(build_path, 'osx')
380
osx_path = os.path.join(root, self.dstroot)
381
self.mkpath(osx_path)
384
log.info("current directory: {0}".format(os.getcwd()))
386
log.info("Current directory: {0}".format(os.getcwd()))
387
bdist = self.get_finalized_command('bdist_com')
388
bdist.dist_dir = root
389
bdist.prefix = osx_path
390
log.info("install_cmd.prefix {0}".format(bdist.prefix))
393
bdist.compile = False
394
purelib_path = os.path.join(osx_path, 'Library', 'Python',
395
sys.version[0:3], 'site-packages')
396
log.info("py_version {0}".format(purelib_path))
397
bdist.bdist_dir = purelib_path
398
bdist.man_root = osx_path
399
bdist.man_prefix = os.path.join('usr', 'local', 'share', 'man')
400
bdist.bin_install_dir = os.path.join(osx_path, 'bin')
401
self.run_command('bdist_com')
403
log.info("current directory: {0}".format(os.getcwd()))
404
log.info("bdist_com cmd finish")
406
if self.distribution.data_files:
407
install_cmd = self.get_finalized_command('install_data')
408
log.info("install_cmd.dist_dir {0}".format(root))
409
install_cmd.install_dir = root
410
log.info("install_cmd.root {0}".format(osx_path))
411
install_cmd.root = osx_path
412
log.info("install_cmd.prefix {0}".format(bdist.prefix))
414
self.run_command('install_data')
416
log.info("current directory: {0}".format(os.getcwd()))
417
log.info("install_cmd cmd finish")
419
# Copy necessary files to build osx package.
421
log.info('dir(bdist) {0}'.format(dir(bdist)))
422
log.info('bdist.dist_name {0}'.format(bdist.dist_name))
424
template_name = "{0}-commercial-{1}"
425
self._prepare_pgk_base(template_name, root=root, gpl=False)
428
log.info("current directory: {0}".format(os.getcwd()))
430
self._create_pkg(template_name, dmg=self.create_dmg, root=root,
431
sign=self.sign, identity=self.identity)
433
os.chdir(self.started_dir)
435
log.info("current directory: {0}".format(os.getcwd()))
436
if not self.keep_temp:
437
remove_tree(build_path, dry_run=self.dry_run)